mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:37:35 +00:00
LibWeb: Convert Web::DOM::Position::to_deprecated_string to String
This commit is contained in:
parent
cd5868a0f1
commit
2c4acba883
2 changed files with 8 additions and 9 deletions
|
@ -18,11 +18,11 @@ Position::Position(Node& node, unsigned offset)
|
|||
{
|
||||
}
|
||||
|
||||
DeprecatedString Position::to_deprecated_string() const
|
||||
ErrorOr<String> Position::to_string() const
|
||||
{
|
||||
if (!node())
|
||||
return DeprecatedString::formatted("DOM::Position(nullptr, {})", offset());
|
||||
return DeprecatedString::formatted("DOM::Position({} ({})), {})", node()->node_name(), node(), offset());
|
||||
return String::formatted("DOM::Position(nullptr, {})", offset());
|
||||
return String::formatted("DOM::Position({} ({})), {})", node()->node_name(), node(), offset());
|
||||
}
|
||||
|
||||
bool Position::increment_offset()
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Error.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibJS/Heap/Handle.h>
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
@ -35,7 +37,7 @@ public:
|
|||
return m_node.ptr() == other.m_node.ptr() && m_offset == other.m_offset;
|
||||
}
|
||||
|
||||
DeprecatedString to_deprecated_string() const;
|
||||
ErrorOr<String> to_string() const;
|
||||
|
||||
private:
|
||||
JS::Handle<Node> m_node;
|
||||
|
@ -44,13 +46,10 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace AK {
|
||||
template<>
|
||||
struct Formatter<Web::DOM::Position> : Formatter<StringView> {
|
||||
struct AK::Formatter<Web::DOM::Position> : Formatter<StringView> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, Web::DOM::Position const& value)
|
||||
{
|
||||
return Formatter<StringView>::format(builder, value.to_deprecated_string());
|
||||
return Formatter<StringView>::format(builder, TRY(value.to_string()));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue