Changeset 285032 in webkit


Ignore:
Timestamp:
Oct 29, 2021 9:22:04 AM (9 months ago)
Author:
Antti Koivisto
Message:

Make :-webkit-any() a synonym of :is()
https://bugs.webkit.org/show_bug.cgi?id=232482

Reviewed by Simon Fraser.

Source/WebCore:

:-webkit-any() is an obscure obsolete subset version of the standard :is(). It can become a full synonym.
Another obsolete version :matches() is already a full synonym.

The main difference is that :is allows complex selectors and uses forgiving parsing.

  • css/SelectorChecker.cpp:

(WebCore::SelectorChecker::checkOne const):

  • css/parser/CSSSelectorParser.cpp:

(WebCore::CSSSelectorParser::consumePseudo):

  • cssjit/SelectorCompiler.cpp:

(WebCore::SelectorCompiler::addPseudoClassType):

LayoutTests:

  • fast/css/pseudo-any-expected.txt:
  • fast/css/pseudo-any.html:
  • fast/dom/SelectorAPI/not-supported-namespace-in-selector-expected.txt:
  • fast/dom/SelectorAPI/not-supported-namespace-in-selector.html:
  • fast/selectors/invalid-functional-pseudo-class-expected.txt:
  • fast/selectors/invalid-functional-pseudo-class.html:
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r285030 r285032  
     12021-10-29  Antti Koivisto  <antti@apple.com>
     2
     3        Make :-webkit-any() a synonym of :is()
     4        https://bugs.webkit.org/show_bug.cgi?id=232482
     5
     6        Reviewed by Simon Fraser.
     7
     8        * fast/css/pseudo-any-expected.txt:
     9        * fast/css/pseudo-any.html:
     10        * fast/dom/SelectorAPI/not-supported-namespace-in-selector-expected.txt:
     11        * fast/dom/SelectorAPI/not-supported-namespace-in-selector.html:
     12        * fast/selectors/invalid-functional-pseudo-class-expected.txt:
     13        * fast/selectors/invalid-functional-pseudo-class.html:
     14
    1152021-10-29  Ayumi Kojima  <ayumi_kojima@apple.com>
    216
  • trunk/LayoutTests/fast/css/pseudo-any-expected.txt

    r82183 r285032  
    7676
    7777s
    78 PASS document.defaultView.getComputedStyle(element, null).getPropertyValue('background-color') is 'rgba(0, 0, 0, 0)'
     78PASS document.defaultView.getComputedStyle(element, null).getPropertyValue('background-color') is 'rgb(0, 0, 255)'
    7979
    8080div span
  • trunk/LayoutTests/fast/css/pseudo-any.html

    r155263 r285032  
    2222
    2323:-webkit-any(s,:nonexistentpseudo) {
    24     background-color: red;
     24    background-color: blue;
    2525}
    2626
    2727div~q {
    28     background-color: blue;
     28    background-color: red;
    2929}
    3030:-webkit-any(div ~ q) {
     
    3232}
    3333:-webkit-any(div~q) {
    34     background-color: red;
     34    background-color: blue;
    3535}
    3636
    3737q+q {
    38     background-color: blue;
     38    background-color: red;
    3939}
    4040:-webkit-any(q+q) {
    41     background-color: red;
     41    background-color: blue;
    4242}
    4343
    4444q>span {
    45     background-color: blue;
     45    background-color: red;
    4646}
    4747:-webkit-any(q>span) {
    48     background-color: red;
     48    background-color: blue;
    4949}
    5050
     
    5656}
    5757:-webkit-any( div span ) {
    58     background-color: red;
     58    background-color: blue;
    5959}
    6060</style>
     
    153153assertWhite("#container-div a[name]");
    154154
    155 assertWhite("s");
     155assertBlue("s");
    156156assertBlue("div span");
    157157assertBlue("div ~ q");
  • trunk/LayoutTests/fast/dom/SelectorAPI/not-supported-namespace-in-selector-expected.txt

    r219663 r285032  
    3737PASS: document.body.matches('[|name=value]') did not throw
    3838PASS: document.body.webkitMatchesSelector('[|name=value]') did not throw
    39 PASS: document.querySelector(':-webkit-any(bbb|pre)') throws: SyntaxError: The string did not match the expected pattern.
     39PASS: document.querySelector(':-webkit-any(bbb|pre)') did not throw
    4040PASS: document.querySelector('div [bbb|name=value]') throws: SyntaxError: The string did not match the expected pattern.
    4141PASS: document.querySelectorAll('div [bbb|name=value]') throws: SyntaxError: The string did not match the expected pattern.
  • trunk/LayoutTests/fast/dom/SelectorAPI/not-supported-namespace-in-selector.html

    r167631 r285032  
    7171        shouldNotThrow("document.body.webkitMatchesSelector('[|name=value]')");
    7272
    73         shouldThrow("document.querySelector(':-webkit-any(bbb|pre)')");
     73        shouldNotThrow("document.querySelector(':-webkit-any(bbb|pre)')");
    7474
    7575        shouldThrow("document.querySelector('div [bbb|name=value]')");
  • trunk/LayoutTests/fast/selectors/invalid-functional-pseudo-class-expected.txt

    r268741 r285032  
    88PASS document.querySelectorAll(":-webkit-any\\\").length threw exception SyntaxError: Unexpected EOF.
    99PASS document.querySelectorAll(":-webkit-any\\\\").length threw exception SyntaxError: The string did not match the expected pattern..
    10 PASS document.querySelectorAll(":-webkit-any\(").length threw exception SyntaxError: The string did not match the expected pattern..
     10PASS document.querySelectorAll(":-webkit-any\(").length did not throw exception.
    1111PASS document.querySelectorAll(":-webkit-any\\(").length threw exception SyntaxError: The string did not match the expected pattern..
    1212PASS document.querySelectorAll(":-webkit-any\\\(").length threw exception SyntaxError: The string did not match the expected pattern..
     
    1919PASS document.querySelectorAll(":-webkit-any\\\( .foo").length threw exception SyntaxError: The string did not match the expected pattern..
    2020PASS document.querySelectorAll(":-webkit-any\\\\( .foo").length threw exception SyntaxError: The string did not match the expected pattern..
    21 PASS document.querySelectorAll(":-webkit-any\()").length threw exception SyntaxError: The string did not match the expected pattern..
     21PASS document.querySelectorAll(":-webkit-any\()").length did not throw exception.
    2222PASS document.querySelectorAll(":-webkit-any\\()").length threw exception SyntaxError: The string did not match the expected pattern..
    2323PASS document.querySelectorAll(":-webkit-any\\\()").length threw exception SyntaxError: The string did not match the expected pattern..
  • trunk/LayoutTests/fast/selectors/invalid-functional-pseudo-class.html

    r268741 r285032  
    3939
    4040function testQuerySelector(functonalPseudoClassName) {
    41     for (var testCase of invalidRules(functonalPseudoClassName))
     41    for (var testCase of invalidRules(functonalPseudoClassName)) {
     42        if (testCase == ':-webkit-any\\()' || testCase == ':-webkit-any\\(') {
     43            shouldNotThrow('document.querySelectorAll("' + testCase + '").length');
     44            continue;
     45        }
    4246        shouldThrow('document.querySelectorAll("' + testCase + '").length');
     47    }
    4348}
    4449
  • trunk/Source/WebCore/ChangeLog

    r285030 r285032  
     12021-10-29  Antti Koivisto  <antti@apple.com>
     2
     3        Make :-webkit-any() a synonym of :is()
     4        https://bugs.webkit.org/show_bug.cgi?id=232482
     5
     6        Reviewed by Simon Fraser.
     7
     8        :-webkit-any() is an obscure obsolete subset version of the standard :is(). It can become a full synonym.
     9        Another obsolete version :matches() is already a full synonym.
     10
     11        The main difference is that :is allows complex selectors and uses forgiving parsing.
     12
     13        * css/SelectorChecker.cpp:
     14        (WebCore::SelectorChecker::checkOne const):
     15        * css/parser/CSSSelectorParser.cpp:
     16        (WebCore::CSSSelectorParser::consumePseudo):
     17        * cssjit/SelectorCompiler.cpp:
     18        (WebCore::SelectorCompiler::addPseudoClassType):
     19
    1202021-10-29  Ayumi Kojima  <ayumi_kojima@apple.com>
    221
  • trunk/Source/WebCore/css/SelectorChecker.cpp

    r284973 r285032  
    816816        }
    817817        case CSSSelector::PseudoClassIs:
     818        case CSSSelector::PseudoClassWhere:
    818819        case CSSSelector::PseudoClassMatches:
    819         case CSSSelector::PseudoClassWhere:
     820        case CSSSelector::PseudoClassAny:
    820821            {
    821822                bool hasMatchedAnything = false;
     
    966967            if (&element == element.document().cssTarget())
    967968                return true;
    968             break;
    969         case CSSSelector::PseudoClassAny:
    970             {
    971                 LocalContext subcontext(context);
    972                 subcontext.inFunctionalPseudoClass = true;
    973                 subcontext.pseudoElementEffective = false;
    974                 for (subcontext.selector = selector.selectorList()->first(); subcontext.selector; subcontext.selector = CSSSelectorList::next(subcontext.selector)) {
    975                     subcontext.firstSelectorOfTheFragment = subcontext.selector;
    976                     PseudoIdSet ignoreDynamicPseudo;
    977                     if (matchRecursively(checkingContext, subcontext, ignoreDynamicPseudo).match == Match::SelectorMatches)
    978                         return true;
    979                 }
    980             }
    981969            break;
    982970        case CSSSelector::PseudoClassAutofill:
  • trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp

    r284973 r285032  
    743743        }
    744744        case CSSSelector::PseudoClassIs:
     745        case CSSSelector::PseudoClassWhere:
    745746        case CSSSelector::PseudoClassMatches:
    746         case CSSSelector::PseudoClassWhere: {
     747        case CSSSelector::PseudoClassAny: {
    747748            SetForScope<bool> resistDefaultNamespace(m_resistDefaultNamespace, true);
    748749            DisallowPseudoElementsScope scope(*this);
     
    754755            return selector;
    755756        }
    756         case CSSSelector::PseudoClassAny:
    757757        case CSSSelector::PseudoClassHost: {
    758758            auto selectorList = makeUnique<CSSSelectorList>();
  • trunk/Source/WebCore/cssjit/SelectorCompiler.cpp

    r284973 r285032  
    10661066            return functionType;
    10671067        }
    1068 
    1069     case CSSSelector::PseudoClassAny:
    1070         {
    1071             Vector<SelectorFragment, 32> anyFragments;
    1072             FunctionType functionType = FunctionType::SimpleSelectorChecker;
    1073             for (const CSSSelector* rootSelector = selector.selectorList()->first(); rootSelector; rootSelector = CSSSelectorList::next(rootSelector)) {
    1074                 SelectorFragmentList fragmentList;
    1075                 VisitedMode ignoreVisitedMode = VisitedMode::None;
    1076                 FunctionType subFunctionType = constructFragments(rootSelector, selectorContext, fragmentList, FragmentsLevel::InFunctionalPseudoType, positionInRootFragments, visitedMatchEnabled, ignoreVisitedMode, PseudoElementMatchingBehavior::NeverMatch);
    1077                 ASSERT_WITH_MESSAGE(ignoreVisitedMode == VisitedMode::None, ":visited is disabled in the functional pseudo classes");
    1078 
    1079                 // Since this fragment always unmatch against the element, don't insert it to anyFragments.
    1080                 if (subFunctionType == FunctionType::CannotMatchAnything)
    1081                     continue;
    1082 
    1083                 if (subFunctionType == FunctionType::CannotCompile)
    1084                     return FunctionType::CannotCompile;
    1085 
    1086                 // :any() may not contain complex selectors which have combinators.
    1087                 ASSERT(fragmentList.size() == 1);
    1088                 if (fragmentList.size() != 1)
    1089                     return FunctionType::CannotCompile;
    1090 
    1091                 const SelectorFragment& subFragment = fragmentList.first();
    1092                 anyFragments.append(subFragment);
    1093                 functionType = mostRestrictiveFunctionType(functionType, subFunctionType);
    1094             }
    1095 
    1096             // Since all fragments in :any() cannot match anything, this :any() filter cannot match anything.
    1097             if (anyFragments.isEmpty())
    1098                 return FunctionType::CannotMatchAnything;
    1099 
    1100             ASSERT(!anyFragments.isEmpty());
    1101             fragment.anyFilters.append(anyFragments);
    1102 
    1103             return functionType;
    1104         }
    1105 
    11061068    case CSSSelector::PseudoClassLang:
    11071069        {
     
    11131075
    11141076    case CSSSelector::PseudoClassIs:
     1077    case CSSSelector::PseudoClassWhere:
    11151078    case CSSSelector::PseudoClassMatches:
    1116     case CSSSelector::PseudoClassWhere:
     1079    case CSSSelector::PseudoClassAny:
    11171080        {
    11181081            SelectorList matchesList;
Note: See TracChangeset for help on using the changeset viewer.