mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:27:43 +00:00
LibWeb: Let supported_property_names() return Vector<FlyString>
Ultimately, this API should probably be replaced with something that updates a cache on relevant DOM mutations instead of regenerating the list of property names again and again.
This commit is contained in:
parent
0178929387
commit
41f56b0df9
19 changed files with 42 additions and 48 deletions
|
@ -91,13 +91,13 @@ Vector<DOMStringMap::NameValuePair> 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<String> DOMStringMap::supported_property_names() const
|
||||
Vector<FlyString> 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<String> names;
|
||||
Vector<FlyString> names;
|
||||
auto name_value_pairs = get_name_value_pairs();
|
||||
for (auto& name_value_pair : name_value_pairs) {
|
||||
names.append(name_value_pair.name.to_string());
|
||||
names.append(name_value_pair.name);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ private:
|
|||
|
||||
// ^LegacyPlatformObject
|
||||
virtual WebIDL::ExceptionOr<JS::Value> named_item_value(FlyString const&) const override;
|
||||
virtual Vector<String> supported_property_names() const override;
|
||||
virtual Vector<FlyString> supported_property_names() const override;
|
||||
|
||||
virtual bool supports_indexed_properties() const override { return false; }
|
||||
virtual bool supports_named_properties() const override { return true; }
|
||||
|
|
|
@ -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<String> MimeTypeArray::supported_property_names() const
|
||||
Vector<FlyString> 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::Window>(HTML::relevant_global_object(*this));
|
||||
|
@ -36,9 +36,9 @@ Vector<String> MimeTypeArray::supported_property_names() const
|
|||
return {};
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/system-state.html#pdf-viewer-mime-types
|
||||
static Vector<String> const mime_types = {
|
||||
"application/pdf"_string,
|
||||
"text/pdf"_string,
|
||||
static Vector<FlyString> const mime_types = {
|
||||
"application/pdf"_fly_string,
|
||||
"text/pdf"_fly_string,
|
||||
};
|
||||
|
||||
return mime_types;
|
||||
|
|
|
@ -28,7 +28,7 @@ private:
|
|||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
// ^Bindings::LegacyPlatformObject
|
||||
virtual Vector<String> supported_property_names() const override;
|
||||
virtual Vector<FlyString> supported_property_names() const override;
|
||||
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) const override;
|
||||
virtual WebIDL::ExceptionOr<JS::Value> named_item_value(FlyString const& name) const override;
|
||||
virtual bool is_supported_property_index(u32) const override;
|
||||
|
|
|
@ -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<String> Plugin::supported_property_names() const
|
||||
Vector<FlyString> 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::Window>(HTML::relevant_global_object(*this));
|
||||
|
@ -60,9 +60,9 @@ Vector<String> Plugin::supported_property_names() const
|
|||
return {};
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/system-state.html#pdf-viewer-mime-types
|
||||
static Vector<String> const mime_types = {
|
||||
"application/pdf"_string,
|
||||
"text/pdf"_string,
|
||||
static Vector<FlyString> const mime_types = {
|
||||
"application/pdf"_fly_string,
|
||||
"text/pdf"_fly_string,
|
||||
};
|
||||
|
||||
return mime_types;
|
||||
|
|
|
@ -34,7 +34,7 @@ private:
|
|||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
// ^Bindings::LegacyPlatformObject
|
||||
virtual Vector<String> supported_property_names() const override;
|
||||
virtual Vector<FlyString> supported_property_names() const override;
|
||||
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) const override;
|
||||
virtual WebIDL::ExceptionOr<JS::Value> named_item_value(FlyString const& name) const override;
|
||||
virtual bool is_supported_property_index(u32) const override;
|
||||
|
|
|
@ -34,7 +34,7 @@ void PluginArray::refresh() const
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/system-state.html#pdf-viewing-support:support-named-properties
|
||||
Vector<String> PluginArray::supported_property_names() const
|
||||
Vector<FlyString> 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::Window>(HTML::relevant_global_object(*this));
|
||||
|
@ -42,12 +42,12 @@ Vector<String> PluginArray::supported_property_names() const
|
|||
return {};
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/system-state.html#pdf-viewer-plugin-names
|
||||
static Vector<String> const plugin_names = {
|
||||
"PDF Viewer"_string,
|
||||
"Chrome PDF Viewer"_string,
|
||||
"Chromium PDF Viewer"_string,
|
||||
"Microsoft Edge PDF Viewer"_string,
|
||||
"WebKit built-in PDF"_string,
|
||||
static Vector<FlyString> const plugin_names = {
|
||||
"PDF Viewer"_fly_string,
|
||||
"Chrome PDF Viewer"_fly_string,
|
||||
"Chromium PDF Viewer"_fly_string,
|
||||
"Microsoft Edge PDF Viewer"_fly_string,
|
||||
"WebKit built-in PDF"_fly_string,
|
||||
};
|
||||
|
||||
return plugin_names;
|
||||
|
|
|
@ -29,7 +29,7 @@ private:
|
|||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
// ^Bindings::LegacyPlatformObject
|
||||
virtual Vector<String> supported_property_names() const override;
|
||||
virtual Vector<FlyString> supported_property_names() const override;
|
||||
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) const override;
|
||||
virtual WebIDL::ExceptionOr<JS::Value> named_item_value(FlyString const& name) const override;
|
||||
virtual bool is_supported_property_index(u32) const override;
|
||||
|
|
|
@ -149,10 +149,10 @@ void Storage::broadcast(StringView key, StringView old_value, StringView new_val
|
|||
// FIXME: Implement.
|
||||
}
|
||||
|
||||
Vector<String> Storage::supported_property_names() const
|
||||
Vector<FlyString> 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<String> names;
|
||||
Vector<FlyString> names;
|
||||
names.ensure_capacity(m_map.size());
|
||||
for (auto const& key : m_map.keys())
|
||||
names.unchecked_append(key);
|
||||
|
|
|
@ -40,7 +40,7 @@ private:
|
|||
// ^LegacyPlatformObject
|
||||
virtual WebIDL::ExceptionOr<JS::Value> named_item_value(FlyString const&) const override;
|
||||
virtual WebIDL::ExceptionOr<DidDeletionFail> delete_value(String const&) override;
|
||||
virtual Vector<String> supported_property_names() const override;
|
||||
virtual Vector<FlyString> supported_property_names() const override;
|
||||
virtual WebIDL::ExceptionOr<void> set_value_of_named_property(String const& key, JS::Value value) override;
|
||||
|
||||
virtual bool supports_indexed_properties() const override { return false; }
|
||||
|
|
|
@ -1548,7 +1548,7 @@ OrderedHashMap<String, JS::NonnullGCPtr<Navigable>> Window::document_tree_child_
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/#named-access-on-the-window-object
|
||||
Vector<String> Window::supported_property_names()
|
||||
Vector<FlyString> 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,
|
||||
|
@ -1575,13 +1575,7 @@ Vector<String> Window::supported_property_names()
|
|||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
Vector<String> names;
|
||||
names.ensure_capacity(property_names.size());
|
||||
for (auto const& name : property_names) {
|
||||
names.append(name.to_string());
|
||||
}
|
||||
|
||||
return names;
|
||||
return property_names.values();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/#named-access-on-the-window-object
|
||||
|
|
|
@ -203,7 +203,7 @@ public:
|
|||
|
||||
[[nodiscard]] OrderedHashMap<String, JS::NonnullGCPtr<Navigable>> document_tree_child_navigable_target_name_property_set();
|
||||
|
||||
[[nodiscard]] Vector<String> supported_property_names();
|
||||
[[nodiscard]] Vector<FlyString> supported_property_names();
|
||||
[[nodiscard]] WebIDL::ExceptionOr<JS::Value> named_item_value(FlyString const&);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue