forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[css-nesting] New behavior for interleaved declarations and rules
https://bugs.webkit.org/show_bug.cgi?id=275365 rdar://130094168 Reviewed by Tim Nguyen. w3c/csswg-drafts#10234 Before this CSSWG resolution, any declaration inside a style rule (whatever its position relative to other rules), would be shifted up at the top of the rule to be able to represent a style rule with a single leading block of declarations. This patch implements the new resolved behavior so the order of interleaved declarations is respected during cascade. https://drafts.csswg.org/css-nesting/#the-cssnestrule This patch introduces a new StyleRuleNestedDeclarations class to be able to store a block of declarations in-between rules and fit with the already existing RuleData/RuleSet mechanism. Its CSSOM representation (CSSNestedDeclarations) is purposedly not serialized as a rule in the CSSOM but like a list of declarations. The CSSOM insertRule() functions (on CSSStyleRule/CSSGroupingRule) are modified to allow inserting block of declarations. w3c/csswg-drafts#10520 * LayoutTests/TestExpectations: * LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/cssom-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/cssom.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/mixed-declarations-rules-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/mixed-declarations-rules.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/nested-declarations-cssom-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/nested-declarations-matching-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/serialize-group-rules-with-decls-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-syntax/custom-property-rule-ambiguity.html: Manual sync from WPT * 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/bindings/js/JSCSSRuleCustom.cpp: (WebCore::toJSNewlyCreated): * Source/WebCore/css/CSSGradientValue.h: * Source/WebCore/css/CSSNestedDeclarations.cpp: Added. (WebCore::CSSNestedDeclarations::CSSNestedDeclarations): (WebCore::CSSNestedDeclarations::style): (WebCore::CSSNestedDeclarations::cssText const): (WebCore::CSSNestedDeclarations::reattach): * Source/WebCore/css/CSSNestedDeclarations.h: Added. * Source/WebCore/css/CSSNestedDeclarations.idl: Added. * Source/WebCore/css/CSSShapeSegmentValue.cpp: * Source/WebCore/css/CSSStyleRule.cpp: (WebCore::CSSStyleRule::insertRule): * Source/WebCore/css/CSSStyleRule.h: * Source/WebCore/css/StyleRule.cpp: (WebCore::StyleRuleBase::visitDerived): (WebCore::StyleRuleBase::createCSSOMWrapper const): (WebCore::StyleRuleNestedDeclarations::StyleRuleNestedDeclarations): (WebCore::StyleRuleNestedDeclarations::debugDescription const): * Source/WebCore/css/StyleRule.h: (WebCore::StyleRuleBase::isStyleRuleNestedDeclarations const): (isType): * Source/WebCore/css/StyleRuleType.h: * Source/WebCore/css/StyleSheetContents.cpp: (WebCore::StyleSheetContents::traverseRules const): (WebCore::StyleSheetContents::traverseSubresources const): (WebCore::StyleSheetContents::mayDependOnBaseURL const): * Source/WebCore/css/calc/CSSCalcTree+Simplification.cpp: * Source/WebCore/css/calc/CSSCalcTree+Simplification.h: * Source/WebCore/css/parser/CSSParser.h: * Source/WebCore/css/parser/CSSParserImpl.cpp: (WebCore::CSSParserImpl::parseNestedDeclarations): (WebCore::CSSParserImpl::createNestedDeclarationsRule): (WebCore::CSSParserImpl::consumeNestedGroupRules): (WebCore::CSSParserImpl::consumeBlockContent): (WebCore::CSSParserImpl::createNestingParentRule): Deleted. * Source/WebCore/css/parser/CSSParserImpl.h: * Source/WebCore/css/parser/CSSPropertyParserConsumer+Image.cpp: (WebCore::CSSPropertyParserHelpers::consumeImageSetResolutionOrTypeFunction): * Source/WebCore/css/parser/CSSPropertyParserConsumer+Image.h: * Source/WebCore/inspector/InspectorStyleSheet.cpp: (WebCore::flatteningStrategyForStyleRuleType): * Source/WebCore/style/RuleSetBuilder.cpp: (WebCore::Style::RuleSetBuilder::addChildRule): (WebCore::Style::RuleSetBuilder::addStyleRule): * Source/WebCore/style/RuleSetBuilder.h: Canonical link: https://commits.webkit.org/283188@main
- Loading branch information
Showing
38 changed files
with
414 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...ts/imported/w3c/web-platform-tests/css/css-nesting/mixed-declarations-rules-expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<title>Conditional rules with nesting</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-nesting-1/"> | ||
<style> | ||
.test { | ||
background-color: green; | ||
width: 100px; | ||
height: 100px; | ||
} | ||
|
||
body * + * { | ||
margin-top: 8px; | ||
} | ||
</style> | ||
<body> | ||
<p>Tests pass if <strong>block is green</strong></p> | ||
<div class="test"><div></div></div> | ||
</body> |
20 changes: 20 additions & 0 deletions
20
LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/mixed-declarations-rules.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<title>Mixed declarations and rules</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-nesting/#nested-declarations-rule"> | ||
|
||
<style> | ||
div { | ||
width: 100px; | ||
height: 100px; | ||
background-color: blue; | ||
@media all { | ||
background-color: red; | ||
} | ||
background-color: green; | ||
} | ||
</style> | ||
|
||
<body> | ||
<p>Tests pass if <strong>block is green</strong></p> | ||
<div class="test"></div> | ||
</body> |
16 changes: 8 additions & 8 deletions
16
...ts/imported/w3c/web-platform-tests/css/css-nesting/nested-declarations-cssom-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
...imported/w3c/web-platform-tests/css/css-nesting/nested-declarations-matching-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...rted/w3c/web-platform-tests/css/css-nesting/serialize-group-rules-with-decls-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.