mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:47:47 +00:00
LibWeb: Port DOMStringMap from DeprecatedString to String
Porting name to FlyString as it is often compared in lookup, and in many cases, we already have a FlyString to supply anyway.
This commit is contained in:
parent
49a48fcfac
commit
9cd36839d2
2 changed files with 8 additions and 8 deletions
|
@ -82,7 +82,7 @@ Vector<DOMStringMap::NameValuePair> DOMStringMap::get_name_value_pairs() const
|
||||||
builder.append(current_character);
|
builder.append(current_character);
|
||||||
}
|
}
|
||||||
|
|
||||||
list.append({ builder.to_deprecated_string(), value });
|
list.append({ MUST(builder.to_string()), MUST(String::from_deprecated_string(value)) });
|
||||||
});
|
});
|
||||||
|
|
||||||
// 4. Return list.
|
// 4. Return list.
|
||||||
|
@ -97,18 +97,18 @@ Vector<String> DOMStringMap::supported_property_names() const
|
||||||
Vector<String> names;
|
Vector<String> names;
|
||||||
auto name_value_pairs = get_name_value_pairs();
|
auto name_value_pairs = get_name_value_pairs();
|
||||||
for (auto& name_value_pair : name_value_pairs) {
|
for (auto& name_value_pair : name_value_pairs) {
|
||||||
names.append(MUST(String::from_deprecated_string(name_value_pair.name)));
|
names.append(name_value_pair.name.to_string());
|
||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/dom.html#dom-domstringmap-nameditem
|
// https://html.spec.whatwg.org/multipage/dom.html#dom-domstringmap-nameditem
|
||||||
DeprecatedString DOMStringMap::determine_value_of_named_property(DeprecatedString const& name) const
|
String DOMStringMap::determine_value_of_named_property(FlyString const& name) const
|
||||||
{
|
{
|
||||||
// To determine the value of a named property name for a DOMStringMap, return the value component of the name-value pair whose name component is name in the list returned from getting the
|
// To determine the value of a named property name for a DOMStringMap, return the value component of the name-value pair whose name component is name in the list returned from getting the
|
||||||
// DOMStringMap's name-value pairs.
|
// DOMStringMap's name-value pairs.
|
||||||
auto name_value_pairs = get_name_value_pairs();
|
auto name_value_pairs = get_name_value_pairs();
|
||||||
auto optional_value = name_value_pairs.first_matching([&name](NameValuePair& name_value_pair) {
|
auto optional_value = name_value_pairs.first_matching([&name](NameValuePair const& name_value_pair) {
|
||||||
return name_value_pair.name == name;
|
return name_value_pair.name == name;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ WebIDL::ExceptionOr<Bindings::LegacyPlatformObject::DidDeletionFail> DOMStringMa
|
||||||
|
|
||||||
WebIDL::ExceptionOr<JS::Value> DOMStringMap::named_item_value(FlyString const& name) const
|
WebIDL::ExceptionOr<JS::Value> DOMStringMap::named_item_value(FlyString const& name) const
|
||||||
{
|
{
|
||||||
return JS::PrimitiveString::create(vm(), determine_value_of_named_property(name.to_deprecated_fly_string()));
|
return JS::PrimitiveString::create(vm(), determine_value_of_named_property(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ public:
|
||||||
|
|
||||||
virtual ~DOMStringMap() override;
|
virtual ~DOMStringMap() override;
|
||||||
|
|
||||||
DeprecatedString determine_value_of_named_property(DeprecatedString const&) const;
|
String determine_value_of_named_property(FlyString const&) const;
|
||||||
|
|
||||||
virtual WebIDL::ExceptionOr<void> set_value_of_new_named_property(String const&, JS::Value) override;
|
virtual WebIDL::ExceptionOr<void> set_value_of_new_named_property(String const&, JS::Value) override;
|
||||||
virtual WebIDL::ExceptionOr<void> set_value_of_existing_named_property(String const&, JS::Value) override;
|
virtual WebIDL::ExceptionOr<void> set_value_of_existing_named_property(String const&, JS::Value) override;
|
||||||
|
@ -52,8 +52,8 @@ private:
|
||||||
virtual bool named_property_deleter_has_identifier() const override { return false; }
|
virtual bool named_property_deleter_has_identifier() const override { return false; }
|
||||||
|
|
||||||
struct NameValuePair {
|
struct NameValuePair {
|
||||||
DeprecatedString name;
|
FlyString name;
|
||||||
DeprecatedString value;
|
String value;
|
||||||
};
|
};
|
||||||
|
|
||||||
Vector<NameValuePair> get_name_value_pairs() const;
|
Vector<NameValuePair> get_name_value_pairs() const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue