From c405ba6b08dc6026f3819b5c760fe9429a4ac9ee Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sun, 3 Sep 2023 15:46:55 +1200 Subject: [PATCH] LibWeb: Port HTMLBaseElement interface from DeprecatedString to String --- Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp | 12 +++++------- Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h | 4 ++-- Userland/Libraries/LibWeb/HTML/HTMLBaseElement.idl | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp index dd82ed40cb..0ad8e32876 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp @@ -80,15 +80,13 @@ void HTMLBaseElement::set_the_frozen_base_url() } // https://html.spec.whatwg.org/multipage/semantics.html#dom-base-href -DeprecatedString HTMLBaseElement::href() const +String HTMLBaseElement::href() const { // 1. Let document be element's node document. - auto& document = this->document(); + auto const& document = this->document(); // 2. Let url be the value of the href attribute of this element, if it has one, and the empty string otherwise. - auto url = DeprecatedString::empty(); - if (has_attribute(AttributeNames::href)) - url = deprecated_attribute(AttributeNames::href); + auto url = attribute(AttributeNames::href).value_or(String {}); // 3. Let urlRecord be the result of parsing url with document's fallback base URL, and document's character encoding. (Thus, the base element isn't affected by other base elements or itself.) // FIXME: Pass in document's character encoding. @@ -99,11 +97,11 @@ DeprecatedString HTMLBaseElement::href() const return url; // 5. Return the serialization of urlRecord. - return url_record.to_deprecated_string(); + return MUST(url_record.to_string()); } // https://html.spec.whatwg.org/multipage/semantics.html#dom-base-href -WebIDL::ExceptionOr HTMLBaseElement::set_href(DeprecatedString const& href) +WebIDL::ExceptionOr HTMLBaseElement::set_href(String const& href) { // The href IDL attribute, on setting, must set the href content attribute to the given new value. return set_attribute(AttributeNames::href, href); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h index c12954abc8..b115784729 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h @@ -16,8 +16,8 @@ class HTMLBaseElement final : public HTMLElement { public: virtual ~HTMLBaseElement() override; - DeprecatedString href() const; - WebIDL::ExceptionOr set_href(DeprecatedString const& href); + String href() const; + WebIDL::ExceptionOr set_href(String const& href); AK::URL const& frozen_base_url() const { return m_frozen_base_url; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.idl index 8a9b26d594..fe82387616 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.idl +++ b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.idl @@ -1,7 +1,7 @@ #import // https://html.spec.whatwg.org/multipage/semantics.html#htmlbaseelement -[Exposed=Window, UseDeprecatedAKString] +[Exposed=Window] interface HTMLBaseElement : HTMLElement { [HTMLConstructor] constructor();