haikuwebkit/LayoutTests/fast/selectors/where-specificity.html

61 lines
2.5 KiB
HTML
Raw Permalink Normal View History

[CSS selectors] Support :where() pseudo class https://bugs.webkit.org/show_bug.cgi?id=210690 Reviewed by Sam Weinig. LayoutTests/imported/w3c: * web-platform-tests/css/selectors/invalidation/where-expected.txt: Source/WebCore: "The Specificity-adjustment pseudo-class, :where(), is a functional pseudo-class with the same syntax and functionality as :is(). Unlike :is(), neither the :where pseudo-class, nor any of its arguments contribute to the specificity of the selector—its specificity is always zero. This is useful for introducing filters in a selector while keeping the associated style declarations easy to override." https://drafts.csswg.org/selectors-4/#zero-matches In terms of implementation this is just another alias for :is() with different (always 0) specificity. Test: fast/selectors/where-specificity.html * css/CSSSelector.cpp: (WebCore::simpleSelectorSpecificityInternal): Here is where it differs from PseudoClassIs. (WebCore::CSSSelector::selectorText const): * css/CSSSelector.h: * css/SelectorChecker.cpp: (WebCore::SelectorChecker::checkOne const): * css/SelectorPseudoClassAndCompatibilityElementMap.in: * css/parser/CSSSelectorParser.cpp: (WebCore::isOnlyPseudoClassFunction): (WebCore::CSSSelectorParser::consumePseudo): * cssjit/SelectorCompiler.cpp: (WebCore::SelectorCompiler::addPseudoClassType): LayoutTests: * fast/selectors/where-specificity-expected.html: Added. * fast/selectors/where-specificity.html: Added. Canonical link: https://commits.webkit.org/223580@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260319 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-18 20:24:31 +00:00
<!doctype html>
<style>
test { display: block; }
.case1 :where(#test) { color: red; background-color: green; }
.case1 #test { color: black; }
.case2 :where(.test) { color: red; background-color: green; }
.case2 .test { color: black; }
.case3 :where(test) { color: red; background-color: green; }
.case3 test { color: black; }
.case4 :where(#other, div .test) { color: red; background-color: green; }
.case4 .test { color: black; }
.case5 #test { color: black; }
.case5 :where(#test) { color: red; background-color: green; }
.case6 .test { color: black; }
.case6 :where(.test) { color: red; background-color: green; }
.case7 test { color: black; }
.case7 :where(test) { color: red; background-color: green; }
.case8 .test { color: black; }
.case8 :where(#other, div .test) { color: red; background-color: green; }
.case9 #test:where(#test) { color: red; background-color: green; }
.case9 #test { color: black; }
.case10 .test:where(.test) { color: red; background-color: green; }
.case10 .test { color: black; }
.case11 test:where(test) { color: red; background-color: green; }
.case11 test { color: black; }
div.case12 .test:where(#other, div .test) { color: red; background-color: green; }
div.case12 .test { color: black; }
.case13 #test { color: red; }
.case13 #test:where(#test) { color: black; background-color: green; }
.case14 .test { color: red; }
.case14 .test:where(.test) { color: black; background-color: green; }
.case15 test { color: red; }
.case15 test:where(test) { color: black; background-color: green; }
div.case16 .test { color: red; }
div.case16 .test:where(#other, div .test) { color: black; background-color: green; }
</style>
<div class=case1><div id=test>Black on green</div></div>
<div class=case2><div class=test>Black on green</div></div>
<div class=case3><test>Black on green</test></div>
<div class=case4><div class=test>Black on green</div></div>
<div class=case5><div id=test>Black on green</div></div>
<div class=case6><div class=test>Black on green</div></div>
<div class=case7><test>Black on green</test></div>
<div class=case8><div class=test>Black on green</div></div>
<div class=case9><div id=test>Black on green</div></div>
<div class=case10><div class=test>Black on green</div></div>
<div class=case11><test>Black on green</test></div>
<div class=case12><div class=test>Black on green</div></div>
<div class=case13><div id=test>Black on green</div></div>
<div class=case14><div class=test>Black on green</div></div>
<div class=case15><test>Black on green</test></div>
<div class=case16><div class=test>Black on green</div></div>