Browse Source

LibWeb: Convert Web::DOM::Position::to_deprecated_string to String

Timothy Flynn 2 năm trước cách đây
mục cha
commit
2c4acba883

+ 3 - 3
Userland/Libraries/LibWeb/DOM/Position.cpp

@@ -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()

+ 5 - 6
Userland/Libraries/LibWeb/DOM/Position.h

@@ -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()));
     }
 };
-
-}