Changeset 284973 in webkit
- Timestamp:
- Oct 28, 2021 1:59:03 AM (9 months ago)
- Location:
- trunk
- Files:
-
- 6 added
- 20 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/TestExpectations (modified) (2 diffs)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/host-context-parsing-expected.txt (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/host-context-parsing.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/host-parsing-expected.txt (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/host-parsing.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/keyframes-001-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/shadow-shared-style-cache-001-expected.txt (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/shadow-shared-style-cache-001.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/slotted-link-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/slotted-parsing-expected.txt (modified) (2 diffs)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/slotted-parsing.html (modified) (2 diffs)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/w3c-import.log (modified) (3 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/CSSSelector.cpp (modified) (1 diff)
-
Source/WebCore/css/CSSSelector.h (modified) (1 diff)
-
Source/WebCore/css/SelectorChecker.cpp (modified) (2 diffs)
-
Source/WebCore/css/SelectorChecker.h (modified) (2 diffs)
-
Source/WebCore/css/SelectorFilter.cpp (modified) (1 diff)
-
Source/WebCore/css/parser/CSSParserSelector.h (modified) (1 diff)
-
Source/WebCore/css/parser/CSSSelectorParser.cpp (modified) (5 diffs)
-
Source/WebCore/cssjit/SelectorCompiler.cpp (modified) (2 diffs)
-
Source/WebCore/style/ElementRuleCollector.cpp (modified) (7 diffs)
-
Source/WebCore/style/ElementRuleCollector.h (modified) (2 diffs)
-
Source/WebCore/style/RuleFeature.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r284972 r284973 1 2021-10-28 Antti Koivisto <antti@apple.com> 2 3 Support ::before and ::after pseudo elements after ::slotted 4 https://bugs.webkit.org/show_bug.cgi?id=178237 5 6 Reviewed by Ryosuke Niwa. 7 8 * TestExpectations: 9 1 10 2021-10-28 Carlos Garcia Campos <cgarcia@igalia.com> 2 11 -
trunk/LayoutTests/TestExpectations
r284921 r284973 3098 3098 imported/w3c/web-platform-tests/css/css-display/run-in/run-in-text-between-005.xht [ ImageOnlyFailure ] 3099 3099 imported/w3c/web-platform-tests/css/css-pseudo/placeholder-input-number.html [ ImageOnlyFailure ] 3100 imported/w3c/web-platform-tests/css/css-scoping/slotted-with-pseudo-element.html [ ImageOnlyFailure ]3101 3100 imported/w3c/web-platform-tests/css/css-text-decor/text-emphasis-color-001.xht [ ImageOnlyFailure ] 3102 3101 imported/w3c/web-platform-tests/css/css-text-decor/text-emphasis-position-above-left-001.xht [ ImageOnlyFailure ] … … 3209 3208 webkit.org/b/190032 compositing/layer-creation/translate-transition-overlap.html [ Failure ] 3210 3209 webkit.org/b/190032 imported/w3c/web-platform-tests/css/css-logical/animation-003.tentative.html [ Failure ] 3211 webkit.org/b/190032 imported/w3c/web-platform-tests/css/css-scoping/keyframes-001.html [ Failure ]3212 3210 3213 3211 # FIXME: Need to implement MediaRecorder dataavailable event to support these testcases -
trunk/LayoutTests/imported/w3c/ChangeLog
r284961 r284973 1 2021-10-28 Antti Koivisto <antti@apple.com> 2 3 Support ::before and ::after pseudo elements after ::slotted 4 https://bugs.webkit.org/show_bug.cgi?id=178237 5 6 Reviewed by Ryosuke Niwa. 7 8 Update the tests from WPT repo. 9 10 * web-platform-tests/css/css-scoping/host-context-parsing-expected.txt: Added. 11 * web-platform-tests/css/css-scoping/host-context-parsing.html: Added. 12 * web-platform-tests/css/css-scoping/host-parsing-expected.txt: Added. 13 * web-platform-tests/css/css-scoping/host-parsing.html: Added. 14 * web-platform-tests/css/css-scoping/keyframes-001-expected.txt: 15 * web-platform-tests/css/css-scoping/shadow-shared-style-cache-001-expected.txt: Added. 16 * web-platform-tests/css/css-scoping/shadow-shared-style-cache-001.html: Added. 17 * web-platform-tests/css/css-scoping/slotted-link-expected.txt: 18 * web-platform-tests/css/css-scoping/slotted-parsing-expected.txt: 19 * web-platform-tests/css/css-scoping/slotted-parsing.html: 20 * web-platform-tests/css/css-scoping/w3c-import.log: 21 1 22 2021-10-27 Kiet Ho <tho22@apple.com> 2 23 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/keyframes-001-expected.txt
r264522 r284973 1 1 2 FAIL @keyframes applies in the shadow tree assert_equals: expected 1 but got 0 2 PASS @keyframes applies in the shadow tree 3 3 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/slotted-link-expected.txt
r232903 r284973 1 1 This link should be green. 2 2 3 FAIL Check that we match :link and not :visited for slotted anchor. assert_equals: Unvisited link should be green. expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" 3 PASS Check that we match :link and not :visited for slotted anchor. 4 4 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/slotted-parsing-expected.txt
r267650 r284973 8 8 PASS "::slotted(*):host(div)" should be an invalid selector 9 9 PASS "::slotted(*):hover" should be an invalid selector 10 PASS "::slotted(*):is(:hover)" should be an invalid selector11 PASS "::slotted(*):where(:hover)" should be an invalid selector12 PASS "::slotted(*):is(#id)" should be an invalid selector13 PASS "::slotted(*):where(#id)" should be an invalid selector14 10 PASS "::slotted(*):read-only" should be an invalid selector 15 11 PASS "::slotted(*)::slotted(*)" should be an invalid selector … … 20 16 PASS "::slotted([attr]:hover)" should be a valid selector 21 17 PASS "::slotted(:not(.a))" should be a valid selector 22 FAIL "::slotted(*)::before" should be a valid selector The string did not match the expected pattern. 23 FAIL "::slotted(*)::after" should be a valid selector The string did not match the expected pattern. 18 FAIL "::slotted(*):is()" should be a valid selector The string did not match the expected pattern. 19 FAIL "::slotted(*):is(:hover)" should be a valid selector The string did not match the expected pattern. 20 FAIL "::slotted(*):is(#id)" should be a valid selector The string did not match the expected pattern. 21 FAIL "::slotted(*):where()" should be a valid selector The string did not match the expected pattern. 22 FAIL "::slotted(*):where(:hover)" should be a valid selector The string did not match the expected pattern. 23 FAIL "::slotted(*):where(#id)" should be a valid selector The string did not match the expected pattern. 24 PASS "::slotted(*)::before" should be a valid selector 25 PASS "::slotted(*)::after" should be a valid selector 24 26 FAIL "::slotted(*)::placeholder" should be a valid selector The string did not match the expected pattern. 25 FAIL "::slotted(*)::marker" should be a valid selector The string did not match the expected pattern. 27 PASS "::slotted(*)::marker" should be a valid selector 26 28 PASS "::slotted(*)::first-line" should be an invalid selector 27 29 PASS "::slotted(*)::first-letter" should be an invalid selector -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/slotted-parsing.html
r264522 r284973 18 18 test_invalid_selector("::slotted(*):host(div)"); 19 19 test_invalid_selector("::slotted(*):hover"); 20 test_invalid_selector("::slotted(*):is(:hover)");21 test_invalid_selector("::slotted(*):where(:hover)");22 test_invalid_selector("::slotted(*):is(#id)");23 test_invalid_selector("::slotted(*):where(#id)");24 20 test_invalid_selector("::slotted(*):read-only"); 25 21 test_invalid_selector("::slotted(*)::slotted(*)"); … … 31 27 test_valid_selector("::slotted([attr]:hover)"); 32 28 test_valid_selector("::slotted(:not(.a))"); 29 30 test_valid_selector("::slotted(*):is()"); 31 test_valid_selector("::slotted(*):is(:hover)", "::slotted(*):is()"); 32 test_valid_selector("::slotted(*):is(#id)", "::slotted(*):is()"); 33 34 test_valid_selector("::slotted(*):where()"); 35 test_valid_selector("::slotted(*):where(:hover)", "::slotted(*):where()"); 36 test_valid_selector("::slotted(*):where(#id)", "::slotted(*):where()"); 33 37 34 38 // Allow tree-abiding pseudo elements after ::slotted -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/w3c-import.log
r281692 r284973 53 53 /LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/css-scoping-shadow-with-rules-no-style-leak.html 54 54 /LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/css-scoping-shadow-with-rules.html 55 /LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/host-context-parsing.html 55 56 /LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/host-context-specificity-001-expected.html 56 57 /LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/host-context-specificity-001.html … … 70 71 /LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/host-nested-001-expected.html 71 72 /LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/host-nested-001.html 73 /LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/host-parsing.html 72 74 /LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/host-slotted-001-expected.html 73 75 /LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/host-slotted-001.html … … 126 128 /LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/shadow-root-insert-into-document-expected.html 127 129 /LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/shadow-root-insert-into-document.html 130 /LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/shadow-shared-style-cache-001.html 128 131 /LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/slot-non-html-display-value.html 129 132 /LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/slotted-invalidation.html -
trunk/Source/WebCore/ChangeLog
r284972 r284973 1 2021-10-28 Antti Koivisto <antti@apple.com> 2 3 Support ::before and ::after pseudo elements after ::slotted 4 https://bugs.webkit.org/show_bug.cgi?id=178237 5 6 Reviewed by Ryosuke Niwa. 7 8 Change the way we resolve ::slotted to improve compatibility. We now traverse through the assigned slot chain in 9 a single pass, similar to ::part matching. 10 11 * css/CSSSelector.cpp: 12 (WebCore::CSSSelector::selectorText const): 13 * css/CSSSelector.h: 14 15 Add a new selection relation ShadowSlotted, similar to the existing ShadowDescendant and ShadowPartDescendant, 16 for switching scopes during selector matching. 17 18 * css/SelectorChecker.cpp: 19 (WebCore::SelectorChecker::matchRecursively const): 20 21 Find the right scope to continue matching on ShadowSlotted relation. Pass in the scope ordinal to find the scope. 22 23 (WebCore::SelectorChecker::checkOne const): 24 25 Match the ::slotted() element. 26 27 * css/SelectorChecker.h: 28 * css/SelectorFilter.cpp: 29 (WebCore::collectSelectorHashes): 30 * css/parser/CSSParserSelector.h: 31 (WebCore::CSSParserSelector::needsImplicitShadowCombinatorForMatching const): 32 * css/parser/CSSSelectorParser.cpp: 33 (WebCore::isPseudoClassValidAfterPseudoElement): 34 (WebCore::isTreeAbidingPseudoElement): 35 36 Add a spec-termed helper. 37 38 (WebCore::isSimpleSelectorValidAfterPseudoElement): 39 (WebCore::CSSSelectorParser::splitCompoundAtImplicitShadowCrossingCombinator): 40 41 Insert ShadowSlotted relation for ::slotted(). 42 43 * cssjit/SelectorCompiler.cpp: 44 (WebCore::SelectorCompiler::fragmentRelationForSelectorRelation): 45 (WebCore::SelectorCompiler::constructFragmentsInternal): 46 * style/ElementRuleCollector.cpp: 47 (WebCore::Style::ElementRuleCollector::clearMatchedRules): 48 (WebCore::Style::ElementRuleCollector::matchSlottedPseudoElementRules): 49 50 Simply get the rules from scopes in the assinged slot chaing and match against them. 51 No need for two passes. 52 53 (WebCore::Style::ElementRuleCollector::ruleMatches): 54 (WebCore::Style::ElementRuleCollector::collectMatchingRulesForList): 55 (WebCore::Style::ElementRuleCollector::collectSlottedPseudoElementRulesForSlot): Deleted. 56 57 Not needed anymore. 58 59 (WebCore::Style::findSlottedPseudoElementSelector): Deleted. 60 * style/ElementRuleCollector.h: 61 * style/RuleFeature.cpp: 62 (WebCore::Style::RuleFeatureSet::computeNextMatchElement): 63 1 64 2021-10-28 Carlos Garcia Campos <cgarcia@igalia.com> 2 65 -
trunk/Source/WebCore/css/CSSSelector.cpp
r284865 r284973 824 824 case CSSSelector::ShadowDescendant: 825 825 case CSSSelector::ShadowPartDescendant: 826 case CSSSelector::ShadowSlotted: 826 827 builder.append(rightSide); 827 828 return tagHistory->selectorText(builder.toString()); -
trunk/Source/WebCore/css/CSSSelector.h
r284865 r284973 88 88 IndirectAdjacent, 89 89 ShadowDescendant, 90 ShadowPartDescendant 90 ShadowPartDescendant, 91 ShadowSlotted 91 92 }; 92 93 -
trunk/Source/WebCore/css/SelectorChecker.cpp
r284865 r284973 409 409 } 410 410 case CSSSelector::ShadowDescendant: 411 case CSSSelector::ShadowPartDescendant: 412 { 413 // When matching foo::part(bar) we skip directly to the tree of element 'foo'. 414 auto* shadowHost = relation == CSSSelector::ShadowPartDescendant ? checkingContext.shadowHostInPartRuleScope : context.element->shadowHost(); 415 if (!shadowHost) 416 return MatchResult::fails(Match::SelectorFailsCompletely); 417 nextContext.element = shadowHost; 418 nextContext.firstSelectorOfTheFragment = nextContext.selector; 419 nextContext.isSubjectOrAdjacentElement = false; 420 PseudoIdSet ignoreDynamicPseudo; 421 MatchResult result = matchRecursively(checkingContext, nextContext, ignoreDynamicPseudo); 422 423 return MatchResult::updateWithMatchType(result, matchType); 424 } 411 case CSSSelector::ShadowPartDescendant: { 412 // When matching foo::part(bar) we skip directly to the tree of element 'foo'. 413 auto* shadowHost = relation == CSSSelector::ShadowPartDescendant ? checkingContext.shadowHostInPartRuleScope : context.element->shadowHost(); 414 if (!shadowHost) 415 return MatchResult::fails(Match::SelectorFailsCompletely); 416 nextContext.element = shadowHost; 417 nextContext.firstSelectorOfTheFragment = nextContext.selector; 418 nextContext.isSubjectOrAdjacentElement = false; 419 PseudoIdSet ignoreDynamicPseudo; 420 MatchResult result = matchRecursively(checkingContext, nextContext, ignoreDynamicPseudo); 421 422 return MatchResult::updateWithMatchType(result, matchType); 423 } 424 case CSSSelector::ShadowSlotted: { 425 auto* slot = context.element->assignedSlot(); 426 if (!slot) 427 return MatchResult::fails(Match::SelectorFailsCompletely); 428 // We continue matching in the scope where this rule came from. 429 auto scopeDepth = static_cast<int>(checkingContext.styleScopeOrdinal); 430 while (--scopeDepth && slot->assignedSlot()) 431 slot = slot->assignedSlot(); 432 if (scopeDepth) 433 return MatchResult::fails(Match::SelectorFailsCompletely); 434 435 nextContext.element = slot; 436 nextContext.firstSelectorOfTheFragment = nextContext.selector; 437 nextContext.isSubjectOrAdjacentElement = false; 438 PseudoIdSet ignoreDynamicPseudo; 439 MatchResult result = matchRecursively(checkingContext, nextContext, ignoreDynamicPseudo); 440 441 return MatchResult::updateWithMatchType(result, matchType); 442 } 425 443 } 426 444 … … 1151 1169 } 1152 1170 #endif 1153 case CSSSelector::PseudoElementSlotted: 1154 // We see ::slotted() pseudo elements when collecting slotted rules from the slot shadow tree only. 1155 ASSERT(checkingContext.resolvingMode == Mode::CollectingRules); 1156 return is<HTMLSlotElement>(element); 1157 1171 case CSSSelector::PseudoElementSlotted: { 1172 if (!context.element->assignedSlot()) 1173 return false; 1174 auto* subselector = context.selector->selectorList()->first(); 1175 LocalContext subcontext(context); 1176 subcontext.selector = subselector; 1177 subcontext.firstSelectorOfTheFragment = subselector; 1178 subcontext.pseudoElementEffective = false; 1179 subcontext.inFunctionalPseudoClass = true; 1180 PseudoIdSet ignoredDynamicPseudo; 1181 return matchRecursively(checkingContext, subcontext, ignoredDynamicPseudo).match == Match::SelectorMatches; 1182 } 1158 1183 case CSSSelector::PseudoElementPart: { 1159 1184 auto translatePartNameToRuleScope = [&](AtomString partName) { -
trunk/Source/WebCore/css/SelectorChecker.h
r278253 r284973 31 31 #include "Element.h" 32 32 #include "StyleRelations.h" 33 #include "StyleScopeOrdinal.h" 33 34 34 35 namespace WebCore { … … 96 97 bool isMatchingHostPseudoClass { false }; 97 98 const Element* shadowHostInPartRuleScope { nullptr }; 99 Style::ScopeOrdinal styleScopeOrdinal { Style::ScopeOrdinal::Element }; 98 100 99 101 // FIXME: It would be nicer to have a separate object for return values. This requires some more work in the selector compiler. -
trunk/Source/WebCore/css/SelectorFilter.cpp
r284865 r284973 196 196 case CSSSelector::ShadowDescendant: 197 197 case CSSSelector::ShadowPartDescendant: 198 case CSSSelector::ShadowSlotted: 198 199 skipOverSubselectors = true; 199 200 break; -
trunk/Source/WebCore/css/parser/CSSParserSelector.h
r284865 r284973 104 104 #endif 105 105 || pseudoElementType() == CSSSelector::PseudoElementPart 106 || pseudoElementType() == CSSSelector::PseudoElementSlotted 106 107 || pseudoElementType() == CSSSelector::PseudoElementWebKitCustomLegacyPrefixed); 107 108 } -
trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp
r284865 r284973 344 344 case CSSSelector::PseudoElementPart: 345 345 return !isTreeStructuralPseudoClass(pseudoClass); 346 case CSSSelector::PseudoElementSlotted: 347 // FIXME: A WPT indicates :is/:where should be parsed but reduce to nothing as their content is not legal in the context. 348 return false; 346 349 case CSSSelector::PseudoElementResizer: 347 350 case CSSSelector::PseudoElementScrollbar: … … 362 365 } 363 366 367 static bool isTreeAbidingPseudoElement(CSSSelector::PseudoElementType pseudoElementType) 368 { 369 switch (pseudoElementType) { 370 // FIXME: This list should also include ::placeholder and ::file-selector-button 371 case CSSSelector::PseudoElementBefore: 372 case CSSSelector::PseudoElementAfter: 373 case CSSSelector::PseudoElementMarker: 374 return true; 375 default: 376 return false; 377 } 378 } 379 364 380 static bool isSimpleSelectorValidAfterPseudoElement(const CSSParserSelector& simpleSelector, CSSSelector::PseudoElementType compoundPseudoElement) 365 381 { … … 368 384 if (compoundPseudoElement == CSSSelector::PseudoElementPart) { 369 385 if (simpleSelector.match() == CSSSelector::PseudoElement && simpleSelector.pseudoElementType() != CSSSelector::PseudoElementPart) 386 return true; 387 } 388 if (compoundPseudoElement == CSSSelector::PseudoElementSlotted) { 389 if (simpleSelector.match() == CSSSelector::PseudoElement && isTreeAbidingPseudoElement(simpleSelector.pseudoElementType())) 370 390 return true; 371 391 } … … 1060 1080 bool isPart = splitAfter->tagHistory()->match() == CSSSelector::PseudoElement && splitAfter->tagHistory()->pseudoElementType() == CSSSelector::PseudoElementPart; 1061 1081 1082 // ::slotted() combines with other pseudo elements. 1083 bool isSlotted = splitAfter->tagHistory()->match() == CSSSelector::PseudoElement && splitAfter->tagHistory()->pseudoElementType() == CSSSelector::PseudoElementSlotted; 1084 1062 1085 std::unique_ptr<CSSParserSelector> secondCompound; 1063 1086 if (context.mode == UASheetMode || isPart) { … … 1069 1092 secondCompound = splitAfter->releaseTagHistory(); 1070 1093 1071 secondCompound->appendTagHistory(isPart ? CSSSelector::ShadowPartDescendant : CSSSelector::ShadowDescendant, WTFMove(compoundSelector)); 1094 auto relation = [&] { 1095 if (isSlotted) 1096 return CSSSelector::ShadowSlotted; 1097 if (isPart) 1098 return CSSSelector::ShadowPartDescendant; 1099 return CSSSelector::ShadowDescendant; 1100 }(); 1101 secondCompound->appendTagHistory(relation, WTFMove(compoundSelector)); 1072 1102 return secondCompound; 1073 1103 } -
trunk/Source/WebCore/cssjit/SelectorCompiler.cpp
r284865 r284973 502 502 case CSSSelector::ShadowDescendant: 503 503 case CSSSelector::ShadowPartDescendant: 504 case CSSSelector::ShadowSlotted: 504 505 ASSERT_NOT_REACHED(); 505 506 } … … 1327 1328 return FunctionType::CannotCompile; 1328 1329 1330 if (relation == CSSSelector::ShadowSlotted) 1331 return FunctionType::CannotCompile; 1332 1329 1333 if (relation == CSSSelector::DirectAdjacent || relation == CSSSelector::IndirectAdjacent) { 1330 1334 FunctionType relationFunctionType = FunctionType::SelectorCheckerWithCheckingContext; -
trunk/Source/WebCore/style/ElementRuleCollector.cpp
r284466 r284973 121 121 { 122 122 m_matchedRules.clear(); 123 m_keepAliveSlottedPseudoElementRules.clear();124 123 m_matchedRuleTransferIndex = 0; 125 124 } … … 284 283 if (!styleScope.resolver().ruleSets().isAuthorStyleDefined()) 285 284 continue; 286 // Find out if there are any ::slotted rules in the shadow tree matching the current slot. 287 // FIXME: This is really part of the slot style and could be cached when resolving it. 288 ElementRuleCollector collector(*slot, styleScope.resolver().ruleSets().authorStyle(), nullptr); 289 auto slottedPseudoElementRules = collector.collectSlottedPseudoElementRulesForSlot(); 290 if (!slottedPseudoElementRules) 291 continue; 292 // Match in the current scope. 293 SetForScope<bool> change(m_isMatchingSlottedPseudoElements, true); 294 295 MatchRequest scopeMatchRequest(nullptr, styleScopeOrdinal); 296 collectMatchingRulesForList(slottedPseudoElementRules.get(), scopeMatchRequest); 297 298 m_keepAliveSlottedPseudoElementRules.append(WTFMove(slottedPseudoElementRules)); 285 286 auto& scopeAuthorRules = styleScope.resolver().ruleSets().authorStyle(); 287 288 MatchRequest scopeMatchRequest(&scopeAuthorRules, styleScopeOrdinal); 289 collectMatchingRulesForList(&scopeAuthorRules.slottedPseudoElementRules(), scopeMatchRequest); 299 290 } 300 291 } … … 348 339 } 349 340 350 std::unique_ptr<RuleSet::RuleDataVector> ElementRuleCollector::collectSlottedPseudoElementRulesForSlot()351 {352 ASSERT(is<HTMLSlotElement>(element()));353 354 clearMatchedRules();355 356 m_mode = SelectorChecker::Mode::CollectingRules;357 358 // Match global author rules.359 MatchRequest matchRequest(m_authorStyle.ptr());360 collectMatchingRulesForList(&m_authorStyle->slottedPseudoElementRules(), matchRequest);361 362 if (m_matchedRules.isEmpty())363 return { };364 365 auto ruleDataVector = makeUnique<RuleSet::RuleDataVector>();366 ruleDataVector->reserveInitialCapacity(m_matchedRules.size());367 for (auto& matchedRule : m_matchedRules)368 ruleDataVector->uncheckedAppend(*matchedRule.ruleData);369 370 return ruleDataVector;371 }372 373 341 void ElementRuleCollector::matchUserRules() 374 342 { … … 408 376 } 409 377 410 static const CSSSelector* findSlottedPseudoElementSelector(const CSSSelector* selector) 411 { 412 for (; selector; selector = selector->tagHistory()) { 413 if (selector->match() == CSSSelector::PseudoElement && selector->pseudoElementType() == CSSSelector::PseudoElementSlotted) { 414 if (auto* list = selector->selectorList()) 415 return list->first(); 416 break; 417 } 418 }; 419 return nullptr; 420 } 421 422 inline bool ElementRuleCollector::ruleMatches(const RuleData& ruleData, unsigned& specificity) 378 inline bool ElementRuleCollector::ruleMatches(const RuleData& ruleData, unsigned& specificity, ScopeOrdinal styleScopeOrdinal) 423 379 { 424 380 // We know a sufficiently simple single part selector matches simply because we found it from the rule hash when filtering the RuleSet. … … 476 432 context.isMatchingHostPseudoClass = m_isMatchingHostPseudoClass; 477 433 context.shadowHostInPartRuleScope = m_shadowHostInPartRuleScope.get(); 434 context.styleScopeOrdinal = styleScopeOrdinal; 478 435 479 436 bool selectorMatches; … … 486 443 { 487 444 auto* selector = ruleData.selector(); 488 auto* selectorForMatching = selector;489 if (m_isMatchingSlottedPseudoElements) {490 selectorForMatching = findSlottedPseudoElementSelector(ruleData.selector());491 if (!selectorForMatching)492 return false;493 }494 445 // Slow path. 495 446 SelectorChecker selectorChecker(element().document()); 496 selectorMatches = selectorChecker.match(*selector ForMatching, element(), context);447 selectorMatches = selectorChecker.match(*selector, element(), context); 497 448 if (selectorMatches) 498 449 specificity = selector->computeSpecificity(); … … 536 487 537 488 unsigned specificity; 538 if (ruleMatches(ruleData, specificity ))489 if (ruleMatches(ruleData, specificity, matchRequest.styleScopeOrdinal)) 539 490 addMatchedRule(ruleData, specificity, matchRequest); 540 491 } -
trunk/Source/WebCore/style/ElementRuleCollector.h
r284466 r284973 136 136 137 137 void collectMatchingShadowPseudoElementRules(const MatchRequest&); 138 std::unique_ptr<RuleSet::RuleDataVector> collectSlottedPseudoElementRulesForSlot();139 138 140 139 void collectMatchingRules(const MatchRequest&); 141 140 void collectMatchingRulesForList(const RuleSet::RuleDataVector*, const MatchRequest&); 142 bool ruleMatches(const RuleData&, unsigned& specificity );141 bool ruleMatches(const RuleData&, unsigned& specificity, ScopeOrdinal); 143 142 144 143 void sortMatchedRules(); … … 164 163 PseudoElementRequest m_pseudoElementRequest { PseudoId::None }; 165 164 SelectorChecker::Mode m_mode { SelectorChecker::Mode::ResolvingStyle }; 166 bool m_isMatchingSlottedPseudoElements { false };167 165 bool m_isMatchingHostPseudoClass { false }; 168 166 RefPtr<const Element> m_shadowHostInPartRuleScope; 169 Vector<std::unique_ptr<RuleSet::RuleDataVector>> m_keepAliveSlottedPseudoElementRules;170 167 171 168 Vector<MatchedRule, 64> m_matchedRules; -
trunk/Source/WebCore/style/RuleFeature.cpp
r284865 r284973 87 87 case CSSSelector::ShadowPartDescendant: 88 88 return MatchElement::Host; 89 case CSSSelector::ShadowSlotted: 90 // FIXME: Implement accurate invalidation. 91 return matchElement; 89 92 }; 90 93 } … … 101 104 case CSSSelector::ShadowPartDescendant: 102 105 return MatchElement::Host; 106 case CSSSelector::ShadowSlotted: 107 // FIXME: Implement accurate invalidation. 108 return matchElement; 103 109 }; 104 110 ASSERT_NOT_REACHED();
Note: See TracChangeset
for help on using the changeset viewer.