Title: [285032] trunk
Revision
285032
Author
[email protected]
Date
2021-10-29 09:22:04 -0700 (Fri, 29 Oct 2021)

Log 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:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (285031 => 285032)


--- trunk/LayoutTests/ChangeLog	2021-10-29 15:52:38 UTC (rev 285031)
+++ trunk/LayoutTests/ChangeLog	2021-10-29 16:22:04 UTC (rev 285032)
@@ -1,3 +1,17 @@
+2021-10-29  Antti Koivisto  <[email protected]>
+
+        Make :-webkit-any() a synonym of :is()
+        https://bugs.webkit.org/show_bug.cgi?id=232482
+
+        Reviewed by Simon Fraser.
+
+        * 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:
+
 2021-10-29  Ayumi Kojima  <[email protected]>
 
         Unreviewed, reverting r285007.

Modified: trunk/LayoutTests/fast/css/pseudo-any-expected.txt (285031 => 285032)


--- trunk/LayoutTests/fast/css/pseudo-any-expected.txt	2021-10-29 15:52:38 UTC (rev 285031)
+++ trunk/LayoutTests/fast/css/pseudo-any-expected.txt	2021-10-29 16:22:04 UTC (rev 285032)
@@ -75,7 +75,7 @@
 PASS document.defaultView.getComputedStyle(element, null).getPropertyValue('background-color') is 'rgba(0, 0, 0, 0)'
 
 s
-PASS document.defaultView.getComputedStyle(element, null).getPropertyValue('background-color') is 'rgba(0, 0, 0, 0)'
+PASS document.defaultView.getComputedStyle(element, null).getPropertyValue('background-color') is 'rgb(0, 0, 255)'
 
 div span
 PASS document.defaultView.getComputedStyle(element, null).getPropertyValue('background-color') is 'rgb(0, 0, 255)'

Modified: trunk/LayoutTests/fast/css/pseudo-any.html (285031 => 285032)


--- trunk/LayoutTests/fast/css/pseudo-any.html	2021-10-29 15:52:38 UTC (rev 285031)
+++ trunk/LayoutTests/fast/css/pseudo-any.html	2021-10-29 16:22:04 UTC (rev 285032)
@@ -21,31 +21,31 @@
 }
 
 :-webkit-any(s,:nonexistentpseudo) {
-    background-color: red;
+    background-color: blue;
 }
 
 div~q {
-    background-color: blue;
+    background-color: red;
 }
 :-webkit-any(div ~ q) {
     background-color: red;
 }
 :-webkit-any(div~q) {
-    background-color: red;
+    background-color: blue;
 }
 
 q+q {
-    background-color: blue;
+    background-color: red;
 }
 :-webkit-any(q+q) {
-    background-color: red;
+    background-color: blue;
 }
 
 q>span {
-    background-color: blue;
+    background-color: red;
 }
 :-webkit-any(q>span) {
-    background-color: red;
+    background-color: blue;
 }
 
 div span {
@@ -55,7 +55,7 @@
     background-color: red;
 }
 :-webkit-any( div span ) {
-    background-color: red;
+    background-color: blue;
 }
 </style>
 This page tests :-webkit-any. This window needs to be focused for the :focus tests to pass.<br>
@@ -152,7 +152,7 @@
 assertGreen("#container-div div");
 assertWhite("#container-div a[name]");
 
-assertWhite("s");
+assertBlue("s");
 assertBlue("div span");
 assertBlue("div ~ q");
 assertBlue("q+q");

Modified: trunk/LayoutTests/fast/dom/SelectorAPI/not-supported-namespace-in-selector-expected.txt (285031 => 285032)


--- trunk/LayoutTests/fast/dom/SelectorAPI/not-supported-namespace-in-selector-expected.txt	2021-10-29 15:52:38 UTC (rev 285031)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/not-supported-namespace-in-selector-expected.txt	2021-10-29 16:22:04 UTC (rev 285032)
@@ -36,7 +36,7 @@
 PASS: document.querySelectorAll('[|name=value]') did not throw
 PASS: document.body.matches('[|name=value]') did not throw
 PASS: document.body.webkitMatchesSelector('[|name=value]') did not throw
-PASS: document.querySelector(':-webkit-any(bbb|pre)') throws: SyntaxError: The string did not match the expected pattern.
+PASS: document.querySelector(':-webkit-any(bbb|pre)') did not throw
 PASS: document.querySelector('div [bbb|name=value]') throws: SyntaxError: The string did not match the expected pattern.
 PASS: document.querySelectorAll('div [bbb|name=value]') throws: SyntaxError: The string did not match the expected pattern.
 PASS: document.body.matches('div [bbb|name=value]') throws: SyntaxError: The string did not match the expected pattern.

Modified: trunk/LayoutTests/fast/dom/SelectorAPI/not-supported-namespace-in-selector.html (285031 => 285032)


--- trunk/LayoutTests/fast/dom/SelectorAPI/not-supported-namespace-in-selector.html	2021-10-29 15:52:38 UTC (rev 285031)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/not-supported-namespace-in-selector.html	2021-10-29 16:22:04 UTC (rev 285032)
@@ -70,7 +70,7 @@
         shouldNotThrow("document.body.matches('[|name=value]')");
         shouldNotThrow("document.body.webkitMatchesSelector('[|name=value]')");
 
-        shouldThrow("document.querySelector(':-webkit-any(bbb|pre)')");
+        shouldNotThrow("document.querySelector(':-webkit-any(bbb|pre)')");
 
         shouldThrow("document.querySelector('div [bbb|name=value]')");
         shouldThrow("document.querySelectorAll('div [bbb|name=value]')");

Modified: trunk/LayoutTests/fast/selectors/invalid-functional-pseudo-class-expected.txt (285031 => 285032)


--- trunk/LayoutTests/fast/selectors/invalid-functional-pseudo-class-expected.txt	2021-10-29 15:52:38 UTC (rev 285031)
+++ trunk/LayoutTests/fast/selectors/invalid-functional-pseudo-class-expected.txt	2021-10-29 16:22:04 UTC (rev 285032)
@@ -7,7 +7,7 @@
 PASS document.querySelectorAll(":-webkit-any\\").length threw exception SyntaxError: The string did not match the expected pattern..
 PASS document.querySelectorAll(":-webkit-any\\\").length threw exception SyntaxError: Unexpected EOF.
 PASS document.querySelectorAll(":-webkit-any\\\\").length threw exception SyntaxError: The string did not match the expected pattern..
-PASS document.querySelectorAll(":-webkit-any\(").length threw exception SyntaxError: The string did not match the expected pattern..
+PASS document.querySelectorAll(":-webkit-any\(").length did not throw exception.
 PASS document.querySelectorAll(":-webkit-any\\(").length threw exception SyntaxError: The string did not match the expected pattern..
 PASS document.querySelectorAll(":-webkit-any\\\(").length threw exception SyntaxError: The string did not match the expected pattern..
 PASS document.querySelectorAll(":-webkit-any\\\\(").length threw exception SyntaxError: The string did not match the expected pattern..
@@ -18,7 +18,7 @@
 PASS document.querySelectorAll(":-webkit-any\\( .foo").length threw exception SyntaxError: The string did not match the expected pattern..
 PASS document.querySelectorAll(":-webkit-any\\\( .foo").length threw exception SyntaxError: The string did not match the expected pattern..
 PASS document.querySelectorAll(":-webkit-any\\\\( .foo").length threw exception SyntaxError: The string did not match the expected pattern..
-PASS document.querySelectorAll(":-webkit-any\()").length threw exception SyntaxError: The string did not match the expected pattern..
+PASS document.querySelectorAll(":-webkit-any\()").length did not throw exception.
 PASS document.querySelectorAll(":-webkit-any\\()").length threw exception SyntaxError: The string did not match the expected pattern..
 PASS document.querySelectorAll(":-webkit-any\\\()").length threw exception SyntaxError: The string did not match the expected pattern..
 PASS document.querySelectorAll(":-webkit-any\\\\()").length threw exception SyntaxError: The string did not match the expected pattern..

Modified: trunk/LayoutTests/fast/selectors/invalid-functional-pseudo-class.html (285031 => 285032)


--- trunk/LayoutTests/fast/selectors/invalid-functional-pseudo-class.html	2021-10-29 15:52:38 UTC (rev 285031)
+++ trunk/LayoutTests/fast/selectors/invalid-functional-pseudo-class.html	2021-10-29 16:22:04 UTC (rev 285032)
@@ -38,8 +38,13 @@
 }
 
 function testQuerySelector(functonalPseudoClassName) {
-    for (var testCase of invalidRules(functonalPseudoClassName))
+    for (var testCase of invalidRules(functonalPseudoClassName)) {
+        if (testCase == ':-webkit-any\\()' || testCase == ':-webkit-any\\(') {
+            shouldNotThrow('document.querySelectorAll("' + testCase + '").length');
+            continue;
+        }
         shouldThrow('document.querySelectorAll("' + testCase + '").length');
+    }
 }
 
 function testStyling(functonalPseudoClassName) {

Modified: trunk/Source/WebCore/ChangeLog (285031 => 285032)


--- trunk/Source/WebCore/ChangeLog	2021-10-29 15:52:38 UTC (rev 285031)
+++ trunk/Source/WebCore/ChangeLog	2021-10-29 16:22:04 UTC (rev 285032)
@@ -1,3 +1,22 @@
+2021-10-29  Antti Koivisto  <[email protected]>
+
+        Make :-webkit-any() a synonym of :is()
+        https://bugs.webkit.org/show_bug.cgi?id=232482
+
+        Reviewed by Simon Fraser.
+
+        :-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):
+
 2021-10-29  Ayumi Kojima  <[email protected]>
 
         Unreviewed, reverting r285007.

Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (285031 => 285032)


--- trunk/Source/WebCore/css/SelectorChecker.cpp	2021-10-29 15:52:38 UTC (rev 285031)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp	2021-10-29 16:22:04 UTC (rev 285032)
@@ -815,8 +815,9 @@
             return isFirstOfType(element, element.tagQName()) && isLastOfType(element, element.tagQName());
         }
         case CSSSelector::PseudoClassIs:
+        case CSSSelector::PseudoClassWhere:
         case CSSSelector::PseudoClassMatches:
-        case CSSSelector::PseudoClassWhere:
+        case CSSSelector::PseudoClassAny:
             {
                 bool hasMatchedAnything = false;
 
@@ -966,19 +967,6 @@
             if (&element == element.document().cssTarget())
                 return true;
             break;
-        case CSSSelector::PseudoClassAny:
-            {
-                LocalContext subcontext(context);
-                subcontext.inFunctionalPseudoClass = true;
-                subcontext.pseudoElementEffective = false;
-                for (subcontext.selector = selector.selectorList()->first(); subcontext.selector; subcontext.selector = CSSSelectorList::next(subcontext.selector)) {
-                    subcontext.firstSelectorOfTheFragment = subcontext.selector;
-                    PseudoIdSet ignoreDynamicPseudo;
-                    if (matchRecursively(checkingContext, subcontext, ignoreDynamicPseudo).match == Match::SelectorMatches)
-                        return true;
-                }
-            }
-            break;
         case CSSSelector::PseudoClassAutofill:
             return isAutofilled(element);
         case CSSSelector::PseudoClassAutofillStrongPassword:

Modified: trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp (285031 => 285032)


--- trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp	2021-10-29 15:52:38 UTC (rev 285031)
+++ trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp	2021-10-29 16:22:04 UTC (rev 285032)
@@ -742,8 +742,9 @@
             return selector;
         }
         case CSSSelector::PseudoClassIs:
+        case CSSSelector::PseudoClassWhere:
         case CSSSelector::PseudoClassMatches:
-        case CSSSelector::PseudoClassWhere: {
+        case CSSSelector::PseudoClassAny: {
             SetForScope<bool> resistDefaultNamespace(m_resistDefaultNamespace, true);
             DisallowPseudoElementsScope scope(*this);
             auto selectorList = makeUnique<CSSSelectorList>();
@@ -753,7 +754,6 @@
             selector->setSelectorList(WTFMove(selectorList));
             return selector;
         }
-        case CSSSelector::PseudoClassAny:
         case CSSSelector::PseudoClassHost: {
             auto selectorList = makeUnique<CSSSelectorList>();
             *selectorList = consumeCompoundSelectorList(block);

Modified: trunk/Source/WebCore/cssjit/SelectorCompiler.cpp (285031 => 285032)


--- trunk/Source/WebCore/cssjit/SelectorCompiler.cpp	2021-10-29 15:52:38 UTC (rev 285031)
+++ trunk/Source/WebCore/cssjit/SelectorCompiler.cpp	2021-10-29 16:22:04 UTC (rev 285032)
@@ -1065,44 +1065,6 @@
 
             return functionType;
         }
-
-    case CSSSelector::PseudoClassAny:
-        {
-            Vector<SelectorFragment, 32> anyFragments;
-            FunctionType functionType = FunctionType::SimpleSelectorChecker;
-            for (const CSSSelector* rootSelector = selector.selectorList()->first(); rootSelector; rootSelector = CSSSelectorList::next(rootSelector)) {
-                SelectorFragmentList fragmentList;
-                VisitedMode ignoreVisitedMode = VisitedMode::None;
-                FunctionType subFunctionType = constructFragments(rootSelector, selectorContext, fragmentList, FragmentsLevel::InFunctionalPseudoType, positionInRootFragments, visitedMatchEnabled, ignoreVisitedMode, PseudoElementMatchingBehavior::NeverMatch);
-                ASSERT_WITH_MESSAGE(ignoreVisitedMode == VisitedMode::None, ":visited is disabled in the functional pseudo classes");
-
-                // Since this fragment always unmatch against the element, don't insert it to anyFragments.
-                if (subFunctionType == FunctionType::CannotMatchAnything)
-                    continue;
-
-                if (subFunctionType == FunctionType::CannotCompile)
-                    return FunctionType::CannotCompile;
-
-                // :any() may not contain complex selectors which have combinators.
-                ASSERT(fragmentList.size() == 1);
-                if (fragmentList.size() != 1)
-                    return FunctionType::CannotCompile;
-
-                const SelectorFragment& subFragment = fragmentList.first();
-                anyFragments.append(subFragment);
-                functionType = mostRestrictiveFunctionType(functionType, subFunctionType);
-            }
-
-            // Since all fragments in :any() cannot match anything, this :any() filter cannot match anything.
-            if (anyFragments.isEmpty())
-                return FunctionType::CannotMatchAnything;
-
-            ASSERT(!anyFragments.isEmpty());
-            fragment.anyFilters.append(anyFragments);
-
-            return functionType;
-        }
-
     case CSSSelector::PseudoClassLang:
         {
             const Vector<AtomString>* selectorLangArgumentList = selector.argumentList();
@@ -1112,8 +1074,9 @@
         }
 
     case CSSSelector::PseudoClassIs:
+    case CSSSelector::PseudoClassWhere:
     case CSSSelector::PseudoClassMatches:
-    case CSSSelector::PseudoClassWhere:
+    case CSSSelector::PseudoClassAny:
         {
             SelectorList matchesList;
             const CSSSelectorList* selectorList = selector.selectorList();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to