mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-27 04:37:22 +00:00
LibWeb/CSS: Implement CSSStyleRule.styleMap
StylePropertyMap is just a stub, so this doesn't yet accomplish much.
This commit is contained in:
parent
3bb54ffd59
commit
215d8b8076
Notes:
github-actions[bot]
2025-08-13 09:15:50 +00:00
Author: https://github.com/AtkinsSJ
Commit: 215d8b8076
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5823
Reviewed-by: https://github.com/trflynn89
12 changed files with 48 additions and 24 deletions
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
||||||
* Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org>
|
* Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
#include <LibWeb/CSS/CSSStyleSheet.h>
|
#include <LibWeb/CSS/CSSStyleSheet.h>
|
||||||
#include <LibWeb/CSS/Parser/Parser.h>
|
#include <LibWeb/CSS/Parser/Parser.h>
|
||||||
#include <LibWeb/CSS/StyleComputer.h>
|
#include <LibWeb/CSS/StyleComputer.h>
|
||||||
|
#include <LibWeb/CSS/StylePropertyMap.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
@ -40,6 +41,7 @@ void CSSStyleRule::visit_edges(Cell::Visitor& visitor)
|
||||||
{
|
{
|
||||||
Base::visit_edges(visitor);
|
Base::visit_edges(visitor);
|
||||||
visitor.visit(m_declaration);
|
visitor.visit(m_declaration);
|
||||||
|
visitor.visit(m_style_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-1/#dom-cssstylerule-style
|
// https://drafts.csswg.org/cssom-1/#dom-cssstylerule-style
|
||||||
|
@ -48,6 +50,14 @@ GC::Ref<CSSStyleProperties> CSSStyleRule::style()
|
||||||
return m_declaration;
|
return m_declaration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://drafts.css-houdini.org/css-typed-om-1/#dom-cssstylerule-stylemap
|
||||||
|
GC::Ref<StylePropertyMap> CSSStyleRule::style_map()
|
||||||
|
{
|
||||||
|
if (!m_style_map)
|
||||||
|
m_style_map = StylePropertyMap::create(realm(), m_declaration);
|
||||||
|
return *m_style_map;
|
||||||
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-1/#serialize-a-css-rule
|
// https://drafts.csswg.org/cssom-1/#serialize-a-css-rule
|
||||||
String CSSStyleRule::serialized() const
|
String CSSStyleRule::serialized() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,6 +31,7 @@ public:
|
||||||
void set_selector_text(StringView);
|
void set_selector_text(StringView);
|
||||||
|
|
||||||
GC::Ref<CSSStyleProperties> style();
|
GC::Ref<CSSStyleProperties> style();
|
||||||
|
GC::Ref<StylePropertyMap> style_map();
|
||||||
|
|
||||||
[[nodiscard]] FlyString const& qualified_layer_name() const { return parent_layer_internal_qualified_name(); }
|
[[nodiscard]] FlyString const& qualified_layer_name() const { return parent_layer_internal_qualified_name(); }
|
||||||
|
|
||||||
|
@ -49,6 +50,7 @@ private:
|
||||||
SelectorList m_selectors;
|
SelectorList m_selectors;
|
||||||
mutable Optional<SelectorList> m_cached_absolutized_selectors;
|
mutable Optional<SelectorList> m_cached_absolutized_selectors;
|
||||||
GC::Ref<CSSStyleProperties> m_declaration;
|
GC::Ref<CSSStyleProperties> m_declaration;
|
||||||
|
GC::Ptr<StylePropertyMap> m_style_map;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#import <CSS/CSSGroupingRule.idl>
|
#import <CSS/CSSGroupingRule.idl>
|
||||||
#import <CSS/CSSStyleProperties.idl>
|
#import <CSS/CSSStyleProperties.idl>
|
||||||
|
#import <CSS/StylePropertyMap.idl>
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom/#the-cssstylerule-interface
|
// https://drafts.csswg.org/cssom/#the-cssstylerule-interface
|
||||||
[Exposed=Window]
|
[Exposed=Window]
|
||||||
|
|
|
@ -8,3 +8,8 @@ interface StylePropertyMap : StylePropertyMapReadOnly {
|
||||||
undefined delete(USVString property);
|
undefined delete(USVString property);
|
||||||
undefined clear();
|
undefined clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// https://drafts.css-houdini.org/css-typed-om-1/#declared-stylepropertymap-objects
|
||||||
|
partial interface CSSStyleRule {
|
||||||
|
[SameObject] readonly attribute StylePropertyMap styleMap;
|
||||||
|
};
|
||||||
|
|
|
@ -2,11 +2,12 @@ Harness status: OK
|
||||||
|
|
||||||
Found 7 tests
|
Found 7 tests
|
||||||
|
|
||||||
7 Fail
|
2 Pass
|
||||||
|
5 Fail
|
||||||
Fail Declared StylePropertyMap only contains properties in the style rule
|
Fail Declared StylePropertyMap only contains properties in the style rule
|
||||||
Fail Declared StylePropertyMap contains CSS property declarations in style rules
|
Fail Declared StylePropertyMap contains CSS property declarations in style rules
|
||||||
Fail Declared StylePropertyMap does not contain inline styles
|
Pass Declared StylePropertyMap does not contain inline styles
|
||||||
Fail Declared StylePropertyMap contains custom property declarations
|
Fail Declared StylePropertyMap contains custom property declarations
|
||||||
Fail Declared StylePropertyMap does not contain properties with invalid values
|
Pass Declared StylePropertyMap does not contain properties with invalid values
|
||||||
Fail Declared StylePropertyMap contains properties with their last valid value
|
Fail Declared StylePropertyMap contains properties with their last valid value
|
||||||
Fail Declared StylePropertyMap is live
|
Fail Declared StylePropertyMap is live
|
|
@ -2,7 +2,8 @@ Harness status: OK
|
||||||
|
|
||||||
Found 3 tests
|
Found 3 tests
|
||||||
|
|
||||||
3 Fail
|
1 Pass
|
||||||
Fail Deleting a shorthand property not in the css rule is a no-op
|
2 Fail
|
||||||
|
Pass Deleting a shorthand property not in the css rule is a no-op
|
||||||
Fail Deleting a shorthand property in the css rule removes both it and its longhands
|
Fail Deleting a shorthand property in the css rule removes both it and its longhands
|
||||||
Fail Deleting a longhand property in the css rule removes both it and its shorthand
|
Fail Deleting a longhand property in the css rule removes both it and its shorthand
|
|
@ -2,8 +2,9 @@ Harness status: OK
|
||||||
|
|
||||||
Found 5 tests
|
Found 5 tests
|
||||||
|
|
||||||
5 Fail
|
1 Pass
|
||||||
Fail Deleting a property not in the css rule is a no-op
|
4 Fail
|
||||||
|
Pass Deleting a property not in the css rule is a no-op
|
||||||
Fail Deleting a property in the css rule removes it from the css rule
|
Fail Deleting a property in the css rule removes it from the css rule
|
||||||
Fail Deleting a custom property in the css rule removes it from the css rule
|
Fail Deleting a custom property in the css rule removes it from the css rule
|
||||||
Fail Deleting a list-valued property in the css rule removes it from the css rule
|
Fail Deleting a list-valued property in the css rule removes it from the css rule
|
||||||
|
|
|
@ -2,6 +2,7 @@ Harness status: OK
|
||||||
|
|
||||||
Found 2 tests
|
Found 2 tests
|
||||||
|
|
||||||
2 Fail
|
1 Pass
|
||||||
|
1 Fail
|
||||||
Fail Getting a shorthand property set explicitly in css rule returns a base CSSStyleValue
|
Fail Getting a shorthand property set explicitly in css rule returns a base CSSStyleValue
|
||||||
Fail Getting a shorthand property that is partially set in css rule returns undefined
|
Pass Getting a shorthand property that is partially set in css rule returns undefined
|
|
@ -2,9 +2,10 @@ Harness status: OK
|
||||||
|
|
||||||
Found 7 tests
|
Found 7 tests
|
||||||
|
|
||||||
7 Fail
|
2 Pass
|
||||||
Fail Getting a custom property not in the CSS rule returns undefined
|
5 Fail
|
||||||
Fail Getting a valid property not in the CSS rule returns undefined
|
Pass Getting a custom property not in the CSS rule returns undefined
|
||||||
|
Pass Getting a valid property not in the CSS rule returns undefined
|
||||||
Fail Getting a valid property from CSS rule returns the correct entry
|
Fail Getting a valid property from CSS rule returns the correct entry
|
||||||
Fail Getting a valid custom property from CSS rule returns the correct entry
|
Fail Getting a valid custom property from CSS rule returns the correct entry
|
||||||
Fail Getting a list-valued property from CSS rule returns only the first value
|
Fail Getting a list-valued property from CSS rule returns only the first value
|
||||||
|
|
|
@ -2,6 +2,7 @@ Harness status: OK
|
||||||
|
|
||||||
Found 2 tests
|
Found 2 tests
|
||||||
|
|
||||||
2 Fail
|
1 Pass
|
||||||
|
1 Fail
|
||||||
Fail StylePropertyMap.getAll() with a shorthand property set explicitly in css rule returns a base CSSStyleValue
|
Fail StylePropertyMap.getAll() with a shorthand property set explicitly in css rule returns a base CSSStyleValue
|
||||||
Fail StylePropertyMap.getAll() with a shorthand property that is partially in css rule returns empty list
|
Pass StylePropertyMap.getAll() with a shorthand property that is partially in css rule returns empty list
|
|
@ -2,11 +2,11 @@ Harness status: OK
|
||||||
|
|
||||||
Found 7 tests
|
Found 7 tests
|
||||||
|
|
||||||
1 Pass
|
3 Pass
|
||||||
6 Fail
|
4 Fail
|
||||||
Pass Calling StylePropertyMap.getAll with an unsupported property throws a TypeError
|
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
|
Pass 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 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 Calling StylePropertyMap.getAll with a valid property returns a single element list with the correct entry
|
||||||
Fail StylePropertyMap.getAll is case-insensitive
|
Fail StylePropertyMap.getAll is case-insensitive
|
||||||
Fail Calling StylePropertyMap.getAll with a valid custom property returns a single element list with the correct entry
|
Fail Calling StylePropertyMap.getAll with a valid custom property returns a single element list with the correct entry
|
||||||
|
|
|
@ -2,14 +2,14 @@ Harness status: OK
|
||||||
|
|
||||||
Found 9 tests
|
Found 9 tests
|
||||||
|
|
||||||
1 Pass
|
4 Pass
|
||||||
8 Fail
|
5 Fail
|
||||||
Pass Calling StylePropertyMap.has with an unsupported property throws a TypeError
|
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
|
Pass 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
|
Pass Calling StylePropertyMap.has with a custom property not in the property model returns false
|
||||||
Fail Calling StylePropertyMap.has with a valid property returns true
|
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 property in mixed case returns true
|
||||||
Fail Calling StylePropertyMap.has with a valid shorthand specified explicitly returns true
|
Fail Calling StylePropertyMap.has with a valid shorthand specified explicitly returns true
|
||||||
Fail Calling StylePropertyMap.has with a valid shorthand only partially specified returns false
|
Pass Calling StylePropertyMap.has with a valid shorthand only partially specified returns false
|
||||||
Fail Calling StylePropertyMap.has with a valid custom property returns true
|
Fail Calling StylePropertyMap.has with a valid custom property returns true
|
||||||
Fail Calling StylePropertyMap.has with a valid list-valued property returns true
|
Fail Calling StylePropertyMap.has with a valid list-valued property returns true
|
Loading…
Add table
Add a link
Reference in a new issue