mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Store custom properties in an OrderedHashMap
We are expected to preserve their order within a style declaration, so let's do that. Passes 1 tracked WPT subtest.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
2674bd428e
commit
95aceb6ec9
Notes:
github-actions[bot]
2025-09-18 13:00:16 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/95aceb6ec99 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6226 Reviewed-by: https://github.com/gmta ✅
@@ -32,7 +32,7 @@ namespace Web::CSS {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(CSSStyleProperties);
|
||||
|
||||
GC::Ref<CSSStyleProperties> CSSStyleProperties::create(JS::Realm& realm, Vector<StyleProperty> properties, HashMap<FlyString, StyleProperty> custom_properties)
|
||||
GC::Ref<CSSStyleProperties> CSSStyleProperties::create(JS::Realm& realm, Vector<StyleProperty> properties, OrderedHashMap<FlyString, StyleProperty> custom_properties)
|
||||
{
|
||||
// https://drafts.csswg.org/cssom/#dom-cssstylerule-style
|
||||
// The style attribute must return a CSSStyleProperties object for the style rule, with the following properties:
|
||||
@@ -54,10 +54,10 @@ GC::Ref<CSSStyleProperties> CSSStyleProperties::create_resolved_style(JS::Realm&
|
||||
// parent CSS rule: Null.
|
||||
// owner node: obj.
|
||||
// AD-HOC: Rather than instantiate with a list of decls, they're generated on demand.
|
||||
return realm.create<CSSStyleProperties>(realm, Computed::Yes, Readonly::Yes, Vector<StyleProperty> {}, HashMap<FlyString, StyleProperty> {}, move(element_reference));
|
||||
return realm.create<CSSStyleProperties>(realm, Computed::Yes, Readonly::Yes, Vector<StyleProperty> {}, OrderedHashMap<FlyString, StyleProperty> {}, move(element_reference));
|
||||
}
|
||||
|
||||
GC::Ref<CSSStyleProperties> CSSStyleProperties::create_element_inline_style(DOM::AbstractElement element_reference, Vector<StyleProperty> properties, HashMap<FlyString, StyleProperty> custom_properties)
|
||||
GC::Ref<CSSStyleProperties> CSSStyleProperties::create_element_inline_style(DOM::AbstractElement element_reference, Vector<StyleProperty> properties, OrderedHashMap<FlyString, StyleProperty> custom_properties)
|
||||
{
|
||||
// https://drafts.csswg.org/cssom/#dom-elementcssinlinestyle-style
|
||||
// The style attribute must return a CSS declaration block object whose readonly flag is unset, whose parent CSS
|
||||
@@ -66,7 +66,7 @@ GC::Ref<CSSStyleProperties> CSSStyleProperties::create_element_inline_style(DOM:
|
||||
return realm.create<CSSStyleProperties>(realm, Computed::No, Readonly::No, convert_declarations_to_specified_order(properties), move(custom_properties), move(element_reference));
|
||||
}
|
||||
|
||||
CSSStyleProperties::CSSStyleProperties(JS::Realm& realm, Computed computed, Readonly readonly, Vector<StyleProperty> properties, HashMap<FlyString, StyleProperty> custom_properties, Optional<DOM::AbstractElement> owner_node)
|
||||
CSSStyleProperties::CSSStyleProperties(JS::Realm& realm, Computed computed, Readonly readonly, Vector<StyleProperty> properties, OrderedHashMap<FlyString, StyleProperty> custom_properties, Optional<DOM::AbstractElement> owner_node)
|
||||
: CSSStyleDeclaration(realm, computed, readonly)
|
||||
, m_properties(move(properties))
|
||||
, m_custom_properties(move(custom_properties))
|
||||
@@ -1312,7 +1312,7 @@ void CSSStyleProperties::empty_the_declarations()
|
||||
m_custom_properties.clear();
|
||||
}
|
||||
|
||||
void CSSStyleProperties::set_the_declarations(Vector<StyleProperty> properties, HashMap<FlyString, StyleProperty> custom_properties)
|
||||
void CSSStyleProperties::set_the_declarations(Vector<StyleProperty> properties, OrderedHashMap<FlyString, StyleProperty> custom_properties)
|
||||
{
|
||||
m_properties = convert_declarations_to_specified_order(properties);
|
||||
m_custom_properties = move(custom_properties);
|
||||
|
||||
Reference in New Issue
Block a user