diff --git a/Userland/Libraries/LibWeb/Bindings/LegacyPlatformObject.cpp b/Userland/Libraries/LibWeb/Bindings/LegacyPlatformObject.cpp index 7cbdaa849a..77072b20cc 100644 --- a/Userland/Libraries/LibWeb/Bindings/LegacyPlatformObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/LegacyPlatformObject.cpp @@ -126,8 +126,8 @@ WebIDL::ExceptionOr LegacyPlatformObject::invoke_indexed_property_setter(J WebIDL::ExceptionOr LegacyPlatformObject::invoke_named_property_setter(DeprecatedString const& property_name, JS::Value value) { // 1. Let creating be true if P is not a supported property name, and false otherwise. - Vector supported_property_names = this->supported_property_names(); - bool creating = !supported_property_names.contains_slow(property_name); + Vector supported_property_names = this->supported_property_names(); + bool creating = !supported_property_names.contains_slow(MUST(String::from_deprecated_string(property_name))); // FIXME: We do not have this information at this point, so converting the value is left as an exercise to the inheritor of LegacyPlatformObject. // 2. Let operation be the operation used to declare the indexed property setter. @@ -219,8 +219,8 @@ JS::ThrowCompletionOr LegacyPlatformObject::internal_define_own_property(J // 1. Let creating be true if P is not a supported property name, and false otherwise. // NOTE: This is in it's own variable to enforce the type. - Vector supported_property_names = this->supported_property_names(); - bool creating = !supported_property_names.contains_slow(property_name_as_string); + Vector supported_property_names = this->supported_property_names(); + bool creating = !supported_property_names.contains_slow(MUST(String::from_deprecated_string(property_name_as_string))); // 2. If O implements an interface with the [LegacyOverrideBuiltIns] extended attribute or O does not have an own property named P, then: // NOTE: Own property lookup has to be done manually instead of using Object::has_own_property, as that would use the overridden internal_get_own_property. @@ -348,7 +348,7 @@ JS::ThrowCompletionOr> LegacyPlatformObject::interna // 3. If O supports named properties, then for each P of O’s supported property names that is visible according to the named property visibility algorithm, append P to keys. if (supports_named_properties()) { for (auto& named_property : supported_property_names()) { - if (TRY(WebIDL::is_named_property_exposed_on_object({ this }, named_property))) + if (TRY(WebIDL::is_named_property_exposed_on_object({ this }, named_property.to_deprecated_string()))) keys.append(JS::PrimitiveString::create(vm, named_property)); } } @@ -381,7 +381,7 @@ WebIDL::ExceptionOr LegacyPlatformObject::named_item_value(FlyString return JS::js_undefined(); } -Vector LegacyPlatformObject::supported_property_names() const +Vector LegacyPlatformObject::supported_property_names() const { return {}; } diff --git a/Userland/Libraries/LibWeb/Bindings/LegacyPlatformObject.h b/Userland/Libraries/LibWeb/Bindings/LegacyPlatformObject.h index ec0f028909..5139c0006b 100644 --- a/Userland/Libraries/LibWeb/Bindings/LegacyPlatformObject.h +++ b/Userland/Libraries/LibWeb/Bindings/LegacyPlatformObject.h @@ -37,7 +37,7 @@ public: virtual WebIDL::ExceptionOr item_value(size_t index) const; virtual WebIDL::ExceptionOr named_item_value(FlyString const& name) const; - virtual Vector supported_property_names() const; + virtual Vector supported_property_names() const; virtual bool is_supported_property_index(u32) const; // NOTE: These will crash if you make has_named_property_setter return true but do not override these methods. diff --git a/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp b/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp index 088ca3223b..3f14d61216 100644 --- a/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp +++ b/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp @@ -99,29 +99,28 @@ Element* HTMLCollection::named_item(FlyString const& name_) const } // https://dom.spec.whatwg.org/#ref-for-dfn-supported-property-names -Vector HTMLCollection::supported_property_names() const +Vector HTMLCollection::supported_property_names() const { // 1. Let result be an empty list. - Vector result; + Vector result; // 2. For each element represented by the collection, in tree order: auto elements = collect_matching_elements(); for (auto& element : elements) { // 1. If element has an ID which is not in result, append element’s ID to result. - if (element->has_attribute(HTML::AttributeNames::id)) { - auto id = element->deprecated_attribute(HTML::AttributeNames::id); - - if (!result.contains_slow(id)) - result.append(id); + if (auto maybe_id = element->attribute(HTML::AttributeNames::id); maybe_id.has_value()) { + if (!result.contains_slow(maybe_id.value())) + result.append(maybe_id.release_value()); } // 2. If element is in the HTML namespace and has a name attribute whose value is neither the empty string nor is in result, append element’s name attribute value to result. - if (element->namespace_uri() == Namespace::HTML && element->has_attribute(HTML::AttributeNames::name)) { - auto name = element->deprecated_attribute(HTML::AttributeNames::name); - - if (!name.is_empty() && !result.contains_slow(name)) - result.append(name); + if (element->namespace_uri() == Namespace::HTML) { + if (auto maybe_name = element->attribute(HTML::AttributeNames::name); maybe_name.has_value()) { + auto name = maybe_name.release_value(); + if (!name.is_empty() && !result.contains_slow(name)) + result.append(move(name)); + } } } diff --git a/Userland/Libraries/LibWeb/DOM/HTMLCollection.h b/Userland/Libraries/LibWeb/DOM/HTMLCollection.h index 3b28e7967d..803b9157db 100644 --- a/Userland/Libraries/LibWeb/DOM/HTMLCollection.h +++ b/Userland/Libraries/LibWeb/DOM/HTMLCollection.h @@ -46,7 +46,7 @@ public: virtual WebIDL::ExceptionOr item_value(size_t index) const override; virtual WebIDL::ExceptionOr named_item_value(FlyString const& name) const override; - virtual Vector supported_property_names() const override; + virtual Vector supported_property_names() const override; virtual bool is_supported_property_index(u32) const override; protected: diff --git a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp index 8e6c713b33..1021bb8da3 100644 --- a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp +++ b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include namespace Web::DOM { @@ -48,16 +49,16 @@ bool NamedNodeMap::is_supported_property_index(u32 index) const } // https://dom.spec.whatwg.org/#ref-for-dfn-supported-property-names%E2%91%A0 -Vector NamedNodeMap::supported_property_names() const +Vector NamedNodeMap::supported_property_names() const { // 1. Let names be the qualified names of the attributes in this NamedNodeMap object’s attribute list, with duplicates omitted, in order. - Vector names; + Vector names; names.ensure_capacity(m_attributes.size()); for (auto const& attribute : m_attributes) { - auto const attribute_name = attribute->name().to_deprecated_fly_string(); + auto const attribute_name = attribute->name(); if (!names.contains_slow(attribute_name)) - names.append(attribute_name); + names.append(attribute_name.to_string()); } // 2. If this NamedNodeMap object’s element is in the HTML namespace and its node document is an HTML document, then for each name in names: @@ -65,7 +66,7 @@ Vector NamedNodeMap::supported_property_names() const if (associated_element().namespace_uri() == Namespace::HTML) { // 1. Let lowercaseName be name, in ASCII lowercase. // 2. If lowercaseName is not equal to name, remove name from names. - names.remove_all_matching([](auto const& name) { return name != name.to_lowercase(); }); + names.remove_all_matching([](auto const& name) { return name != MUST(Infra::to_ascii_lowercase(name)); }); } // 3. Return names. diff --git a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h index 8dd2c19b0f..b5157ca7c3 100644 --- a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h +++ b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h @@ -27,7 +27,7 @@ public: ~NamedNodeMap() = default; virtual bool is_supported_property_index(u32 index) const override; - virtual Vector supported_property_names() const override; + virtual Vector supported_property_names() const override; virtual WebIDL::ExceptionOr item_value(size_t index) const override; virtual WebIDL::ExceptionOr named_item_value(FlyString const& name) const override; diff --git a/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp b/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp index 051fbcbd9b..1fc599eb11 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp +++ b/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp @@ -91,13 +91,13 @@ Vector DOMStringMap::get_name_value_pairs() const // https://html.spec.whatwg.org/multipage/dom.html#concept-domstringmap-pairs // NOTE: There isn't a direct link to this, so the link is to one of the algorithms above it. -Vector DOMStringMap::supported_property_names() const +Vector DOMStringMap::supported_property_names() const { // The supported property names on a DOMStringMap object at any instant are the names of each pair returned from getting the DOMStringMap's name-value pairs at that instant, in the order returned. - Vector names; + Vector names; auto name_value_pairs = get_name_value_pairs(); for (auto& name_value_pair : name_value_pairs) { - names.append(name_value_pair.name); + names.append(MUST(String::from_deprecated_string(name_value_pair.name))); } return names; } diff --git a/Userland/Libraries/LibWeb/HTML/DOMStringMap.h b/Userland/Libraries/LibWeb/HTML/DOMStringMap.h index 8f37a44aa0..5ca4398411 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMStringMap.h +++ b/Userland/Libraries/LibWeb/HTML/DOMStringMap.h @@ -37,7 +37,7 @@ private: // ^LegacyPlatformObject virtual WebIDL::ExceptionOr named_item_value(FlyString const&) const override; - virtual Vector supported_property_names() const override; + virtual Vector supported_property_names() const override; virtual bool supports_indexed_properties() const override { return false; } virtual bool supports_named_properties() const override { return true; } diff --git a/Userland/Libraries/LibWeb/HTML/MimeTypeArray.cpp b/Userland/Libraries/LibWeb/HTML/MimeTypeArray.cpp index 30a998925c..6eabd5a0db 100644 --- a/Userland/Libraries/LibWeb/HTML/MimeTypeArray.cpp +++ b/Userland/Libraries/LibWeb/HTML/MimeTypeArray.cpp @@ -28,7 +28,7 @@ void MimeTypeArray::initialize(JS::Realm& realm) } // https://html.spec.whatwg.org/multipage/system-state.html#pdf-viewing-support:support-named-properties-2 -Vector MimeTypeArray::supported_property_names() const +Vector MimeTypeArray::supported_property_names() const { // The MimeTypeArray interface supports named properties. If the user agent's PDF viewer supported is true, then they are the PDF viewer mime types. Otherwise, they are the empty list. auto const& window = verify_cast(HTML::relevant_global_object(*this)); @@ -37,9 +37,9 @@ Vector MimeTypeArray::supported_property_names() const return {}; // https://html.spec.whatwg.org/multipage/system-state.html#pdf-viewer-mime-types - static Vector mime_types = { - "application/pdf"sv, - "text/pdf"sv, + static Vector const mime_types = { + "application/pdf"_string, + "text/pdf"_string, }; return mime_types; diff --git a/Userland/Libraries/LibWeb/HTML/MimeTypeArray.h b/Userland/Libraries/LibWeb/HTML/MimeTypeArray.h index c5fc228cc6..f0c267304d 100644 --- a/Userland/Libraries/LibWeb/HTML/MimeTypeArray.h +++ b/Userland/Libraries/LibWeb/HTML/MimeTypeArray.h @@ -28,7 +28,7 @@ private: virtual void initialize(JS::Realm&) override; // ^Bindings::LegacyPlatformObject - virtual Vector supported_property_names() const override; + virtual Vector supported_property_names() const override; virtual WebIDL::ExceptionOr item_value(size_t index) const override; virtual WebIDL::ExceptionOr named_item_value(FlyString const& name) const override; virtual bool is_supported_property_index(u32) const override; diff --git a/Userland/Libraries/LibWeb/HTML/Plugin.cpp b/Userland/Libraries/LibWeb/HTML/Plugin.cpp index 49c5996a1d..5237e58a33 100644 --- a/Userland/Libraries/LibWeb/HTML/Plugin.cpp +++ b/Userland/Libraries/LibWeb/HTML/Plugin.cpp @@ -52,7 +52,7 @@ String Plugin::filename() const } // https://html.spec.whatwg.org/multipage/system-state.html#pdf-viewing-support:support-named-properties-3 -Vector Plugin::supported_property_names() const +Vector Plugin::supported_property_names() const { // The Plugin interface supports named properties. If the user agent's PDF viewer supported is true, then they are the PDF viewer mime types. Otherwise, they are the empty list. auto const& window = verify_cast(HTML::relevant_global_object(*this)); @@ -61,9 +61,9 @@ Vector Plugin::supported_property_names() const return {}; // https://html.spec.whatwg.org/multipage/system-state.html#pdf-viewer-mime-types - static Vector mime_types = { - "application/pdf"sv, - "text/pdf"sv, + static Vector const mime_types = { + "application/pdf"_string, + "text/pdf"_string, }; return mime_types; diff --git a/Userland/Libraries/LibWeb/HTML/Plugin.h b/Userland/Libraries/LibWeb/HTML/Plugin.h index c4e58e8c57..5963e633ff 100644 --- a/Userland/Libraries/LibWeb/HTML/Plugin.h +++ b/Userland/Libraries/LibWeb/HTML/Plugin.h @@ -34,7 +34,7 @@ private: virtual void initialize(JS::Realm&) override; // ^Bindings::LegacyPlatformObject - virtual Vector supported_property_names() const override; + virtual Vector supported_property_names() const override; virtual WebIDL::ExceptionOr item_value(size_t index) const override; virtual WebIDL::ExceptionOr named_item_value(FlyString const& name) const override; virtual bool is_supported_property_index(u32) const override; diff --git a/Userland/Libraries/LibWeb/HTML/PluginArray.cpp b/Userland/Libraries/LibWeb/HTML/PluginArray.cpp index 7633ee3b3f..a28cd2c7cb 100644 --- a/Userland/Libraries/LibWeb/HTML/PluginArray.cpp +++ b/Userland/Libraries/LibWeb/HTML/PluginArray.cpp @@ -34,7 +34,7 @@ void PluginArray::refresh() const } // https://html.spec.whatwg.org/multipage/system-state.html#pdf-viewing-support:support-named-properties -Vector PluginArray::supported_property_names() const +Vector PluginArray::supported_property_names() const { // The PluginArray interface supports named properties. If the user agent's PDF viewer supported is true, then they are the PDF viewer plugin names. Otherwise, they are the empty list. auto const& window = verify_cast(HTML::relevant_global_object(*this)); @@ -43,12 +43,12 @@ Vector PluginArray::supported_property_names() const return {}; // https://html.spec.whatwg.org/multipage/system-state.html#pdf-viewer-plugin-names - static Vector plugin_names = { - "PDF Viewer"sv, - "Chrome PDF Viewer"sv, - "Chromium PDF Viewer"sv, - "Microsoft Edge PDF Viewer"sv, - "WebKit built-in PDF"sv, + static Vector const plugin_names = { + "PDF Viewer"_string, + "Chrome PDF Viewer"_string, + "Chromium PDF Viewer"_string, + "Microsoft Edge PDF Viewer"_string, + "WebKit built-in PDF"_string, }; return plugin_names; diff --git a/Userland/Libraries/LibWeb/HTML/PluginArray.h b/Userland/Libraries/LibWeb/HTML/PluginArray.h index 4ebeed1beb..ed26347011 100644 --- a/Userland/Libraries/LibWeb/HTML/PluginArray.h +++ b/Userland/Libraries/LibWeb/HTML/PluginArray.h @@ -29,7 +29,7 @@ private: virtual void initialize(JS::Realm&) override; // ^Bindings::LegacyPlatformObject - virtual Vector supported_property_names() const override; + virtual Vector supported_property_names() const override; virtual WebIDL::ExceptionOr item_value(size_t index) const override; virtual WebIDL::ExceptionOr named_item_value(FlyString const& name) const override; virtual bool is_supported_property_index(u32) const override; diff --git a/Userland/Libraries/LibWeb/HTML/Storage.cpp b/Userland/Libraries/LibWeb/HTML/Storage.cpp index fb37675c77..d428fdf7f8 100644 --- a/Userland/Libraries/LibWeb/HTML/Storage.cpp +++ b/Userland/Libraries/LibWeb/HTML/Storage.cpp @@ -149,13 +149,13 @@ void Storage::broadcast(StringView key, StringView old_value, StringView new_val // FIXME: Implement. } -Vector Storage::supported_property_names() const +Vector Storage::supported_property_names() const { // The supported property names on a Storage object storage are the result of running get the keys on storage's map. - Vector names; + Vector names; names.ensure_capacity(m_map.size()); for (auto const& key : m_map.keys()) - names.unchecked_append(key.to_deprecated_string()); + names.unchecked_append(key); return names; } diff --git a/Userland/Libraries/LibWeb/HTML/Storage.h b/Userland/Libraries/LibWeb/HTML/Storage.h index b9a961767b..d5096867df 100644 --- a/Userland/Libraries/LibWeb/HTML/Storage.h +++ b/Userland/Libraries/LibWeb/HTML/Storage.h @@ -40,7 +40,7 @@ private: // ^LegacyPlatformObject virtual WebIDL::ExceptionOr named_item_value(FlyString const&) const override; virtual WebIDL::ExceptionOr delete_value(DeprecatedString const&) override; - virtual Vector supported_property_names() const override; + virtual Vector supported_property_names() const override; virtual WebIDL::ExceptionOr set_value_of_named_property(DeprecatedString const& key, JS::Value value) override; virtual bool supports_indexed_properties() const override { return false; } diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index 0b368c0ea6..7b36a207b9 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -1563,7 +1563,7 @@ OrderedHashMap> Window::document_tree_child_ } // https://html.spec.whatwg.org/#named-access-on-the-window-object -Vector Window::supported_property_names() +Vector Window::supported_property_names() { // The Window object supports named properties. // The supported property names of a Window object window at any moment consist of the following, @@ -1590,12 +1590,12 @@ Vector Window::supported_property_names() return IterationDecision::Continue; }); - // FIXME: Many copies here. Would be nice to be able to return Vector - Vector names; + Vector names; names.ensure_capacity(property_names.size()); for (auto const& name : property_names) { - names.append(name.to_deprecated_string()); + names.append(name); } + return names; } diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h index ddf20b0c12..a8821032c6 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.h +++ b/Userland/Libraries/LibWeb/HTML/Window.h @@ -201,7 +201,7 @@ public: [[nodiscard]] OrderedHashMap> document_tree_child_navigable_target_name_property_set(); - [[nodiscard]] Vector supported_property_names(); + [[nodiscard]] Vector supported_property_names(); [[nodiscard]] WebIDL::ExceptionOr named_item_value(FlyString const&); private: diff --git a/Userland/Libraries/LibWeb/WebIDL/AbstractOperations.cpp b/Userland/Libraries/LibWeb/WebIDL/AbstractOperations.cpp index bdf8f9f729..22136f0e63 100644 --- a/Userland/Libraries/LibWeb/WebIDL/AbstractOperations.cpp +++ b/Userland/Libraries/LibWeb/WebIDL/AbstractOperations.cpp @@ -317,8 +317,8 @@ JS::ThrowCompletionOr is_named_property_exposed_on_object(Variant supported_property_names = variant.visit([](auto* o) { return o->supported_property_names(); }); - auto property_key_string = property_key.to_string(); + Vector supported_property_names = variant.visit([](auto* o) { return o->supported_property_names(); }); + auto property_key_string = MUST(String::from_deprecated_string(property_key.to_string())); if (!supported_property_names.contains_slow(property_key_string)) return false;