diff --git a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp index d8c30c6f825..aa4d9351e8e 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp +++ b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp @@ -68,8 +68,7 @@ DOMTokenList::DOMTokenList(Element& associated_element, FlyString associated_att { m_legacy_platform_object_flags = LegacyPlatformObjectFlags { .supports_indexed_properties = 1 }; - auto value = associated_element.deprecated_get_attribute(m_associated_attribute); - associated_attribute_changed(value); + associated_attribute_changed(associated_element.get_attribute_value(m_associated_attribute)); } void DOMTokenList::initialize(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 9bbf105abaf..12c05b00f3e 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -134,15 +134,6 @@ Optional Element::get_attribute_ns(Optional const& namespace_ return attribute->value(); } -ByteString Element::deprecated_get_attribute(FlyString const& name) const -{ - auto maybe_attribute = get_attribute(name); - if (!maybe_attribute.has_value()) - return ByteString::empty(); - - return maybe_attribute->to_byte_string(); -} - // https://dom.spec.whatwg.org/#concept-element-attributes-get-value String Element::get_attribute_value(FlyString const& local_name, Optional const& namespace_) const { @@ -1051,7 +1042,7 @@ i32 Element::default_tab_index_value() const // https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex i32 Element::tab_index() const { - auto maybe_table_index = Web::HTML::parse_integer(deprecated_attribute(HTML::AttributeNames::tabindex)); + auto maybe_table_index = Web::HTML::parse_integer(get_attribute_value(HTML::AttributeNames::tabindex)); if (!maybe_table_index.has_value()) return default_tab_index_value(); @@ -2038,10 +2029,10 @@ void Element::for_each_attribute(Function callback) const callback(*m_attributes->item(i)); } -void Element::for_each_attribute(Function callback) const +void Element::for_each_attribute(Function callback) const { for_each_attribute([&callback](Attr const& attr) { - callback(attr.name(), attr.value().to_byte_string()); + callback(attr.name(), attr.value()); }); } diff --git a/Userland/Libraries/LibWeb/DOM/Element.h b/Userland/Libraries/LibWeb/DOM/Element.h index 32f05d62d5b..fa1218c52ea 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.h +++ b/Userland/Libraries/LibWeb/DOM/Element.h @@ -93,12 +93,10 @@ public: bool has_attribute_ns(Optional const& namespace_, FlyString const& name) const; bool has_attributes() const; - ByteString deprecated_attribute(FlyString const& name) const { return deprecated_get_attribute(name); } Optional attribute(FlyString const& name) const { return get_attribute(name); } Optional get_attribute(FlyString const& name) const; Optional get_attribute_ns(Optional const& namespace_, FlyString const& name) const; - ByteString deprecated_get_attribute(FlyString const& name) const; String get_attribute_value(FlyString const& local_name, Optional const& namespace_ = {}) const; WebIDL::ExceptionOr set_attribute(FlyString const& name, String const& value); @@ -135,7 +133,7 @@ public: void for_each_attribute(Function) const; - void for_each_attribute(Function) const; + void for_each_attribute(Function) const; bool has_class(FlyString const&, CaseSensitivity = CaseSensitivity::CaseSensitive) const; Vector const& class_names() const { return m_classes; } diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index 8ed06a34504..102266246b3 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -825,7 +825,7 @@ JS::NonnullGCPtr Node::clone_node(Document* document, bool clone_children) element.for_each_attribute([&](auto& name, auto& value) { // 1. Let copyAttribute be a clone of attribute. // 2. Append copyAttribute to copy. - MUST(element_copy->set_attribute(name, MUST(String::from_byte_string(value)))); + MUST(element_copy->set_attribute(name, value)); }); copy = move(element_copy); @@ -1396,7 +1396,7 @@ bool Node::is_equal_node(Node const* other_node) const // If A is an element, each attribute in its attribute list has an attribute that equals an attribute in B’s attribute list. bool has_same_attributes = true; this_element.for_each_attribute([&](auto& name, auto& value) { - if (other_element.deprecated_get_attribute(name) != value) + if (other_element.get_attribute(name) != value) has_same_attributes = false; }); if (!has_same_attributes) diff --git a/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp b/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp index 18dedf40031..fe37def2c54 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp +++ b/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp @@ -88,7 +88,7 @@ Vector DOMStringMap::get_name_value_pairs() const builder.append(current_character); } - list.append({ MUST(builder.to_string()), MUST(String::from_byte_string(value)) }); + list.append({ MUST(builder.to_string()), value }); }); // 4. Return list. diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h index 00681f9afc9..a7d94b7a1be 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h @@ -20,9 +20,9 @@ class HTMLAnchorElement final public: virtual ~HTMLAnchorElement() override; - ByteString rel() const { return deprecated_attribute(HTML::AttributeNames::rel); } - ByteString target() const { return deprecated_attribute(HTML::AttributeNames::target); } - ByteString download() const { return deprecated_attribute(HTML::AttributeNames::download); } + String rel() const { return get_attribute_value(HTML::AttributeNames::rel); } + String target() const { return get_attribute_value(HTML::AttributeNames::target); } + String download() const { return get_attribute_value(HTML::AttributeNames::download); } String text() const; void set_text(String const&); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp index 9430abbf0cf..d6e7c1691cb 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp @@ -68,7 +68,7 @@ void HTMLBaseElement::set_the_frozen_base_url() auto& document = this->document(); // 2. Let urlRecord be the result of parsing the value of element's href content attribute with document's fallback base URL, and document's character encoding. (Thus, the base element isn't affected by itself.) - auto href = deprecated_attribute(AttributeNames::href); + auto href = get_attribute_value(AttributeNames::href); auto url_record = document.fallback_base_url().complete_url(href); // 3. Set element's frozen base URL to document's fallback base URL, if urlRecord is failure or running Is base allowed for Document? on the resulting URL record and document returns "Blocked", and to urlRecord otherwise. diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp index b6035225e9e..23d60d5cd1c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp @@ -63,17 +63,17 @@ void HTMLBodyElement::attribute_changed(FlyString const& name, Optional HTMLElement::attribute_changed(name, value); if (name.equals_ignoring_ascii_case("link"sv)) { // https://html.spec.whatwg.org/multipage/rendering.html#the-page:rules-for-parsing-a-legacy-colour-value-3 - auto color = parse_legacy_color_value(value.value_or(String {}).to_byte_string()); + auto color = parse_legacy_color_value(value.value_or(String {})); if (color.has_value()) document().set_link_color(color.value()); } else if (name.equals_ignoring_ascii_case("alink"sv)) { // https://html.spec.whatwg.org/multipage/rendering.html#the-page:rules-for-parsing-a-legacy-colour-value-5 - auto color = parse_legacy_color_value(value.value_or(String {}).to_byte_string()); + auto color = parse_legacy_color_value(value.value_or(String {})); if (color.has_value()) document().set_active_link_color(color.value()); } else if (name.equals_ignoring_ascii_case("vlink"sv)) { // https://html.spec.whatwg.org/multipage/rendering.html#the-page:rules-for-parsing-a-legacy-colour-value-4 - auto color = parse_legacy_color_value(value.value_or(String {}).to_byte_string()); + auto color = parse_legacy_color_value(value.value_or(String {})); if (color.has_value()) document().set_visited_link_color(color.value()); } else if (name.equals_ignoring_ascii_case("background"sv)) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLButtonElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLButtonElement.cpp index 508c568967a..03a43eb5fd8 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLButtonElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLButtonElement.cpp @@ -27,7 +27,7 @@ void HTMLButtonElement::initialize(JS::Realm& realm) HTMLButtonElement::TypeAttributeState HTMLButtonElement::type_state() const { - auto value = deprecated_attribute(HTML::AttributeNames::type); + auto value = get_attribute_value(HTML::AttributeNames::type); #define __ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTE(keyword, state) \ if (value.equals_ignoring_ascii_case(#keyword##sv)) \ diff --git a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp index 8a7d2feb7c1..dd999d68bd8 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp @@ -66,8 +66,8 @@ void HTMLCanvasElement::apply_presentational_hints(CSS::StyleProperties& style) // https://html.spec.whatwg.org/multipage/rendering.html#map-to-the-aspect-ratio-property // if element has both attributes w and h, and parsing those attributes' values using the rules for parsing non-negative integers doesn't generate an error for either - auto w = parse_non_negative_integer(deprecated_attribute(HTML::AttributeNames::width)); - auto h = parse_non_negative_integer(deprecated_attribute(HTML::AttributeNames::height)); + auto w = parse_non_negative_integer(get_attribute_value(HTML::AttributeNames::width)); + auto h = parse_non_negative_integer(get_attribute_value(HTML::AttributeNames::height)); if (w.has_value() && h.has_value()) // then the user agent is expected to use the parsed integers as a presentational hint for the 'aspect-ratio' property of the form auto w / h. @@ -85,7 +85,7 @@ unsigned HTMLCanvasElement::width() const // The rules for parsing non-negative integers must be used to obtain their numeric values. // If an attribute is missing, or if parsing its value returns an error, then the default value must be used instead. // The width attribute defaults to 300 - return parse_non_negative_integer(deprecated_attribute(HTML::AttributeNames::width)).value_or(300); + return parse_non_negative_integer(get_attribute_value(HTML::AttributeNames::width)).value_or(300); } unsigned HTMLCanvasElement::height() const @@ -94,7 +94,7 @@ unsigned HTMLCanvasElement::height() const // The rules for parsing non-negative integers must be used to obtain their numeric values. // If an attribute is missing, or if parsing its value returns an error, then the default value must be used instead. // the height attribute defaults to 150 - return parse_non_negative_integer(deprecated_attribute(HTML::AttributeNames::height)).value_or(150); + return parse_non_negative_integer(get_attribute_value(HTML::AttributeNames::height)).value_or(150); } void HTMLCanvasElement::reset_context_to_default_state() diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp index 9eafe372420..c99ee7c0f46 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp @@ -64,7 +64,7 @@ StringView HTMLElement::dir() const { // FIXME: This should probably be `Reflect` in the IDL. // The dir IDL attribute on an element must reflect the dir content attribute of that element, limited to only known values. - auto dir = deprecated_attribute(HTML::AttributeNames::dir); + auto dir = get_attribute_value(HTML::AttributeNames::dir); #define __ENUMERATE_HTML_ELEMENT_DIR_ATTRIBUTE(keyword) \ if (dir.equals_ignoring_ascii_case(#keyword##sv)) \ return #keyword##sv; @@ -526,8 +526,8 @@ String HTMLElement::get_an_elements_target() const TokenizedFeature::NoOpener HTMLElement::get_an_elements_noopener(StringView target) const { // To get an element's noopener, given an a, area, or form element element and a string target: - auto rel = deprecated_attribute(HTML::AttributeNames::rel).to_lowercase(); - auto link_types = rel.view().split_view_if(Infra::is_ascii_whitespace); + auto rel = MUST(get_attribute_value(HTML::AttributeNames::rel).to_lowercase()); + auto link_types = rel.bytes_as_string_view().split_view_if(Infra::is_ascii_whitespace); // 1. If element's link types include the noopener or noreferrer keyword, then return true. if (link_types.contains_slow("noopener"sv) || link_types.contains_slow("noreferrer"sv)) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp index e86d00f1496..08caea25978 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp @@ -807,8 +807,8 @@ void HTMLFormElement::plan_to_navigate_to(AK::URL url, Variantcontent_width().to_int(); // NOTE: This step seems to not be in the spec, but all browsers do it. - auto width_attr = deprecated_get_attribute(HTML::AttributeNames::width); - if (auto converted = width_attr.to_number(); converted.has_value()) - return *converted; + if (auto width_attr = get_attribute(HTML::AttributeNames::width); width_attr.has_value()) { + if (auto converted = width_attr->to_number(); converted.has_value()) + return *converted; + } // ...or else the density-corrected intrinsic width and height of the image, in CSS pixels, // if the image has intrinsic dimensions and is available but not being rendered. @@ -203,9 +204,10 @@ unsigned HTMLImageElement::height() const return paintable_box->content_height().to_int(); // NOTE: This step seems to not be in the spec, but all browsers do it. - auto height_attr = deprecated_get_attribute(HTML::AttributeNames::height); - if (auto converted = height_attr.to_number(); converted.has_value()) - return *converted; + if (auto height_attr = get_attribute(HTML::AttributeNames::height); height_attr.has_value()) { + if (auto converted = height_attr->to_number(); converted.has_value()) + return *converted; + } // ...or else the density-corrected intrinsic height and height of the image, in CSS pixels, // if the image has intrinsic dimensions and is available but not being rendered. @@ -554,7 +556,7 @@ after_step_7: request->set_initiator(Fetch::Infrastructure::Request::Initiator::ImageSet); // 21. Set request's referrer policy to the current state of the element's referrerpolicy attribute. - request->set_referrer_policy(ReferrerPolicy::from_string(deprecated_attribute(HTML::AttributeNames::referrerpolicy))); + request->set_referrer_policy(ReferrerPolicy::from_string(get_attribute_value(HTML::AttributeNames::referrerpolicy))); // FIXME: 22. Set request's priority to the current state of the element's fetchpriority attribute. @@ -769,7 +771,7 @@ void HTMLImageElement::react_to_changes_in_the_environment() request->set_initiator(Fetch::Infrastructure::Request::Initiator::ImageSet); // 3. Set request's referrer policy to the current state of the element's referrerpolicy attribute. - request->set_referrer_policy(ReferrerPolicy::from_string(deprecated_attribute(HTML::AttributeNames::referrerpolicy))); + request->set_referrer_policy(ReferrerPolicy::from_string(get_attribute_value(HTML::AttributeNames::referrerpolicy))); // FIXME: 4. Set request's priority to the current state of the element's fetchpriority attribute. @@ -926,7 +928,7 @@ static void update_the_source_set(DOM::Element& element) continue; // 4. Parse child's srcset attribute and let the returned source set be source set. - auto source_set = parse_a_srcset_attribute(child->deprecated_attribute(HTML::AttributeNames::srcset)); + auto source_set = parse_a_srcset_attribute(child->get_attribute_value(HTML::AttributeNames::srcset)); // 5. If source set has zero image sources, continue to the next child. if (source_set.is_empty()) @@ -935,14 +937,14 @@ static void update_the_source_set(DOM::Element& element) // 6. If child has a media attribute, and its value does not match the environment, continue to the next child. if (child->has_attribute(HTML::AttributeNames::media)) { auto media_query = parse_media_query(CSS::Parser::ParsingContext { element.document() }, - child->deprecated_attribute(HTML::AttributeNames::media)); + child->get_attribute_value(HTML::AttributeNames::media)); if (!media_query || !media_query->evaluate(element.document().window())) { continue; } } // 7. Parse child's sizes attribute, and let source set's source size be the returned value. - source_set.m_source_size = parse_a_sizes_attribute(element.document(), child->deprecated_attribute(HTML::AttributeNames::sizes)); + source_set.m_source_size = parse_a_sizes_attribute(element.document(), child->get_attribute_value(HTML::AttributeNames::sizes)); // FIXME: 8. If child has a type attribute, and its value is an unknown or unsupported MIME type, continue to the next child. if (child->has_attribute(HTML::AttributeNames::type)) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h index 5a3ff398fa6..364096f3680 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h @@ -39,8 +39,8 @@ public: virtual void attribute_changed(FlyString const& name, Optional const& value) override; - ByteString alt() const { return deprecated_attribute(HTML::AttributeNames::alt); } - ByteString src() const { return deprecated_attribute(HTML::AttributeNames::src); } + String alt() const { return get_attribute_value(HTML::AttributeNames::alt); } + String src() const { return get_attribute_value(HTML::AttributeNames::src); } RefPtr immutable_bitmap() const; RefPtr bitmap() const; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 1cf42b0bc63..38e2d386679 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -369,7 +369,7 @@ String HTMLInputElement::value() const || type_state() == TypeAttributeState::ResetButton || type_state() == TypeAttributeState::Button) { // On getting, if the element has a value content attribute, return that attribute's value; otherwise, return the empty string. - return get_attribute(AttributeNames::value).value_or(String {}); + return get_attribute_value(AttributeNames::value); } // https://html.spec.whatwg.org/multipage/input.html#range-state-(type=range):attr-input-value @@ -1015,7 +1015,7 @@ void HTMLInputElement::reset_algorithm() m_dirty_checkedness = false; // set the value of the element to the value of the value content attribute, if there is one, or the empty string otherwise, - m_value = get_attribute(AttributeNames::value).value_or(String {}); + m_value = get_attribute_value(AttributeNames::value); // set the checkedness of the element to true if the element has a checked content attribute and false if it does not, m_checked = has_attribute(AttributeNames::checked); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h index 97da4d6cc5f..5f4004addc5 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -64,7 +64,7 @@ public: TypeAttributeState type_state() const { return m_type; } WebIDL::ExceptionOr set_type(String const&); - ByteString default_value() const { return deprecated_attribute(HTML::AttributeNames::value); } + String default_value() const { return get_attribute_value(HTML::AttributeNames::value); } virtual String value() const override; WebIDL::ExceptionOr set_value(String const&); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp index 30512ef41ab..552459e1059 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp @@ -62,12 +62,12 @@ void HTMLLinkElement::inserted() if (m_relationship & Relationship::Preload) { // FIXME: Respect the "as" attribute. LoadRequest request; - request.set_url(document().parse_url(deprecated_attribute(HTML::AttributeNames::href))); + request.set_url(document().parse_url(get_attribute_value(HTML::AttributeNames::href))); set_resource(ResourceLoader::the().load_resource(Resource::Type::Generic, request)); } else if (m_relationship & Relationship::DNSPrefetch) { - ResourceLoader::the().prefetch_dns(document().parse_url(deprecated_attribute(HTML::AttributeNames::href))); + ResourceLoader::the().prefetch_dns(document().parse_url(get_attribute_value(HTML::AttributeNames::href))); } else if (m_relationship & Relationship::Preconnect) { - ResourceLoader::the().preconnect(document().parse_url(deprecated_attribute(HTML::AttributeNames::href))); + ResourceLoader::the().preconnect(document().parse_url(get_attribute_value(HTML::AttributeNames::href))); } else if (m_relationship & Relationship::Icon) { auto favicon_url = document().parse_url(href()); auto favicon_request = LoadRequest::create_for_url_on_page(favicon_url, &document().page()); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h index fb7418fa1a1..8092409cd4f 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h @@ -29,9 +29,9 @@ public: virtual void inserted() override; - ByteString rel() const { return deprecated_attribute(HTML::AttributeNames::rel); } - ByteString type() const { return deprecated_attribute(HTML::AttributeNames::type); } - ByteString href() const { return deprecated_attribute(HTML::AttributeNames::href); } + String rel() const { return get_attribute_value(HTML::AttributeNames::rel); } + String type() const { return get_attribute_value(HTML::AttributeNames::type); } + String href() const { return get_attribute_value(HTML::AttributeNames::href); } bool has_loaded_icon() const; bool load_favicon_and_use_if_window_is_active(); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp index 5fa5b269d09..02053d91603 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp @@ -578,8 +578,8 @@ public: // 2. ⌛ Process candidate: If candidate does not have a src attribute, or if its src attribute's value is the // empty string, then end the synchronous section, and jump down to the failed with elements step below. String candiate_src; - if (m_candidate->has_attribute(HTML::AttributeNames::src)) - candiate_src = TRY_OR_THROW_OOM(vm, String::from_byte_string(m_candidate->deprecated_attribute(HTML::AttributeNames::src))); + if (auto maybe_src = m_candidate->get_attribute(HTML::AttributeNames::src); maybe_src.has_value()) + candiate_src = *maybe_src; if (candiate_src.is_empty()) { TRY(failed_with_elements()); @@ -826,7 +826,7 @@ WebIDL::ExceptionOr HTMLMediaElement::select_resource() }; // 1. ⌛ If the src attribute's value is the empty string, then end the synchronous section, and jump down to the failed with attribute step below. - auto source = deprecated_attribute(HTML::AttributeNames::src); + auto source = get_attribute_value(HTML::AttributeNames::src); if (source.is_empty()) { failed_with_attribute("The 'src' attribute is empty"_string); return {}; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMetaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMetaElement.cpp index 120c0baa2e4..29ee5755e04 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMetaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMetaElement.cpp @@ -34,7 +34,7 @@ void HTMLMetaElement::initialize(JS::Realm& realm) Optional HTMLMetaElement::http_equiv_state() const { - auto value = deprecated_attribute(HTML::AttributeNames::http_equiv); + auto value = get_attribute_value(HTML::AttributeNames::http_equiv); #define __ENUMERATE_HTML_META_HTTP_EQUIV_ATTRIBUTE(keyword, state) \ if (value.equals_ignoring_ascii_case(#keyword##sv)) \ @@ -96,7 +96,7 @@ void HTMLMetaElement::inserted() if (!has_attribute(AttributeNames::content)) break; - auto input = deprecated_attribute(AttributeNames::content); + auto input = get_attribute_value(AttributeNames::content); if (input.is_empty()) break; @@ -105,7 +105,7 @@ void HTMLMetaElement::inserted() break; } default: - dbgln("FIXME: Implement '{}' http-equiv state", deprecated_attribute(AttributeNames::http_equiv)); + dbgln("FIXME: Implement '{}' http-equiv state", get_attribute_value(AttributeNames::http_equiv)); break; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp index 3bb5602500e..777aa2d914a 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp @@ -71,7 +71,7 @@ void HTMLObjectElement::attribute_changed(FlyString const& name, Optionalis_empty()) { // 1. If the type attribute is present and its value is not a type that the user agent supports, and is not a type that the user agent can find a plugin for, then the user agent may jump to the step below labeled fallback without fetching the content to examine its real type. // 2. Parse a URL given the data attribute, relative to the element's node document. - auto url = document().parse_url(data); + auto url = document().parse_url(*maybe_data); // 3. If that failed, fire an event named error at the element, then jump to the step below labeled fallback. if (!url.is_valid()) { @@ -170,7 +170,7 @@ void HTMLObjectElement::resource_did_load() // 4.8. Determine the resource type, as follows: // 1. Let the resource type be unknown. - Optional resource_type; + Optional resource_type; // FIXME: 2. If the user agent is configured to strictly obey Content-Type headers for this resource, and the resource has associated Content-Type metadata, then let the resource type be the type specified in the resource's Content-Type metadata, and jump to the step below labeled handler. // FIXME: 3. If there is a type attribute present on the object element, and that attribute's value is not a type that the user agent supports, but it is a type that a plugin supports, then let the resource type be the type specified in that type attribute, and jump to the step below labeled handler. @@ -195,7 +195,7 @@ void HTMLObjectElement::resource_did_load() if (auto type = this->type(); !type.is_empty() && (type != "application/octet-stream"sv)) { // 1. If the attribute's value is a type that a plugin supports, or the attribute's value is a type that starts with "image/" that is not also an XML MIME type, then let the resource type be the type specified in that type attribute. // FIXME: This only partially implements this step. - if (type.starts_with("image/"sv)) + if (type.starts_with_bytes("image/"sv)) resource_type = move(type); // 2. Jump to the step below labeled handler. @@ -203,7 +203,7 @@ void HTMLObjectElement::resource_did_load() } // * Otherwise, if the resource does not have associated Content-Type metadata else { - Optional tentative_type; + Optional tentative_type; // 1. If there is a type attribute present on the object element, then let the tentative type be the type specified in that type attribute. // Otherwise, let tentative type be the computed type of the resource. @@ -213,7 +213,7 @@ void HTMLObjectElement::resource_did_load() // FIXME: For now, ignore application/ MIME types as we cannot render yet them anyways. We will need to implement the MIME type sniffing // algorithm in order to map all unknown MIME types to "application/octet-stream". else if (auto type = resource()->mime_type(); !type.starts_with("application/"sv)) - tentative_type = move(type); + tentative_type = MUST(String::from_byte_string(type)); // 2. If tentative type is not application/octet-stream, then let resource type be tentative type and jump to the step below labeled handler. if (tentative_type.has_value() && tentative_type != "application/octet-stream"sv) @@ -221,8 +221,7 @@ void HTMLObjectElement::resource_did_load() } // FIXME: 5. If applying the URL parser algorithm to the URL of the specified resource (after any redirects) results in a URL record whose path component matches a pattern that a plugin supports, then let resource type be the type that that plugin can handle. - - run_object_representation_handler_steps(move(resource_type)); + run_object_representation_handler_steps(resource_type.has_value() ? resource_type->to_byte_string() : ByteString::empty()); } static bool is_xml_mime_type(StringView resource_type) @@ -314,7 +313,7 @@ void HTMLObjectElement::run_object_representation_fallback_steps() void HTMLObjectElement::load_image() { // NOTE: This currently reloads the image instead of reusing the resource we've already downloaded. - auto data = deprecated_attribute(HTML::AttributeNames::data); + auto data = get_attribute_value(HTML::AttributeNames::data); auto url = document().parse_url(data); m_image_request = HTML::SharedImageRequest::get_or_create(realm(), document().page(), url); m_image_request->add_callbacks( diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h index b82cf4d9dbb..88118a0cf5d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h @@ -40,7 +40,7 @@ public: String data() const; void set_data(String const& data) { MUST(set_attribute(HTML::AttributeNames::data, data)); } - ByteString type() const { return deprecated_attribute(HTML::AttributeNames::type); } + String type() const { return get_attribute_value(HTML::AttributeNames::type); } // ^FormAssociatedElement // https://html.spec.whatwg.org/multipage/forms.html#category-listed diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp index 65b2f523c1d..7f973061b7e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp @@ -259,14 +259,14 @@ void HTMLScriptElement::prepare_script() // 20. If el has an event attribute and a for attribute, and el's type is "classic", then: if (m_script_type == ScriptType::Classic && has_attribute(HTML::AttributeNames::event) && has_attribute(HTML::AttributeNames::for_)) { // 1. Let for be the value of el's' for attribute. - auto for_ = deprecated_attribute(HTML::AttributeNames::for_); + auto for_ = get_attribute_value(HTML::AttributeNames::for_); // 2. Let event be the value of el's event attribute. - auto event = deprecated_attribute(HTML::AttributeNames::event); + auto event = get_attribute_value(HTML::AttributeNames::event); // 3. Strip leading and trailing ASCII whitespace from event and for. - for_ = for_.trim(Infra::ASCII_WHITESPACE); - event = event.trim(Infra::ASCII_WHITESPACE); + for_ = MUST(for_.trim(Infra::ASCII_WHITESPACE)); + event = MUST(event.trim(Infra::ASCII_WHITESPACE)); // 4. If for is not an ASCII case-insensitive match for the string "window", then return. if (!Infra::is_ascii_case_insensitive_match(for_, "window"sv)) { @@ -287,7 +287,7 @@ void HTMLScriptElement::prepare_script() Optional encoding; if (has_attribute(HTML::AttributeNames::charset)) { - auto charset = TextCodec::get_standardized_encoding(deprecated_attribute(HTML::AttributeNames::charset)); + auto charset = TextCodec::get_standardized_encoding(get_attribute_value(HTML::AttributeNames::charset)); if (charset.has_value()) encoding = String::from_utf8(*charset).release_value_but_fixme_should_propagate_errors(); } @@ -309,9 +309,8 @@ void HTMLScriptElement::prepare_script() // 25. If el has an integrity attribute, then let integrity metadata be that attribute's value. // Otherwise, let integrity metadata be the empty string. String integrity_metadata; - if (has_attribute(HTML::AttributeNames::integrity)) { - auto integrity = deprecated_attribute(HTML::AttributeNames::integrity); - integrity_metadata = String::from_byte_string(integrity).release_value_but_fixme_should_propagate_errors(); + if (auto maybe_integrity = attribute(HTML::AttributeNames::integrity); maybe_integrity.has_value()) { + integrity_metadata = *maybe_integrity; } // 26. Let referrer policy be the current state of el's referrerpolicy content attribute. @@ -348,7 +347,7 @@ void HTMLScriptElement::prepare_script() } // 2. Let src be the value of el's src attribute. - auto src = deprecated_attribute(HTML::AttributeNames::src); + auto src = get_attribute_value(HTML::AttributeNames::src); // 3. If src is the empty string, then queue an element task on the DOM manipulation task source given el to fire an event named error at el, and return. if (src.is_empty()) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp index 03453561506..605ad5cef2c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp @@ -193,9 +193,10 @@ Optional HTMLSelectElement::default_role() const if (has_attribute(AttributeNames::multiple)) return ARIA::Role::listbox; if (has_attribute(AttributeNames::size)) { - auto size_attribute = deprecated_attribute(AttributeNames::size).to_number(); - if (size_attribute.has_value() && size_attribute.value() > 1) - return ARIA::Role::listbox; + if (auto size_string = get_attribute(HTML::AttributeNames::size); size_string.has_value()) { + if (auto size = size_string->to_number(); size.has_value() && *size > 1) + return ARIA::Role::listbox; + } } // https://www.w3.org/TR/html-aria/#el-select return ARIA::Role::combobox; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp index ff6b9749f96..fc187774273 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp @@ -53,7 +53,7 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl return; } if (name == HTML::AttributeNames::valign) { - if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value.view(), CSS::PropertyID::VerticalAlign)) + if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value, CSS::PropertyID::VerticalAlign)) style.set_property(CSS::PropertyID::VerticalAlign, parsed_value.release_nonnull()); return; } @@ -65,7 +65,7 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl } else if (value.equals_ignoring_ascii_case("right"sv)) { style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebRight)); } else { - if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value.view(), CSS::PropertyID::TextAlign)) + if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value, CSS::PropertyID::TextAlign)) style.set_property(CSS::PropertyID::TextAlign, parsed_value.release_nonnull()); } return; @@ -112,7 +112,7 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl // https://html.spec.whatwg.org/multipage/tables.html#algorithm-for-processing-rows unsigned int HTMLTableCellElement::col_span() const { - auto optional_value = Web::HTML::parse_non_negative_integer(deprecated_attribute(HTML::AttributeNames::colspan)); + auto optional_value = Web::HTML::parse_non_negative_integer(get_attribute_value(HTML::AttributeNames::colspan)); // If parsing that value failed, or returned zero, or if the attribute is absent, then let colspan be 1, instead. if (!optional_value.has_value() || optional_value.value() == 0) { @@ -139,7 +139,7 @@ WebIDL::ExceptionOr HTMLTableCellElement::set_col_span(unsigned int value) unsigned int HTMLTableCellElement::row_span() const { // If parsing that value failed or if the attribute is absent, then let rowspan be 1, instead. - auto value = Web::HTML::parse_non_negative_integer(deprecated_attribute(HTML::AttributeNames::rowspan)).value_or(1); + auto value = Web::HTML::parse_non_negative_integer(get_attribute_value(HTML::AttributeNames::rowspan)).value_or(1); // If rowspan is greater than 65534, let it be 65534 instead. if (value > 65534) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp index fef49fe5029..97493cb168e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp @@ -44,7 +44,7 @@ void HTMLTableElement::visit_edges(Cell::Visitor& visitor) visitor.visit(m_t_bodies); } -static unsigned parse_border(ByteString const& value) +static unsigned parse_border(StringView value) { return value.to_number().value_or(0); } @@ -66,7 +66,7 @@ void HTMLTableElement::apply_presentational_hints(CSS::StyleProperties& style) c if (value.equals_ignoring_ascii_case("center"sv)) { style.set_property(CSS::PropertyID::MarginLeft, CSS::IdentifierStyleValue::create(CSS::ValueID::Auto)); style.set_property(CSS::PropertyID::MarginRight, CSS::IdentifierStyleValue::create(CSS::ValueID::Auto)); - } else if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value.view(), CSS::PropertyID::Float)) { + } else if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value, CSS::PropertyID::Float)) { style.set_property(CSS::PropertyID::Float, parsed_value.release_nonnull()); } return; @@ -435,7 +435,7 @@ WebIDL::ExceptionOr HTMLTableElement::delete_row(long index) unsigned int HTMLTableElement::border() const { - return parse_border(deprecated_attribute(HTML::AttributeNames::border)); + return parse_border(get_attribute_value(HTML::AttributeNames::border)); } unsigned int HTMLTableElement::padding() const diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp index fc1f7590480..c917b27fb4d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp @@ -53,7 +53,7 @@ void HTMLTableRowElement::apply_presentational_hints(CSS::StyleProperties& style style.set_property(CSS::PropertyID::BackgroundImage, CSS::ImageStyleValue::create(parsed_value)); return; } else if (name == HTML::AttributeNames::valign) { - if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value.view(), CSS::PropertyID::VerticalAlign)) + if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value, CSS::PropertyID::VerticalAlign)) style.set_property(CSS::PropertyID::VerticalAlign, parsed_value.release_nonnull()); return; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp index 98780faaf53..b5e613e7e75 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp @@ -195,7 +195,7 @@ void HTMLTextAreaElement::create_shadow_tree_if_needed() MUST(element->append_child(*m_placeholder_element)); m_placeholder_text_node = heap().allocate(realm(), document(), String {}); - m_placeholder_text_node->set_data(get_attribute(HTML::AttributeNames::placeholder).value_or(String {})); + m_placeholder_text_node->set_data(get_attribute_value(HTML::AttributeNames::placeholder)); m_placeholder_text_node->set_editable_text_node_owner(Badge {}, *this); MUST(m_placeholder_element->append_child(*m_placeholder_text_node)); diff --git a/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp b/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp index 9dd02e363bd..bd86af7f39b 100644 --- a/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp +++ b/Userland/Libraries/LibWeb/HTML/NavigableContainer.cpp @@ -196,7 +196,7 @@ Optional NavigableContainer::shared_attribute_processing_steps_for_ifra // 2. If element has a src attribute specified, and its value is not the empty string, // then parse the value of that attribute relative to element's node document. // If this is successful, then set url to the resulting URL record. - auto src_attribute_value = deprecated_attribute(HTML::AttributeNames::src); + auto src_attribute_value = get_attribute_value(HTML::AttributeNames::src); if (!src_attribute_value.is_empty()) { auto parsed_src = document().parse_url(src_attribute_value); if (parsed_src.is_valid()) diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp index 19b0f8220c0..98a0b251b1e 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp @@ -4555,9 +4555,11 @@ RefPtr parse_nonzero_dimension_value(StringView string) } // https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-a-legacy-colour-value -Optional parse_legacy_color_value(ByteString input) +Optional parse_legacy_color_value(StringView string) { // 1. Let input be the string being parsed + ByteString input = MUST(ByteString::from_utf8(string)); + // 2. If input is the empty string, then return an error. if (input.is_empty()) return {}; diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h index 1edf987e75b..cdae5ea79ff 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h @@ -202,6 +202,6 @@ private: RefPtr parse_dimension_value(StringView); RefPtr parse_nonzero_dimension_value(StringView); -Optional parse_legacy_color_value(ByteString input); +Optional parse_legacy_color_value(StringView); } diff --git a/Userland/Libraries/LibWeb/Layout/FrameBox.cpp b/Userland/Libraries/LibWeb/Layout/FrameBox.cpp index ebc3aec106d..21a95c45f74 100644 --- a/Userland/Libraries/LibWeb/Layout/FrameBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/FrameBox.cpp @@ -24,8 +24,8 @@ void FrameBox::prepare_for_replaced_layout() VERIFY(dom_node().nested_browsing_context()); // FIXME: Do proper error checking, etc. - set_natural_width(dom_node().deprecated_attribute(HTML::AttributeNames::width).to_number().value_or(300)); - set_natural_height(dom_node().deprecated_attribute(HTML::AttributeNames::height).to_number().value_or(150)); + set_natural_width(dom_node().get_attribute_value(HTML::AttributeNames::width).to_number().value_or(300)); + set_natural_height(dom_node().get_attribute_value(HTML::AttributeNames::height).to_number().value_or(150)); } void FrameBox::did_set_content_size() diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp index 9376efb2053..8c6452a1429 100644 --- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp @@ -72,7 +72,7 @@ void TableFormattingContext::compute_constrainedness() m_columns[column_index].is_constrained = true; } auto const& col_node = static_cast(*column_box.dom_node()); - unsigned span = col_node.deprecated_attribute(HTML::AttributeNames::span).to_number().value_or(1); + unsigned span = col_node.get_attribute_value(HTML::AttributeNames::span).to_number().value_or(1); column_index += span; }); }); @@ -189,7 +189,7 @@ void TableFormattingContext::compute_outer_content_sizes() // The outer max-content width of a table-column or table-column-group is max(min-width, min(max-width, width)). m_columns[column_index].max_size = max(min_width, min(max_width, width)); auto const& col_node = static_cast(*column_box.dom_node()); - unsigned span = col_node.deprecated_attribute(HTML::AttributeNames::span).to_number().value_or(1); + unsigned span = col_node.get_attribute_value(HTML::AttributeNames::span).to_number().value_or(1); column_index += span; }); }); @@ -1380,7 +1380,7 @@ void TableFormattingContext::BorderConflictFinder::collect_conflicting_col_eleme for (auto* child_of_column_group = child->first_child(); child_of_column_group; child_of_column_group = child_of_column_group->next_sibling()) { VERIFY(child_of_column_group->display().is_table_column()); auto const& col_node = static_cast(*child_of_column_group->dom_node()); - unsigned span = col_node.deprecated_attribute(HTML::AttributeNames::span).to_number().value_or(1); + unsigned span = col_node.get_attribute_value(HTML::AttributeNames::span).to_number().value_or(1); for (size_t i = column_index; i < column_index + span; ++i) { m_col_elements_by_index[i] = child_of_column_group; } @@ -1744,7 +1744,7 @@ void TableFormattingContext::initialize_intrinsic_percentages_from_rows_or_colum m_columns[column_index].has_intrinsic_percentage = computed_values.max_width().is_percentage() || computed_values.width().is_percentage(); m_columns[column_index].intrinsic_percentage = min(width_percentage, max_width_percentage); auto const& col_node = static_cast(*column_box.dom_node()); - unsigned span = col_node.deprecated_attribute(HTML::AttributeNames::span).to_number().value_or(1); + unsigned span = col_node.get_attribute_value(HTML::AttributeNames::span).to_number().value_or(1); column_index += span; }); }); diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index 4d0bed3c6e6..eb7dd834a41 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -285,9 +285,9 @@ bool EventHandler::handle_mouseup(CSSPixelPoint position, CSSPixelPoint screen_p auto url = document->parse_url(href); dbgln("Web::EventHandler: Clicking on a link to {}", url); if (button == GUI::MouseButton::Middle) { - m_browsing_context->page().client().page_did_middle_click_link(url, link->target(), modifiers); + m_browsing_context->page().client().page_did_middle_click_link(url, link->target().to_byte_string(), modifiers); } else if (button == GUI::MouseButton::Secondary) { - m_browsing_context->page().client().page_did_request_link_context_menu(m_browsing_context->to_top_level_position(position), url, link->target(), modifiers); + m_browsing_context->page().client().page_did_request_link_context_menu(m_browsing_context->to_top_level_position(position), url, link->target().to_byte_string(), modifiers); } } else if (button == GUI::MouseButton::Secondary) { if (is(*node)) { diff --git a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp index c3f84c0390b..0829c26ebcc 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp @@ -54,10 +54,10 @@ void SVGForeignObjectElement::apply_presentational_hints(CSS::StyleProperties& s { Base::apply_presentational_hints(style); auto parsing_context = CSS::Parser::ParsingContext { document() }; - if (auto width_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width)) + if (auto width_value = parse_css_value(parsing_context, get_attribute_value(Web::HTML::AttributeNames::width), CSS::PropertyID::Width)) style.set_property(CSS::PropertyID::Width, width_value.release_nonnull()); - if (auto height_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::height), CSS::PropertyID::Height)) + if (auto height_value = parse_css_value(parsing_context, get_attribute_value(Web::HTML::AttributeNames::height), CSS::PropertyID::Height)) style.set_property(CSS::PropertyID::Height, height_value.release_nonnull()); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGGradientElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGradientElement.cpp index 576dac5c8d0..71bb28ed1b3 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGradientElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGGradientElement.cpp @@ -94,9 +94,9 @@ JS::GCPtr SVGGradientElement::linked_gradient() const // FIXME: This entire function is an ad-hoc hack! // It can only resolve # in the same document. - auto link = has_attribute(AttributeNames::href) ? deprecated_get_attribute(AttributeNames::href) : deprecated_get_attribute("xlink:href"_fly_string); - if (auto href = link; !href.is_empty()) { - auto url = document().parse_url(href); + auto link = has_attribute(AttributeNames::href) ? get_attribute(AttributeNames::href) : get_attribute("xlink:href"_fly_string); + if (auto href = link; href.has_value() && !link->is_empty()) { + auto url = document().parse_url(*href); auto id = url.fragment(); if (!id.has_value() || id->is_empty()) return {}; diff --git a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp index ce3ff6489f8..aedc46e6a26 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp @@ -42,7 +42,7 @@ void SVGSVGElement::apply_presentational_hints(CSS::StyleProperties& style) cons auto width_attribute = attribute(SVG::AttributeNames::width); auto parsing_context = CSS::Parser::ParsingContext { document(), CSS::Parser::ParsingContext::Mode::SVGPresentationAttribute }; - if (auto width_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width)) { + if (auto width_value = parse_css_value(parsing_context, width_attribute.value_or(String {}), CSS::PropertyID::Width)) { style.set_property(CSS::PropertyID::Width, width_value.release_nonnull()); } else if (width_attribute == "") { // If the `width` attribute is an empty string, it defaults to 100%. @@ -53,7 +53,7 @@ void SVGSVGElement::apply_presentational_hints(CSS::StyleProperties& style) cons // Height defaults to 100% auto height_attribute = attribute(SVG::AttributeNames::height); - if (auto height_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::height), CSS::PropertyID::Height)) { + if (auto height_value = parse_css_value(parsing_context, height_attribute.value_or(String {}), CSS::PropertyID::Height)) { style.set_property(CSS::PropertyID::Height, height_value.release_nonnull()); } else if (height_attribute == "") { // If the `height` attribute is an empty string, it defaults to 100%. @@ -84,15 +84,15 @@ void SVGSVGElement::update_fallback_view_box_for_svg_as_image() Optional width; Optional height; - auto width_attribute = deprecated_attribute(SVG::AttributeNames::width); + auto width_attribute = get_attribute_value(SVG::AttributeNames::width); auto parsing_context = CSS::Parser::ParsingContext { document() }; - if (auto width_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width)) { + if (auto width_value = parse_css_value(parsing_context, width_attribute, CSS::PropertyID::Width)) { if (width_value->is_length() && width_value->as_length().length().is_absolute()) width = width_value->as_length().length().absolute_length_to_px().to_double(); } - auto height_attribute = deprecated_attribute(SVG::AttributeNames::height); - if (auto height_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::height), CSS::PropertyID::Height)) { + auto height_attribute = get_attribute_value(SVG::AttributeNames::height); + if (auto height_value = parse_css_value(parsing_context, height_attribute, CSS::PropertyID::Height)) { if (height_value->is_length() && height_value->as_length().length().is_absolute()) height = height_value->as_length().length().absolute_length_to_px().to_double(); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp index b3cd0f99b92..b3b6d0ca985 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp @@ -107,7 +107,7 @@ void SVGUseElement::svg_element_removed(SVGElement& svg_element) return; } - if (svg_element.deprecated_attribute("id"_fly_string).matches(m_referenced_id.value())) { + if (AK::StringUtils::matches(svg_element.get_attribute_value("id"_fly_string), m_referenced_id.value())) { shadow_root()->remove_all_children(); } } diff --git a/Userland/Services/WebContent/ConnectionFromClient.cpp b/Userland/Services/WebContent/ConnectionFromClient.cpp index 97ebd2c472f..d169c3eacd1 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.cpp +++ b/Userland/Services/WebContent/ConnectionFromClient.cpp @@ -457,7 +457,7 @@ void ConnectionFromClient::debug_request(ByteString const& request, ByteString c load_html("

Failed to find <link rel="match" /> in ref test page!

Make sure you added it."); } else { auto link = maybe_link.release_value(); - auto url = document->parse_url(link->deprecated_get_attribute(Web::HTML::AttributeNames::href)); + auto url = document->parse_url(link->get_attribute_value(Web::HTML::AttributeNames::href)); load_url(url); } } diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp index 9847c5504ef..a2170a74ac5 100644 --- a/Userland/Services/WebContent/WebDriverConnection.cpp +++ b/Userland/Services/WebContent/WebDriverConnection.cpp @@ -1073,7 +1073,8 @@ Messages::WebDriverClient::GetElementAttributeResponse WebDriverConnection::get_ // -> Otherwise else { // The result of getting an attribute by name name. - result = element->deprecated_get_attribute(name); + if (auto attr = element->get_attribute(name); attr.has_value()) + result = attr->to_byte_string(); } // 5. Return success with data result.