diff --git a/Libraries/LibWeb/CSS/ElementCSSInlineStyle.idl b/Libraries/LibWeb/CSS/ElementCSSInlineStyle.idl index 8a09f8f5e02..0cb33e50037 100644 --- a/Libraries/LibWeb/CSS/ElementCSSInlineStyle.idl +++ b/Libraries/LibWeb/CSS/ElementCSSInlineStyle.idl @@ -1,6 +1,10 @@ #import +#import // https://w3c.github.io/csswg-drafts/cssom/#elementcssinlinestyle interface mixin ElementCSSInlineStyle { [SameObject, PutForwards=cssText, ImplementedAs=style_for_bindings] readonly attribute CSSStyleProperties style; + + // https://drafts.css-houdini.org/css-typed-om-1/#declared-stylepropertymap-objects + [SameObject] readonly attribute StylePropertyMap attributeStyleMap; }; diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cpp index 5b4a0cfae5a..807972156aa 100644 --- a/Libraries/LibWeb/DOM/Element.cpp +++ b/Libraries/LibWeb/DOM/Element.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -123,6 +124,7 @@ void Element::visit_edges(Cell::Visitor& visitor) visitor.visit(m_cascaded_properties); visitor.visit(m_computed_properties); visitor.visit(m_computed_style_map_cache); + visitor.visit(m_attribute_style_map); if (m_pseudo_element_data) { for (auto& pseudo_element : *m_pseudo_element_data) { visitor.visit(pseudo_element.value); @@ -1109,9 +1111,18 @@ GC::Ref Element::style_for_bindings() return *m_inline_style; } +GC::Ref Element::attribute_style_map() +{ + if (!m_attribute_style_map) + m_attribute_style_map = CSS::StylePropertyMap::create(realm(), style_for_bindings()); + return *m_attribute_style_map; +} + void Element::set_inline_style(GC::Ptr style) { m_inline_style = style; + if (m_attribute_style_map) + m_attribute_style_map = nullptr; set_needs_style_update(true); } diff --git a/Libraries/LibWeb/DOM/Element.h b/Libraries/LibWeb/DOM/Element.h index 642d224ad47..548f1003a9c 100644 --- a/Libraries/LibWeb/DOM/Element.h +++ b/Libraries/LibWeb/DOM/Element.h @@ -226,6 +226,7 @@ public: void set_inline_style(GC::Ptr); GC::Ref style_for_bindings(); + GC::Ref attribute_style_map(); CSS::StyleSheetList& document_or_shadow_root_style_sheets(); ElementByIdMap& document_or_shadow_root_element_by_id_map(); @@ -566,6 +567,7 @@ private: GC::Ptr m_attributes; GC::Ptr m_inline_style; + GC::Ptr m_attribute_style_map; GC::Ptr m_class_list; GC::Ptr m_shadow_root; diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/delete-shorthand.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/delete-shorthand.txt index be104e8fd59..9dc110007cd 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/delete-shorthand.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/delete-shorthand.txt @@ -2,7 +2,8 @@ Harness status: OK Found 3 tests -3 Fail -Fail Deleting a shorthand property not in the inline style is a no-op +1 Pass +2 Fail +Pass Deleting a shorthand property not in the inline style is a no-op Fail Deleting a shorthand property in the inline style removes both it and its longhands Fail Deleting a longhand property in the inline style removes both it and its shorthand \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/delete.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/delete.txt index e48066113ae..90f2b5d5ced 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/delete.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/delete.txt @@ -2,8 +2,9 @@ Harness status: OK Found 5 tests -5 Fail -Fail Deleting a property not in the inline style is a no-op +1 Pass +4 Fail +Pass Deleting a property not in the inline style is a no-op Fail Deleting a property in the inline style removes it from the inline style Fail Deleting a custom property in the inline style removes it from the inline style Fail Deleting a list-valued property in the inline style removes it from the inline style diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/get-shorthand.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/get-shorthand.txt index e4c0ed456d9..dfd9eab4c0e 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/get-shorthand.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/get-shorthand.txt @@ -2,7 +2,8 @@ Harness status: OK Found 3 tests -3 Fail +2 Pass +1 Fail Fail Getting an shorthand property set explicitly in inline style returns a base CSSStyleValue -Fail Getting a shorthand property that is partially set in inline style returns null -Fail Getting an attributeStyleMap shorthand property from an element without a style attribute \ No newline at end of file +Pass Getting a shorthand property that is partially set in inline style returns null +Pass Getting an attributeStyleMap shorthand property from an element without a style attribute \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/get.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/get.txt index dea2ab8459d..d7e7211a0a3 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/get.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/get.txt @@ -2,9 +2,10 @@ Harness status: OK Found 7 tests -7 Fail -Fail Getting a custom property not in the inline style returns undefined -Fail Getting a valid property not in the inline style returns undefined +2 Pass +5 Fail +Pass Getting a custom property not in the inline style returns undefined +Pass Getting a valid property not in the inline style returns undefined Fail Getting a valid property from inline style returns the correct entry Fail Getting a valid custom property from inline style returns the correct entry Fail Getting a list-valued property from inline style returns only the first value diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/getAll-shorthand.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/getAll-shorthand.txt index cd09be7e6f5..9b7a6b55937 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/getAll-shorthand.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/getAll-shorthand.txt @@ -2,6 +2,7 @@ Harness status: OK Found 2 tests -2 Fail +1 Pass +1 Fail Fail StylePropertyMap.getAll() with a shorthand property set explicitly in inline style returns a base CSSStyleValue -Fail StylePropertyMap.getAll() with a shorthand property that is partially in inline style returns empty list \ No newline at end of file +Pass StylePropertyMap.getAll() with a shorthand property that is partially in inline style returns empty list \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/getAll.tentative.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/getAll.tentative.txt index d50ed00e172..3cd6f1618dc 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/getAll.tentative.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/getAll.tentative.txt @@ -2,11 +2,11 @@ Harness status: OK Found 7 tests -1 Pass -6 Fail +3 Pass +4 Fail Pass Calling StylePropertyMap.getAll with an unsupported property throws a TypeError -Fail Calling StylePropertyMap.getAll with a property not in the property model returns an empty list -Fail Calling StylePropertyMap.getAll with a custom property not in the property model returns an empty list +Pass Calling StylePropertyMap.getAll with a property not in the property model returns an empty list +Pass Calling StylePropertyMap.getAll with a custom property not in the property model returns an empty list Fail Calling StylePropertyMap.getAll with a valid property returns a single element list with the correct entry Fail StylePropertyMap.getAll is case-insensitive Fail Calling StylePropertyMap.getAll with a valid custom property returns a single element list with the correct entry diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/has.tentative.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/has.tentative.txt index cabd386f393..968fa33ebf4 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/has.tentative.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/has.tentative.txt @@ -2,12 +2,12 @@ Harness status: OK Found 8 tests -1 Pass -7 Fail +4 Pass +4 Fail Pass Calling StylePropertyMap.has with an unsupported property throws a TypeError -Fail Calling StylePropertyMap.has with a property not in the property model returns false -Fail Calling StylePropertyMap.has with a custom property not in the property model returns false -Fail Calling StylePropertyMap.has with a valid property in mixed case returns false +Pass Calling StylePropertyMap.has with a property not in the property model returns false +Pass Calling StylePropertyMap.has with a custom property not in the property model returns false +Pass Calling StylePropertyMap.has with a valid property in mixed case returns false Fail Calling StylePropertyMap.has with a valid property returns true Fail Calling StylePropertyMap.has with a valid property in mixed case returns true Fail Calling StylePropertyMap.has with a valid custom property returns true