From 9f047819a53a26f28caffdf00a609a687b9c46f2 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sat, 26 Aug 2023 16:39:52 +1200 Subject: [PATCH] LibWeb: Port Selection interface from DeprecatedString to String --- Userland/Libraries/LibWeb/Selection/Selection.cpp | 14 +++++++------- Userland/Libraries/LibWeb/Selection/Selection.h | 4 ++-- Userland/Libraries/LibWeb/Selection/Selection.idl | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Userland/Libraries/LibWeb/Selection/Selection.cpp b/Userland/Libraries/LibWeb/Selection/Selection.cpp index 72aa62b0e6..2bb2fc75bd 100644 --- a/Userland/Libraries/LibWeb/Selection/Selection.cpp +++ b/Userland/Libraries/LibWeb/Selection/Selection.cpp @@ -104,13 +104,13 @@ unsigned Selection::range_count() const return 0; } -DeprecatedString Selection::type() const +String Selection::type() const { if (!m_range) - return "None"; + return "None"_string; if (m_range->collapsed()) - return "Caret"; - return "Range"; + return "Caret"_string; + return "Range"_string; } // https://w3c.github.io/selection-api/#dom-selection-getrangeat @@ -421,13 +421,13 @@ bool Selection::contains_node(JS::NonnullGCPtr node, bool allow_parti && (end_relative_position == DOM::RelativeBoundaryPointPosition::Equal || end_relative_position == DOM::RelativeBoundaryPointPosition::After); } -DeprecatedString Selection::to_deprecated_string() const +String Selection::to_string() const { // FIXME: This needs more work to be compatible with other engines. // See https://www.w3.org/Bugs/Public/show_bug.cgi?id=10583 if (!m_range) - return DeprecatedString::empty(); - return m_range->to_deprecated_string(); + return String {}; + return String::from_deprecated_string(m_range->to_deprecated_string()).release_value(); } JS::NonnullGCPtr Selection::document() const diff --git a/Userland/Libraries/LibWeb/Selection/Selection.h b/Userland/Libraries/LibWeb/Selection/Selection.h index d6586b0258..f3df07e9a8 100644 --- a/Userland/Libraries/LibWeb/Selection/Selection.h +++ b/Userland/Libraries/LibWeb/Selection/Selection.h @@ -31,7 +31,7 @@ public: unsigned focus_offset() const; bool is_collapsed() const; unsigned range_count() const; - DeprecatedString type() const; + String type() const; WebIDL::ExceptionOr> get_range_at(unsigned index); void add_range(JS::NonnullGCPtr); WebIDL::ExceptionOr remove_range(JS::NonnullGCPtr); @@ -48,7 +48,7 @@ public: delete_from_document(); bool contains_node(JS::NonnullGCPtr, bool allow_partial_containment) const; - DeprecatedString to_deprecated_string() const; + String to_string() const; // Non-standard convenience accessor for the selection's range. JS::GCPtr range() const; diff --git a/Userland/Libraries/LibWeb/Selection/Selection.idl b/Userland/Libraries/LibWeb/Selection/Selection.idl index c783f029ce..341a1f9a94 100644 --- a/Userland/Libraries/LibWeb/Selection/Selection.idl +++ b/Userland/Libraries/LibWeb/Selection/Selection.idl @@ -1,7 +1,7 @@ #import #import -[Exposed=Window] +[Exposed=Window, UseNewAKString] interface Selection { readonly attribute Node? anchorNode;