2020-08-02 11:47:27 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-02 11:47:27 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <LibWeb/DOM/Node.h>
|
|
|
|
#include <LibWeb/DOM/Position.h>
|
|
|
|
|
|
|
|
namespace Web::DOM {
|
|
|
|
|
|
|
|
Position::Position(Node& node, unsigned offset)
|
|
|
|
: m_node(node)
|
|
|
|
, m_offset(offset)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Position::~Position()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-01-09 14:02:45 +01:00
|
|
|
String Position::to_string() const
|
2020-08-02 11:47:27 +02:00
|
|
|
{
|
2021-01-09 14:02:45 +01:00
|
|
|
if (!node())
|
|
|
|
return String::formatted("DOM::Position(nullptr, {})", offset());
|
|
|
|
return String::formatted("DOM::Position({} ({})), {})", node()->node_name(), node(), offset());
|
2020-08-02 11:47:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|