1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:28:12 +00:00

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.
This commit is contained in:
Shannon Booth 2023-11-19 18:10:36 +13:00 committed by Sam Atkins
parent 6a2a7cad61
commit eca9874e56
77 changed files with 178 additions and 193 deletions

View file

@ -88,18 +88,14 @@ void Attr::change_attribute(String value)
m_value = move(value); m_value = move(value);
// 3. Handle attribute changes for attribute with attributes element, oldValue, and value. // 3. Handle attribute changes for attribute with attributes 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 // https://dom.spec.whatwg.org/#handle-attribute-changes
void Attr::handle_attribute_changes(Element& element, Optional<DeprecatedString> old_value, Optional<DeprecatedString> new_value) void Attr::handle_attribute_changes(Element& element, Optional<String> const& old_value, Optional<String> 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 attributes local name, attributes namespace, oldValue, « », « », null, and null. // 1. Queue a mutation record of "attributes" for element with attributes local name, attributes 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 attributes local name, oldValue, newValue, and attributes namespace. // 2. If element is custom, then enqueue a custom element callback reaction with element, callback name "attributeChangedCallback", and an argument list containing attributes local name, oldValue, newValue, and attributes namespace.
if (element.is_custom()) { if (element.is_custom()) {
@ -107,8 +103,8 @@ void Attr::handle_attribute_changes(Element& element, Optional<DeprecatedString>
JS::MarkedVector<JS::Value> arguments { vm.heap() }; JS::MarkedVector<JS::Value> arguments { vm.heap() };
arguments.append(JS::PrimitiveString::create(vm, local_name())); 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(!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.release_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())); 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)); element.enqueue_a_custom_element_callback_reaction(HTML::CustomElementReactionNames::attributeChangedCallback, move(arguments));

View file

@ -41,7 +41,7 @@ public:
// Always returns true: https://dom.spec.whatwg.org/#dom-attr-specified // Always returns true: https://dom.spec.whatwg.org/#dom-attr-specified
constexpr bool specified() const { return true; } constexpr bool specified() const { return true; }
void handle_attribute_changes(Element&, Optional<DeprecatedString> old_value, Optional<DeprecatedString> new_value); void handle_attribute_changes(Element&, Optional<String> const& old_value, Optional<String> const& new_value);
private: private:
Attr(Document&, QualifiedName, String value, Element*); Attr(Document&, QualifiedName, String value, Element*);

View file

@ -74,7 +74,7 @@ WebIDL::ExceptionOr<void> CharacterData::replace_data(size_t offset, size_t coun
count = length - offset; count = length - offset;
// 4. Queue a mutation record of "characterData" for node with null, null, nodes data, « », « », null, and null. // 4. Queue a mutation record of "characterData" for node with null, null, nodes 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 nodes data after offset code units. // 5. Insert data into nodes data after offset code units.
// 6. Let delete offset be offset + datas length. // 6. Let delete offset be offset + datas length.

View file

@ -81,11 +81,11 @@ Element::Element(Document& document, DOM::QualifiedName qualified_name)
return; return;
// 2. If value is null and oldValue is the empty string, then 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; return;
// 3. If value is the empty string and oldValue is null, then 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; return;
// 4. If value is null or the empty string, then set elements name to the empty string. // 4. If value is null or the empty string, then set elements name to the empty string.
@ -93,7 +93,7 @@ Element::Element(Document& document, DOM::QualifiedName qualified_name)
set_slottable_name({}); set_slottable_name({});
// 5. Otherwise, set elements name to value. // 5. Otherwise, set elements name to value.
else else
set_slottable_name(MUST(String::from_deprecated_string(*value))); set_slottable_name(*value);
// 6. If element is assigned, then run assign slottables for elements assigned slot. // 6. If element is assigned, then run assign slottables for elements assigned slot.
if (auto assigned_slot = assigned_slot_internal()) 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)); m_attribute_change_steps.append(move(steps));
} }
void Element::run_attribute_change_steps(FlyString const& local_name, Optional<DeprecatedString> const& old_value, Optional<DeprecatedString> const& value, Optional<FlyString> const& namespace_) void Element::run_attribute_change_steps(FlyString const& local_name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_)
{ {
for (auto const& attribute_change_steps : m_attribute_change_steps) for (auto const& attribute_change_steps : m_attribute_change_steps)
attribute_change_steps(local_name, old_value, value, namespace_); attribute_change_steps(local_name, old_value, value, namespace_);
@ -476,17 +476,17 @@ void Element::run_attribute_change_steps(FlyString const& local_name, Optional<D
invalidate_style_after_attribute_change(local_name); invalidate_style_after_attribute_change(local_name);
} }
void Element::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void Element::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
auto value_or_empty = value.value_or(""); auto value_or_empty = value.value_or(String {});
if (name == HTML::AttributeNames::id) { if (name == HTML::AttributeNames::id) {
if (!value.has_value()) if (!value.has_value())
m_id = {}; m_id = {};
else else
m_id = MUST(FlyString::from_deprecated_fly_string(value_or_empty)); m_id = value_or_empty;
} else if (name == HTML::AttributeNames::class_) { } 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.clear();
m_classes.ensure_capacity(new_classes.size()); m_classes.ensure_capacity(new_classes.size());
for (auto& new_class : new_classes) { for (auto& new_class : new_classes) {

View file

@ -147,11 +147,11 @@ public:
virtual void apply_presentational_hints(CSS::StyleProperties&) const { } virtual void apply_presentational_hints(CSS::StyleProperties&) const { }
// https://dom.spec.whatwg.org/#concept-element-attributes-change-ext // https://dom.spec.whatwg.org/#concept-element-attributes-change-ext
using AttributeChangeSteps = Function<void(FlyString const& local_name, Optional<DeprecatedString> const& old_value, Optional<DeprecatedString> const& value, Optional<FlyString> const& namespace_)>; using AttributeChangeSteps = Function<void(FlyString const& local_name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_)>;
void add_attribute_change_steps(AttributeChangeSteps steps); void add_attribute_change_steps(AttributeChangeSteps steps);
void run_attribute_change_steps(FlyString const& local_name, Optional<DeprecatedString> const& old_value, Optional<DeprecatedString> const& value, Optional<FlyString> const& namespace_); void run_attribute_change_steps(FlyString const& local_name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_);
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value); virtual void attribute_changed(FlyString const& name, Optional<String> const& value);
struct [[nodiscard]] RequiredInvalidationAfterStyleChange { struct [[nodiscard]] RequiredInvalidationAfterStyleChange {
bool repaint { false }; bool repaint { false };

View file

@ -269,7 +269,7 @@ void NamedNodeMap::replace_attribute(Attr& old_attribute, Attr& new_attribute, s
old_attribute.set_owner_element(nullptr); old_attribute.set_owner_element(nullptr);
// 4. Handle attribute changes for oldAttr with newAttrs element, oldAttrs value, and newAttrs value. // 4. Handle attribute changes for oldAttr with newAttrs element, oldAttrs value, and newAttrs 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 // 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()); attribute.set_owner_element(&associated_element());
// 3. Handle attribute changes for attribute with element, null, and attributes value. // 3. Handle attribute changes for attribute with element, null, and attributes 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 // 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); attribute->set_owner_element(nullptr);
// 4. Handle attribute changes for attribute with element, attributes value, and null. // 4. Handle attribute changes for attribute with element, attributes 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 // https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-name

View file

@ -1533,7 +1533,7 @@ Painting::PaintableBox* Node::paintable_box()
} }
// https://dom.spec.whatwg.org/#queue-a-mutation-record // https://dom.spec.whatwg.org/#queue-a-mutation-record
void Node::queue_mutation_record(FlyString const& type, Optional<DeprecatedString> attribute_name, Optional<DeprecatedString> attribute_namespace, Optional<DeprecatedString> old_value, Vector<JS::Handle<Node>> added_nodes, Vector<JS::Handle<Node>> removed_nodes, Node* previous_sibling, Node* next_sibling) const void Node::queue_mutation_record(FlyString const& type, Optional<FlyString> const& attribute_name, Optional<FlyString> const& attribute_namespace, Optional<String> const& old_value, Vector<JS::Handle<Node>> added_nodes, Vector<JS::Handle<Node>> 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. // 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. // FIXME: This is a total hack.
@ -1541,7 +1541,7 @@ void Node::queue_mutation_record(FlyString const& type, Optional<DeprecatedStrin
// 1. Let interestedObservers be an empty map. // 1. Let interestedObservers be an empty map.
// mutationObserver -> mappedOldValue // mutationObserver -> mappedOldValue
OrderedHashMap<MutationObserver*, Optional<DeprecatedString>> interested_observers; OrderedHashMap<MutationObserver*, Optional<String>> interested_observers;
// 2. Let nodes be the inclusive ancestors of target. // 2. Let nodes be the inclusive ancestors of target.
// 3. For each node in nodes, and then for each registered of nodes registered observer list: // 3. For each node in nodes, and then for each registered of nodes registered observer list:
@ -1559,7 +1559,7 @@ void Node::queue_mutation_record(FlyString const& type, Optional<DeprecatedStrin
// then: // then:
if (!(node != this && !options.subtree) if (!(node != this && !options.subtree)
&& !(type == MutationType::attributes && (!options.attributes.has_value() || !options.attributes.value())) && !(type == MutationType::attributes && (!options.attributes.has_value() || !options.attributes.value()))
&& !(type == MutationType::attributes && options.attribute_filter.has_value() && (attribute_namespace.has_value() || !options.attribute_filter->contains_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::characterData && (!options.character_data.has_value() || !options.character_data.value()))
&& !(type == MutationType::childList && !options.child_list)) { && !(type == MutationType::childList && !options.child_list)) {
// 1. Let mo be registereds observer. // 1. Let mo be registereds observer.
@ -1585,13 +1585,17 @@ void Node::queue_mutation_record(FlyString const& type, Optional<DeprecatedStrin
// 4. For each observer → mappedOldValue of interestedObservers: // 4. For each observer → mappedOldValue of interestedObservers:
for (auto& interested_observer : interested_observers) { for (auto& interested_observer : interested_observers) {
// FIXME: The MutationRecord constructor shuld take an Optional<FlyString> attribute name and namespace
Optional<String> string_attribute_name;
if (attribute_name.has_value())
string_attribute_name = attribute_name->to_string();
Optional<String> 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, // 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. // 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 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);
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);
// 2. Enqueue record to observers record queue. // 2. Enqueue record to observers record queue.
interested_observer.key->enqueue_record({}, move(record)); interested_observer.key->enqueue_record({}, move(record));

View file

@ -259,7 +259,7 @@ public:
void add_registered_observer(RegisteredObserver& registered_observer) { m_registered_observer_list.append(registered_observer); } void add_registered_observer(RegisteredObserver& registered_observer) { m_registered_observer_list.append(registered_observer); }
void queue_mutation_record(FlyString const& type, Optional<DeprecatedString> attribute_name, Optional<DeprecatedString> attribute_namespace, Optional<DeprecatedString> old_value, Vector<JS::Handle<Node>> added_nodes, Vector<JS::Handle<Node>> removed_nodes, Node* previous_sibling, Node* next_sibling) const; void queue_mutation_record(FlyString const& type, Optional<FlyString> const& attribute_name, Optional<FlyString> const& attribute_namespace, Optional<String> const& old_value, Vector<JS::Handle<Node>> added_nodes, Vector<JS::Handle<Node>> removed_nodes, Node* previous_sibling, Node* next_sibling) const;
// https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-descendant // https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-descendant
template<typename Callback> template<typename Callback>

View file

@ -27,7 +27,7 @@ void HTMLAnchorElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLAnchorElementPrototype>(realm, "HTMLAnchorElement")); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLAnchorElementPrototype>(realm, "HTMLAnchorElement"));
} }
void HTMLAnchorElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void HTMLAnchorElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
HTMLElement::attribute_changed(name, value); HTMLElement::attribute_changed(name, value);
if (name == HTML::AttributeNames::href) { if (name == HTML::AttributeNames::href) {

View file

@ -43,7 +43,7 @@ private:
void run_activation_behavior(Web::DOM::Event const&); void run_activation_behavior(Web::DOM::Event const&);
// ^DOM::Element // ^DOM::Element
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
virtual i32 default_tab_index_value() const override; virtual i32 default_tab_index_value() const override;
// ^HTML::HTMLHyperlinkElementUtils // ^HTML::HTMLHyperlinkElementUtils

View file

@ -23,7 +23,7 @@ void HTMLAreaElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLAreaElementPrototype>(realm, "HTMLAreaElement")); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLAreaElementPrototype>(realm, "HTMLAreaElement"));
} }
void HTMLAreaElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void HTMLAreaElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
HTMLElement::attribute_changed(name, value); HTMLElement::attribute_changed(name, value);
if (name == HTML::AttributeNames::href) { if (name == HTML::AttributeNames::href) {

View file

@ -26,7 +26,7 @@ private:
virtual void initialize(JS::Realm&) override; virtual void initialize(JS::Realm&) override;
// ^DOM::Element // ^DOM::Element
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
virtual i32 default_tab_index_value() const override; virtual i32 default_tab_index_value() const override;
// ^HTML::HTMLHyperlinkElementUtils // ^HTML::HTMLHyperlinkElementUtils

View file

@ -43,7 +43,7 @@ void HTMLBaseElement::removed_from(Node* parent)
document().update_base_element({}); document().update_base_element({});
} }
void HTMLBaseElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void HTMLBaseElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
HTMLElement::attribute_changed(name, value); HTMLElement::attribute_changed(name, value);

View file

@ -23,7 +23,7 @@ public:
virtual void inserted() override; virtual void inserted() override;
virtual void removed_from(Node*) override; virtual void removed_from(Node*) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
private: private:
HTMLBaseElement(DOM::Document&, DOM::QualifiedName); HTMLBaseElement(DOM::Document&, DOM::QualifiedName);

View file

@ -55,26 +55,26 @@ void HTMLBodyElement::apply_presentational_hints(CSS::StyleProperties& style) co
}); });
} }
void HTMLBodyElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void HTMLBodyElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
HTMLElement::attribute_changed(name, value); HTMLElement::attribute_changed(name, value);
if (name.equals_ignoring_ascii_case("link"sv)) { 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 // 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()) if (color.has_value())
document().set_link_color(color.value()); document().set_link_color(color.value());
} else if (name.equals_ignoring_ascii_case("alink"sv)) { } 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 // 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()) if (color.has_value())
document().set_active_link_color(color.value()); document().set_active_link_color(color.value());
} else if (name.equals_ignoring_ascii_case("vlink"sv)) { } 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 // 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()) if (color.has_value())
document().set_visited_link_color(color.value()); document().set_visited_link_color(color.value());
} else if (name.equals_ignoring_ascii_case("background"sv)) { } 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] { m_background_style_value->on_animate = [this] {
if (layout_node()) { if (layout_node()) {
layout_node()->set_needs_display(); layout_node()->set_needs_display();
@ -83,9 +83,9 @@ void HTMLBodyElement::attribute_changed(FlyString const& name, Optional<Deprecat
} }
#undef __ENUMERATE #undef __ENUMERATE
#define __ENUMERATE(attribute_name, event_name) \ #define __ENUMERATE(attribute_name, event_name) \
if (name == HTML::AttributeNames::attribute_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)); })); \ element_event_handler_attribute_changed(event_name, value); \
} }
ENUMERATE_WINDOW_EVENT_HANDLERS(__ENUMERATE) ENUMERATE_WINDOW_EVENT_HANDLERS(__ENUMERATE)
#undef __ENUMERATE #undef __ENUMERATE

View file

@ -20,7 +20,7 @@ class HTMLBodyElement final
public: public:
virtual ~HTMLBodyElement() override; virtual ~HTMLBodyElement() override;
virtual void attribute_changed(FlyString const&, Optional<DeprecatedString> const&) override; virtual void attribute_changed(FlyString const&, Optional<String> const&) override;
virtual void apply_presentational_hints(CSS::StyleProperties&) const override; virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
// https://www.w3.org/TR/html-aria/#el-body // https://www.w3.org/TR/html-aria/#el-body

View file

@ -41,7 +41,7 @@ void HTMLDetailsElement::initialize(JS::Realm& realm)
create_shadow_tree(realm).release_value_but_fixme_should_propagate_errors(); create_shadow_tree(realm).release_value_but_fixme_should_propagate_errors();
} }
void HTMLDetailsElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void HTMLDetailsElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
Base::attribute_changed(name, value); Base::attribute_changed(name, value);

View file

@ -31,7 +31,7 @@ private:
virtual void visit_edges(Cell::Visitor&) override; virtual void visit_edges(Cell::Visitor&) override;
virtual void children_changed() override; virtual void children_changed() override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
void queue_a_details_toggle_event_task(String old_state, String new_state); void queue_a_details_toggle_event_task(String old_state, String new_state);

View file

@ -224,7 +224,7 @@ bool HTMLElement::cannot_navigate() const
return !is<HTML::HTMLAnchorElement>(this) && !is_connected(); return !is<HTML::HTMLAnchorElement>(this) && !is_connected();
} }
void HTMLElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void HTMLElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
Element::attribute_changed(name, value); Element::attribute_changed(name, value);
@ -248,9 +248,9 @@ void HTMLElement::attribute_changed(FlyString const& name, Optional<DeprecatedSt
// 1. If namespace is not null, or localName is not the name of an event handler content attribute on element, then return. // 1. If namespace is not null, or localName is not the name of an event handler content attribute on element, then return.
// FIXME: Add the namespace part once we support attribute namespaces. // FIXME: Add the namespace part once we support attribute namespaces.
#undef __ENUMERATE #undef __ENUMERATE
#define __ENUMERATE(attribute_name, event_name) \ #define __ENUMERATE(attribute_name, event_name) \
if (name == HTML::AttributeNames::attribute_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)); })); \ element_event_handler_attribute_changed(event_name, value); \
} }
ENUMERATE_GLOBAL_EVENT_HANDLERS(__ENUMERATE) ENUMERATE_GLOBAL_EVENT_HANDLERS(__ENUMERATE)
#undef __ENUMERATE #undef __ENUMERATE

View file

@ -70,7 +70,7 @@ protected:
virtual void initialize(JS::Realm&) override; virtual void initialize(JS::Realm&) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
virtual void visit_edges(Cell::Visitor&) override; virtual void visit_edges(Cell::Visitor&) override;

View file

@ -23,14 +23,14 @@ void HTMLFrameSetElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLFrameSetElementPrototype>(realm, "HTMLFrameSetElement")); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLFrameSetElementPrototype>(realm, "HTMLFrameSetElement"));
} }
void HTMLFrameSetElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void HTMLFrameSetElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
HTMLElement::attribute_changed(name, value); HTMLElement::attribute_changed(name, value);
#undef __ENUMERATE #undef __ENUMERATE
#define __ENUMERATE(attribute_name, event_name) \ #define __ENUMERATE(attribute_name, event_name) \
if (name == HTML::AttributeNames::attribute_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)); })); \ element_event_handler_attribute_changed(event_name, value); \
} }
ENUMERATE_WINDOW_EVENT_HANDLERS(__ENUMERATE) ENUMERATE_WINDOW_EVENT_HANDLERS(__ENUMERATE)
#undef __ENUMERATE #undef __ENUMERATE

View file

@ -24,7 +24,7 @@ private:
HTMLFrameSetElement(DOM::Document&, DOM::QualifiedName); HTMLFrameSetElement(DOM::Document&, DOM::QualifiedName);
virtual void initialize(JS::Realm&) override; virtual void initialize(JS::Realm&) override;
virtual void attribute_changed(FlyString const&, Optional<DeprecatedString> const&) override; virtual void attribute_changed(FlyString const&, Optional<String> const&) override;
// ^HTML::GlobalEventHandlers // ^HTML::GlobalEventHandlers
virtual EventTarget& global_event_handlers_to_event_target(FlyString const& event_name) override; virtual EventTarget& global_event_handlers_to_event_target(FlyString const& event_name) override;

View file

@ -33,7 +33,7 @@ JS::GCPtr<Layout::Node> HTMLIFrameElement::create_layout_node(NonnullRefPtr<CSS:
return heap().allocate_without_realm<Layout::FrameBox>(document(), *this, move(style)); return heap().allocate_without_realm<Layout::FrameBox>(document(), *this, move(style));
} }
void HTMLIFrameElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void HTMLIFrameElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
HTMLElement::attribute_changed(name, value); HTMLElement::attribute_changed(name, value);
if (m_content_navigable) if (m_content_navigable)

View file

@ -36,7 +36,7 @@ private:
// ^DOM::Element // ^DOM::Element
virtual void inserted() override; virtual void inserted() override;
virtual void removed_from(Node*) override; virtual void removed_from(Node*) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
virtual i32 default_tab_index_value() const override; virtual i32 default_tab_index_value() const override;
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#process-the-iframe-attributes // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#process-the-iframe-attributes

View file

@ -95,16 +95,12 @@ void HTMLImageElement::apply_presentational_hints(CSS::StyleProperties& style) c
}); });
} }
void HTMLImageElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void HTMLImageElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
HTMLElement::attribute_changed(name, value); HTMLElement::attribute_changed(name, value);
if (name == HTML::AttributeNames::crossorigin) { if (name == HTML::AttributeNames::crossorigin) {
if (!value.has_value()) { m_cors_setting = cors_setting_attribute_from_keyword(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());
}
} }
if (name.is_one_of(HTML::AttributeNames::src, HTML::AttributeNames::srcset)) { if (name.is_one_of(HTML::AttributeNames::src, HTML::AttributeNames::srcset)) {

View file

@ -32,7 +32,7 @@ class HTMLImageElement final
public: public:
virtual ~HTMLImageElement() override; virtual ~HTMLImageElement() override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
DeprecatedString alt() const { return deprecated_attribute(HTML::AttributeNames::alt); } DeprecatedString alt() const { return deprecated_attribute(HTML::AttributeNames::alt); }
DeprecatedString src() const { return deprecated_attribute(HTML::AttributeNames::src); } DeprecatedString src() const { return deprecated_attribute(HTML::AttributeNames::src); }

View file

@ -627,7 +627,7 @@ void HTMLInputElement::did_lose_focus()
}); });
} }
void HTMLInputElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void HTMLInputElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
HTMLElement::attribute_changed(name, value); HTMLElement::attribute_changed(name, value);
if (name == HTML::AttributeNames::checked) { if (name == HTML::AttributeNames::checked) {
@ -643,7 +643,7 @@ void HTMLInputElement::attribute_changed(FlyString const& name, Optional<Depreca
set_checked(true, ChangeSource::Programmatic); set_checked(true, ChangeSource::Programmatic);
} }
} else if (name == HTML::AttributeNames::type) { } else if (name == HTML::AttributeNames::type) {
m_type = parse_type_attribute(value.value_or("")); m_type = parse_type_attribute(value.value_or(String {}));
} else if (name == HTML::AttributeNames::value) { } else if (name == HTML::AttributeNames::value) {
if (!value.has_value()) { if (!value.has_value()) {
if (!m_dirty_value) { if (!m_dirty_value) {
@ -655,7 +655,7 @@ void HTMLInputElement::attribute_changed(FlyString const& name, Optional<Depreca
} }
} else { } else {
if (!m_dirty_value) { if (!m_dirty_value) {
m_value = value_sanitization_algorithm(*value); m_value = value_sanitization_algorithm(value->to_deprecated_string());
update_placeholder_visibility(); update_placeholder_visibility();
if (type_state() == TypeAttributeState::Color && m_color_well_element) if (type_state() == TypeAttributeState::Color && m_color_well_element)
@ -664,12 +664,9 @@ void HTMLInputElement::attribute_changed(FlyString const& name, Optional<Depreca
} }
} else if (name == HTML::AttributeNames::placeholder) { } else if (name == HTML::AttributeNames::placeholder) {
if (m_placeholder_text_node) if (m_placeholder_text_node)
m_placeholder_text_node->set_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) { } else if (name == HTML::AttributeNames::readonly) {
if (value.has_value()) handle_readonly_attribute(value);
handle_readonly_attribute(MUST(String::from_deprecated_string(*value)));
else
handle_readonly_attribute({});
} }
} }

View file

@ -114,7 +114,7 @@ public:
virtual bool is_focusable() const override { return m_type != TypeAttributeState::Hidden; } virtual bool is_focusable() const override { return m_type != TypeAttributeState::Hidden; }
// ^HTMLElement // ^HTMLElement
virtual void attribute_changed(FlyString const&, Optional<DeprecatedString> const&) override; virtual void attribute_changed(FlyString const&, Optional<String> const&) override;
// ^FormAssociatedElement // ^FormAssociatedElement
// https://html.spec.whatwg.org/multipage/forms.html#category-listed // https://html.spec.whatwg.org/multipage/forms.html#category-listed

View file

@ -23,6 +23,7 @@
#include <LibWeb/HTML/PotentialCORSRequest.h> #include <LibWeb/HTML/PotentialCORSRequest.h>
#include <LibWeb/HTML/TraversableNavigable.h> #include <LibWeb/HTML/TraversableNavigable.h>
#include <LibWeb/Infra/CharacterTypes.h> #include <LibWeb/Infra/CharacterTypes.h>
#include <LibWeb/Infra/Strings.h>
#include <LibWeb/Loader/ResourceLoader.h> #include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/Page/Page.h> #include <LibWeb/Page/Page.h>
#include <LibWeb/Platform/ImageCodecPlugin.h> #include <LibWeb/Platform/ImageCodecPlugin.h>
@ -77,7 +78,7 @@ bool HTMLLinkElement::has_loaded_icon() const
return m_relationship & Relationship::Icon && resource() && resource()->is_loaded() && resource()->has_encoded_data(); return m_relationship & Relationship::Icon && resource() && resource()->is_loaded() && resource()->has_encoded_data();
} }
void HTMLLinkElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void HTMLLinkElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
HTMLElement::attribute_changed(name, value); HTMLElement::attribute_changed(name, value);
@ -85,11 +86,11 @@ void HTMLLinkElement::attribute_changed(FlyString const& name, Optional<Deprecat
if (name == HTML::AttributeNames::rel) { if (name == HTML::AttributeNames::rel) {
m_relationship = 0; m_relationship = 0;
// Keywords are always ASCII case-insensitive, and must be compared as such. // Keywords are always ASCII case-insensitive, and must be compared as such.
auto lowercased_value = value.value_or("").to_lowercase(); auto lowercased_value = MUST(Infra::to_ascii_lowercase(value.value_or(String {})));
// To determine which link types apply to a link, a, area, or form element, // To determine which link types apply to a link, a, area, or form element,
// the element's rel attribute must be split on ASCII whitespace. // the element's rel attribute must be split on ASCII whitespace.
// The resulting tokens are the keywords for the link types that apply to that element. // The resulting tokens are the keywords for the link types that apply to that element.
auto parts = lowercased_value.split_view(Infra::is_ascii_whitespace); auto parts = lowercased_value.bytes_as_string_view().split_view_if(Infra::is_ascii_whitespace);
for (auto& part : parts) { for (auto& part : parts) {
if (part == "stylesheet"sv) if (part == "stylesheet"sv)
m_relationship |= Relationship::Stylesheet; m_relationship |= Relationship::Stylesheet;

View file

@ -41,7 +41,7 @@ private:
HTMLLinkElement(DOM::Document&, DOM::QualifiedName); HTMLLinkElement(DOM::Document&, DOM::QualifiedName);
virtual void initialize(JS::Realm&) override; virtual void initialize(JS::Realm&) override;
void attribute_changed(FlyString const&, Optional<DeprecatedString> const&) override; void attribute_changed(FlyString const&, Optional<String> const&) override;
// ^ResourceClient // ^ResourceClient
virtual void resource_did_fail() override; virtual void resource_did_fail() override;

View file

@ -83,17 +83,14 @@ void HTMLMediaElement::visit_edges(Cell::Visitor& visitor)
visitor.visit(m_fetch_controller); visitor.visit(m_fetch_controller);
} }
void HTMLMediaElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void HTMLMediaElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
Base::attribute_changed(name, value); Base::attribute_changed(name, value);
if (name == HTML::AttributeNames::src) { if (name == HTML::AttributeNames::src) {
load_element().release_value_but_fixme_should_propagate_errors(); load_element().release_value_but_fixme_should_propagate_errors();
} else if (name == HTML::AttributeNames::crossorigin) { } else if (name == HTML::AttributeNames::crossorigin) {
if (!value.has_value()) m_crossorigin = cors_setting_attribute_from_keyword(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());
} else if (name == HTML::AttributeNames::muted) { } else if (name == HTML::AttributeNames::muted) {
set_muted(true); set_muted(true);
} }

View file

@ -134,7 +134,7 @@ protected:
virtual void initialize(JS::Realm&) override; virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override; virtual void visit_edges(Cell::Visitor&) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
virtual void removed_from(DOM::Node*) override; virtual void removed_from(DOM::Node*) override;
virtual void children_changed() override; virtual void children_changed() override;

View file

@ -45,7 +45,7 @@ void HTMLObjectElement::visit_edges(Cell::Visitor& visitor)
visitor.visit(m_image_request); visitor.visit(m_image_request);
} }
void HTMLObjectElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void HTMLObjectElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
NavigableContainer::attribute_changed(name, value); NavigableContainer::attribute_changed(name, value);

View file

@ -34,7 +34,7 @@ class HTMLObjectElement final
public: public:
virtual ~HTMLObjectElement() override; virtual ~HTMLObjectElement() override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
String data() const; String data() const;
void set_data(String const& data) { MUST(set_attribute(HTML::AttributeNames::data, data)); } void set_data(String const& data) { MUST(set_attribute(HTML::AttributeNames::data, data)); }

View file

@ -31,7 +31,7 @@ void HTMLOptionElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLOptionElementPrototype>(realm, "HTMLOptionElement")); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLOptionElementPrototype>(realm, "HTMLOptionElement"));
} }
void HTMLOptionElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void HTMLOptionElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
HTMLElement::attribute_changed(name, value); HTMLElement::attribute_changed(name, value);

View file

@ -40,7 +40,7 @@ private:
virtual void initialize(JS::Realm&) override; virtual void initialize(JS::Realm&) override;
void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; void attribute_changed(FlyString const& name, Optional<String> const& value) override;
void ask_for_a_reset(); void ask_for_a_reset();

View file

@ -45,15 +45,12 @@ void HTMLScriptElement::visit_edges(Cell::Visitor& visitor)
visitor.visit(m_preparation_time_document); visitor.visit(m_preparation_time_document);
} }
void HTMLScriptElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void HTMLScriptElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
Base::attribute_changed(name, value); Base::attribute_changed(name, value);
if (name == HTML::AttributeNames::crossorigin) { if (name == HTML::AttributeNames::crossorigin) {
if (!value.has_value()) m_crossorigin = cors_setting_attribute_from_keyword(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());
} else if (name == HTML::AttributeNames::referrerpolicy) { } else if (name == HTML::AttributeNames::referrerpolicy) {
if (!value.has_value()) if (!value.has_value())
m_referrer_policy.clear(); m_referrer_policy.clear();

View file

@ -62,7 +62,7 @@ private:
virtual void initialize(JS::Realm&) override; virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override; virtual void visit_edges(Cell::Visitor&) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
// https://html.spec.whatwg.org/multipage/scripting.html#prepare-the-script-element // https://html.spec.whatwg.org/multipage/scripting.html#prepare-the-script-element
void prepare_script(); void prepare_script();

View file

@ -24,11 +24,11 @@ HTMLSlotElement::HTMLSlotElement(DOM::Document& document, DOM::QualifiedName qua
return; return;
// 2. If value is null and oldValue is the empty string, then 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; return;
// 3. If value is the empty string and oldValue is null, then 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; return;
// 4. If value is null or the empty string, then set elements name to the empty string. // 4. If value is null or the empty string, then set elements name to the empty string.
@ -36,7 +36,7 @@ HTMLSlotElement::HTMLSlotElement(DOM::Document& document, DOM::QualifiedName qua
set_slot_name({}); set_slot_name({});
// 5. Otherwise, set elements name to value. // 5. Otherwise, set elements name to value.
else else
set_slot_name(MUST(String::from_deprecated_string(*value))); set_slot_name(*value);
// 6. Run assign slottables for a tree with elements root. // 6. Run assign slottables for a tree with elements root.
DOM::assign_slottables_for_a_tree(root()); DOM::assign_slottables_for_a_tree(root());

View file

@ -40,15 +40,12 @@ void HTMLVideoElement::visit_edges(Cell::Visitor& visitor)
visitor.visit(m_fetch_controller); visitor.visit(m_fetch_controller);
} }
void HTMLVideoElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void HTMLVideoElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
Base::attribute_changed(name, value); Base::attribute_changed(name, value);
if (name == HTML::AttributeNames::poster) { if (name == HTML::AttributeNames::poster) {
if (!value.has_value()) determine_element_poster_frame(value).release_value_but_fixme_should_propagate_errors();
determine_element_poster_frame({}).release_value_but_fixme_should_propagate_errors();
else
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 // https://html.spec.whatwg.org/multipage/media.html#attr-video-poster
WebIDL::ExceptionOr<void> HTMLVideoElement::determine_element_poster_frame(Optional<StringView> const& poster) WebIDL::ExceptionOr<void> HTMLVideoElement::determine_element_poster_frame(Optional<String> const& poster)
{ {
auto& realm = this->realm(); auto& realm = this->realm();
auto& vm = realm.vm(); auto& vm = realm.vm();

View file

@ -47,7 +47,7 @@ private:
virtual void initialize(JS::Realm&) override; virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override; virtual void visit_edges(Cell::Visitor&) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override; virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
@ -55,7 +55,7 @@ private:
virtual void on_paused() override; virtual void on_paused() override;
virtual void on_seek(double, MediaSeekMode) override; virtual void on_seek(double, MediaSeekMode) override;
WebIDL::ExceptionOr<void> determine_element_poster_frame(Optional<StringView> const& poster); WebIDL::ExceptionOr<void> determine_element_poster_frame(Optional<String> const& poster);
JS::GCPtr<HTML::VideoTrack> m_video_track; JS::GCPtr<HTML::VideoTrack> m_video_track;
VideoFrame m_current_frame; VideoFrame m_current_frame;

View file

@ -22,18 +22,18 @@ void SVGCircleElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGCircleElementPrototype>(realm, "SVGCircleElement")); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGCircleElementPrototype>(realm, "SVGCircleElement"));
} }
void SVGCircleElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void SVGCircleElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
SVGGeometryElement::attribute_changed(name, value); SVGGeometryElement::attribute_changed(name, value);
if (name == SVG::AttributeNames::cx) { 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(); m_path.clear();
} else if (name == SVG::AttributeNames::cy) { } 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(); m_path.clear();
} else if (name == SVG::AttributeNames::r) { } 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(); m_path.clear();
} }
} }

View file

@ -17,7 +17,7 @@ class SVGCircleElement final : public SVGGeometryElement {
public: public:
virtual ~SVGCircleElement() override = default; virtual ~SVGCircleElement() override = default;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
virtual Gfx::Path& get_path() override; virtual Gfx::Path& get_path() override;

View file

@ -34,7 +34,7 @@ void SVGElement::visit_edges(Cell::Visitor& visitor)
visitor.visit(m_dataset); visitor.visit(m_dataset);
} }
void SVGElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void SVGElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
Base::attribute_changed(name, value); Base::attribute_changed(name, value);

View file

@ -17,7 +17,7 @@ class SVGElement : public DOM::Element {
public: public:
virtual bool requires_svg_container() const override { return true; } virtual bool requires_svg_container() const override { return true; }
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
virtual void children_changed() override; virtual void children_changed() override;
virtual void inserted() override; virtual void inserted() override;

View file

@ -22,21 +22,21 @@ void SVGEllipseElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGEllipseElementPrototype>(realm, "SVGEllipseElement")); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGEllipseElementPrototype>(realm, "SVGEllipseElement"));
} }
void SVGEllipseElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void SVGEllipseElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
SVGGeometryElement::attribute_changed(name, value); SVGGeometryElement::attribute_changed(name, value);
if (name == SVG::AttributeNames::cx) { 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(); m_path.clear();
} else if (name == SVG::AttributeNames::cy) { } 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(); m_path.clear();
} else if (name == SVG::AttributeNames::rx) { } 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(); m_path.clear();
} else if (name == SVG::AttributeNames::ry) { } 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(); m_path.clear();
} }
} }

View file

@ -17,7 +17,7 @@ class SVGEllipseElement final : public SVGGeometryElement {
public: public:
virtual ~SVGEllipseElement() override = default; virtual ~SVGEllipseElement() override = default;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
virtual Gfx::Path& get_path() override; virtual Gfx::Path& get_path() override;

View file

@ -17,15 +17,15 @@ SVGGradientElement::SVGGradientElement(DOM::Document& document, DOM::QualifiedNa
{ {
} }
void SVGGradientElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void SVGGradientElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
SVGElement::attribute_changed(name, value); SVGElement::attribute_changed(name, value);
if (name == AttributeNames::gradientUnits) { 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) { } 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) { } 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); m_gradient_transform = transform_from_transform_list(*transform_list);
} else { } else {
m_gradient_transform = {}; m_gradient_transform = {};

View file

@ -40,7 +40,7 @@ class SVGGradientElement : public SVGElement {
public: public:
virtual ~SVGGradientElement() override = default; virtual ~SVGGradientElement() override = default;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
virtual Optional<Gfx::PaintStyle const&> to_gfx_paint_style(SVGPaintContext const&) const = 0; virtual Optional<Gfx::PaintStyle const&> to_gfx_paint_style(SVGPaintContext const&) const = 0;

View file

@ -32,11 +32,11 @@ void SVGGraphicsElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGGraphicsElementPrototype>(realm, "SVGGraphicsElement")); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGGraphicsElementPrototype>(realm, "SVGGraphicsElement"));
} }
void SVGGraphicsElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void SVGGraphicsElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
SVGElement::attribute_changed(name, value); SVGElement::attribute_changed(name, value);
if (name == "transform"sv) { 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()) if (transform_list.has_value())
m_transform = transform_from_transform_list(*transform_list); m_transform = transform_from_transform_list(*transform_list);
} }

View file

@ -24,7 +24,7 @@ class SVGGraphicsElement : public SVGElement {
public: public:
virtual void apply_presentational_hints(CSS::StyleProperties&) const override; virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
Optional<Gfx::Color> fill_color() const; Optional<Gfx::Color> fill_color() const;
Optional<FillRule> fill_rule() const; Optional<FillRule> fill_rule() const;

View file

@ -22,21 +22,21 @@ void SVGLineElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGLineElementPrototype>(realm, "SVGLineElement")); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGLineElementPrototype>(realm, "SVGLineElement"));
} }
void SVGLineElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void SVGLineElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
SVGGeometryElement::attribute_changed(name, value); SVGGeometryElement::attribute_changed(name, value);
if (name == SVG::AttributeNames::x1) { 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(); m_path.clear();
} else if (name == SVG::AttributeNames::y1) { } 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(); m_path.clear();
} else if (name == SVG::AttributeNames::x2) { } 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(); m_path.clear();
} else if (name == SVG::AttributeNames::y2) { } 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(); m_path.clear();
} }
} }

View file

@ -17,7 +17,7 @@ class SVGLineElement final : public SVGGeometryElement {
public: public:
virtual ~SVGLineElement() override = default; virtual ~SVGLineElement() override = default;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
virtual Gfx::Path& get_path() override; virtual Gfx::Path& get_path() override;

View file

@ -24,22 +24,22 @@ void SVGLinearGradientElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGLinearGradientElementPrototype>(realm, "SVGLinearGradientElement")); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGLinearGradientElementPrototype>(realm, "SVGLinearGradientElement"));
} }
void SVGLinearGradientElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void SVGLinearGradientElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
SVGGradientElement::attribute_changed(name, value); SVGGradientElement::attribute_changed(name, value);
// FIXME: Should allow for `<number-percentage> | <length>` for x1, x2, y1, y2 // FIXME: Should allow for `<number-percentage> | <length>` for x1, x2, y1, y2
if (name == SVG::AttributeNames::x1) { 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; m_paint_style = nullptr;
} else if (name == SVG::AttributeNames::y1) { } 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; m_paint_style = nullptr;
} else if (name == SVG::AttributeNames::x2) { } 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; m_paint_style = nullptr;
} else if (name == SVG::AttributeNames::y2) { } 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; m_paint_style = nullptr;
} }
} }

View file

@ -18,7 +18,7 @@ class SVGLinearGradientElement : public SVGGradientElement {
public: public:
virtual ~SVGLinearGradientElement() override = default; virtual ~SVGLinearGradientElement() override = default;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
virtual Optional<Gfx::PaintStyle const&> to_gfx_paint_style(SVGPaintContext const&) const override; virtual Optional<Gfx::PaintStyle const&> to_gfx_paint_style(SVGPaintContext const&) const override;

View file

@ -31,13 +31,13 @@ JS::GCPtr<Layout::Node> SVGMaskElement::create_layout_node(NonnullRefPtr<CSS::St
return heap().allocate_without_realm<Layout::SVGGraphicsBox>(document(), *this, move(style)); return heap().allocate_without_realm<Layout::SVGGraphicsBox>(document(), *this, move(style));
} }
void SVGMaskElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void SVGMaskElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
SVGGraphicsElement::attribute_changed(name, value); SVGGraphicsElement::attribute_changed(name, value);
if (name == AttributeNames::maskUnits) { 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) { } 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 {}));
} }
} }

View file

@ -17,7 +17,7 @@ class SVGMaskElement final : public SVGGraphicsElement {
public: public:
virtual ~SVGMaskElement() override; virtual ~SVGMaskElement() override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override; virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;

View file

@ -93,12 +93,12 @@ void SVGPathElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGPathElementPrototype>(realm, "SVGPathElement")); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGPathElementPrototype>(realm, "SVGPathElement"));
} }
void SVGPathElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void SVGPathElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
SVGGeometryElement::attribute_changed(name, value); SVGGeometryElement::attribute_changed(name, value);
if (name == "d") { 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(); m_path.clear();
} }
} }

View file

@ -19,7 +19,7 @@ class SVGPathElement final : public SVGGeometryElement {
public: public:
virtual ~SVGPathElement() override = default; virtual ~SVGPathElement() override = default;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
virtual Gfx::Path& get_path() override; virtual Gfx::Path& get_path() override;

View file

@ -22,12 +22,12 @@ void SVGPolygonElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGPolygonElementPrototype>(realm, "SVGPolygonElement")); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGPolygonElementPrototype>(realm, "SVGPolygonElement"));
} }
void SVGPolygonElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void SVGPolygonElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
SVGGeometryElement::attribute_changed(name, value); SVGGeometryElement::attribute_changed(name, value);
if (name == SVG::AttributeNames::points) { 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(); m_path.clear();
} }
} }

View file

@ -16,7 +16,7 @@ class SVGPolygonElement final : public SVGGeometryElement {
public: public:
virtual ~SVGPolygonElement() override = default; virtual ~SVGPolygonElement() override = default;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
virtual Gfx::Path& get_path() override; virtual Gfx::Path& get_path() override;

View file

@ -22,12 +22,12 @@ void SVGPolylineElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGPolylineElementPrototype>(realm, "SVGPolylineElement")); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGPolylineElementPrototype>(realm, "SVGPolylineElement"));
} }
void SVGPolylineElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void SVGPolylineElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
SVGGeometryElement::attribute_changed(name, value); SVGGeometryElement::attribute_changed(name, value);
if (name == SVG::AttributeNames::points) { 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(); m_path.clear();
} }
} }

View file

@ -16,7 +16,7 @@ class SVGPolylineElement final : public SVGGeometryElement {
public: public:
virtual ~SVGPolylineElement() override = default; virtual ~SVGPolylineElement() override = default;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
virtual Gfx::Path& get_path() override; virtual Gfx::Path& get_path() override;

View file

@ -21,29 +21,29 @@ void SVGRadialGradientElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGRadialGradientElementPrototype>(realm, "SVGRadialGradientElement")); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGRadialGradientElementPrototype>(realm, "SVGRadialGradientElement"));
} }
void SVGRadialGradientElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void SVGRadialGradientElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
SVGGradientElement::attribute_changed(name, value); SVGGradientElement::attribute_changed(name, value);
// FIXME: These are <length> or <coordinate> in the spec, but all examples seem to allow percentages // FIXME: These are <length> or <coordinate> in the spec, but all examples seem to allow percentages
// and unitless values. // and unitless values.
if (name == SVG::AttributeNames::cx) { 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; m_paint_style = nullptr;
} else if (name == SVG::AttributeNames::cy) { } 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; m_paint_style = nullptr;
} else if (name == SVG::AttributeNames::fx) { } 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; m_paint_style = nullptr;
} else if (name == SVG::AttributeNames::fy) { } 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; m_paint_style = nullptr;
} else if (name == SVG::AttributeNames::fr) { } 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; m_paint_style = nullptr;
} else if (name == SVG::AttributeNames::r) { } 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; m_paint_style = nullptr;
} }
} }

View file

@ -18,7 +18,7 @@ class SVGRadialGradientElement : public SVGGradientElement {
public: public:
virtual ~SVGRadialGradientElement() override = default; virtual ~SVGRadialGradientElement() override = default;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
virtual Optional<Gfx::PaintStyle const&> to_gfx_paint_style(SVGPaintContext const&) const override; virtual Optional<Gfx::PaintStyle const&> to_gfx_paint_style(SVGPaintContext const&) const override;

View file

@ -24,27 +24,27 @@ void SVGRectElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGRectElementPrototype>(realm, "SVGRectElement")); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGRectElementPrototype>(realm, "SVGRectElement"));
} }
void SVGRectElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void SVGRectElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
SVGGeometryElement::attribute_changed(name, value); SVGGeometryElement::attribute_changed(name, value);
if (name == SVG::AttributeNames::x) { 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(); m_path.clear();
} else if (name == SVG::AttributeNames::y) { } 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(); m_path.clear();
} else if (name == SVG::AttributeNames::width) { } 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(); m_path.clear();
} else if (name == SVG::AttributeNames::height) { } 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(); m_path.clear();
} else if (name == SVG::AttributeNames::rx) { } 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(); m_path.clear();
} else if (name == SVG::AttributeNames::ry) { } 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(); m_path.clear();
} }
} }

View file

@ -17,7 +17,7 @@ class SVGRectElement final : public SVGGeometryElement {
public: public:
virtual ~SVGRectElement() override = default; virtual ~SVGRectElement() override = default;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
virtual Gfx::Path& get_path() override; virtual Gfx::Path& get_path() override;

View file

@ -61,14 +61,14 @@ void SVGSVGElement::apply_presentational_hints(CSS::StyleProperties& style) cons
} }
} }
void SVGSVGElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void SVGSVGElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
SVGGraphicsElement::attribute_changed(name, value); SVGGraphicsElement::attribute_changed(name, value);
if (name.equals_ignoring_ascii_case(SVG::AttributeNames::viewBox)) 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)) 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)) 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(); update_fallback_view_box_for_svg_as_image();
} }

View file

@ -36,7 +36,7 @@ private:
virtual bool is_svg_svg_element() const override { return true; } virtual bool is_svg_svg_element() const override { return true; }
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
void update_fallback_view_box_for_svg_as_image(); void update_fallback_view_box_for_svg_as_image();

View file

@ -19,11 +19,11 @@ SVGStopElement::SVGStopElement(DOM::Document& document, DOM::QualifiedName quali
{ {
} }
void SVGStopElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void SVGStopElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
SVGElement::attribute_changed(name, value); SVGElement::attribute_changed(name, value);
if (name == SVG::AttributeNames::offset) { if (name == SVG::AttributeNames::offset) {
m_offset = AttributeParser::parse_number_percentage(value.value_or("")); m_offset = AttributeParser::parse_number_percentage(value.value_or(String {}));
} }
} }

View file

@ -19,7 +19,7 @@ class SVGStopElement final : public SVGElement {
public: public:
virtual ~SVGStopElement() override = default; virtual ~SVGStopElement() override = default;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
JS::NonnullGCPtr<SVGAnimatedNumber> offset() const; JS::NonnullGCPtr<SVGAnimatedNumber> offset() const;

View file

@ -39,11 +39,11 @@ void SVGSymbolElement::apply_presentational_hints(CSS::StyleProperties& style) c
} }
} }
void SVGSymbolElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void SVGSymbolElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
Base::attribute_changed(name, value); Base::attribute_changed(name, value);
if (name.equals_ignoring_ascii_case(SVG::AttributeNames::viewBox)) 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 bool SVGSymbolElement::is_direct_child_of_use_shadow_tree() const

View file

@ -29,7 +29,7 @@ private:
bool is_direct_child_of_use_shadow_tree() const; bool is_direct_child_of_use_shadow_tree() const;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
Optional<ViewBox> m_view_box; Optional<ViewBox> m_view_box;
}; };

View file

@ -28,18 +28,18 @@ void SVGTextPositioningElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGTextPositioningElementPrototype>(realm, "SVGTextPositioningElement")); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGTextPositioningElementPrototype>(realm, "SVGTextPositioningElement"));
} }
void SVGTextPositioningElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void SVGTextPositioningElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
SVGGraphicsElement::attribute_changed(name, value); SVGGraphicsElement::attribute_changed(name, value);
if (name == SVG::AttributeNames::x) { 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) { } 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) { } 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) { } 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);
} }
} }

View file

@ -16,7 +16,7 @@ class SVGTextPositioningElement : public SVGTextContentElement {
WEB_PLATFORM_OBJECT(SVGTextPositioningElement, SVGTextContentElement); WEB_PLATFORM_OBJECT(SVGTextPositioningElement, SVGTextContentElement);
public: public:
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
Gfx::FloatPoint get_offset() const; Gfx::FloatPoint get_offset() const;

View file

@ -45,18 +45,18 @@ void SVGUseElement::visit_edges(Cell::Visitor& visitor)
visitor.visit(m_document_observer); visitor.visit(m_document_observer);
} }
void SVGUseElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) void SVGUseElement::attribute_changed(FlyString const& name, Optional<String> const& value)
{ {
Base::attribute_changed(name, value); Base::attribute_changed(name, value);
// https://svgwg.org/svg2-draft/struct.html#UseLayout // https://svgwg.org/svg2-draft/struct.html#UseLayout
if (name == SVG::AttributeNames::x) { 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) { } 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) { } else if (name == SVG::AttributeNames::href) {
// FIXME: Support the xlink:href attribute as a fallback // 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()); clone_element_tree_as_our_shadow_tree(referenced_element());
} }

View file

@ -20,7 +20,7 @@ class SVGUseElement final : public SVGGraphicsElement {
public: public:
virtual ~SVGUseElement() override = default; virtual ~SVGUseElement() override = default;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override; virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
virtual void inserted() override; virtual void inserted() override;