Changeset 175453 in webkit


Ignore:
Timestamp:
Nov 1, 2014 11:11:11 AM (9 years ago)
Author:
benjamin@webkit.org
Message:

Fix the specificity of the extended :not() selector
https://bugs.webkit.org/show_bug.cgi?id=138275

Patch by Benjamin Poulain <bpoulain@apple.com> on 2014-11-01
Reviewed by Andreas Kling.

Source/WebCore:

The current draft says "The specificity of a :not() pseudo-class
is the specificity of the most specifc complex selector in its selector list."

It is still unclear how :not() plays with other new selectors. Until that is clarified,
this only handle the simple cases.

Tests: fast/css/not-self-specificity.html

fast/css/not-specificity-1.html
fast/css/not-specificity-2.html
fast/css/not-specificity-3.html
fast/css/not-specificity-4.html
fast/css/not-specificity-5.html
fast/css/not-specificity-6.html

  • css/CSSSelector.cpp:

(WebCore::CSSSelector::specificityForOneSelector):

LayoutTests:

  • fast/css/not-self-specificity-expected.html: Added.
  • fast/css/not-self-specificity.html: Added.

Test that :not() itself does not influence the specificity,
only the nested selectors contribute to the global specificity.

  • fast/css/not-specificity-1-expected.html: Added.
  • fast/css/not-specificity-1.html: Added.
  • fast/css/not-specificity-2-expected.html: Added.
  • fast/css/not-specificity-2.html: Added.
  • fast/css/not-specificity-3-expected.html: Added.
  • fast/css/not-specificity-3.html: Added.

Tests for compound selectors.
All tests are variations of the same base testing specificity
and position.

  • fast/css/not-specificity-4-expected.html: Added.
  • fast/css/not-specificity-4.html: Added.
  • fast/css/not-specificity-5-expected.html: Added.
  • fast/css/not-specificity-5.html: Added.
  • fast/css/not-specificity-6-expected.html: Added.
  • fast/css/not-specificity-6.html: Added.

Same thing for complex selectors.

  • fast/selectors/class-style-update-with-not-expected.txt:

Yeah, one more test fixed :)

Location:
trunk
Files:
14 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r175452 r175453  
     12014-11-01  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        Fix the specificity of the extended :not() selector
     4        https://bugs.webkit.org/show_bug.cgi?id=138275
     5
     6        Reviewed by Andreas Kling.
     7
     8        * fast/css/not-self-specificity-expected.html: Added.
     9        * fast/css/not-self-specificity.html: Added.
     10        Test that :not() itself does not influence the specificity,
     11        only the nested selectors contribute to the global specificity.
     12
     13        * fast/css/not-specificity-1-expected.html: Added.
     14        * fast/css/not-specificity-1.html: Added.
     15        * fast/css/not-specificity-2-expected.html: Added.
     16        * fast/css/not-specificity-2.html: Added.
     17        * fast/css/not-specificity-3-expected.html: Added.
     18        * fast/css/not-specificity-3.html: Added.
     19        Tests for compound selectors.
     20        All tests are variations of the same base testing specificity
     21        and position.
     22
     23        * fast/css/not-specificity-4-expected.html: Added.
     24        * fast/css/not-specificity-4.html: Added.
     25        * fast/css/not-specificity-5-expected.html: Added.
     26        * fast/css/not-specificity-5.html: Added.
     27        * fast/css/not-specificity-6-expected.html: Added.
     28        * fast/css/not-specificity-6.html: Added.
     29        Same thing for complex selectors.
     30
     31        * fast/selectors/class-style-update-with-not-expected.txt:
     32        Yeah, one more test fixed :)
     33
    1342014-11-01  Hunseop Jeong  <hs85.jeong@samsung.com>
    235
  • trunk/LayoutTests/fast/selectors/class-style-update-with-not-expected.txt

    r175018 r175453  
    2828PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(0, 1, 2)"
    2929PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 1, 2)"
    30 FAIL getComputedStyle(document.querySelectorAll("target")[0]).color should be rgb(3, 4, 5). Was rgb(0, 1, 2).
    31 FAIL getComputedStyle(document.querySelectorAll("target")[1]).color should be rgb(3, 4, 5). Was rgb(0, 1, 2).
    32 FAIL getComputedStyle(document.querySelectorAll("target")[0]).color should be rgb(6, 7, 8). Was rgb(0, 1, 2).
    33 FAIL getComputedStyle(document.querySelectorAll("target")[1]).color should be rgb(6, 7, 8). Was rgb(0, 1, 2).
    34 FAIL getComputedStyle(document.querySelectorAll("target")[0]).color should be rgb(9, 10, 11). Was rgb(0, 1, 2).
    35 FAIL getComputedStyle(document.querySelectorAll("target")[1]).color should be rgb(9, 10, 11). Was rgb(0, 1, 2).
    36 FAIL getComputedStyle(document.querySelectorAll("target")[0]).color should be rgb(12, 13, 14). Was rgb(0, 1, 2).
    37 FAIL getComputedStyle(document.querySelectorAll("target")[1]).color should be rgb(12, 13, 14). Was rgb(0, 1, 2).
     30PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(3, 4, 5)"
     31PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(3, 4, 5)"
     32PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(6, 7, 8)"
     33PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(6, 7, 8)"
     34PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(9, 10, 11)"
     35PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(9, 10, 11)"
     36PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(12, 13, 14)"
     37PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(12, 13, 14)"
    3838PASS successfullyParsed is true
    3939
  • trunk/Source/WebCore/ChangeLog

    r175447 r175453  
     12014-11-01  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        Fix the specificity of the extended :not() selector
     4        https://bugs.webkit.org/show_bug.cgi?id=138275
     5
     6        Reviewed by Andreas Kling.
     7
     8        The current draft says "The specificity of a :not() pseudo-class
     9        is the specificity of the most specifc complex selector in its selector list."
     10
     11        It is still unclear how :not() plays with other new selectors. Until that is clarified,
     12        this only handle the simple cases.
     13
     14        Tests: fast/css/not-self-specificity.html
     15               fast/css/not-specificity-1.html
     16               fast/css/not-specificity-2.html
     17               fast/css/not-specificity-3.html
     18               fast/css/not-specificity-4.html
     19               fast/css/not-specificity-5.html
     20               fast/css/not-specificity-6.html
     21
     22        * css/CSSSelector.cpp:
     23        (WebCore::CSSSelector::specificityForOneSelector):
     24
    1252014-10-31  Benjamin Poulain  <bpoulain@apple.com>
    226
  • trunk/Source/WebCore/css/CSSSelector.cpp

    r175447 r175453  
    102102        // FIXME: PseudoAny should base the specificity on the sub-selectors.
    103103        // See http://lists.w3.org/Archives/Public/www-style/2010Sep/0530.html
     104
     105#if ENABLE(CSS_SELECTORS_LEVEL4)
     106        if (pseudoClassType() == PseudoClassNot) {
     107            ASSERT_WITH_MESSAGE(selectorList() && selectorList()->first(), "The parser should never generate a valid selector for an empty :not().");
     108
     109            unsigned maxSpecificity = 0;
     110            for (const CSSSelector* subSelector = selectorList()->first(); subSelector; subSelector = CSSSelectorList::next(subSelector))
     111                maxSpecificity = std::max(maxSpecificity, subSelector->specificity());
     112            return maxSpecificity;
     113        }
     114        FALLTHROUGH;
     115#else
    104116        if (pseudoClassType() == PseudoClassNot && selectorList())
    105117            return selectorList()->first()->specificityForOneSelector();
    106118        FALLTHROUGH;
     119#endif
    107120    case Exact:
    108121    case Class:
Note: See TracChangeset for help on using the changeset viewer.