haikuwebkit/LayoutTests/fast/css/nth-child-specificity-1-exp...

18 lines
768 B
HTML
Raw Permalink Normal View History

Add the dynamic specificity of the selector list argument when matching :nth-child() and :nth-last-child() https://bugs.webkit.org/show_bug.cgi?id=139001 Reviewed by Andreas Kling. Source/WebCore: When matching :nth-child(An+B of selector list) or :nth-last-child(An+B of selector list), we were previously ignoring the arguments. That behavior seems to be confusing for users. We made the proposal to include the selector list like when using :matches(): http://lists.w3.org/Archives/Public/www-style/2014Oct/0533.html David Baron also agrees with this behavior: http://lists.w3.org/Archives/Public/www-style/2014Oct/0534.html This patch adds the specificity computation. Tests: fast/css/nth-child-specificity-1.html fast/css/nth-child-specificity-2.html fast/css/nth-last-child-specificity-1.html fast/css/nth-last-child-specificity-2.html * css/CSSSelector.cpp: (WebCore::simpleSelectorFunctionalPseudoClassStaticSpecificity): * css/SelectorChecker.cpp: (WebCore::SelectorChecker::checkOne): (WebCore::SelectorChecker::matchSelectorList): * css/SelectorChecker.h: * cssjit/SelectorCompiler.cpp: (WebCore::SelectorCompiler::addPseudoClassType): LayoutTests: * fast/css/nth-child-specificity-1-expected.html: Added. * fast/css/nth-child-specificity-1.html: Added. * fast/css/nth-child-specificity-2-expected.html: Added. * fast/css/nth-child-specificity-2.html: Added. * fast/css/nth-child-specificity-3-expected.html: Added. * fast/css/nth-child-specificity-3.html: Added. * fast/css/nth-child-specificity-4-expected.html: Added. * fast/css/nth-child-specificity-4.html: Added. * fast/css/nth-last-child-specificity-1-expected.html: Added. * fast/css/nth-last-child-specificity-1.html: Added. * fast/css/nth-last-child-specificity-2-expected.html: Added. * fast/css/nth-last-child-specificity-2.html: Added. * fast/css/nth-last-child-specificity-3-expected.html: Added. * fast/css/nth-last-child-specificity-3.html: Added. * fast/css/nth-last-child-specificity-4-expected.html: Added. * fast/css/nth-last-child-specificity-4.html: Added. Canonical link: https://commits.webkit.org/157001@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176623 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-12-02 02:29:53 +00:00
<!doctype html>
<html>
<body>
<p>This test the specificity of :nth-child() with static specificity. The test passes if the text "target" is displayed white on green background. There should be 2 red rects on each side.</p>
<div>
<foo style="color: red; background-color: red;">Not target</foo>
<padding></padding>
<bar style="color: red; background-color: red;">Not target</bar>
<more-padding></more-padding>
<target style="color: white; background-color: green;">Target</target>
<more-padding></more-padding>
<foo style="color: red; background-color: red;">Not target</foo>
<padding></padding>
<bar style="color: red; background-color: red;">Not target</bar>
</div>
</body>
</html>