Title: [276209] trunk
Revision
276209
Author
[email protected]
Date
2021-04-17 15:38:29 -0700 (Sat, 17 Apr 2021)

Log Message

Consider making CSSStyleSheet::rules() just an alias of CSSStyleSheet::cssRules().
https://bugs.webkit.org/show_bug.cgi?id=197725

Patch by Tyler Wilcock <[email protected]> on 2021-04-17
Reviewed by Darin Adler.

LayoutTests/imported/w3c:

To match other browsers and the below WPT, CSSStyleSheet.rules now aliases
CSSStyleSheet.cssRulesForBindings, meaning we pass two more tests.

* web-platform-tests/css/cssom/CSSStyleSheet-expected.txt:

Source/WebCore:

To match other browsers (Blink and Gecko) and pass a WPT, CSSStyleSheet.rules now aliases
CSSStyleSheet.cssRulesForBindings.  CSSStyleSheet.rulesForBindings is deleted.

Tested by
imported/w3c/web-platform-tests/css/cssom/CSSStyleSheet.html.

* css/CSSStyleSheet.cpp:
(WebCore::CSSStyleSheet::rulesForBindings): Deleted.
(WebCore::CSSStyleSheet::rules): Deleted.

* css/CSSStyleSheet.h:
Change `rules()` to be an inlined alias for `cssRulesForBindings()`.

* css/CSSStyleSheet.idl:
Remove [ImplementedAs=rulesForBindings], as this function has been
deleted.

Source/WebKit:

CSSStyleSheet.rules has been changed to alias CSSStyleSheet.cssRulesForBindings.  Now,
to access just the CSSRuleList, CSSStyleSheet.cssRules must be called.

* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMCSSStyleSheet.cpp:
(webkit_dom_css_style_sheet_get_rules):
Use CSSStyleSheet.cssRules instead of CSSStyleSheet.rules (deleted
with this patch) to get access to the CSSRuleList of this
stylesheet.

Source/WebKitLegacy/mac:

CSSStyleSheet.rules has been changed to alias CSSStyleSheet.cssRulesForBindings.  Now,
to access just the CSSRuleList, CSSStyleSheet.cssRules must be called.

* DOM/DOMCSSStyleSheet.mm:
(-[DOMCSSStyleSheet rules]):
Update this function to call IMPL->cssRules instead of IMPL->rules.

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (276208 => 276209)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-04-17 22:21:20 UTC (rev 276208)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-04-17 22:38:29 UTC (rev 276209)
@@ -1,3 +1,15 @@
+2021-04-17  Tyler Wilcock  <[email protected]>
+
+        Consider making CSSStyleSheet::rules() just an alias of CSSStyleSheet::cssRules().
+        https://bugs.webkit.org/show_bug.cgi?id=197725
+
+        Reviewed by Darin Adler.
+
+        To match other browsers and the below WPT, CSSStyleSheet.rules now aliases
+        CSSStyleSheet.cssRulesForBindings, meaning we pass two more tests.
+
+        * web-platform-tests/css/cssom/CSSStyleSheet-expected.txt:
+
 2021-04-17  Tim Nguyen  <[email protected]>
 
         Don't omit conic gradient starting angle when serializing when starting angle is under 0

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom/CSSStyleSheet-expected.txt (276208 => 276209)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom/CSSStyleSheet-expected.txt	2021-04-17 22:21:20 UTC (rev 276208)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom/CSSStyleSheet-expected.txt	2021-04-17 22:38:29 UTC (rev 276209)
@@ -13,7 +13,7 @@
 PASS addRule with #foo selectors
 PASS addRule with no argument adds "undefined" selector
 PASS addRule with index greater than length throws
-FAIL cssRules and rules are the same object assert_equals: expected object "[object CSSRuleList]" but got object "[object CSSRuleList]"
+PASS cssRules and rules are the same object
 PASS cssRules returns the same object twice
-FAIL rules returns the same object twice assert_equals: expected object "[object CSSRuleList]" but got object "[object CSSRuleList]"
+PASS rules returns the same object twice
 

Modified: trunk/Source/WebCore/ChangeLog (276208 => 276209)


--- trunk/Source/WebCore/ChangeLog	2021-04-17 22:21:20 UTC (rev 276208)
+++ trunk/Source/WebCore/ChangeLog	2021-04-17 22:38:29 UTC (rev 276209)
@@ -1,5 +1,29 @@
 2021-04-17  Tyler Wilcock  <[email protected]>
 
+        Consider making CSSStyleSheet::rules() just an alias of CSSStyleSheet::cssRules().
+        https://bugs.webkit.org/show_bug.cgi?id=197725
+
+        Reviewed by Darin Adler.
+
+        To match other browsers (Blink and Gecko) and pass a WPT, CSSStyleSheet.rules now aliases
+        CSSStyleSheet.cssRulesForBindings.  CSSStyleSheet.rulesForBindings is deleted.
+
+        Tested by
+        imported/w3c/web-platform-tests/css/cssom/CSSStyleSheet.html.
+
+        * css/CSSStyleSheet.cpp:
+        (WebCore::CSSStyleSheet::rulesForBindings): Deleted.
+        (WebCore::CSSStyleSheet::rules): Deleted.
+
+        * css/CSSStyleSheet.h:
+        Change `rules()` to be an inlined alias for `cssRulesForBindings()`.
+
+        * css/CSSStyleSheet.idl:
+        Remove [ImplementedAs=rulesForBindings], as this function has been
+        deleted.
+
+2021-04-17  Tyler Wilcock  <[email protected]>
+
         Media queries with max-width greater than 999999999px evaluate to false
         https://bugs.webkit.org/show_bug.cgi?id=224097
 

Modified: trunk/Source/WebCore/css/CSSStyleSheet.cpp (276208 => 276209)


--- trunk/Source/WebCore/css/CSSStyleSheet.cpp	2021-04-17 22:21:20 UTC (rev 276208)
+++ trunk/Source/WebCore/css/CSSStyleSheet.cpp	2021-04-17 22:38:29 UTC (rev 276209)
@@ -254,26 +254,6 @@
     return document->securityOrigin().canRequest(baseURL);
 }
 
-ExceptionOr<Ref<CSSRuleList>> CSSStyleSheet::rulesForBindings()
-{
-    auto rules = this->rules();
-    if (!rules)
-        return Exception { SecurityError, "Not allowed to access cross-origin stylesheet"_s };
-    return rules.releaseNonNull();
-}
-
-RefPtr<CSSRuleList> CSSStyleSheet::rules()
-{
-    if (!canAccessRules())
-        return nullptr;
-    // IE behavior.
-    auto ruleList = StaticCSSRuleList::create();
-    unsigned ruleCount = length();
-    for (unsigned i = 0; i < ruleCount; ++i)
-        ruleList->rules().append(item(i));
-    return ruleList;
-}
-
 ExceptionOr<unsigned> CSSStyleSheet::insertRule(const String& ruleString, unsigned index)
 {
     ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size() == m_contents->ruleCount());

Modified: trunk/Source/WebCore/css/CSSStyleSheet.h (276208 => 276209)


--- trunk/Source/WebCore/css/CSSStyleSheet.h	2021-04-17 22:21:20 UTC (rev 276208)
+++ trunk/Source/WebCore/css/CSSStyleSheet.h	2021-04-17 22:38:29 UTC (rev 276209)
@@ -20,6 +20,7 @@
 
 #pragma once
 
+#include "CSSRuleList.h"
 #include "ExceptionOr.h"
 #include "StyleSheet.h"
 #include <memory>
@@ -33,7 +34,6 @@
 class CSSImportRule;
 class CSSParser;
 class CSSRule;
-class CSSRuleList;
 class CSSStyleSheet;
 class CachedCSSStyleSheet;
 class Document;
@@ -62,14 +62,13 @@
     bool disabled() const final { return m_isDisabled; }
     void setDisabled(bool) final;
 
+    WEBCORE_EXPORT RefPtr<CSSRuleList> cssRules();
     ExceptionOr<Ref<CSSRuleList>> cssRulesForBindings();
-    ExceptionOr<Ref<CSSRuleList>> rulesForBindings();
+    ExceptionOr<Ref<CSSRuleList>> rules() { return this->cssRulesForBindings(); }
 
-    WEBCORE_EXPORT RefPtr<CSSRuleList> cssRules();
     WEBCORE_EXPORT ExceptionOr<unsigned> insertRule(const String& rule, unsigned index);
     WEBCORE_EXPORT ExceptionOr<void> deleteRule(unsigned index);
     
-    WEBCORE_EXPORT RefPtr<CSSRuleList> rules();
     WEBCORE_EXPORT ExceptionOr<int> addRule(const String& selector, const String& style, Optional<unsigned> index);
     ExceptionOr<void> removeRule(unsigned index) { return deleteRule(index); }
     

Modified: trunk/Source/WebCore/css/CSSStyleSheet.idl (276208 => 276209)


--- trunk/Source/WebCore/css/CSSStyleSheet.idl	2021-04-17 22:21:20 UTC (rev 276208)
+++ trunk/Source/WebCore/css/CSSStyleSheet.idl	2021-04-17 22:38:29 UTC (rev 276209)
@@ -26,7 +26,7 @@
     unsigned long insertRule(DOMString rule, optional unsigned long index = 0);
     undefined deleteRule(unsigned long index);
 
-    [ImplementedAs=rulesForBindings] readonly attribute CSSRuleList rules;
+    readonly attribute CSSRuleList rules;
     long addRule(optional DOMString selector = "undefined", optional DOMString style = "undefined", optional unsigned long index);
     undefined removeRule(optional unsigned long index = 0);
 };

Modified: trunk/Source/WebKit/ChangeLog (276208 => 276209)


--- trunk/Source/WebKit/ChangeLog	2021-04-17 22:21:20 UTC (rev 276208)
+++ trunk/Source/WebKit/ChangeLog	2021-04-17 22:38:29 UTC (rev 276209)
@@ -1,3 +1,19 @@
+2021-04-17  Tyler Wilcock  <[email protected]>
+
+        Consider making CSSStyleSheet::rules() just an alias of CSSStyleSheet::cssRules().
+        https://bugs.webkit.org/show_bug.cgi?id=197725
+
+        Reviewed by Darin Adler.
+
+        CSSStyleSheet.rules has been changed to alias CSSStyleSheet.cssRulesForBindings.  Now,
+        to access just the CSSRuleList, CSSStyleSheet.cssRules must be called.
+
+        * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMCSSStyleSheet.cpp:
+        (webkit_dom_css_style_sheet_get_rules):
+        Use CSSStyleSheet.cssRules instead of CSSStyleSheet.rules (deleted
+        with this patch) to get access to the CSSRuleList of this
+        stylesheet.
+
 2021-04-17  Sam Weinig  <[email protected]>
 
         Move RuntimeEnabledFeatures to Settings (Part 1)

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMCSSStyleSheet.cpp (276208 => 276209)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMCSSStyleSheet.cpp	2021-04-17 22:21:20 UTC (rev 276208)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMCSSStyleSheet.cpp	2021-04-17 22:38:29 UTC (rev 276209)
@@ -212,7 +212,7 @@
     WebCore::JSMainThreadNullState state;
     g_return_val_if_fail(WEBKIT_DOM_IS_CSS_STYLE_SHEET(self), 0);
     WebCore::CSSStyleSheet* item = WebKit::core(self);
-    RefPtr<WebCore::CSSRuleList> gobjectResult = WTF::getPtr(item->rules());
+    RefPtr<WebCore::CSSRuleList> gobjectResult = WTF::getPtr(item->cssRules());
     return WebKit::kit(gobjectResult.get());
 }
 

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (276208 => 276209)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2021-04-17 22:21:20 UTC (rev 276208)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2021-04-17 22:38:29 UTC (rev 276209)
@@ -1,3 +1,17 @@
+2021-04-17  Tyler Wilcock  <[email protected]>
+
+        Consider making CSSStyleSheet::rules() just an alias of CSSStyleSheet::cssRules().
+        https://bugs.webkit.org/show_bug.cgi?id=197725
+
+        Reviewed by Darin Adler.
+
+        CSSStyleSheet.rules has been changed to alias CSSStyleSheet.cssRulesForBindings.  Now,
+        to access just the CSSRuleList, CSSStyleSheet.cssRules must be called.
+
+        * DOM/DOMCSSStyleSheet.mm:
+        (-[DOMCSSStyleSheet rules]):
+        Update this function to call IMPL->cssRules instead of IMPL->rules.
+
 2021-04-16  Ryosuke Niwa  <[email protected]>
 
         Deploy Ref/RefPtr in Editor

Modified: trunk/Source/WebKitLegacy/mac/DOM/DOMCSSStyleSheet.mm (276208 => 276209)


--- trunk/Source/WebKitLegacy/mac/DOM/DOMCSSStyleSheet.mm	2021-04-17 22:21:20 UTC (rev 276208)
+++ trunk/Source/WebKitLegacy/mac/DOM/DOMCSSStyleSheet.mm	2021-04-17 22:38:29 UTC (rev 276209)
@@ -59,7 +59,9 @@
 - (DOMCSSRuleList *)rules
 {
     WebCore::JSMainThreadNullState state;
-    return kit(WTF::getPtr(IMPL->rules()));
+    // Calling IMPL->cssRules (not IMPL->rules) is intentional, as `rules` should just be an alias for `cssRules`.
+    // See https://bugs.webkit.org/show_bug.cgi?id=197725 for more information.
+    return kit(WTF::getPtr(IMPL->cssRules()));
 }
 
 - (unsigned)insertRule:(NSString *)rule index:(unsigned)index
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to