Skip to content
Permalink
Browse files
[@Property] Add @Property rule parsing and CSSOM
https://bugs.webkit.org/show_bug.cgi?id=249554
rdar://103493363

Reviewed by Cameron McCormack.

https://drafts.css-houdini.org/css-properties-values-api/#at-property-rule

The properties defined by @Property rules are not yet registered with this patch.

* LayoutTests/imported/w3c/web-platform-tests/css/css-conditional/js/CSS-supports-CSSStyleDeclaration-expected.txt:

The CSS property code generator adds all properties unconditionally to CSSStyleDeclaration interface.
However descriptors should in most cases be omitted. That's why these newly added descriptors turn into fails in this test.

* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/at-property-cssom-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/at-property-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/idlharness-expected.txt:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/animation/CSSPropertyAnimation.cpp:
(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):

Use isDescriptorOnly to reduce need for special casing. Descriptors are never animatable.

* Source/WebCore/bindings/js/JSCSSRuleCustom.cpp:
(WebCore::toJSNewlyCreated):
* Source/WebCore/css/CSSProperties.json:

Add 'syntax', 'inherits' and 'initial-value' descriptors

* Source/WebCore/css/CSSPropertyRule.cpp: Added.
(WebCore::CSSPropertyRule::CSSPropertyRule):
(WebCore::CSSPropertyRule::create):
(WebCore::CSSPropertyRule::name const):
(WebCore::CSSPropertyRule::syntax const):
(WebCore::CSSPropertyRule::inherits const):
(WebCore::CSSPropertyRule::initialValue const):
(WebCore::CSSPropertyRule::cssText const):
(WebCore::CSSPropertyRule::reattach):
* Source/WebCore/css/CSSPropertyRule.h: Added.
* Source/WebCore/css/CSSPropertyRule.idl: Added.

Add a CSSOM wrapper.

* Source/WebCore/css/CSSValueKeywords.in:

Add 'true' and 'false'.

* Source/WebCore/css/ComputedStyleExtractor.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* Source/WebCore/css/DOMCSSCustomPropertyDescriptor.h:
* Source/WebCore/css/StyleRule.cpp:
(WebCore::StyleRuleBase::visitDerived):
(WebCore::StyleRuleBase::createCSSOMWrapper const):
(WebCore::StyleRuleProperty::StyleRuleProperty):
(WebCore::StyleRuleProperty::create):

Add StyleRuleProperty type for representing @Property in stylesheets.

* Source/WebCore/css/StyleRule.h:
(WebCore::StyleRuleBase::isPropertyRule const):
(isType):
* Source/WebCore/css/StyleRuleType.h:
* Source/WebCore/css/StyleSheetContents.cpp:
(WebCore::StyleSheetContents::traverseSubresources const):
* Source/WebCore/css/parser/CSSAtRuleID.cpp:
(WebCore::cssAtRuleID):
* Source/WebCore/css/parser/CSSAtRuleID.h:
* Source/WebCore/css/parser/CSSParserContext.cpp:
(WebCore::add):
* Source/WebCore/css/parser/CSSParserImpl.cpp:
(WebCore::CSSParserImpl::consumeAtRule):
(WebCore::CSSParserImpl::consumePropertyRule):
* Source/WebCore/css/parser/CSSParserImpl.h:
* Source/WebCore/css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::parseValue):
(WebCore::CSSPropertyParser::parsePropertyDescriptor):
* Source/WebCore/css/parser/CSSPropertyParser.h:
* Source/WebCore/inspector/InspectorStyleSheet.cpp:
(WebCore::flatteningStrategyForStyleRuleType):

Canonical link: https://commits.webkit.org/258067@main
  • Loading branch information
anttijk committed Dec 19, 2022
1 parent e6ff73f commit 8c6f3e96197beab5fd3a56bbf50678b20becb0c1
Show file tree
Hide file tree
Showing 31 changed files with 492 additions and 120 deletions.
@@ -981,9 +981,9 @@ PASS image-rendering: _camel_cased_attribute v. CSS.supports
PASS image-rendering: _dashed_attribute v. CSS.supports
PASS ime-mode: _camel_cased_attribute v. CSS.supports
PASS ime-mode: _dashed_attribute v. CSS.supports
PASS inherits: _camel_cased_attribute v. CSS.supports
PASS initial-value: _camel_cased_attribute v. CSS.supports
PASS initial-value: _dashed_attribute v. CSS.supports
FAIL inherits: _camel_cased_attribute v. CSS.supports assert_equals: expected true but got false
FAIL initial-value: _camel_cased_attribute v. CSS.supports assert_equals: expected true but got false
FAIL initial-value: _dashed_attribute v. CSS.supports assert_equals: expected true but got false
PASS inline-size: _camel_cased_attribute v. CSS.supports
PASS inline-size: _dashed_attribute v. CSS.supports
PASS inset: _camel_cased_attribute v. CSS.supports
@@ -1357,7 +1357,7 @@ PASS stroke-width: _camel_cased_attribute v. CSS.supports
PASS stroke-width: _dashed_attribute v. CSS.supports
PASS supported-color-schemes: _camel_cased_attribute v. CSS.supports
PASS supported-color-schemes: _dashed_attribute v. CSS.supports
PASS syntax: _camel_cased_attribute v. CSS.supports
FAIL syntax: _camel_cased_attribute v. CSS.supports assert_equals: expected true but got false
PASS tab-size: _camel_cased_attribute v. CSS.supports
PASS tab-size: _dashed_attribute v. CSS.supports
PASS table-layout: _camel_cased_attribute v. CSS.supports
@@ -1,64 +1,64 @@

FAIL Rule for --valid has expected cssText assert_true: expected true got false
FAIL Rule for --valid-reverse has expected cssText assert_true: expected true got false
FAIL Rule for --valid-universal has expected cssText assert_true: expected true got false
FAIL Rule for --valid-whitespace has expected cssText assert_true: expected true got false
FAIL Rule for --vALId has expected cssText assert_true: expected true got false
FAIL Rule for --no-descriptors has expected cssText assert_true: expected true got false
FAIL Rule for --no-syntax has expected cssText assert_true: expected true got false
FAIL Rule for --no-inherits has expected cssText assert_true: expected true got false
FAIL Rule for --no-initial-value has expected cssText assert_true: expected true got false
FAIL Rule for --syntax-only has expected cssText assert_true: expected true got false
FAIL Rule for --inherits-only has expected cssText assert_true: expected true got false
FAIL Rule for --initial-value-only has expected cssText assert_true: expected true got false
FAIL Rule for --tab tab has expected cssText assert_true: expected true got false
FAIL CSSRule.type returns 0 null is not an object (evaluating 'rule.type')
FAIL Rule for --valid returns expected value for CSSPropertyRule.name assert_true: expected true got false
FAIL Rule for --valid-reverse returns expected value for CSSPropertyRule.name assert_true: expected true got false
FAIL Rule for --valid-universal returns expected value for CSSPropertyRule.name assert_true: expected true got false
FAIL Rule for --valid-whitespace returns expected value for CSSPropertyRule.name assert_true: expected true got false
FAIL Rule for --vALId returns expected value for CSSPropertyRule.name assert_true: expected true got false
FAIL Rule for --no-descriptors returns expected value for CSSPropertyRule.name assert_true: expected true got false
FAIL Rule for --no-syntax returns expected value for CSSPropertyRule.name assert_true: expected true got false
FAIL Rule for --no-inherits returns expected value for CSSPropertyRule.name assert_true: expected true got false
FAIL Rule for --no-initial-value returns expected value for CSSPropertyRule.name assert_true: expected true got false
FAIL Rule for --syntax-only returns expected value for CSSPropertyRule.name assert_true: expected true got false
FAIL Rule for --inherits-only returns expected value for CSSPropertyRule.name assert_true: expected true got false
FAIL Rule for --initial-value-only returns expected value for CSSPropertyRule.name assert_true: expected true got false
FAIL Rule for --valid returns expected value for CSSPropertyRule.syntax assert_true: expected true got false
FAIL Rule for --valid-reverse returns expected value for CSSPropertyRule.syntax assert_true: expected true got false
FAIL Rule for --valid-universal returns expected value for CSSPropertyRule.syntax assert_true: expected true got false
FAIL Rule for --valid-whitespace returns expected value for CSSPropertyRule.syntax assert_true: expected true got false
FAIL Rule for --vALId returns expected value for CSSPropertyRule.syntax assert_true: expected true got false
FAIL Rule for --no-descriptors returns expected value for CSSPropertyRule.syntax assert_true: expected true got false
FAIL Rule for --no-syntax returns expected value for CSSPropertyRule.syntax assert_true: expected true got false
FAIL Rule for --no-inherits returns expected value for CSSPropertyRule.syntax assert_true: expected true got false
FAIL Rule for --no-initial-value returns expected value for CSSPropertyRule.syntax assert_true: expected true got false
FAIL Rule for --syntax-only returns expected value for CSSPropertyRule.syntax assert_true: expected true got false
FAIL Rule for --inherits-only returns expected value for CSSPropertyRule.syntax assert_true: expected true got false
FAIL Rule for --initial-value-only returns expected value for CSSPropertyRule.syntax assert_true: expected true got false
FAIL Rule for --valid returns expected value for CSSPropertyRule.inherits assert_true: expected true got false
FAIL Rule for --valid-reverse returns expected value for CSSPropertyRule.inherits assert_true: expected true got false
FAIL Rule for --valid-universal returns expected value for CSSPropertyRule.inherits assert_true: expected true got false
FAIL Rule for --valid-whitespace returns expected value for CSSPropertyRule.inherits assert_true: expected true got false
FAIL Rule for --vALId returns expected value for CSSPropertyRule.inherits assert_true: expected true got false
FAIL Rule for --no-descriptors returns expected value for CSSPropertyRule.inherits assert_true: expected true got false
FAIL Rule for --no-syntax returns expected value for CSSPropertyRule.inherits assert_true: expected true got false
FAIL Rule for --no-inherits returns expected value for CSSPropertyRule.inherits assert_true: expected true got false
FAIL Rule for --no-initial-value returns expected value for CSSPropertyRule.inherits assert_true: expected true got false
FAIL Rule for --syntax-only returns expected value for CSSPropertyRule.inherits assert_true: expected true got false
FAIL Rule for --inherits-only returns expected value for CSSPropertyRule.inherits assert_true: expected true got false
FAIL Rule for --initial-value-only returns expected value for CSSPropertyRule.inherits assert_true: expected true got false
FAIL Rule for --valid returns expected value for CSSPropertyRule.initialValue assert_true: expected true got false
FAIL Rule for --valid-reverse returns expected value for CSSPropertyRule.initialValue assert_true: expected true got false
FAIL Rule for --valid-universal returns expected value for CSSPropertyRule.initialValue assert_true: expected true got false
FAIL Rule for --valid-whitespace returns expected value for CSSPropertyRule.initialValue assert_true: expected true got false
FAIL Rule for --vALId returns expected value for CSSPropertyRule.initialValue assert_true: expected true got false
FAIL Rule for --no-descriptors returns expected value for CSSPropertyRule.initialValue assert_true: expected true got false
FAIL Rule for --no-syntax returns expected value for CSSPropertyRule.initialValue assert_true: expected true got false
FAIL Rule for --no-inherits returns expected value for CSSPropertyRule.initialValue assert_true: expected true got false
FAIL Rule for --no-initial-value returns expected value for CSSPropertyRule.initialValue assert_true: expected true got false
FAIL Rule for --syntax-only returns expected value for CSSPropertyRule.initialValue assert_true: expected true got false
FAIL Rule for --inherits-only returns expected value for CSSPropertyRule.initialValue assert_true: expected true got false
FAIL Rule for --initial-value-only returns expected value for CSSPropertyRule.initialValue assert_true: expected true got false
PASS Rule for --valid has expected cssText
PASS Rule for --valid-reverse has expected cssText
PASS Rule for --valid-universal has expected cssText
PASS Rule for --valid-whitespace has expected cssText
PASS Rule for --vALId has expected cssText
PASS Rule for --no-descriptors has expected cssText
PASS Rule for --no-syntax has expected cssText
PASS Rule for --no-inherits has expected cssText
PASS Rule for --no-initial-value has expected cssText
PASS Rule for --syntax-only has expected cssText
PASS Rule for --inherits-only has expected cssText
PASS Rule for --initial-value-only has expected cssText
PASS Rule for --tab tab has expected cssText
FAIL CSSRule.type returns 0 assert_equals: expected 0 but got 21
PASS Rule for --valid returns expected value for CSSPropertyRule.name
PASS Rule for --valid-reverse returns expected value for CSSPropertyRule.name
PASS Rule for --valid-universal returns expected value for CSSPropertyRule.name
PASS Rule for --valid-whitespace returns expected value for CSSPropertyRule.name
PASS Rule for --vALId returns expected value for CSSPropertyRule.name
PASS Rule for --no-descriptors returns expected value for CSSPropertyRule.name
PASS Rule for --no-syntax returns expected value for CSSPropertyRule.name
PASS Rule for --no-inherits returns expected value for CSSPropertyRule.name
PASS Rule for --no-initial-value returns expected value for CSSPropertyRule.name
PASS Rule for --syntax-only returns expected value for CSSPropertyRule.name
PASS Rule for --inherits-only returns expected value for CSSPropertyRule.name
PASS Rule for --initial-value-only returns expected value for CSSPropertyRule.name
PASS Rule for --valid returns expected value for CSSPropertyRule.syntax
PASS Rule for --valid-reverse returns expected value for CSSPropertyRule.syntax
PASS Rule for --valid-universal returns expected value for CSSPropertyRule.syntax
PASS Rule for --valid-whitespace returns expected value for CSSPropertyRule.syntax
PASS Rule for --vALId returns expected value for CSSPropertyRule.syntax
PASS Rule for --no-descriptors returns expected value for CSSPropertyRule.syntax
PASS Rule for --no-syntax returns expected value for CSSPropertyRule.syntax
PASS Rule for --no-inherits returns expected value for CSSPropertyRule.syntax
PASS Rule for --no-initial-value returns expected value for CSSPropertyRule.syntax
PASS Rule for --syntax-only returns expected value for CSSPropertyRule.syntax
PASS Rule for --inherits-only returns expected value for CSSPropertyRule.syntax
PASS Rule for --initial-value-only returns expected value for CSSPropertyRule.syntax
PASS Rule for --valid returns expected value for CSSPropertyRule.inherits
PASS Rule for --valid-reverse returns expected value for CSSPropertyRule.inherits
PASS Rule for --valid-universal returns expected value for CSSPropertyRule.inherits
PASS Rule for --valid-whitespace returns expected value for CSSPropertyRule.inherits
PASS Rule for --vALId returns expected value for CSSPropertyRule.inherits
PASS Rule for --no-descriptors returns expected value for CSSPropertyRule.inherits
PASS Rule for --no-syntax returns expected value for CSSPropertyRule.inherits
PASS Rule for --no-inherits returns expected value for CSSPropertyRule.inherits
PASS Rule for --no-initial-value returns expected value for CSSPropertyRule.inherits
PASS Rule for --syntax-only returns expected value for CSSPropertyRule.inherits
PASS Rule for --inherits-only returns expected value for CSSPropertyRule.inherits
PASS Rule for --initial-value-only returns expected value for CSSPropertyRule.inherits
FAIL Rule for --valid returns expected value for CSSPropertyRule.initialValue assert_equals: expected " red" but got "red"
FAIL Rule for --valid-reverse returns expected value for CSSPropertyRule.initialValue assert_equals: expected " 0px" but got "0px"
PASS Rule for --valid-universal returns expected value for CSSPropertyRule.initialValue
FAIL Rule for --valid-whitespace returns expected value for CSSPropertyRule.initialValue assert_equals: expected " red, blue" but got "red, blue"
FAIL Rule for --vALId returns expected value for CSSPropertyRule.initialValue assert_equals: expected " red" but got "red"
PASS Rule for --no-descriptors returns expected value for CSSPropertyRule.initialValue
FAIL Rule for --no-syntax returns expected value for CSSPropertyRule.initialValue assert_equals: expected " red" but got "red"
FAIL Rule for --no-inherits returns expected value for CSSPropertyRule.initialValue assert_equals: expected " red" but got "red"
PASS Rule for --no-initial-value returns expected value for CSSPropertyRule.initialValue
PASS Rule for --syntax-only returns expected value for CSSPropertyRule.initialValue
PASS Rule for --inherits-only returns expected value for CSSPropertyRule.initialValue
FAIL Rule for --initial-value-only returns expected value for CSSPropertyRule.initialValue assert_equals: expected " red" but got "red"

@@ -1,28 +1,28 @@

FAIL Attribute 'syntax' returns expected value for ["<color>"] undefined is not an object (evaluating 'rule.syntax')
FAIL Attribute 'syntax' returns expected value for ["<color> | none"] undefined is not an object (evaluating 'rule.syntax')
FAIL Attribute 'syntax' returns expected value for ["<color># | <image> | none"] undefined is not an object (evaluating 'rule.syntax')
FAIL Attribute 'syntax' returns expected value for ["foo | bar | baz"] undefined is not an object (evaluating 'rule.syntax')
FAIL Attribute 'syntax' returns expected value for ["*"] undefined is not an object (evaluating 'rule.syntax')
FAIL Attribute 'syntax' returns expected value for ["notasyntax"] undefined is not an object (evaluating 'rule.syntax')
FAIL Attribute 'syntax' returns expected value for [red] undefined is not an object (evaluating 'rule.syntax')
FAIL Attribute 'syntax' returns expected value for [rgb(255, 0, 0)] undefined is not an object (evaluating 'rule.syntax')
FAIL Attribute 'syntax' returns expected value for [<color>] undefined is not an object (evaluating 'rule.syntax')
FAIL Attribute 'syntax' returns expected value for [foo | bar] undefined is not an object (evaluating 'rule.syntax')
FAIL Attribute 'initial-value' returns expected value for [10px] undefined is not an object (evaluating 'rule.initialValue')
FAIL Attribute 'initial-value' returns expected value for [rgb(1, 2, 3)] undefined is not an object (evaluating 'rule.initialValue')
FAIL Attribute 'initial-value' returns expected value for [red] undefined is not an object (evaluating 'rule.initialValue')
FAIL Attribute 'initial-value' returns expected value for [foo] undefined is not an object (evaluating 'rule.initialValue')
FAIL Attribute 'initial-value' returns expected value for [if(){}] undefined is not an object (evaluating 'rule.initialValue')
FAIL Attribute 'initial-value' returns expected value for [var(--x)] undefined is not an object (evaluating 'rule.initialValue')
FAIL Attribute 'inherits' returns expected value for [true] undefined is not an object (evaluating 'rule.inherits')
FAIL Attribute 'inherits' returns expected value for [false] undefined is not an object (evaluating 'rule.inherits')
FAIL Attribute 'inherits' returns expected value for [none] undefined is not an object (evaluating 'rule.inherits')
FAIL Attribute 'inherits' returns expected value for [0] undefined is not an object (evaluating 'rule.inherits')
FAIL Attribute 'inherits' returns expected value for [1] undefined is not an object (evaluating 'rule.inherits')
FAIL Attribute 'inherits' returns expected value for ["true"] undefined is not an object (evaluating 'rule.inherits')
FAIL Attribute 'inherits' returns expected value for ["false"] undefined is not an object (evaluating 'rule.inherits')
FAIL Attribute 'inherits' returns expected value for [calc(0)] undefined is not an object (evaluating 'rule.inherits')
PASS Attribute 'syntax' returns expected value for ["<color>"]
PASS Attribute 'syntax' returns expected value for ["<color> | none"]
PASS Attribute 'syntax' returns expected value for ["<color># | <image> | none"]
PASS Attribute 'syntax' returns expected value for ["foo | bar | baz"]
PASS Attribute 'syntax' returns expected value for ["*"]
PASS Attribute 'syntax' returns expected value for ["notasyntax"]
PASS Attribute 'syntax' returns expected value for [red]
PASS Attribute 'syntax' returns expected value for [rgb(255, 0, 0)]
PASS Attribute 'syntax' returns expected value for [<color>]
PASS Attribute 'syntax' returns expected value for [foo | bar]
PASS Attribute 'initial-value' returns expected value for [10px]
PASS Attribute 'initial-value' returns expected value for [rgb(1, 2, 3)]
PASS Attribute 'initial-value' returns expected value for [red]
PASS Attribute 'initial-value' returns expected value for [foo]
PASS Attribute 'initial-value' returns expected value for [if(){}]
PASS Attribute 'initial-value' returns expected value for [var(--x)]
PASS Attribute 'inherits' returns expected value for [true]
PASS Attribute 'inherits' returns expected value for [false]
PASS Attribute 'inherits' returns expected value for [none]
PASS Attribute 'inherits' returns expected value for [0]
PASS Attribute 'inherits' returns expected value for [1]
PASS Attribute 'inherits' returns expected value for ["true"]
PASS Attribute 'inherits' returns expected value for ["false"]
PASS Attribute 'inherits' returns expected value for [calc(0)]
PASS Invalid property name does not parse [foo]
PASS Invalid property name does not parse [-foo]
FAIL Rule applied [*, if(){}, false] assert_equals: expected "if(){}" but got ""

0 comments on commit 8c6f3e9

Please sign in to comment.