Skip to content
Permalink
Browse files
[@Property] Register custom properties from @Property rules
https://bugs.webkit.org/show_bug.cgi?id=249579
<rdar://problem/103516443>

Reviewed by Sam Weinig.

Make @Property registrations from stylesheets work.

* LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/layer-cssom-order-reverse-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/layer-property-override-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-inner-at-rules-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/at-property-animation-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/at-property-shadow-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/at-property-stylesheets-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/at-property-viewport-units-dynamic-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/at-property-viewport-units-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/determine-registration-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-crosstalk-expected.txt:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/animation/CSSPropertyAnimation.cpp:
* Source/WebCore/css/CSSPropertyRule.cpp:
(WebCore::CSSPropertyRule::initialValue const):
(WebCore::CSSPropertyRule::cssText const):
* Source/WebCore/css/CSSVariableReferenceValue.cpp:
(WebCore::resolveVariableReference):
* Source/WebCore/css/ComputedStyleExtractor.cpp:
(WebCore::ComputedStyleExtractor::customPropertyValue):
* Source/WebCore/css/DOMCSSRegisterCustomProperty.cpp:
(WebCore::DOMCSSRegisterCustomProperty::registerProperty):
* Source/WebCore/css/StyleProperties.cpp:
(WebCore::MutableStyleProperties::setCustomProperty):
* Source/WebCore/css/StyleRule.h:
* Source/WebCore/css/parser/CSSParser.cpp:
(WebCore::CSSParser::parseValueWithVariableReferences):
* Source/WebCore/css/parser/CSSParserImpl.cpp:
(WebCore::CSSParserImpl::consumePropertyRule):

Pass the initial value as parser tokens instead of a string to avoid unnecessary re-tokenization.

* Source/WebCore/dom/Document.cpp:
(WebCore::Document::customPropertyRegistry const):
(WebCore::Document::registerCSSCustomProperty): Deleted.
* Source/WebCore/dom/Document.h:
(WebCore::Document::registeredCSSCustomProperties const): Deleted.

Move registry ownership to Style::Scope.

* Source/WebCore/style/CustomPropertyRegistry.cpp: Added.
(WebCore::Style::CustomPropertyRegistry::CustomPropertyRegistry):
(WebCore::Style::CustomPropertyRegistry::get const):

Look up API registrations first, then stylesheet registrations.

(WebCore::Style::CustomPropertyRegistry::registerFromAPI):
(WebCore::Style::CustomPropertyRegistry::registerFromStylesheet):

Logic for registering a descriptor from a @Property rule.

(WebCore::Style::CustomPropertyRegistry::clearRegisteredFromStylesheets):
* Source/WebCore/style/CustomPropertyRegistry.h: Added.

Add a registry class.

* Source/WebCore/style/RuleSetBuilder.cpp:
(WebCore::Style::RuleSetBuilder::addChildRules):

Collect property rules.
Use switch.

(WebCore::Style::RuleSetBuilder::addMutatingRulesToResolver):

Register the collected property rules in correct order.

* Source/WebCore/style/RuleSetBuilder.h:
* Source/WebCore/style/StyleBuilder.cpp:
(WebCore::Style::Builder::applyProperty):
* Source/WebCore/style/StyleResolver.h:
(WebCore::Style::Resolver::rootDefaultStyle const):
* Source/WebCore/style/StyleScope.cpp:
(WebCore::Style::Scope::Scope):
(WebCore::Style::Scope::clearResolver):
(WebCore::Style::Scope::updateResolver):
* Source/WebCore/style/StyleScope.h:
(WebCore::Style::Scope::customPropertyRegistry const):
(WebCore::Style::Scope::customPropertyRegistry):

Style::Scope owns the registry.

Canonical link: https://commits.webkit.org/258106@main
  • Loading branch information
anttijk committed Dec 20, 2022
1 parent 6faa6ae commit ab61bade88f0ba511ef1d2ea8dd191bbce7a8e73
Show file tree
Hide file tree
Showing 32 changed files with 376 additions and 128 deletions.
@@ -5,6 +5,6 @@ PASS Insert layer invalidates style
PASS Delete layer invalidates style
PASS Insert layer invalidates @font-face
PASS Delete layer invalidates @font-face
FAIL Insert layer invalidates @property assert_equals: expected "green" but got ""
FAIL Delete layer invalidates @property assert_equals: expected "green" but got ""
PASS Insert layer invalidates @property
PASS Delete layer invalidates @property

@@ -1,6 +1,6 @@

FAIL @property unlayered overrides layered assert_equals: expected "rgb(0, 128, 0)" but got "rgba(0, 0, 0, 0)"
FAIL @property override between layers assert_equals: expected "rgb(0, 128, 0)" but got "rgba(0, 0, 0, 0)"
FAIL @property override update with appended sheet 1 assert_equals: expected "rgb(0, 128, 0)" but got "rgba(0, 0, 0, 0)"
FAIL @property override update with appended sheet 2 assert_equals: expected "rgb(0, 128, 0)" but got "rgba(0, 0, 0, 0)"
PASS @property unlayered overrides layered
PASS @property override between layers
PASS @property override update with appended sheet 1
PASS @property override update with appended sheet 2

@@ -1,6 +1,6 @@

PASS @keyframes is defined regardless of evaluation
FAIL @property is defined regardless of evaluation assert_equals: expected "20px" but got "1em"
PASS @property is defined regardless of evaluation
PASS @layer order respected regardless of evaluation
PASS @font-face is defined regardless of evaluation
PASS @media works inside @container
@@ -1,14 +1,14 @@

FAIL @keyframes works with @property assert_equals: expected "150px" but got "200px"
FAIL @keyframes picks up the latest @property in the document assert_equals: expected "rgb(150, 150, 150)" but got "rgb(200, 200, 200)"
FAIL Ongoing animation picks up redeclared custom property assert_equals: expected "0px" but got "rgb(200, 200, 200)"
FAIL Ongoing animation matches new keyframes against the current registration assert_equals: expected "0px" but got "rgb(200, 200, 200)"
FAIL Ongoing animation picks up redeclared intial value assert_equals: expected "200px" but got "400px"
FAIL Ongoing animation picks up redeclared inherits flag assert_equals: expected "200px" but got "400px"
FAIL Ongoing animation picks up redeclared meaning of 'unset' assert_equals: expected "200px" but got "400px"
FAIL Transitioning from initial value assert_equals: expected "rgb(255, 0, 0)" but got ""
FAIL Transitioning from specified value assert_equals: expected "rgb(0, 0, 255)" but got "blue"
FAIL Transition triggered by initial value change assert_equals: expected "100px" but got ""
FAIL No transition when changing types assert_equals: expected "100px" but got ""
PASS @keyframes works with @property
PASS @keyframes picks up the latest @property in the document
FAIL Ongoing animation picks up redeclared custom property assert_equals: expected "rgb(150, 150, 150)" but got "0px"
PASS Ongoing animation matches new keyframes against the current registration
FAIL Ongoing animation picks up redeclared intial value assert_equals: expected "250px" but got "200px"
FAIL Ongoing animation picks up redeclared inherits flag assert_equals: expected "250px" but got "200px"
FAIL Ongoing animation picks up redeclared meaning of 'unset' assert_equals: expected "250px" but got "200px"
FAIL Transitioning from initial value assert_equals: expected "rgb(128, 0, 128)" but got "rgb(0, 0, 255)"
FAIL Transitioning from specified value assert_equals: expected "rgb(0, 64, 128)" but got "rgb(0, 128, 0)"
FAIL Transition triggered by initial value change assert_equals: expected "150px" but got "200px"
PASS No transition when changing types
FAIL No transition when removing @property rule assert_equals: expected " 100px" but got "100px"

@@ -25,29 +25,29 @@ 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 ""
FAIL Rule applied [<angle>, 42deg, false] assert_equals: expected "42deg" but got ""
FAIL Rule applied [<angle>, 1turn, false] assert_equals: expected "360deg" but got ""
FAIL Rule applied [<color>, green, false] assert_equals: expected "rgb(0, 128, 0)" but got ""
FAIL Rule applied [<color>, rgb(1, 2, 3), false] assert_equals: expected "rgb(1, 2, 3)" but got ""
FAIL Rule applied [<image>, url("http://a/"), false] assert_equals: expected "url(\"http://a/\")" but got ""
FAIL Rule applied [<integer>, 5, false] assert_equals: expected "5" but got ""
FAIL Rule applied [<length-percentage>, 10px, false] assert_equals: expected "10px" but got ""
FAIL Rule applied [<length-percentage>, 10%, false] assert_equals: expected "10%" but got ""
FAIL Rule applied [<length-percentage>, calc(10% + 10px), false] assert_equals: expected "calc(10% + 10px)" but got ""
FAIL Rule applied [<length>, 10px, false] assert_equals: expected "10px" but got ""
FAIL Rule applied [<number>, 2.5, false] assert_equals: expected "2.5" but got ""
FAIL Rule applied [<percentage>, 10%, false] assert_equals: expected "10%" but got ""
FAIL Rule applied [<resolution>, 50dppx, false] assert_equals: expected "50dppx" but got ""
FAIL Rule applied [<resolution>, 96dpi, false] assert_equals: expected "1dppx" but got ""
FAIL Rule applied [<time>, 10s, false] assert_equals: expected "10s" but got ""
FAIL Rule applied [<time>, 1000ms, false] assert_equals: expected "1s" but got ""
FAIL Rule applied [<transform-function>, rotateX(0deg), false] assert_equals: expected "rotateX(0deg)" but got ""
FAIL Rule applied [<transform-list>, rotateX(0deg), false] assert_equals: expected "rotateX(0deg)" but got ""
FAIL Rule applied [<transform-list>, rotateX(0deg) translateX(10px), false] assert_equals: expected "rotateX(0deg) translateX(10px)" but got ""
FAIL Rule applied [<url>, url("http://a/"), false] assert_equals: expected "url(\"http://a/\")" but got ""
FAIL Rule applied [<color>, tomato, false] assert_equals: expected "rgb(255, 99, 71)" but got ""
FAIL Rule applied [<color>, tomato, true] assert_equals: expected "rgb(255, 99, 71)" but got ""
PASS Rule applied [*, if(){}, false]
PASS Rule applied [<angle>, 42deg, false]
PASS Rule applied [<angle>, 1turn, false]
PASS Rule applied [<color>, green, false]
PASS Rule applied [<color>, rgb(1, 2, 3), false]
PASS Rule applied [<image>, url("http://a/"), false]
PASS Rule applied [<integer>, 5, false]
PASS Rule applied [<length-percentage>, 10px, false]
PASS Rule applied [<length-percentage>, 10%, false]
PASS Rule applied [<length-percentage>, calc(10% + 10px), false]
PASS Rule applied [<length>, 10px, false]
PASS Rule applied [<number>, 2.5, false]
PASS Rule applied [<percentage>, 10%, false]
PASS Rule applied [<resolution>, 50dppx, false]
PASS Rule applied [<resolution>, 96dpi, false]
PASS Rule applied [<time>, 10s, false]
PASS Rule applied [<time>, 1000ms, false]
PASS Rule applied [<transform-function>, rotateX(0deg), false]
PASS Rule applied [<transform-list>, rotateX(0deg), false]
PASS Rule applied [<transform-list>, rotateX(0deg) translateX(10px), false]
PASS Rule applied [<url>, url("http://a/"), false]
PASS Rule applied [<color>, tomato, false]
PASS Rule applied [<color>, tomato, true]
PASS Rule applied for "*", even with no initial value
PASS Rule not applied [undefined, green, false]
PASS Rule not applied [<color>, undefined, false]
@@ -56,9 +56,9 @@ PASS Rule not applied [<gandalf>, grey, false]
PASS Rule not applied [gandalf, grey, false]
PASS Rule not applied [<color>, notacolor, false]
PASS Rule not applied [<length>, 10em, false]
FAIL Non-inherited properties do not inherit assert_equals: expected "0px" but got "40px"
PASS Non-inherited properties do not inherit
PASS Inherited properties inherit
FAIL Initial values substituted as computed value assert_equals: expected "rgb(0, 128, 0)" but got ""
PASS Initial values substituted as computed value
PASS Non-universal registration are invalid without an initial value
FAIL Initial value may be omitted for universal registration assert_equals: expected "" but got "calc(1px + 1px)"
PASS Initial value may be omitted for universal registration

@@ -1,3 +1,3 @@

FAIL @property rules in shadow trees should have no effect assert_equals: expected "2px" but got "calc(1px + 1px)"
FAIL @property rules in shadow trees should have no effect assert_equals: expected " calc(1px + 1px)" but got "2px"

@@ -1,7 +1,7 @@

FAIL @property detected when stylesheet appears assert_equals: expected "1px" but got ""
FAIL @property removal detected when last @property rule disappears assert_equals: expected "1px" but got ""
FAIL @property detected in second stylesheet assert_equals: expected "2px" but got ""
FAIL @property removal detected with removal of second stylesheet assert_equals: expected "2px" but got ""
FAIL @property removal detected with removal of first stylesheet assert_equals: expected "1px" but got ""
PASS @property detected when stylesheet appears
PASS @property removal detected when last @property rule disappears
PASS @property detected in second stylesheet
PASS @property removal detected with removal of second stylesheet
PASS @property removal detected with removal of first stylesheet

@@ -1,4 +1,4 @@


FAIL @property: viewport units in initial value (dynamic) assert_equals: expected "40px" but got ""
FAIL @property: viewport units in initial value (dynamic) assert_equals: expected "10px" but got "40px"

@@ -1,27 +1,27 @@


FAIL 10vw is 40px assert_equals: expected "40px" but got ""
FAIL 10vh is 20px assert_equals: expected "20px" but got ""
FAIL 10vi is 40px assert_equals: expected "40px" but got ""
FAIL 10vb is 20px assert_equals: expected "20px" but got ""
FAIL 10vmin is 20px assert_equals: expected "20px" but got ""
FAIL 10vmax is 40px assert_equals: expected "40px" but got ""
FAIL 10svw is 40px assert_equals: expected "40px" but got ""
FAIL 10svh is 20px assert_equals: expected "20px" but got ""
FAIL 10svi is 40px assert_equals: expected "40px" but got ""
FAIL 10svb is 20px assert_equals: expected "20px" but got ""
FAIL 10svmin is 20px assert_equals: expected "20px" but got ""
FAIL 10svmax is 40px assert_equals: expected "40px" but got ""
FAIL 10lvw is 40px assert_equals: expected "40px" but got ""
FAIL 10lvh is 20px assert_equals: expected "20px" but got ""
FAIL 10lvi is 40px assert_equals: expected "40px" but got ""
FAIL 10lvb is 20px assert_equals: expected "20px" but got ""
FAIL 10lvmin is 20px assert_equals: expected "20px" but got ""
FAIL 10lvmax is 40px assert_equals: expected "40px" but got ""
FAIL 10dvw is 40px assert_equals: expected "40px" but got ""
FAIL 10dvh is 20px assert_equals: expected "20px" but got ""
FAIL 10dvi is 40px assert_equals: expected "40px" but got ""
FAIL 10dvb is 20px assert_equals: expected "20px" but got ""
FAIL 10dvmin is 20px assert_equals: expected "20px" but got ""
FAIL 10dvmax is 40px assert_equals: expected "40px" but got ""
PASS 10vw is 40px
PASS 10vh is 20px
PASS 10vi is 40px
PASS 10vb is 20px
PASS 10vmin is 20px
PASS 10vmax is 40px
PASS 10svw is 40px
PASS 10svh is 20px
PASS 10svi is 40px
PASS 10svb is 20px
PASS 10svmin is 20px
PASS 10svmax is 40px
PASS 10lvw is 40px
PASS 10lvh is 20px
PASS 10lvi is 40px
PASS 10lvb is 20px
PASS 10lvmin is 20px
PASS 10lvmax is 40px
PASS 10dvw is 40px
PASS 10dvh is 20px
PASS 10dvi is 40px
PASS 10dvb is 20px
PASS 10dvmin is 20px
PASS 10dvmax is 40px

@@ -1,15 +1,15 @@

FAIL @property determines the registration when uncontested assert_equals: expected "1px" but got ""
PASS @property determines the registration when uncontested
PASS CSS.registerProperty wins over @property
FAIL @property later in document order wins assert_equals: expected "6" but got ""
FAIL @property later in stylesheet wins assert_equals: expected "rgb(255, 0, 0)" but got ""
PASS @property later in document order wins
PASS @property later in stylesheet wins
PASS CSS.registerProperty determines the registration when uncontested
FAIL @property registrations are cleared when rule removed assert_equals: expected "10px" but got ""
PASS @property registrations are cleared when rule removed
FAIL Computed value becomes token sequence when @property is removed assert_equals: expected " calc(1px + 1px)" but got "calc(1px + 1px)"
FAIL Inherited status is reflected in computed styles when @property is removed assert_equals: expected " 10px" but got "10px"
FAIL Invalid @property rule (missing syntax) does not overwrite previous valid rule assert_equals: expected "1px" but got ""
FAIL Invalid @property rule (missing inherits descriptor) does not overwrite previous valid rule assert_equals: expected "1px" but got ""
FAIL Invalid @property rule (missing initial-value) does not overwrite previous valid rule assert_equals: expected "1px" but got ""
FAIL Previous invalid rule does not prevent valid rule from causing registration assert_equals: expected "1px" but got ""
FAIL Unknown descriptors are ignored and do not invalidate rule assert_equals: expected "1px" but got ""
PASS Invalid @property rule (missing syntax) does not overwrite previous valid rule
PASS Invalid @property rule (missing inherits descriptor) does not overwrite previous valid rule
PASS Invalid @property rule (missing initial-value) does not overwrite previous valid rule
PASS Previous invalid rule does not prevent valid rule from causing registration
PASS Unknown descriptors are ignored and do not invalidate rule

@@ -1,3 +1,3 @@

FAIL Only #c should be affected by --x:42 assert_equals: expected "0" but got ""
PASS Only #c should be affected by --x:42

@@ -2694,6 +2694,7 @@ style/ChildChangeInvalidation.cpp
style/ClassChangeInvalidation.cpp
style/ColorFromPrimitiveValue.cpp
style/ContainerQueryEvaluator.cpp
style/CustomPropertyRegistry.cpp
style/ElementRuleCollector.cpp
style/FilterOperationsBuilder.cpp
style/HasSelectorFilter.cpp
@@ -5573,6 +5573,7 @@
E47FC8A325B84D72005495FC /* LoadSchedulingMode.h in Headers */ = {isa = PBXBuildFile; fileRef = E47FC8A125B84D71005495FC /* LoadSchedulingMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
E48137B91DB3B526005C59BF /* StyleValidity.h in Headers */ = {isa = PBXBuildFile; fileRef = E48137B81DB3B526005C59BF /* StyleValidity.h */; settings = {ATTRIBUTES = (Private, ); }; };
E4863CFE23842E9E00972158 /* RuleData.h in Headers */ = {isa = PBXBuildFile; fileRef = E4863CFD23842E9E00972158 /* RuleData.h */; };
E49054EB2950A9BA0041D57B /* CustomPropertyRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = E49054EA2950A9B90041D57B /* CustomPropertyRegistry.h */; };
E4946EAF156E64DD00D3297F /* StyleRuleImport.h in Headers */ = {isa = PBXBuildFile; fileRef = E4946EAD156E64DD00D3297F /* StyleRuleImport.h */; settings = {ATTRIBUTES = (Private, ); }; };
E49BD9FA131FD2ED003C56F0 /* CSSValuePool.h in Headers */ = {isa = PBXBuildFile; fileRef = E49BD9F9131FD2ED003C56F0 /* CSSValuePool.h */; };
E4A664CC2521D4AF007081DC /* InlineIteratorBox.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A664C62521B778007081DC /* InlineIteratorBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -18203,6 +18204,8 @@
E48137B81DB3B526005C59BF /* StyleValidity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleValidity.h; sourceTree = "<group>"; };
E4863CFA23842E8700972158 /* RuleData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RuleData.cpp; sourceTree = "<group>"; };
E4863CFD23842E9E00972158 /* RuleData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuleData.h; sourceTree = "<group>"; };
E49054E82950A98B0041D57B /* CustomPropertyRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomPropertyRegistry.cpp; sourceTree = "<group>"; };
E49054EA2950A9B90041D57B /* CustomPropertyRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomPropertyRegistry.h; sourceTree = "<group>"; };
E4946EAC156E64DD00D3297F /* StyleRuleImport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleRuleImport.cpp; sourceTree = "<group>"; };
E4946EAD156E64DD00D3297F /* StyleRuleImport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleRuleImport.h; sourceTree = "<group>"; };
E49BD9F9131FD2ED003C56F0 /* CSSValuePool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSValuePool.h; sourceTree = "<group>"; };
@@ -32669,6 +32672,8 @@
72CDE0E228FE23000059719E /* ColorFromPrimitiveValue.h */,
E4AAB38827AA95E0009F5899 /* ContainerQueryEvaluator.cpp */,
E4AAB38527AA95D7009F5899 /* ContainerQueryEvaluator.h */,
E49054E82950A98B0041D57B /* CustomPropertyRegistry.cpp */,
E49054EA2950A9B90041D57B /* CustomPropertyRegistry.h */,
FBDB619A16D6032A00BB3394 /* ElementRuleCollector.cpp */,
FBDB619E16D6036500BB3394 /* ElementRuleCollector.h */,
72CDE0DF28FE21700059719E /* FilterOperationsBuilder.cpp */,
@@ -35597,6 +35602,7 @@
62CD325A1157E57C0063B0A7 /* CustomEvent.h in Headers */,
5C5D2385227A0652000B9BDA /* CustomHeaderFields.h in Headers */,
4B1E13E721790D660042CF98 /* CustomPaintCanvas.h in Headers */,
E49054EB2950A9BA0041D57B /* CustomPropertyRegistry.h in Headers */,
7B8ED5F026F0C13D008AC023 /* CVUtilities.h in Headers */,
A8CB413E0E8633FD0032C4F0 /* DashArray.h in Headers */,
97BC6A211505F081001B74AC /* Database.h in Headers */,
@@ -42,6 +42,7 @@
#include "ComputedStyleExtractor.h"
#include "ContentData.h"
#include "CounterDirectives.h"
#include "CustomPropertyRegistry.h"
#include "Document.h"
#include "FloatConversion.h"
#include "FontCascade.h"
@@ -4024,7 +4025,7 @@ static std::pair<const CSSCustomPropertyValue*, const CSSCustomPropertyValue*> c
// for a custom property that was not explicitly set.
auto initialValue = [&]() -> const CSSCustomPropertyValue* {
if (auto* document = client.document()) {
if (auto registered = document->registeredCSSCustomProperties().get(customProperty))
if (auto registered = document->customPropertyRegistry().get(customProperty))
return registered->initialValue();
}
return nullptr;
@@ -27,6 +27,7 @@
#include "CSSPropertyRule.h"

#include "CSSMarkup.h"
#include "CSSParserTokenRange.h"
#include "CSSStyleSheet.h"
#include "StyleRule.h"
#include <wtf/text/StringBuilder.h>
@@ -63,7 +64,10 @@ bool CSSPropertyRule::inherits() const

String CSSPropertyRule::initialValue() const
{
return m_propertyRule->descriptor().initialValue;
if (!m_propertyRule->descriptor().initialValue)
return nullString();

return m_propertyRule->descriptor().initialValue->tokenRange().serialize();
}

String CSSPropertyRule::cssText() const
@@ -85,8 +89,8 @@ String CSSPropertyRule::cssText() const
if (descriptor.inherits)
builder.append("inherits: ", *descriptor.inherits ? "true" : "false", "; ");

if (!descriptor.initialValue.isNull())
builder.append("initial-value: ", descriptor.initialValue, "; ");
if (descriptor.initialValue)
builder.append("initial-value: ", initialValue(), "; ");

builder.append("}");

0 comments on commit ab61bad

Please sign in to comment.