From eca9874e567b4475f88800d682620a59959281e2 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sun, 19 Nov 2023 18:10:36 +1300 Subject: [PATCH] LibWeb: Port Element::attribute_changed from DeprecatedString to String Which as you would expect has a bunch of fallout, but also results in a whole lot of awkward conversions falling away. --- Userland/Libraries/LibWeb/DOM/Attr.cpp | 14 +++++-------- Userland/Libraries/LibWeb/DOM/Attr.h | 2 +- .../Libraries/LibWeb/DOM/CharacterData.cpp | 2 +- Userland/Libraries/LibWeb/DOM/Element.cpp | 16 +++++++-------- Userland/Libraries/LibWeb/DOM/Element.h | 6 +++--- .../Libraries/LibWeb/DOM/NamedNodeMap.cpp | 6 +++--- Userland/Libraries/LibWeb/DOM/Node.cpp | 20 +++++++++++-------- Userland/Libraries/LibWeb/DOM/Node.h | 2 +- .../LibWeb/HTML/HTMLAnchorElement.cpp | 2 +- .../Libraries/LibWeb/HTML/HTMLAnchorElement.h | 2 +- .../Libraries/LibWeb/HTML/HTMLAreaElement.cpp | 2 +- .../Libraries/LibWeb/HTML/HTMLAreaElement.h | 2 +- .../Libraries/LibWeb/HTML/HTMLBaseElement.cpp | 2 +- .../Libraries/LibWeb/HTML/HTMLBaseElement.h | 2 +- .../Libraries/LibWeb/HTML/HTMLBodyElement.cpp | 16 +++++++-------- .../Libraries/LibWeb/HTML/HTMLBodyElement.h | 2 +- .../LibWeb/HTML/HTMLDetailsElement.cpp | 2 +- .../LibWeb/HTML/HTMLDetailsElement.h | 2 +- .../Libraries/LibWeb/HTML/HTMLElement.cpp | 8 ++++---- Userland/Libraries/LibWeb/HTML/HTMLElement.h | 2 +- .../LibWeb/HTML/HTMLFrameSetElement.cpp | 8 ++++---- .../LibWeb/HTML/HTMLFrameSetElement.h | 2 +- .../LibWeb/HTML/HTMLIFrameElement.cpp | 2 +- .../Libraries/LibWeb/HTML/HTMLIFrameElement.h | 2 +- .../LibWeb/HTML/HTMLImageElement.cpp | 8 ++------ .../Libraries/LibWeb/HTML/HTMLImageElement.h | 2 +- .../LibWeb/HTML/HTMLInputElement.cpp | 13 +++++------- .../Libraries/LibWeb/HTML/HTMLInputElement.h | 2 +- .../Libraries/LibWeb/HTML/HTMLLinkElement.cpp | 7 ++++--- .../Libraries/LibWeb/HTML/HTMLLinkElement.h | 2 +- .../LibWeb/HTML/HTMLMediaElement.cpp | 7 ++----- .../Libraries/LibWeb/HTML/HTMLMediaElement.h | 2 +- .../LibWeb/HTML/HTMLObjectElement.cpp | 2 +- .../Libraries/LibWeb/HTML/HTMLObjectElement.h | 2 +- .../LibWeb/HTML/HTMLOptionElement.cpp | 2 +- .../Libraries/LibWeb/HTML/HTMLOptionElement.h | 2 +- .../LibWeb/HTML/HTMLScriptElement.cpp | 7 ++----- .../Libraries/LibWeb/HTML/HTMLScriptElement.h | 2 +- .../Libraries/LibWeb/HTML/HTMLSlotElement.cpp | 6 +++--- .../LibWeb/HTML/HTMLVideoElement.cpp | 9 +++------ .../Libraries/LibWeb/HTML/HTMLVideoElement.h | 4 ++-- .../Libraries/LibWeb/SVG/SVGCircleElement.cpp | 8 ++++---- .../Libraries/LibWeb/SVG/SVGCircleElement.h | 2 +- Userland/Libraries/LibWeb/SVG/SVGElement.cpp | 2 +- Userland/Libraries/LibWeb/SVG/SVGElement.h | 2 +- .../LibWeb/SVG/SVGEllipseElement.cpp | 10 +++++----- .../Libraries/LibWeb/SVG/SVGEllipseElement.h | 2 +- .../LibWeb/SVG/SVGGradientElement.cpp | 8 ++++---- .../Libraries/LibWeb/SVG/SVGGradientElement.h | 2 +- .../LibWeb/SVG/SVGGraphicsElement.cpp | 4 ++-- .../Libraries/LibWeb/SVG/SVGGraphicsElement.h | 2 +- .../Libraries/LibWeb/SVG/SVGLineElement.cpp | 10 +++++----- .../Libraries/LibWeb/SVG/SVGLineElement.h | 2 +- .../LibWeb/SVG/SVGLinearGradientElement.cpp | 10 +++++----- .../LibWeb/SVG/SVGLinearGradientElement.h | 2 +- .../Libraries/LibWeb/SVG/SVGMaskElement.cpp | 6 +++--- .../Libraries/LibWeb/SVG/SVGMaskElement.h | 2 +- .../Libraries/LibWeb/SVG/SVGPathElement.cpp | 4 ++-- .../Libraries/LibWeb/SVG/SVGPathElement.h | 2 +- .../LibWeb/SVG/SVGPolygonElement.cpp | 4 ++-- .../Libraries/LibWeb/SVG/SVGPolygonElement.h | 2 +- .../LibWeb/SVG/SVGPolylineElement.cpp | 4 ++-- .../Libraries/LibWeb/SVG/SVGPolylineElement.h | 2 +- .../LibWeb/SVG/SVGRadialGradientElement.cpp | 14 ++++++------- .../LibWeb/SVG/SVGRadialGradientElement.h | 2 +- .../Libraries/LibWeb/SVG/SVGRectElement.cpp | 14 ++++++------- .../Libraries/LibWeb/SVG/SVGRectElement.h | 2 +- .../Libraries/LibWeb/SVG/SVGSVGElement.cpp | 6 +++--- Userland/Libraries/LibWeb/SVG/SVGSVGElement.h | 2 +- .../Libraries/LibWeb/SVG/SVGStopElement.cpp | 4 ++-- .../Libraries/LibWeb/SVG/SVGStopElement.h | 2 +- .../Libraries/LibWeb/SVG/SVGSymbolElement.cpp | 4 ++-- .../Libraries/LibWeb/SVG/SVGSymbolElement.h | 2 +- .../LibWeb/SVG/SVGTextPositioningElement.cpp | 10 +++++----- .../LibWeb/SVG/SVGTextPositioningElement.h | 2 +- .../Libraries/LibWeb/SVG/SVGUseElement.cpp | 8 ++++---- Userland/Libraries/LibWeb/SVG/SVGUseElement.h | 2 +- 77 files changed, 178 insertions(+), 193 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Attr.cpp b/Userland/Libraries/LibWeb/DOM/Attr.cpp index 57a60c4e92..d9654e59b9 100644 --- a/Userland/Libraries/LibWeb/DOM/Attr.cpp +++ b/Userland/Libraries/LibWeb/DOM/Attr.cpp @@ -88,18 +88,14 @@ void Attr::change_attribute(String value) m_value = move(value); // 3. Handle attribute changes for attribute with attribute’s element, oldValue, and value. - handle_attribute_changes(*owner_element(), old_value.to_deprecated_string(), m_value.to_deprecated_string()); + handle_attribute_changes(*owner_element(), old_value, m_value); } // https://dom.spec.whatwg.org/#handle-attribute-changes -void Attr::handle_attribute_changes(Element& element, Optional old_value, Optional new_value) +void Attr::handle_attribute_changes(Element& element, Optional const& old_value, Optional const& new_value) { - DeprecatedString deprecated_namespace_uri; - if (namespace_uri().has_value()) - deprecated_namespace_uri = namespace_uri().value().to_deprecated_fly_string(); - // 1. Queue a mutation record of "attributes" for element with attribute’s local name, attribute’s namespace, oldValue, « », « », null, and null. - element.queue_mutation_record(MutationType::attributes, local_name().to_deprecated_fly_string(), deprecated_namespace_uri, old_value, {}, {}, nullptr, nullptr); + element.queue_mutation_record(MutationType::attributes, local_name(), namespace_uri(), old_value, {}, {}, nullptr, nullptr); // 2. If element is custom, then enqueue a custom element callback reaction with element, callback name "attributeChangedCallback", and an argument list containing attribute’s local name, oldValue, newValue, and attribute’s namespace. if (element.is_custom()) { @@ -107,8 +103,8 @@ void Attr::handle_attribute_changes(Element& element, Optional JS::MarkedVector arguments { vm.heap() }; arguments.append(JS::PrimitiveString::create(vm, local_name())); - arguments.append(!old_value.has_value() ? JS::js_null() : JS::PrimitiveString::create(vm, old_value.release_value())); - arguments.append(!new_value.has_value() ? JS::js_null() : JS::PrimitiveString::create(vm, new_value.release_value())); + arguments.append(!old_value.has_value() ? JS::js_null() : JS::PrimitiveString::create(vm, old_value.value())); + arguments.append(!new_value.has_value() ? JS::js_null() : JS::PrimitiveString::create(vm, new_value.value())); arguments.append(!namespace_uri().has_value() ? JS::js_null() : JS::PrimitiveString::create(vm, namespace_uri().value())); element.enqueue_a_custom_element_callback_reaction(HTML::CustomElementReactionNames::attributeChangedCallback, move(arguments)); diff --git a/Userland/Libraries/LibWeb/DOM/Attr.h b/Userland/Libraries/LibWeb/DOM/Attr.h index 104e55fa2c..5375996de2 100644 --- a/Userland/Libraries/LibWeb/DOM/Attr.h +++ b/Userland/Libraries/LibWeb/DOM/Attr.h @@ -41,7 +41,7 @@ public: // Always returns true: https://dom.spec.whatwg.org/#dom-attr-specified constexpr bool specified() const { return true; } - void handle_attribute_changes(Element&, Optional old_value, Optional new_value); + void handle_attribute_changes(Element&, Optional const& old_value, Optional const& new_value); private: Attr(Document&, QualifiedName, String value, Element*); diff --git a/Userland/Libraries/LibWeb/DOM/CharacterData.cpp b/Userland/Libraries/LibWeb/DOM/CharacterData.cpp index c2eecce9e4..4c3ceeda61 100644 --- a/Userland/Libraries/LibWeb/DOM/CharacterData.cpp +++ b/Userland/Libraries/LibWeb/DOM/CharacterData.cpp @@ -74,7 +74,7 @@ WebIDL::ExceptionOr CharacterData::replace_data(size_t offset, size_t coun count = length - offset; // 4. Queue a mutation record of "characterData" for node with null, null, node’s data, « », « », null, and null. - queue_mutation_record(MutationType::characterData, {}, {}, m_data.to_deprecated_string(), {}, {}, nullptr, nullptr); + queue_mutation_record(MutationType::characterData, {}, {}, m_data, {}, {}, nullptr, nullptr); // 5. Insert data into node’s data after offset code units. // 6. Let delete offset be offset + data’s length. diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index a346157aa8..6ebe538322 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -81,11 +81,11 @@ Element::Element(Document& document, DOM::QualifiedName qualified_name) return; // 2. If value is null and oldValue is the empty string, then return. - if (!value.has_value() && old_value == DeprecatedString::empty()) + if (!value.has_value() && old_value == String {}) return; // 3. If value is the empty string and oldValue is null, then return. - if (value == DeprecatedString::empty() && !old_value.has_value()) + if (value == String {} && !old_value.has_value()) return; // 4. If value is null or the empty string, then set element’s name to the empty string. @@ -93,7 +93,7 @@ Element::Element(Document& document, DOM::QualifiedName qualified_name) set_slottable_name({}); // 5. Otherwise, set element’s name to value. else - set_slottable_name(MUST(String::from_deprecated_string(*value))); + set_slottable_name(*value); // 6. If element is assigned, then run assign slottables for element’s assigned slot. if (auto assigned_slot = assigned_slot_internal()) @@ -466,7 +466,7 @@ void Element::add_attribute_change_steps(AttributeChangeSteps steps) m_attribute_change_steps.append(move(steps)); } -void Element::run_attribute_change_steps(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_) +void Element::run_attribute_change_steps(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_) { for (auto const& attribute_change_steps : m_attribute_change_steps) attribute_change_steps(local_name, old_value, value, namespace_); @@ -476,17 +476,17 @@ void Element::run_attribute_change_steps(FlyString const& local_name, Optional const& value) +void Element::attribute_changed(FlyString const& name, Optional const& value) { - auto value_or_empty = value.value_or(""); + auto value_or_empty = value.value_or(String {}); if (name == HTML::AttributeNames::id) { if (!value.has_value()) m_id = {}; else - m_id = MUST(FlyString::from_deprecated_fly_string(value_or_empty)); + m_id = value_or_empty; } else if (name == HTML::AttributeNames::class_) { - auto new_classes = value_or_empty.split_view(Infra::is_ascii_whitespace); + auto new_classes = value_or_empty.bytes_as_string_view().split_view_if(Infra::is_ascii_whitespace); m_classes.clear(); m_classes.ensure_capacity(new_classes.size()); for (auto& new_class : new_classes) { diff --git a/Userland/Libraries/LibWeb/DOM/Element.h b/Userland/Libraries/LibWeb/DOM/Element.h index 9daefee8fd..9948d396e1 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.h +++ b/Userland/Libraries/LibWeb/DOM/Element.h @@ -147,11 +147,11 @@ public: virtual void apply_presentational_hints(CSS::StyleProperties&) const { } // https://dom.spec.whatwg.org/#concept-element-attributes-change-ext - using AttributeChangeSteps = Function const& old_value, Optional const& value, Optional const& namespace_)>; + using AttributeChangeSteps = Function const& old_value, Optional const& value, Optional const& namespace_)>; void add_attribute_change_steps(AttributeChangeSteps steps); - void run_attribute_change_steps(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_); - virtual void attribute_changed(FlyString const& name, Optional const& value); + void run_attribute_change_steps(FlyString const& local_name, Optional const& old_value, Optional const& value, Optional const& namespace_); + virtual void attribute_changed(FlyString const& name, Optional const& value); struct [[nodiscard]] RequiredInvalidationAfterStyleChange { bool repaint { false }; diff --git a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp index 456cb40fe1..912fd2b484 100644 --- a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp +++ b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp @@ -269,7 +269,7 @@ void NamedNodeMap::replace_attribute(Attr& old_attribute, Attr& new_attribute, s old_attribute.set_owner_element(nullptr); // 4. Handle attribute changes for oldAttr with newAttr’s element, oldAttr’s value, and newAttr’s value. - old_attribute.handle_attribute_changes(*new_attribute.owner_element(), old_attribute.value().to_deprecated_string(), new_attribute.value().to_deprecated_string()); + old_attribute.handle_attribute_changes(*new_attribute.owner_element(), old_attribute.value(), new_attribute.value()); } // https://dom.spec.whatwg.org/#concept-element-attributes-append @@ -282,7 +282,7 @@ void NamedNodeMap::append_attribute(Attr& attribute) attribute.set_owner_element(&associated_element()); // 3. Handle attribute changes for attribute with element, null, and attribute’s value. - attribute.handle_attribute_changes(associated_element(), {}, attribute.value().to_deprecated_string()); + attribute.handle_attribute_changes(associated_element(), {}, attribute.value()); } // https://dom.spec.whatwg.org/#concept-element-attributes-remove @@ -301,7 +301,7 @@ void NamedNodeMap::remove_attribute_at_index(size_t attribute_index) attribute->set_owner_element(nullptr); // 4. Handle attribute changes for attribute with element, attribute’s value, and null. - attribute->handle_attribute_changes(*element, attribute->value().to_deprecated_string(), {}); + attribute->handle_attribute_changes(*element, attribute->value(), {}); } // https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-name diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index a1281a11a5..f2616c4bc0 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -1533,7 +1533,7 @@ Painting::PaintableBox* Node::paintable_box() } // https://dom.spec.whatwg.org/#queue-a-mutation-record -void Node::queue_mutation_record(FlyString const& type, Optional attribute_name, Optional attribute_namespace, Optional old_value, Vector> added_nodes, Vector> removed_nodes, Node* previous_sibling, Node* next_sibling) const +void Node::queue_mutation_record(FlyString const& type, Optional const& attribute_name, Optional const& attribute_namespace, Optional const& old_value, Vector> added_nodes, Vector> removed_nodes, Node* previous_sibling, Node* next_sibling) const { // NOTE: We defer garbage collection until the end of the scope, since we can't safely use MutationObserver* as a hashmap key otherwise. // FIXME: This is a total hack. @@ -1541,7 +1541,7 @@ void Node::queue_mutation_record(FlyString const& type, Optional mappedOldValue - OrderedHashMap> interested_observers; + OrderedHashMap> interested_observers; // 2. Let nodes be the inclusive ancestors of target. // 3. For each node in nodes, and then for each registered of node’s registered observer list: @@ -1559,7 +1559,7 @@ void Node::queue_mutation_record(FlyString const& type, Optionalcontains_slow(attribute_name.value_or("").view()))) + && !(type == MutationType::attributes && options.attribute_filter.has_value() && (attribute_namespace.has_value() || !options.attribute_filter->contains_slow(attribute_name.value_or(String {})))) && !(type == MutationType::characterData && (!options.character_data.has_value() || !options.character_data.value())) && !(type == MutationType::childList && !options.child_list)) { // 1. Let mo be registered’s observer. @@ -1585,13 +1585,17 @@ void Node::queue_mutation_record(FlyString const& type, Optional attribute name and namespace + Optional string_attribute_name; + if (attribute_name.has_value()) + string_attribute_name = attribute_name->to_string(); + Optional string_attribute_namespace; + if (attribute_namespace.has_value()) + string_attribute_name = attribute_namespace->to_string(); + // 1. Let record be a new MutationRecord object with its type set to type, target set to target, attributeName set to name, attributeNamespace set to namespace, oldValue set to mappedOldValue, // addedNodes set to addedNodes, removedNodes set to removedNodes, previousSibling set to previousSibling, and nextSibling set to nextSibling. - auto maybe_attribute_name = attribute_name.map([](auto& name) { return MUST(String::from_deprecated_string(name)); }); - auto maybe_attribute_namespace = attribute_namespace.map([](auto& ns) { return MUST(String::from_deprecated_string(ns)); }); - auto maybe_interested_observer = interested_observer.value.map([](auto& value) { return MUST(String::from_deprecated_string(value)); }); - - auto record = MutationRecord::create(realm(), type, *this, added_nodes_list, removed_nodes_list, previous_sibling, next_sibling, maybe_attribute_name, maybe_attribute_namespace, /* mappedOldValue */ maybe_interested_observer); + auto record = MutationRecord::create(realm(), type, *this, added_nodes_list, removed_nodes_list, previous_sibling, next_sibling, string_attribute_name, string_attribute_namespace, /* mappedOldValue */ interested_observer.value); // 2. Enqueue record to observer’s record queue. interested_observer.key->enqueue_record({}, move(record)); diff --git a/Userland/Libraries/LibWeb/DOM/Node.h b/Userland/Libraries/LibWeb/DOM/Node.h index 698f268bd6..96ec472a8a 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.h +++ b/Userland/Libraries/LibWeb/DOM/Node.h @@ -259,7 +259,7 @@ public: void add_registered_observer(RegisteredObserver& registered_observer) { m_registered_observer_list.append(registered_observer); } - void queue_mutation_record(FlyString const& type, Optional attribute_name, Optional attribute_namespace, Optional old_value, Vector> added_nodes, Vector> removed_nodes, Node* previous_sibling, Node* next_sibling) const; + void queue_mutation_record(FlyString const& type, Optional const& attribute_name, Optional const& attribute_namespace, Optional const& old_value, Vector> added_nodes, Vector> removed_nodes, Node* previous_sibling, Node* next_sibling) const; // https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-descendant template diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp index 2054a02ebf..cf9f59fbdf 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp @@ -27,7 +27,7 @@ void HTMLAnchorElement::initialize(JS::Realm& realm) set_prototype(&Bindings::ensure_web_prototype(realm, "HTMLAnchorElement")); } -void HTMLAnchorElement::attribute_changed(FlyString const& name, Optional const& value) +void HTMLAnchorElement::attribute_changed(FlyString const& name, Optional const& value) { HTMLElement::attribute_changed(name, value); if (name == HTML::AttributeNames::href) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h index 2cf76f8c5c..ac541012ef 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h @@ -43,7 +43,7 @@ private: void run_activation_behavior(Web::DOM::Event const&); // ^DOM::Element - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; virtual i32 default_tab_index_value() const override; // ^HTML::HTMLHyperlinkElementUtils diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.cpp index d909e19786..d5da4e8549 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.cpp @@ -23,7 +23,7 @@ void HTMLAreaElement::initialize(JS::Realm& realm) set_prototype(&Bindings::ensure_web_prototype(realm, "HTMLAreaElement")); } -void HTMLAreaElement::attribute_changed(FlyString const& name, Optional const& value) +void HTMLAreaElement::attribute_changed(FlyString const& name, Optional const& value) { HTMLElement::attribute_changed(name, value); if (name == HTML::AttributeNames::href) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.h index 6cf5f42ba7..4a3835adda 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.h @@ -26,7 +26,7 @@ private: virtual void initialize(JS::Realm&) override; // ^DOM::Element - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; virtual i32 default_tab_index_value() const override; // ^HTML::HTMLHyperlinkElementUtils diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp index 53cb75100d..400d5ffd23 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp @@ -43,7 +43,7 @@ void HTMLBaseElement::removed_from(Node* parent) document().update_base_element({}); } -void HTMLBaseElement::attribute_changed(FlyString const& name, Optional const& value) +void HTMLBaseElement::attribute_changed(FlyString const& name, Optional const& value) { HTMLElement::attribute_changed(name, value); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h index 1e6c2cbf9d..2fb6ea056c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h @@ -23,7 +23,7 @@ public: virtual void inserted() override; virtual void removed_from(Node*) override; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; private: HTMLBaseElement(DOM::Document&, DOM::QualifiedName); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp index 37fd5d3ea1..2395c0a753 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp @@ -55,26 +55,26 @@ void HTMLBodyElement::apply_presentational_hints(CSS::StyleProperties& style) co }); } -void HTMLBodyElement::attribute_changed(FlyString const& name, Optional const& value) +void HTMLBodyElement::attribute_changed(FlyString const& name, Optional const& value) { 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("")); + auto color = parse_legacy_color_value(value.value_or(String {}).to_deprecated_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("")); + auto color = parse_legacy_color_value(value.value_or(String {}).to_deprecated_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("")); + auto color = parse_legacy_color_value(value.value_or(String {}).to_deprecated_string()); if (color.has_value()) document().set_visited_link_color(color.value()); } else if (name.equals_ignoring_ascii_case("background"sv)) { - m_background_style_value = CSS::ImageStyleValue::create(document().parse_url(value.value_or(""))); + m_background_style_value = CSS::ImageStyleValue::create(document().parse_url(value.value_or(String {}))); m_background_style_value->on_animate = [this] { if (layout_node()) { layout_node()->set_needs_display(); @@ -83,9 +83,9 @@ void HTMLBodyElement::attribute_changed(FlyString const& name, Optional const&) override; + virtual void attribute_changed(FlyString const&, Optional const&) override; virtual void apply_presentational_hints(CSS::StyleProperties&) const override; // https://www.w3.org/TR/html-aria/#el-body diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp index 653df30042..1943a9ddba 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp @@ -41,7 +41,7 @@ void HTMLDetailsElement::initialize(JS::Realm& realm) create_shadow_tree(realm).release_value_but_fixme_should_propagate_errors(); } -void HTMLDetailsElement::attribute_changed(FlyString const& name, Optional const& value) +void HTMLDetailsElement::attribute_changed(FlyString const& name, Optional const& value) { Base::attribute_changed(name, value); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.h b/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.h index d9d6f6c3bb..74b4dddcb0 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.h @@ -31,7 +31,7 @@ private: virtual void visit_edges(Cell::Visitor&) override; virtual void children_changed() override; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; void queue_a_details_toggle_event_task(String old_state, String new_state); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp index 90b411fdcf..90395257a7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp @@ -224,7 +224,7 @@ bool HTMLElement::cannot_navigate() const return !is(this) && !is_connected(); } -void HTMLElement::attribute_changed(FlyString const& name, Optional const& value) +void HTMLElement::attribute_changed(FlyString const& name, Optional const& value) { Element::attribute_changed(name, value); @@ -248,9 +248,9 @@ void HTMLElement::attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; virtual void visit_edges(Cell::Visitor&) override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp index f56bc9ae42..1250398a24 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp @@ -23,14 +23,14 @@ void HTMLFrameSetElement::initialize(JS::Realm& realm) set_prototype(&Bindings::ensure_web_prototype(realm, "HTMLFrameSetElement")); } -void HTMLFrameSetElement::attribute_changed(FlyString const& name, Optional const& value) +void HTMLFrameSetElement::attribute_changed(FlyString const& name, Optional const& value) { HTMLElement::attribute_changed(name, value); #undef __ENUMERATE -#define __ENUMERATE(attribute_name, event_name) \ - if (name == HTML::AttributeNames::attribute_name) { \ - element_event_handler_attribute_changed(event_name, value.map([](auto& v) { return MUST(String::from_deprecated_string(v)); })); \ +#define __ENUMERATE(attribute_name, event_name) \ + if (name == HTML::AttributeNames::attribute_name) { \ + element_event_handler_attribute_changed(event_name, value); \ } ENUMERATE_WINDOW_EVENT_HANDLERS(__ENUMERATE) #undef __ENUMERATE diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.h b/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.h index be77d235fc..6f7d8fda89 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.h @@ -24,7 +24,7 @@ private: HTMLFrameSetElement(DOM::Document&, DOM::QualifiedName); virtual void initialize(JS::Realm&) override; - virtual void attribute_changed(FlyString const&, Optional const&) override; + virtual void attribute_changed(FlyString const&, Optional const&) override; // ^HTML::GlobalEventHandlers virtual EventTarget& global_event_handlers_to_event_target(FlyString const& event_name) override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index 7488390a55..2dff0eebd9 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -33,7 +33,7 @@ JS::GCPtr HTMLIFrameElement::create_layout_node(NonnullRefPtr(document(), *this, move(style)); } -void HTMLIFrameElement::attribute_changed(FlyString const& name, Optional const& value) +void HTMLIFrameElement::attribute_changed(FlyString const& name, Optional const& value) { HTMLElement::attribute_changed(name, value); if (m_content_navigable) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h index 4cd0b915af..662c502544 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h @@ -36,7 +36,7 @@ private: // ^DOM::Element virtual void inserted() override; virtual void removed_from(Node*) override; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; virtual i32 default_tab_index_value() const override; // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#process-the-iframe-attributes diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp index c835fe760b..c6babd1fcb 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp @@ -95,16 +95,12 @@ void HTMLImageElement::apply_presentational_hints(CSS::StyleProperties& style) c }); } -void HTMLImageElement::attribute_changed(FlyString const& name, Optional const& value) +void HTMLImageElement::attribute_changed(FlyString const& name, Optional const& value) { HTMLElement::attribute_changed(name, value); if (name == HTML::AttributeNames::crossorigin) { - if (!value.has_value()) { - m_cors_setting = CORSSettingAttribute::NoCORS; - } else { - m_cors_setting = cors_setting_attribute_from_keyword(String::from_deprecated_string(*value).release_value_but_fixme_should_propagate_errors()); - } + m_cors_setting = cors_setting_attribute_from_keyword(value); } if (name.is_one_of(HTML::AttributeNames::src, HTML::AttributeNames::srcset)) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h index 6211929617..f682e14474 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h @@ -32,7 +32,7 @@ class HTMLImageElement final public: virtual ~HTMLImageElement() override; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; DeprecatedString alt() const { return deprecated_attribute(HTML::AttributeNames::alt); } DeprecatedString src() const { return deprecated_attribute(HTML::AttributeNames::src); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 585bd1f2a4..c2bab657b5 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -627,7 +627,7 @@ void HTMLInputElement::did_lose_focus() }); } -void HTMLInputElement::attribute_changed(FlyString const& name, Optional const& value) +void HTMLInputElement::attribute_changed(FlyString const& name, Optional const& value) { HTMLElement::attribute_changed(name, value); if (name == HTML::AttributeNames::checked) { @@ -643,7 +643,7 @@ void HTMLInputElement::attribute_changed(FlyString const& name, Optionalto_deprecated_string()); update_placeholder_visibility(); if (type_state() == TypeAttributeState::Color && m_color_well_element) @@ -664,12 +664,9 @@ void HTMLInputElement::attribute_changed(FlyString const& name, Optionalset_data(MUST(String::from_deprecated_string(value.value_or("")))); + m_placeholder_text_node->set_data(value.value_or(String {})); } else if (name == HTML::AttributeNames::readonly) { - if (value.has_value()) - handle_readonly_attribute(MUST(String::from_deprecated_string(*value))); - else - handle_readonly_attribute({}); + handle_readonly_attribute(value); } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h index 0970dd73f6..9d1c1797fd 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -114,7 +114,7 @@ public: virtual bool is_focusable() const override { return m_type != TypeAttributeState::Hidden; } // ^HTMLElement - virtual void attribute_changed(FlyString const&, Optional const&) override; + virtual void attribute_changed(FlyString const&, Optional const&) override; // ^FormAssociatedElement // https://html.spec.whatwg.org/multipage/forms.html#category-listed diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp index cb7d10ef0c..cd50ca2da2 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -77,7 +78,7 @@ bool HTMLLinkElement::has_loaded_icon() const return m_relationship & Relationship::Icon && resource() && resource()->is_loaded() && resource()->has_encoded_data(); } -void HTMLLinkElement::attribute_changed(FlyString const& name, Optional const& value) +void HTMLLinkElement::attribute_changed(FlyString const& name, Optional const& value) { HTMLElement::attribute_changed(name, value); @@ -85,11 +86,11 @@ void HTMLLinkElement::attribute_changed(FlyString const& name, Optional const&) override; + void attribute_changed(FlyString const&, Optional const&) override; // ^ResourceClient virtual void resource_did_fail() override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp index 2ea83a3adc..c1dc519054 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp @@ -83,17 +83,14 @@ void HTMLMediaElement::visit_edges(Cell::Visitor& visitor) visitor.visit(m_fetch_controller); } -void HTMLMediaElement::attribute_changed(FlyString const& name, Optional const& value) +void HTMLMediaElement::attribute_changed(FlyString const& name, Optional const& value) { Base::attribute_changed(name, value); if (name == HTML::AttributeNames::src) { load_element().release_value_but_fixme_should_propagate_errors(); } else if (name == HTML::AttributeNames::crossorigin) { - if (!value.has_value()) - m_crossorigin = cors_setting_attribute_from_keyword({}); - else - m_crossorigin = cors_setting_attribute_from_keyword(String::from_deprecated_string(*value).release_value_but_fixme_should_propagate_errors()); + m_crossorigin = cors_setting_attribute_from_keyword(value); } else if (name == HTML::AttributeNames::muted) { set_muted(true); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h index 573b08d9b7..a477308c96 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h @@ -134,7 +134,7 @@ protected: virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; virtual void removed_from(DOM::Node*) override; virtual void children_changed() override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp index e3163b1134..cb7de1f1d5 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp @@ -45,7 +45,7 @@ void HTMLObjectElement::visit_edges(Cell::Visitor& visitor) visitor.visit(m_image_request); } -void HTMLObjectElement::attribute_changed(FlyString const& name, Optional const& value) +void HTMLObjectElement::attribute_changed(FlyString const& name, Optional const& value) { NavigableContainer::attribute_changed(name, value); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h index 44e591bd7f..6ed05588bd 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h @@ -34,7 +34,7 @@ class HTMLObjectElement final public: virtual ~HTMLObjectElement() override; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; String data() const; void set_data(String const& data) { MUST(set_attribute(HTML::AttributeNames::data, data)); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp index 407dd26b37..f72898bdc5 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp @@ -31,7 +31,7 @@ void HTMLOptionElement::initialize(JS::Realm& realm) set_prototype(&Bindings::ensure_web_prototype(realm, "HTMLOptionElement")); } -void HTMLOptionElement::attribute_changed(FlyString const& name, Optional const& value) +void HTMLOptionElement::attribute_changed(FlyString const& name, Optional const& value) { HTMLElement::attribute_changed(name, value); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.h b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.h index 8205e16e59..2f85bff6a5 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.h @@ -40,7 +40,7 @@ private: virtual void initialize(JS::Realm&) override; - void attribute_changed(FlyString const& name, Optional const& value) override; + void attribute_changed(FlyString const& name, Optional const& value) override; void ask_for_a_reset(); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp index ae181c749b..95b599eaf4 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp @@ -45,15 +45,12 @@ void HTMLScriptElement::visit_edges(Cell::Visitor& visitor) visitor.visit(m_preparation_time_document); } -void HTMLScriptElement::attribute_changed(FlyString const& name, Optional const& value) +void HTMLScriptElement::attribute_changed(FlyString const& name, Optional const& value) { Base::attribute_changed(name, value); if (name == HTML::AttributeNames::crossorigin) { - if (!value.has_value()) - m_crossorigin = cors_setting_attribute_from_keyword({}); - else - m_crossorigin = cors_setting_attribute_from_keyword(String::from_deprecated_string(*value).release_value_but_fixme_should_propagate_errors()); + m_crossorigin = cors_setting_attribute_from_keyword(value); } else if (name == HTML::AttributeNames::referrerpolicy) { if (!value.has_value()) m_referrer_policy.clear(); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h index fcd1b7953d..efc79312d3 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h @@ -62,7 +62,7 @@ private: virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; // https://html.spec.whatwg.org/multipage/scripting.html#prepare-the-script-element void prepare_script(); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.cpp index b4ef3b0988..c1928b9de2 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.cpp @@ -24,11 +24,11 @@ HTMLSlotElement::HTMLSlotElement(DOM::Document& document, DOM::QualifiedName qua return; // 2. If value is null and oldValue is the empty string, then return. - if (!value.has_value() && old_value == DeprecatedString::empty()) + if (!value.has_value() && old_value == String {}) return; // 3. If value is the empty string and oldValue is null, then return. - if (value == DeprecatedString::empty() && !old_value.has_value()) + if (value == String {} && !old_value.has_value()) return; // 4. If value is null or the empty string, then set element’s name to the empty string. @@ -36,7 +36,7 @@ HTMLSlotElement::HTMLSlotElement(DOM::Document& document, DOM::QualifiedName qua set_slot_name({}); // 5. Otherwise, set element’s name to value. else - set_slot_name(MUST(String::from_deprecated_string(*value))); + set_slot_name(*value); // 6. Run assign slottables for a tree with element’s root. DOM::assign_slottables_for_a_tree(root()); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp index e3bb7ae090..71e6eaa453 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp @@ -40,15 +40,12 @@ void HTMLVideoElement::visit_edges(Cell::Visitor& visitor) visitor.visit(m_fetch_controller); } -void HTMLVideoElement::attribute_changed(FlyString const& name, Optional const& value) +void HTMLVideoElement::attribute_changed(FlyString const& name, Optional const& value) { Base::attribute_changed(name, value); if (name == HTML::AttributeNames::poster) { - if (!value.has_value()) - determine_element_poster_frame({}).release_value_but_fixme_should_propagate_errors(); - else - determine_element_poster_frame(*value).release_value_but_fixme_should_propagate_errors(); + determine_element_poster_frame(value).release_value_but_fixme_should_propagate_errors(); } } @@ -126,7 +123,7 @@ void HTMLVideoElement::on_seek(double position, MediaSeekMode seek_mode) } // https://html.spec.whatwg.org/multipage/media.html#attr-video-poster -WebIDL::ExceptionOr HTMLVideoElement::determine_element_poster_frame(Optional const& poster) +WebIDL::ExceptionOr HTMLVideoElement::determine_element_poster_frame(Optional const& poster) { auto& realm = this->realm(); auto& vm = realm.vm(); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.h b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.h index ce22d3f3a2..4856ea319d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.h @@ -47,7 +47,7 @@ private: virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; @@ -55,7 +55,7 @@ private: virtual void on_paused() override; virtual void on_seek(double, MediaSeekMode) override; - WebIDL::ExceptionOr determine_element_poster_frame(Optional const& poster); + WebIDL::ExceptionOr determine_element_poster_frame(Optional const& poster); JS::GCPtr m_video_track; VideoFrame m_current_frame; diff --git a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp index c23d27c562..19ded4af40 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp @@ -22,18 +22,18 @@ void SVGCircleElement::initialize(JS::Realm& realm) set_prototype(&Bindings::ensure_web_prototype(realm, "SVGCircleElement")); } -void SVGCircleElement::attribute_changed(FlyString const& name, Optional const& value) +void SVGCircleElement::attribute_changed(FlyString const& name, Optional const& value) { SVGGeometryElement::attribute_changed(name, value); if (name == SVG::AttributeNames::cx) { - m_center_x = AttributeParser::parse_coordinate(value.value_or("")); + m_center_x = AttributeParser::parse_coordinate(value.value_or(String {})); m_path.clear(); } else if (name == SVG::AttributeNames::cy) { - m_center_y = AttributeParser::parse_coordinate(value.value_or("")); + m_center_y = AttributeParser::parse_coordinate(value.value_or(String {})); m_path.clear(); } else if (name == SVG::AttributeNames::r) { - m_radius = AttributeParser::parse_positive_length(value.value_or("")); + m_radius = AttributeParser::parse_positive_length(value.value_or(String {})); m_path.clear(); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.h b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.h index 7ae028bf57..60a7952a31 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.h @@ -17,7 +17,7 @@ class SVGCircleElement final : public SVGGeometryElement { public: virtual ~SVGCircleElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; virtual Gfx::Path& get_path() override; diff --git a/Userland/Libraries/LibWeb/SVG/SVGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGElement.cpp index 562342124c..d8d74cc0f4 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGElement.cpp @@ -34,7 +34,7 @@ void SVGElement::visit_edges(Cell::Visitor& visitor) visitor.visit(m_dataset); } -void SVGElement::attribute_changed(FlyString const& name, Optional const& value) +void SVGElement::attribute_changed(FlyString const& name, Optional const& value) { Base::attribute_changed(name, value); diff --git a/Userland/Libraries/LibWeb/SVG/SVGElement.h b/Userland/Libraries/LibWeb/SVG/SVGElement.h index 1e5a4075c3..91d3cc3d4a 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGElement.h @@ -17,7 +17,7 @@ class SVGElement : public DOM::Element { public: virtual bool requires_svg_container() const override { return true; } - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; virtual void children_changed() override; virtual void inserted() override; diff --git a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp index f78877ac2e..f13b0d0619 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp @@ -22,21 +22,21 @@ void SVGEllipseElement::initialize(JS::Realm& realm) set_prototype(&Bindings::ensure_web_prototype(realm, "SVGEllipseElement")); } -void SVGEllipseElement::attribute_changed(FlyString const& name, Optional const& value) +void SVGEllipseElement::attribute_changed(FlyString const& name, Optional const& value) { SVGGeometryElement::attribute_changed(name, value); if (name == SVG::AttributeNames::cx) { - m_center_x = AttributeParser::parse_coordinate(value.value_or("")); + m_center_x = AttributeParser::parse_coordinate(value.value_or(String {})); m_path.clear(); } else if (name == SVG::AttributeNames::cy) { - m_center_y = AttributeParser::parse_coordinate(value.value_or("")); + m_center_y = AttributeParser::parse_coordinate(value.value_or(String {})); m_path.clear(); } else if (name == SVG::AttributeNames::rx) { - m_radius_x = AttributeParser::parse_positive_length(value.value_or("")); + m_radius_x = AttributeParser::parse_positive_length(value.value_or(String {})); m_path.clear(); } else if (name == SVG::AttributeNames::ry) { - m_radius_y = AttributeParser::parse_positive_length(value.value_or("")); + m_radius_y = AttributeParser::parse_positive_length(value.value_or(String {})); m_path.clear(); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.h b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.h index 6178695df9..f86bcf98ab 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.h @@ -17,7 +17,7 @@ class SVGEllipseElement final : public SVGGeometryElement { public: virtual ~SVGEllipseElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; virtual Gfx::Path& get_path() override; diff --git a/Userland/Libraries/LibWeb/SVG/SVGGradientElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGradientElement.cpp index ef9d5ec2ef..7efcd45688 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGradientElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGGradientElement.cpp @@ -17,15 +17,15 @@ SVGGradientElement::SVGGradientElement(DOM::Document& document, DOM::QualifiedNa { } -void SVGGradientElement::attribute_changed(FlyString const& name, Optional const& value) +void SVGGradientElement::attribute_changed(FlyString const& name, Optional const& value) { SVGElement::attribute_changed(name, value); if (name == AttributeNames::gradientUnits) { - m_gradient_units = AttributeParser::parse_units(value.value_or("")); + m_gradient_units = AttributeParser::parse_units(value.value_or(String {})); } else if (name == AttributeNames::spreadMethod) { - m_spread_method = AttributeParser::parse_spread_method(value.value_or("")); + m_spread_method = AttributeParser::parse_spread_method(value.value_or(String {})); } else if (name == AttributeNames::gradientTransform) { - if (auto transform_list = AttributeParser::parse_transform(value.value_or("")); transform_list.has_value()) { + if (auto transform_list = AttributeParser::parse_transform(value.value_or(String {})); transform_list.has_value()) { m_gradient_transform = transform_from_transform_list(*transform_list); } else { m_gradient_transform = {}; diff --git a/Userland/Libraries/LibWeb/SVG/SVGGradientElement.h b/Userland/Libraries/LibWeb/SVG/SVGGradientElement.h index b80ae944fb..ae9ac23e37 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGradientElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGGradientElement.h @@ -40,7 +40,7 @@ class SVGGradientElement : public SVGElement { public: virtual ~SVGGradientElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; virtual Optional to_gfx_paint_style(SVGPaintContext const&) const = 0; diff --git a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp index 0eb74a9f81..a0bcbb9c25 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp @@ -32,11 +32,11 @@ void SVGGraphicsElement::initialize(JS::Realm& realm) set_prototype(&Bindings::ensure_web_prototype(realm, "SVGGraphicsElement")); } -void SVGGraphicsElement::attribute_changed(FlyString const& name, Optional const& value) +void SVGGraphicsElement::attribute_changed(FlyString const& name, Optional const& value) { SVGElement::attribute_changed(name, value); if (name == "transform"sv) { - auto transform_list = AttributeParser::parse_transform(value.value_or("")); + auto transform_list = AttributeParser::parse_transform(value.value_or(String {})); if (transform_list.has_value()) m_transform = transform_from_transform_list(*transform_list); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.h b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.h index 33ed54e710..89ebe14b2d 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.h @@ -24,7 +24,7 @@ class SVGGraphicsElement : public SVGElement { public: virtual void apply_presentational_hints(CSS::StyleProperties&) const override; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; Optional fill_color() const; Optional fill_rule() const; diff --git a/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp index 6cb4190b8f..1c9ebaf7ef 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp @@ -22,21 +22,21 @@ void SVGLineElement::initialize(JS::Realm& realm) set_prototype(&Bindings::ensure_web_prototype(realm, "SVGLineElement")); } -void SVGLineElement::attribute_changed(FlyString const& name, Optional const& value) +void SVGLineElement::attribute_changed(FlyString const& name, Optional const& value) { SVGGeometryElement::attribute_changed(name, value); if (name == SVG::AttributeNames::x1) { - m_x1 = AttributeParser::parse_coordinate(value.value_or("")); + m_x1 = AttributeParser::parse_coordinate(value.value_or(String {})); m_path.clear(); } else if (name == SVG::AttributeNames::y1) { - m_y1 = AttributeParser::parse_coordinate(value.value_or("")); + m_y1 = AttributeParser::parse_coordinate(value.value_or(String {})); m_path.clear(); } else if (name == SVG::AttributeNames::x2) { - m_x2 = AttributeParser::parse_coordinate(value.value_or("")); + m_x2 = AttributeParser::parse_coordinate(value.value_or(String {})); m_path.clear(); } else if (name == SVG::AttributeNames::y2) { - m_y2 = AttributeParser::parse_coordinate(value.value_or("")); + m_y2 = AttributeParser::parse_coordinate(value.value_or(String {})); m_path.clear(); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGLineElement.h b/Userland/Libraries/LibWeb/SVG/SVGLineElement.h index b95433c173..7962c99610 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLineElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGLineElement.h @@ -17,7 +17,7 @@ class SVGLineElement final : public SVGGeometryElement { public: virtual ~SVGLineElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; virtual Gfx::Path& get_path() override; diff --git a/Userland/Libraries/LibWeb/SVG/SVGLinearGradientElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGLinearGradientElement.cpp index 69755a4c4b..319128ee5c 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLinearGradientElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGLinearGradientElement.cpp @@ -24,22 +24,22 @@ void SVGLinearGradientElement::initialize(JS::Realm& realm) set_prototype(&Bindings::ensure_web_prototype(realm, "SVGLinearGradientElement")); } -void SVGLinearGradientElement::attribute_changed(FlyString const& name, Optional const& value) +void SVGLinearGradientElement::attribute_changed(FlyString const& name, Optional const& value) { SVGGradientElement::attribute_changed(name, value); // FIXME: Should allow for ` | ` for x1, x2, y1, y2 if (name == SVG::AttributeNames::x1) { - m_x1 = AttributeParser::parse_number_percentage(value.value_or("")); + m_x1 = AttributeParser::parse_number_percentage(value.value_or(String {})); m_paint_style = nullptr; } else if (name == SVG::AttributeNames::y1) { - m_y1 = AttributeParser::parse_number_percentage(value.value_or("")); + m_y1 = AttributeParser::parse_number_percentage(value.value_or(String {})); m_paint_style = nullptr; } else if (name == SVG::AttributeNames::x2) { - m_x2 = AttributeParser::parse_number_percentage(value.value_or("")); + m_x2 = AttributeParser::parse_number_percentage(value.value_or(String {})); m_paint_style = nullptr; } else if (name == SVG::AttributeNames::y2) { - m_y2 = AttributeParser::parse_number_percentage(value.value_or("")); + m_y2 = AttributeParser::parse_number_percentage(value.value_or(String {})); m_paint_style = nullptr; } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGLinearGradientElement.h b/Userland/Libraries/LibWeb/SVG/SVGLinearGradientElement.h index 835fd594da..144e5a03fb 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLinearGradientElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGLinearGradientElement.h @@ -18,7 +18,7 @@ class SVGLinearGradientElement : public SVGGradientElement { public: virtual ~SVGLinearGradientElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; virtual Optional to_gfx_paint_style(SVGPaintContext const&) const override; diff --git a/Userland/Libraries/LibWeb/SVG/SVGMaskElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGMaskElement.cpp index 2723f6210d..5125a1c8ce 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGMaskElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGMaskElement.cpp @@ -31,13 +31,13 @@ JS::GCPtr SVGMaskElement::create_layout_node(NonnullRefPtr(document(), *this, move(style)); } -void SVGMaskElement::attribute_changed(FlyString const& name, Optional const& value) +void SVGMaskElement::attribute_changed(FlyString const& name, Optional const& value) { SVGGraphicsElement::attribute_changed(name, value); if (name == AttributeNames::maskUnits) { - m_mask_units = AttributeParser::parse_units(value.value_or("")); + m_mask_units = AttributeParser::parse_units(value.value_or(String {})); } else if (name == AttributeNames::maskContentUnits) { - m_mask_content_units = AttributeParser::parse_units(value.value_or("")); + m_mask_content_units = AttributeParser::parse_units(value.value_or(String {})); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGMaskElement.h b/Userland/Libraries/LibWeb/SVG/SVGMaskElement.h index 14cc49f948..cf81a7ae13 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGMaskElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGMaskElement.h @@ -17,7 +17,7 @@ class SVGMaskElement final : public SVGGraphicsElement { public: virtual ~SVGMaskElement() override; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; virtual JS::GCPtr create_layout_node(NonnullRefPtr) override; diff --git a/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp index e0234f31d5..f8c77da146 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp @@ -93,12 +93,12 @@ void SVGPathElement::initialize(JS::Realm& realm) set_prototype(&Bindings::ensure_web_prototype(realm, "SVGPathElement")); } -void SVGPathElement::attribute_changed(FlyString const& name, Optional const& value) +void SVGPathElement::attribute_changed(FlyString const& name, Optional const& value) { SVGGeometryElement::attribute_changed(name, value); if (name == "d") { - m_instructions = AttributeParser::parse_path_data(value.value_or("")); + m_instructions = AttributeParser::parse_path_data(value.value_or(String {})); m_path.clear(); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGPathElement.h b/Userland/Libraries/LibWeb/SVG/SVGPathElement.h index 9685b6458f..56dc6ba6e6 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPathElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGPathElement.h @@ -19,7 +19,7 @@ class SVGPathElement final : public SVGGeometryElement { public: virtual ~SVGPathElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; virtual Gfx::Path& get_path() override; diff --git a/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.cpp index b9d4583dee..e56d376fd4 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.cpp @@ -22,12 +22,12 @@ void SVGPolygonElement::initialize(JS::Realm& realm) set_prototype(&Bindings::ensure_web_prototype(realm, "SVGPolygonElement")); } -void SVGPolygonElement::attribute_changed(FlyString const& name, Optional const& value) +void SVGPolygonElement::attribute_changed(FlyString const& name, Optional const& value) { SVGGeometryElement::attribute_changed(name, value); if (name == SVG::AttributeNames::points) { - m_points = AttributeParser::parse_points(value.value_or("")); + m_points = AttributeParser::parse_points(value.value_or(String {})); m_path.clear(); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.h b/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.h index 4499fdd6bf..a48a5603b7 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.h @@ -16,7 +16,7 @@ class SVGPolygonElement final : public SVGGeometryElement { public: virtual ~SVGPolygonElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; virtual Gfx::Path& get_path() override; diff --git a/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.cpp index 7306098d0c..9fb7e67961 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.cpp @@ -22,12 +22,12 @@ void SVGPolylineElement::initialize(JS::Realm& realm) set_prototype(&Bindings::ensure_web_prototype(realm, "SVGPolylineElement")); } -void SVGPolylineElement::attribute_changed(FlyString const& name, Optional const& value) +void SVGPolylineElement::attribute_changed(FlyString const& name, Optional const& value) { SVGGeometryElement::attribute_changed(name, value); if (name == SVG::AttributeNames::points) { - m_points = AttributeParser::parse_points(value.value_or("")); + m_points = AttributeParser::parse_points(value.value_or(String {})); m_path.clear(); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.h b/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.h index 2905e714d3..76c1db57c6 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.h @@ -16,7 +16,7 @@ class SVGPolylineElement final : public SVGGeometryElement { public: virtual ~SVGPolylineElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; virtual Gfx::Path& get_path() override; diff --git a/Userland/Libraries/LibWeb/SVG/SVGRadialGradientElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGRadialGradientElement.cpp index e4d1adf8be..ff032ca612 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGRadialGradientElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGRadialGradientElement.cpp @@ -21,29 +21,29 @@ void SVGRadialGradientElement::initialize(JS::Realm& realm) set_prototype(&Bindings::ensure_web_prototype(realm, "SVGRadialGradientElement")); } -void SVGRadialGradientElement::attribute_changed(FlyString const& name, Optional const& value) +void SVGRadialGradientElement::attribute_changed(FlyString const& name, Optional const& value) { SVGGradientElement::attribute_changed(name, value); // FIXME: These are or in the spec, but all examples seem to allow percentages // and unitless values. if (name == SVG::AttributeNames::cx) { - m_cx = AttributeParser::parse_number_percentage(value.value_or("")); + m_cx = AttributeParser::parse_number_percentage(value.value_or(String {})); m_paint_style = nullptr; } else if (name == SVG::AttributeNames::cy) { - m_cy = AttributeParser::parse_number_percentage(value.value_or("")); + m_cy = AttributeParser::parse_number_percentage(value.value_or(String {})); m_paint_style = nullptr; } else if (name == SVG::AttributeNames::fx) { - m_fx = AttributeParser::parse_number_percentage(value.value_or("")); + m_fx = AttributeParser::parse_number_percentage(value.value_or(String {})); m_paint_style = nullptr; } else if (name == SVG::AttributeNames::fy) { - m_fy = AttributeParser::parse_number_percentage(value.value_or("")); + m_fy = AttributeParser::parse_number_percentage(value.value_or(String {})); m_paint_style = nullptr; } else if (name == SVG::AttributeNames::fr) { - m_fr = AttributeParser::parse_number_percentage(value.value_or("")); + m_fr = AttributeParser::parse_number_percentage(value.value_or(String {})); m_paint_style = nullptr; } else if (name == SVG::AttributeNames::r) { - m_r = AttributeParser::parse_number_percentage(value.value_or("")); + m_r = AttributeParser::parse_number_percentage(value.value_or(String {})); m_paint_style = nullptr; } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGRadialGradientElement.h b/Userland/Libraries/LibWeb/SVG/SVGRadialGradientElement.h index 2bbb6d5764..0d86adb8c5 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGRadialGradientElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGRadialGradientElement.h @@ -18,7 +18,7 @@ class SVGRadialGradientElement : public SVGGradientElement { public: virtual ~SVGRadialGradientElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; virtual Optional to_gfx_paint_style(SVGPaintContext const&) const override; diff --git a/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp index ce9c951148..11db73d2f2 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp @@ -24,27 +24,27 @@ void SVGRectElement::initialize(JS::Realm& realm) set_prototype(&Bindings::ensure_web_prototype(realm, "SVGRectElement")); } -void SVGRectElement::attribute_changed(FlyString const& name, Optional const& value) +void SVGRectElement::attribute_changed(FlyString const& name, Optional const& value) { SVGGeometryElement::attribute_changed(name, value); if (name == SVG::AttributeNames::x) { - m_x = AttributeParser::parse_coordinate(value.value_or("")); + m_x = AttributeParser::parse_coordinate(value.value_or(String {})); m_path.clear(); } else if (name == SVG::AttributeNames::y) { - m_y = AttributeParser::parse_coordinate(value.value_or("")); + m_y = AttributeParser::parse_coordinate(value.value_or(String {})); m_path.clear(); } else if (name == SVG::AttributeNames::width) { - m_width = AttributeParser::parse_positive_length(value.value_or("")); + m_width = AttributeParser::parse_positive_length(value.value_or(String {})); m_path.clear(); } else if (name == SVG::AttributeNames::height) { - m_height = AttributeParser::parse_positive_length(value.value_or("")); + m_height = AttributeParser::parse_positive_length(value.value_or(String {})); m_path.clear(); } else if (name == SVG::AttributeNames::rx) { - m_radius_x = AttributeParser::parse_length(value.value_or("")); + m_radius_x = AttributeParser::parse_length(value.value_or(String {})); m_path.clear(); } else if (name == SVG::AttributeNames::ry) { - m_radius_y = AttributeParser::parse_length(value.value_or("")); + m_radius_y = AttributeParser::parse_length(value.value_or(String {})); m_path.clear(); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGRectElement.h b/Userland/Libraries/LibWeb/SVG/SVGRectElement.h index 9349f96cc7..c8dc7f30e7 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGRectElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGRectElement.h @@ -17,7 +17,7 @@ class SVGRectElement final : public SVGGeometryElement { public: virtual ~SVGRectElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; virtual Gfx::Path& get_path() override; diff --git a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp index 8356991d5e..1b7f4d2e57 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp @@ -61,14 +61,14 @@ void SVGSVGElement::apply_presentational_hints(CSS::StyleProperties& style) cons } } -void SVGSVGElement::attribute_changed(FlyString const& name, Optional const& value) +void SVGSVGElement::attribute_changed(FlyString const& name, Optional const& value) { SVGGraphicsElement::attribute_changed(name, value); if (name.equals_ignoring_ascii_case(SVG::AttributeNames::viewBox)) - m_view_box = try_parse_view_box(value.value_or("")); + m_view_box = try_parse_view_box(value.value_or(String {})); if (name.equals_ignoring_ascii_case(SVG::AttributeNames::preserveAspectRatio)) - m_preserve_aspect_ratio = AttributeParser::parse_preserve_aspect_ratio(value.value_or("")); + m_preserve_aspect_ratio = AttributeParser::parse_preserve_aspect_ratio(value.value_or(String {})); if (name.equals_ignoring_ascii_case(SVG::AttributeNames::width) || name.equals_ignoring_ascii_case(SVG::AttributeNames::height)) update_fallback_view_box_for_svg_as_image(); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.h b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.h index b135417507..4d3f643982 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.h @@ -36,7 +36,7 @@ private: virtual bool is_svg_svg_element() const override { return true; } - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; void update_fallback_view_box_for_svg_as_image(); diff --git a/Userland/Libraries/LibWeb/SVG/SVGStopElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGStopElement.cpp index 0abc378d09..7efc8d6645 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGStopElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGStopElement.cpp @@ -19,11 +19,11 @@ SVGStopElement::SVGStopElement(DOM::Document& document, DOM::QualifiedName quali { } -void SVGStopElement::attribute_changed(FlyString const& name, Optional const& value) +void SVGStopElement::attribute_changed(FlyString const& name, Optional const& value) { SVGElement::attribute_changed(name, value); if (name == SVG::AttributeNames::offset) { - m_offset = AttributeParser::parse_number_percentage(value.value_or("")); + m_offset = AttributeParser::parse_number_percentage(value.value_or(String {})); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGStopElement.h b/Userland/Libraries/LibWeb/SVG/SVGStopElement.h index a2e3ad73ed..219c572b61 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGStopElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGStopElement.h @@ -19,7 +19,7 @@ class SVGStopElement final : public SVGElement { public: virtual ~SVGStopElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; JS::NonnullGCPtr offset() const; diff --git a/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.cpp index d5794578ef..2cf3c88918 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.cpp @@ -39,11 +39,11 @@ void SVGSymbolElement::apply_presentational_hints(CSS::StyleProperties& style) c } } -void SVGSymbolElement::attribute_changed(FlyString const& name, Optional const& value) +void SVGSymbolElement::attribute_changed(FlyString const& name, Optional const& value) { Base::attribute_changed(name, value); if (name.equals_ignoring_ascii_case(SVG::AttributeNames::viewBox)) - m_view_box = try_parse_view_box(value.value_or("")); + m_view_box = try_parse_view_box(value.value_or(String {})); } bool SVGSymbolElement::is_direct_child_of_use_shadow_tree() const diff --git a/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.h b/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.h index 7562945775..51ffdda933 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.h @@ -29,7 +29,7 @@ private: bool is_direct_child_of_use_shadow_tree() const; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; Optional m_view_box; }; diff --git a/Userland/Libraries/LibWeb/SVG/SVGTextPositioningElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGTextPositioningElement.cpp index a7a7787629..abbfeaf807 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGTextPositioningElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGTextPositioningElement.cpp @@ -28,18 +28,18 @@ void SVGTextPositioningElement::initialize(JS::Realm& realm) set_prototype(&Bindings::ensure_web_prototype(realm, "SVGTextPositioningElement")); } -void SVGTextPositioningElement::attribute_changed(FlyString const& name, Optional const& value) +void SVGTextPositioningElement::attribute_changed(FlyString const& name, Optional const& value) { SVGGraphicsElement::attribute_changed(name, value); if (name == SVG::AttributeNames::x) { - m_x = AttributeParser::parse_coordinate(value.value_or("")).value_or(m_x); + m_x = AttributeParser::parse_coordinate(value.value_or(String {})).value_or(m_x); } else if (name == SVG::AttributeNames::y) { - m_y = AttributeParser::parse_coordinate(value.value_or("")).value_or(m_y); + m_y = AttributeParser::parse_coordinate(value.value_or(String {})).value_or(m_y); } else if (name == SVG::AttributeNames::dx) { - m_dx = AttributeParser::parse_coordinate(value.value_or("")).value_or(m_dx); + m_dx = AttributeParser::parse_coordinate(value.value_or(String {})).value_or(m_dx); } else if (name == SVG::AttributeNames::dy) { - m_dy = AttributeParser::parse_coordinate(value.value_or("")).value_or(m_dy); + m_dy = AttributeParser::parse_coordinate(value.value_or(String {})).value_or(m_dy); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGTextPositioningElement.h b/Userland/Libraries/LibWeb/SVG/SVGTextPositioningElement.h index 67c609fda1..f6b3788ed2 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGTextPositioningElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGTextPositioningElement.h @@ -16,7 +16,7 @@ class SVGTextPositioningElement : public SVGTextContentElement { WEB_PLATFORM_OBJECT(SVGTextPositioningElement, SVGTextContentElement); public: - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; Gfx::FloatPoint get_offset() const; diff --git a/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp index 342e98459e..84440d79b7 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp @@ -45,18 +45,18 @@ void SVGUseElement::visit_edges(Cell::Visitor& visitor) visitor.visit(m_document_observer); } -void SVGUseElement::attribute_changed(FlyString const& name, Optional const& value) +void SVGUseElement::attribute_changed(FlyString const& name, Optional const& value) { Base::attribute_changed(name, value); // https://svgwg.org/svg2-draft/struct.html#UseLayout if (name == SVG::AttributeNames::x) { - m_x = AttributeParser::parse_coordinate(value.value_or("")); + m_x = AttributeParser::parse_coordinate(value.value_or(String {})); } else if (name == SVG::AttributeNames::y) { - m_y = AttributeParser::parse_coordinate(value.value_or("")); + m_y = AttributeParser::parse_coordinate(value.value_or(String {})); } else if (name == SVG::AttributeNames::href) { // FIXME: Support the xlink:href attribute as a fallback - m_referenced_id = parse_id_from_href(value.value_or("")); + m_referenced_id = parse_id_from_href(value.value_or(String {}).to_deprecated_string()); clone_element_tree_as_our_shadow_tree(referenced_element()); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGUseElement.h b/Userland/Libraries/LibWeb/SVG/SVGUseElement.h index 91dfa88b97..edbae451d3 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGUseElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGUseElement.h @@ -20,7 +20,7 @@ class SVGUseElement final : public SVGGraphicsElement { public: virtual ~SVGUseElement() override = default; - virtual void attribute_changed(FlyString const& name, Optional const& value) override; + virtual void attribute_changed(FlyString const& name, Optional const& value) override; virtual void inserted() override;