ladybird/Libraries/LibWeb/DOM/Position.cpp
Shannon Booth f87041bf3a LibGC+Everywhere: Factor out a LibGC from LibJS
Resulting in a massive rename across almost everywhere! Alongside the
namespace change, we now have the following names:

 * JS::NonnullGCPtr -> GC::Ref
 * JS::GCPtr -> GC::Ptr
 * JS::HeapFunction -> GC::Function
 * JS::CellImpl -> GC::Cell
 * JS::Handle -> GC::Root
2024-11-15 14:49:20 +01:00

35 lines
777 B
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
* Copyright (c) 2021, Max Wipfli <mail@maxwipfli.ch>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/DOM/Node.h>
#include <LibWeb/DOM/Position.h>
#include <LibWeb/DOM/Text.h>
namespace Web::DOM {
GC_DEFINE_ALLOCATOR(Position);
Position::Position(GC::Ptr<Node> node, unsigned offset)
: m_node(node)
, m_offset(offset)
{
}
void Position::visit_edges(Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_node);
}
ErrorOr<String> Position::to_string() const
{
if (!node())
return String::formatted("DOM::Position(nullptr, {})", offset());
return String::formatted("DOM::Position({} ({})), {})", node()->node_name(), node().ptr(), offset());
}
}