Skip to content

Commit

Permalink
[CSS Nesting] Rebuild rule set from original (not resolved) selector
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=255521
rdar://108137916

Reviewed by Antti Koivisto.

When there is a modification of a selector by CSSOM,
the next resolution should work on the original user-written selector,
not on the previously resolved selector.

* LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/invalidation-004-expected.txt:
* Source/WebCore/style/RuleSetBuilder.cpp:
(WebCore::Style::RuleSetBuilder::resolveSelectorListWithNesting):

Canonical link: https://commits.webkit.org/263026@main
  • Loading branch information
mdubet committed Apr 17, 2023
1 parent ee7f5c5 commit 9eba2e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
@@ -1,4 +1,4 @@
Test passes if color is green.

FAIL CSS Selectors nested invalidation through @media by selectorText assert_equals: expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
PASS CSS Selectors nested invalidation through @media by selectorText

6 changes: 3 additions & 3 deletions Source/WebCore/style/RuleSetBuilder.cpp
Expand Up @@ -221,11 +221,11 @@ void RuleSetBuilder::resolveSelectorListWithNesting(StyleRuleWithNesting& rule)
if (m_styleRuleStack.size())
parentResolvedSelectorList = m_styleRuleStack.last();

// If it's a top-level rule wihout a nesting parent selector, keep the selector list as is.
if (!rule.selectorList().hasExplicitNestingParent() && !parentResolvedSelectorList)
// If it's a top-level rule without a nesting parent selector, keep the selector list as is.
if (!rule.originalSelectorList().hasExplicitNestingParent() && !parentResolvedSelectorList)
return;

auto resolvedSelectorList = CSSSelectorParser::resolveNestingParent(rule.selectorList(), parentResolvedSelectorList);
auto resolvedSelectorList = CSSSelectorParser::resolveNestingParent(rule.originalSelectorList(), parentResolvedSelectorList);
ASSERT(!resolvedSelectorList.hasExplicitNestingParent());
rule.wrapperAdoptSelectorList(WTFMove(resolvedSelectorList));
}
Expand Down

0 comments on commit 9eba2e0

Please sign in to comment.