diff --git a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp index d742301264..e6d3303157 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp +++ b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp @@ -234,7 +234,7 @@ void DOMTokenList::set_value(String const& value) if (!associated_element) return; - MUST(associated_element->set_attribute(m_associated_attribute.to_deprecated_fly_string(), value.to_deprecated_string())); + MUST(associated_element->set_attribute(m_associated_attribute, value)); } WebIDL::ExceptionOr DOMTokenList::validate_token(StringView token) const @@ -253,14 +253,12 @@ void DOMTokenList::run_update_steps() if (!associated_element) return; - auto deprecated_attribute = m_associated_attribute.to_deprecated_fly_string(); - // 1. If the associated element does not have an associated attribute and token set is empty, then return. - if (!associated_element->has_attribute(deprecated_attribute) && m_token_set.is_empty()) + if (!associated_element->has_attribute(m_associated_attribute) && m_token_set.is_empty()) return; // 2. Set an attribute value for the associated element using associated attribute’s local name and the result of running the ordered set serializer for token set. - MUST(associated_element->set_attribute(deprecated_attribute, value().to_deprecated_string())); + MUST(associated_element->set_attribute(m_associated_attribute, value())); } WebIDL::ExceptionOr DOMTokenList::item_value(size_t index) const diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 0604117571..bea7d270c1 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -176,7 +176,7 @@ JS::GCPtr Element::get_attribute_node(FlyString const& name) const } // https://dom.spec.whatwg.org/#dom-element-setattribute -WebIDL::ExceptionOr Element::set_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) +WebIDL::ExceptionOr Element::set_attribute(FlyString const& name, String const& value) { // 1. If qualifiedName does not match the Name production in XML, then throw an "InvalidCharacterError" DOMException. // FIXME: Proper name validation @@ -193,23 +193,18 @@ WebIDL::ExceptionOr Element::set_attribute(DeprecatedFlyString const& name // 4. If attribute is null, create an attribute whose local name is qualifiedName, value is value, and node document // is this’s node document, then append this attribute to this, and then return. if (!attribute) { - auto new_attribute = Attr::create(document(), MUST(String::from_deprecated_string(insert_as_lowercase ? name.to_lowercase() : name)), MUST(String::from_deprecated_string(value))); + auto new_attribute = Attr::create(document(), insert_as_lowercase ? MUST(Infra::to_ascii_lowercase(name)) : name, value); m_attributes->append_attribute(new_attribute); return {}; } // 5. Change attribute to value. - attribute->change_attribute(MUST(String::from_deprecated_string(value))); + attribute->change_attribute(value); return {}; } -WebIDL::ExceptionOr Element::set_attribute(DeprecatedFlyString const& name, String const& value) -{ - return set_attribute(name, value.to_deprecated_string()); -} - // https://dom.spec.whatwg.org/#validate-and-extract WebIDL::ExceptionOr validate_and_extract(JS::Realm& realm, Optional namespace_, DeprecatedFlyString qualified_name) { diff --git a/Userland/Libraries/LibWeb/DOM/Element.h b/Userland/Libraries/LibWeb/DOM/Element.h index b5e1a4aee8..d99d379815 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.h +++ b/Userland/Libraries/LibWeb/DOM/Element.h @@ -105,12 +105,7 @@ public: DeprecatedString deprecated_get_attribute(StringView name) const; DeprecatedString get_attribute_value(StringView local_name, DeprecatedFlyString const& namespace_ = {}) const; - WebIDL::ExceptionOr set_attribute(DeprecatedFlyString const& name, DeprecatedString const& value); - WebIDL::ExceptionOr set_attribute(DeprecatedFlyString const& name, String const& value); - WebIDL::ExceptionOr set_attribute(FlyString const& name, String const& value) - { - return set_attribute(name.to_deprecated_fly_string(), value); - } + WebIDL::ExceptionOr set_attribute(FlyString const& name, String const& value); // FIXME: This should be taking an Optional WebIDL::ExceptionOr set_attribute_ns(Optional const& namespace_, FlyString const& qualified_name, FlyString const& value); @@ -271,55 +266,55 @@ public: } // https://www.w3.org/TR/wai-aria-1.2/#accessibilityroleandproperties-correspondence - ARIA_IMPL(role, "role"sv); - ARIA_IMPL(aria_active_descendant, "aria-activedescendant"sv); - ARIA_IMPL(aria_atomic, "aria-atomic"sv); - ARIA_IMPL(aria_auto_complete, "aria-autocomplete"sv); - ARIA_IMPL(aria_busy, "aria-busy"sv); - ARIA_IMPL(aria_checked, "aria-checked"sv); - ARIA_IMPL(aria_col_count, "aria-colcount"sv); - ARIA_IMPL(aria_col_index, "aria-colindex"sv); - ARIA_IMPL(aria_col_span, "aria-colspan"sv); - ARIA_IMPL(aria_controls, "aria-controls"sv); - ARIA_IMPL(aria_current, "aria-current"sv); - ARIA_IMPL(aria_described_by, "aria-describedby"sv); - ARIA_IMPL(aria_details, "aria-details"sv); - ARIA_IMPL(aria_drop_effect, "aria-dropeffect"sv); - ARIA_IMPL(aria_error_message, "aria-errormessage"sv); - ARIA_IMPL(aria_disabled, "aria-disabled"sv); - ARIA_IMPL(aria_expanded, "aria-expanded"sv); - ARIA_IMPL(aria_flow_to, "aria-flowto"sv); - ARIA_IMPL(aria_grabbed, "aria-grabbed"sv); - ARIA_IMPL(aria_has_popup, "aria-haspopup"sv); - ARIA_IMPL(aria_hidden, "aria-hidden"sv); - ARIA_IMPL(aria_invalid, "aria-invalid"sv); - ARIA_IMPL(aria_key_shortcuts, "aria-keyshortcuts"sv); - ARIA_IMPL(aria_label, "aria-label"sv); - ARIA_IMPL(aria_labelled_by, "aria-labelledby"sv); - ARIA_IMPL(aria_level, "aria-level"sv); - ARIA_IMPL(aria_live, "aria-live"sv); - ARIA_IMPL(aria_modal, "aria-modal"sv); - ARIA_IMPL(aria_multi_line, "aria-multiline"sv); - ARIA_IMPL(aria_multi_selectable, "aria-multiselectable"sv); - ARIA_IMPL(aria_orientation, "aria-orientation"sv); - ARIA_IMPL(aria_owns, "aria-owns"sv); - ARIA_IMPL(aria_placeholder, "aria-placeholder"sv); - ARIA_IMPL(aria_pos_in_set, "aria-posinset"sv); - ARIA_IMPL(aria_pressed, "aria-pressed"sv); - ARIA_IMPL(aria_read_only, "aria-readonly"sv); - ARIA_IMPL(aria_relevant, "aria-relevant"sv); - ARIA_IMPL(aria_required, "aria-required"sv); - ARIA_IMPL(aria_role_description, "aria-roledescription"sv); - ARIA_IMPL(aria_row_count, "aria-rowcount"sv); - ARIA_IMPL(aria_row_index, "aria-rowindex"sv); - ARIA_IMPL(aria_row_span, "aria-rowspan"sv); - ARIA_IMPL(aria_selected, "aria-selected"sv); - ARIA_IMPL(aria_set_size, "aria-setsize"sv); - ARIA_IMPL(aria_sort, "aria-sort"sv); - ARIA_IMPL(aria_value_max, "aria-valuemax"sv); - ARIA_IMPL(aria_value_min, "aria-valuemin"sv); - ARIA_IMPL(aria_value_now, "aria-valuenow"sv); - ARIA_IMPL(aria_value_text, "aria-valuetext"sv); + ARIA_IMPL(role, "role"_fly_string); + ARIA_IMPL(aria_active_descendant, "aria-activedescendant"_fly_string); + ARIA_IMPL(aria_atomic, "aria-atomic"_fly_string); + ARIA_IMPL(aria_auto_complete, "aria-autocomplete"_fly_string); + ARIA_IMPL(aria_busy, "aria-busy"_fly_string); + ARIA_IMPL(aria_checked, "aria-checked"_fly_string); + ARIA_IMPL(aria_col_count, "aria-colcount"_fly_string); + ARIA_IMPL(aria_col_index, "aria-colindex"_fly_string); + ARIA_IMPL(aria_col_span, "aria-colspan"_fly_string); + ARIA_IMPL(aria_controls, "aria-controls"_fly_string); + ARIA_IMPL(aria_current, "aria-current"_fly_string); + ARIA_IMPL(aria_described_by, "aria-describedby"_fly_string); + ARIA_IMPL(aria_details, "aria-details"_fly_string); + ARIA_IMPL(aria_drop_effect, "aria-dropeffect"_fly_string); + ARIA_IMPL(aria_error_message, "aria-errormessage"_fly_string); + ARIA_IMPL(aria_disabled, "aria-disabled"_fly_string); + ARIA_IMPL(aria_expanded, "aria-expanded"_fly_string); + ARIA_IMPL(aria_flow_to, "aria-flowto"_fly_string); + ARIA_IMPL(aria_grabbed, "aria-grabbed"_fly_string); + ARIA_IMPL(aria_has_popup, "aria-haspopup"_fly_string); + ARIA_IMPL(aria_hidden, "aria-hidden"_fly_string); + ARIA_IMPL(aria_invalid, "aria-invalid"_fly_string); + ARIA_IMPL(aria_key_shortcuts, "aria-keyshortcuts"_fly_string); + ARIA_IMPL(aria_label, "aria-label"_fly_string); + ARIA_IMPL(aria_labelled_by, "aria-labelledby"_fly_string); + ARIA_IMPL(aria_level, "aria-level"_fly_string); + ARIA_IMPL(aria_live, "aria-live"_fly_string); + ARIA_IMPL(aria_modal, "aria-modal"_fly_string); + ARIA_IMPL(aria_multi_line, "aria-multiline"_fly_string); + ARIA_IMPL(aria_multi_selectable, "aria-multiselectable"_fly_string); + ARIA_IMPL(aria_orientation, "aria-orientation"_fly_string); + ARIA_IMPL(aria_owns, "aria-owns"_fly_string); + ARIA_IMPL(aria_placeholder, "aria-placeholder"_fly_string); + ARIA_IMPL(aria_pos_in_set, "aria-posinset"_fly_string); + ARIA_IMPL(aria_pressed, "aria-pressed"_fly_string); + ARIA_IMPL(aria_read_only, "aria-readonly"_fly_string); + ARIA_IMPL(aria_relevant, "aria-relevant"_fly_string); + ARIA_IMPL(aria_required, "aria-required"_fly_string); + ARIA_IMPL(aria_role_description, "aria-roledescription"_fly_string); + ARIA_IMPL(aria_row_count, "aria-rowcount"_fly_string); + ARIA_IMPL(aria_row_index, "aria-rowindex"_fly_string); + ARIA_IMPL(aria_row_span, "aria-rowspan"_fly_string); + ARIA_IMPL(aria_selected, "aria-selected"_fly_string); + ARIA_IMPL(aria_set_size, "aria-setsize"_fly_string); + ARIA_IMPL(aria_sort, "aria-sort"_fly_string); + ARIA_IMPL(aria_value_max, "aria-valuemax"_fly_string); + ARIA_IMPL(aria_value_min, "aria-valuemin"_fly_string); + ARIA_IMPL(aria_value_now, "aria-valuenow"_fly_string); + ARIA_IMPL(aria_value_text, "aria-valuetext"_fly_string); #undef ARIA_IMPL diff --git a/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp b/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp index d953fbd80d..4ea24e2f93 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp +++ b/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp @@ -121,7 +121,7 @@ WebIDL::ExceptionOr DOMStringMap::set_value_of_new_named_property(Deprecat { // NOTE: Since LegacyPlatformObject does not know the type of value, we must convert it ourselves. // The type of `value` is `DOMString`. - auto value = TRY(unconverted_value.to_deprecated_string(vm())); + auto value = TRY(unconverted_value.to_string(vm())); AK::StringBuilder builder; @@ -149,7 +149,7 @@ WebIDL::ExceptionOr DOMStringMap::set_value_of_new_named_property(Deprecat builder.append(current_character); } - auto data_name = builder.to_deprecated_string(); + auto data_name = MUST(builder.to_string()); // FIXME: 4. If name does not match the XML Name production, throw an "InvalidCharacterError" DOMException. diff --git a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp index 6b38721d17..5343b8f38c 100644 --- a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp +++ b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp @@ -84,8 +84,8 @@ void XMLDocumentBuilder::element_start(const XML::Name& name, HashMapappend_child(node)); } - for (auto& attribute : attributes) - MUST(node->set_attribute(attribute.key, attribute.value)); + for (auto const& attribute : attributes) + MUST(node->set_attribute(MUST(FlyString::from_deprecated_fly_string(attribute.key)), MUST(String::from_deprecated_string(attribute.value)))); m_current_node = node.ptr(); }