Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CSS nesting: parsing of style rule inside style rule.
https://bugs.webkit.org/show_bug.cgi?id=249263 rdar://103146832 Reviewed by Antti Koivisto. This implements experimental support to parse nested style rule inside style rule. This is based on the css-nesting-1 editor draft as of today, which describes the so-called "option 3" (non letter start) syntax. https://github.com/w3c/csswg-drafts/blob/main/css-nesting-1/proposals.md This is missing: - any support for having nested at-rule inside style rule. - CSSOM - selector matching * LayoutTests/fast/css/style-enumerate-properties-expected.txt: * LayoutTests/fast/css/style-enumerate-properties.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/cssom-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/invalidation-004-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/parsing-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/parsing.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/serialize-group-rules-with-decls.tentative-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/serialize-group-rules-with-decls.tentative.html: * LayoutTests/imported/w3c/web-platform-tests/css/selectors/nesting-parsing-expected.txt: Removed. * LayoutTests/imported/w3c/web-platform-tests/css/selectors/nesting-parsing.html: Removed. * LayoutTests/imported/w3c/web-platform-tests/css/selectors/old-tests/css3-modsel-156.xml: * LayoutTests/imported/w3c/web-platform-tests/css/selectors/old-tests/css3-modsel-156b.xml: * LayoutTests/imported/w3c/web-platform-tests/css/selectors/old-tests/css3-modsel-156c.xml: * LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Element-matches-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Element-webkitMatchesSelector-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/dom/nodes/ParentNode-querySelector-All-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/dom/nodes/ParentNode-querySelector-All-xht-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/dom/nodes/selectors.js: * Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml: * Source/WebCore/css/CSSComputedStyleDeclaration.cpp: (WebCore::CSSComputedStyleDeclaration::cssRules const): * Source/WebCore/css/CSSComputedStyleDeclaration.h: * Source/WebCore/css/CSSSelector.cpp: (WebCore::simpleSelectorSpecificity): (WebCore::CSSSelector::selectorText const): * Source/WebCore/css/CSSSelector.h: * Source/WebCore/css/CSSStyleDeclaration.h: * Source/WebCore/css/CSSStyleDeclaration.idl: * Source/WebCore/css/CSSStyleRule.cpp: (WebCore::CSSStyleRule::cssText const): * Source/WebCore/css/PropertySetCSSStyleDeclaration.h: * Source/WebCore/css/SelectorChecker.cpp: (WebCore::SelectorChecker::checkOne const): * Source/WebCore/css/StyleProperties.cpp: (WebCore::MutableStyleProperties::createEmpty): * Source/WebCore/css/StyleProperties.h: * Source/WebCore/css/StyleRule.cpp: (WebCore::StyleRule::averageSizeInBytes): (WebCore::StyleRule::StyleRule): (WebCore::StyleRule::create): (WebCore::StyleRule::createForSplitting): * Source/WebCore/css/StyleRule.h: * Source/WebCore/css/parser/CSSParser.cpp: (WebCore::CSSParser::parseSelector): * Source/WebCore/css/parser/CSSParserContext.cpp: (WebCore::operator==): (WebCore::add): * Source/WebCore/css/parser/CSSParserContext.h: * Source/WebCore/css/parser/CSSParserImpl.cpp: (WebCore::CSSParserImpl::parseRule): (WebCore::CSSParserImpl::consumeRuleList): (WebCore::CSSParserImpl::consumeQualifiedRule): (WebCore::CSSParserImpl::consumeStyleRule): (WebCore::CSSParserImpl::consumeDeclarationListOrStyleBlockHelper): (WebCore::CSSParserImpl::consumeDeclarationList): (WebCore::CSSParserImpl::consumeStyleBlock): * Source/WebCore/css/parser/CSSParserImpl.h: (WebCore::CSSParserImpl::consumeQualifiedRule): (WebCore::CSSParserImpl::consumeStyleRule): (WebCore::CSSParserImpl::consumeDeclarationListOrStyleBlockHelper): (WebCore::CSSParserImpl::consumeStyleBlock): * Source/WebCore/css/parser/CSSSelectorParser.cpp: (WebCore::parseCSSSelector): (WebCore::CSSSelectorParser::CSSSelectorParser): (WebCore::CSSSelectorParser::consumeSimpleSelector): (WebCore::CSSSelectorParser::consumeNesting): * Source/WebCore/css/parser/CSSSelectorParser.h: * Source/WebCore/cssjit/SelectorCompiler.cpp: (WebCore::SelectorCompiler::addPseudoClassType): Canonical link: https://commits.webkit.org/258079@main
- Loading branch information
Showing
40 changed files
with
310 additions
and
153 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
2 changes: 1 addition & 1 deletion
2
LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/invalidation-004-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Test passes if color is green. | ||
|
||
FAIL CSS Selectors nested invalidation through @media by selectorText undefined is not an object (evaluating 'document.styleSheets[0].rules[1].selectorText = '.a'') | ||
FAIL CSS Selectors nested invalidation through @media by selectorText assert_equals: expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" | ||
|
66 changes: 43 additions & 23 deletions
66
LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/parsing-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,65 @@ | ||
|
||
FAIL .foo { | ||
PASS .foo { | ||
& { color: green; } | ||
} assert_equals: expected ".foo {\n & { color: green; }\n}" but got ".foo { }" | ||
FAIL .foo { | ||
} | ||
PASS .foo { //color: red; color: green; } | ||
PASS .foo { | ||
&.bar { color: green; } | ||
} assert_equals: expected ".foo {\n &.bar { color: green; }\n}" but got ".foo { }" | ||
FAIL .foo { | ||
} | ||
PASS .foo { | ||
& .bar { color: green; } | ||
} assert_equals: expected ".foo {\n & .bar { color: green; }\n}" but got ".foo { }" | ||
FAIL .foo { | ||
} | ||
PASS .foo { | ||
& > .bar { color: green; } | ||
} assert_equals: expected ".foo {\n & > .bar { color: green; }\n}" but got ".foo { }" | ||
FAIL .foo { | ||
} | ||
PASS .foo { | ||
&:is(.bar, &.baz) { color: green; } | ||
} assert_equals: expected ".foo {\n &:is(.bar, &.baz) { color: green; }\n}" but got ".foo { }" | ||
FAIL .foo { | ||
} | ||
PASS .foo { | ||
.bar& { color: green; } | ||
} assert_equals: expected ".foo {\n .bar& { color: green; }\n}" but got ".foo { }" | ||
FAIL .foo { | ||
} | ||
PASS .foo { | ||
.bar & { color: green; } | ||
} assert_equals: expected ".foo {\n .bar & { color: green; }\n}" but got ".foo { }" | ||
FAIL .foo { | ||
} | ||
PASS .foo { | ||
.bar > & { color: green; } | ||
} assert_equals: expected ".foo {\n .bar > & { color: green; }\n}" but got ".foo { }" | ||
FAIL .foo, .bar { | ||
} | ||
PASS .foo, .bar { | ||
& + .baz, &.qux { color: green; } | ||
} assert_equals: expected ".foo, .bar {\n & + .baz, &.qux { color: green; }\n}" but got ".foo, .bar { }" | ||
FAIL .foo { | ||
} | ||
PASS .foo { | ||
& .bar & .baz & .qux { color: green; } | ||
} assert_equals: expected ".foo {\n & .bar & .baz & .qux { color: green; }\n}" but got ".foo { }" | ||
} | ||
FAIL .foo { | ||
@media (min-width: 50px) { | ||
& { color: green; } | ||
} | ||
} assert_equals: expected ".foo {\n @media (min-width: 50px) {\n & { color: green; }\n}\n}" but got ".foo { }" | ||
} assert_equals: expected ".foo {\n @media (min-width: 50px) { color: green; }\n}" but got ".foo { }" | ||
FAIL .foo { | ||
@media (min-width: 50px) { color: green; } | ||
} assert_equals: expected ".foo {\n @media (min-width: 50px) { color: green; }\n}" but got ".foo { }" | ||
FAIL main { | ||
PASS main { | ||
& > section, & > article { | ||
& > header { color: green; } | ||
} | ||
} assert_equals: expected "main {\n & > section, & > article {\n & > header { color: green; }\n}\n}" but got "main { }" | ||
} | ||
PASS .foo { | ||
:has(div) { color: green; } | ||
} | ||
PASS .foo { | ||
.bar { | ||
&& { color: green; } | ||
} | ||
} | ||
PASS .foo { | ||
color: red; ident { color: green; } | ||
} | ||
PASS .foo { | ||
//color: comment; & { color: green; } | ||
} | ||
PASS .foo { | ||
.bar { | ||
functionalnotation(div) { color: green; } | ||
|
||
} | ||
|
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
14 changes: 0 additions & 14 deletions
14
LayoutTests/imported/w3c/web-platform-tests/css/selectors/nesting-parsing-expected.txt
This file was deleted.
Oops, something went wrong.
42 changes: 0 additions & 42 deletions
42
LayoutTests/imported/w3c/web-platform-tests/css/selectors/nesting-parsing.html
This file was deleted.
Oops, something went wrong.
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.