⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 276209 in webkit


Ignore:
Timestamp:
Apr 17, 2021, 3:38:29 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Tyler Wilcock <Tyler Wilcock> 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.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r276203 r276209  
     12021-04-17  Tyler Wilcock  <twilco.o@protonmail.com>
     2
     3        Consider making CSSStyleSheet::rules() just an alias of CSSStyleSheet::cssRules().
     4        https://bugs.webkit.org/show_bug.cgi?id=197725
     5
     6        Reviewed by Darin Adler.
     7
     8        To match other browsers and the below WPT, CSSStyleSheet.rules now aliases
     9        CSSStyleSheet.cssRulesForBindings, meaning we pass two more tests.
     10
     11        * web-platform-tests/css/cssom/CSSStyleSheet-expected.txt:
     12
    1132021-04-17  Tim Nguyen  <ntim@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom/CSSStyleSheet-expected.txt

    r267650 r276209  
    1414PASS addRule with no argument adds "undefined" selector
    1515PASS addRule with index greater than length throws
    16 FAIL cssRules and rules are the same object assert_equals: expected object "[object CSSRuleList]" but got object "[object CSSRuleList]"
     16PASS cssRules and rules are the same object
    1717PASS cssRules returns the same object twice
    18 FAIL rules returns the same object twice assert_equals: expected object "[object CSSRuleList]" but got object "[object CSSRuleList]"
     18PASS rules returns the same object twice
    1919
  • trunk/Source/WebCore/ChangeLog

    r276208 r276209  
     12021-04-17  Tyler Wilcock  <twilco.o@protonmail.com>
     2
     3        Consider making CSSStyleSheet::rules() just an alias of CSSStyleSheet::cssRules().
     4        https://bugs.webkit.org/show_bug.cgi?id=197725
     5
     6        Reviewed by Darin Adler.
     7
     8        To match other browsers (Blink and Gecko) and pass a WPT, CSSStyleSheet.rules now aliases
     9        CSSStyleSheet.cssRulesForBindings.  CSSStyleSheet.rulesForBindings is deleted.
     10
     11        Tested by
     12        imported/w3c/web-platform-tests/css/cssom/CSSStyleSheet.html.
     13
     14        * css/CSSStyleSheet.cpp:
     15        (WebCore::CSSStyleSheet::rulesForBindings): Deleted.
     16        (WebCore::CSSStyleSheet::rules): Deleted.
     17
     18        * css/CSSStyleSheet.h:
     19        Change `rules()` to be an inlined alias for `cssRulesForBindings()`.
     20
     21        * css/CSSStyleSheet.idl:
     22        Remove [ImplementedAs=rulesForBindings], as this function has been
     23        deleted.
     24
    1252021-04-17  Tyler Wilcock  <twilco.o@protonmail.com>
    226
  • trunk/Source/WebCore/css/CSSStyleSheet.cpp

    r270296 r276209  
    255255}
    256256
    257 ExceptionOr<Ref<CSSRuleList>> CSSStyleSheet::rulesForBindings()
    258 {
    259     auto rules = this->rules();
    260     if (!rules)
    261         return Exception { SecurityError, "Not allowed to access cross-origin stylesheet"_s };
    262     return rules.releaseNonNull();
    263 }
    264 
    265 RefPtr<CSSRuleList> CSSStyleSheet::rules()
    266 {
    267     if (!canAccessRules())
    268         return nullptr;
    269     // IE behavior.
    270     auto ruleList = StaticCSSRuleList::create();
    271     unsigned ruleCount = length();
    272     for (unsigned i = 0; i < ruleCount; ++i)
    273         ruleList->rules().append(item(i));
    274     return ruleList;
    275 }
    276 
    277257ExceptionOr<unsigned> CSSStyleSheet::insertRule(const String& ruleString, unsigned index)
    278258{
  • trunk/Source/WebCore/css/CSSStyleSheet.h

    r270296 r276209  
    2121#pragma once
    2222
     23#include "CSSRuleList.h"
    2324#include "ExceptionOr.h"
    2425#include "StyleSheet.h"
     
    3435class CSSParser;
    3536class CSSRule;
    36 class CSSRuleList;
    3737class CSSStyleSheet;
    3838class CachedCSSStyleSheet;
     
    6363    void setDisabled(bool) final;
    6464
     65    WEBCORE_EXPORT RefPtr<CSSRuleList> cssRules();
    6566    ExceptionOr<Ref<CSSRuleList>> cssRulesForBindings();
    66     ExceptionOr<Ref<CSSRuleList>> rulesForBindings();
     67    ExceptionOr<Ref<CSSRuleList>> rules() { return this->cssRulesForBindings(); }
    6768
    68     WEBCORE_EXPORT RefPtr<CSSRuleList> cssRules();
    6969    WEBCORE_EXPORT ExceptionOr<unsigned> insertRule(const String& rule, unsigned index);
    7070    WEBCORE_EXPORT ExceptionOr<void> deleteRule(unsigned index);
    7171   
    72     WEBCORE_EXPORT RefPtr<CSSRuleList> rules();
    7372    WEBCORE_EXPORT ExceptionOr<int> addRule(const String& selector, const String& style, Optional<unsigned> index);
    7473    ExceptionOr<void> removeRule(unsigned index) { return deleteRule(index); }
  • trunk/Source/WebCore/css/CSSStyleSheet.idl

    r274832 r276209  
    2727    undefined deleteRule(unsigned long index);
    2828
    29     [ImplementedAs=rulesForBindings] readonly attribute CSSRuleList rules;
     29    readonly attribute CSSRuleList rules;
    3030    long addRule(optional DOMString selector = "undefined", optional DOMString style = "undefined", optional unsigned long index);
    3131    undefined removeRule(optional unsigned long index = 0);
  • trunk/Source/WebKit/ChangeLog

    r276204 r276209  
     12021-04-17  Tyler Wilcock  <twilco.o@protonmail.com>
     2
     3        Consider making CSSStyleSheet::rules() just an alias of CSSStyleSheet::cssRules().
     4        https://bugs.webkit.org/show_bug.cgi?id=197725
     5
     6        Reviewed by Darin Adler.
     7
     8        CSSStyleSheet.rules has been changed to alias CSSStyleSheet.cssRulesForBindings.  Now,
     9        to access just the CSSRuleList, CSSStyleSheet.cssRules must be called.
     10
     11        * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMCSSStyleSheet.cpp:
     12        (webkit_dom_css_style_sheet_get_rules):
     13        Use CSSStyleSheet.cssRules instead of CSSStyleSheet.rules (deleted
     14        with this patch) to get access to the CSSRuleList of this
     15        stylesheet.
     16
    1172021-04-17  Sam Weinig  <weinig@apple.com>
    218
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMCSSStyleSheet.cpp

    r234586 r276209  
    213213    g_return_val_if_fail(WEBKIT_DOM_IS_CSS_STYLE_SHEET(self), 0);
    214214    WebCore::CSSStyleSheet* item = WebKit::core(self);
    215     RefPtr<WebCore::CSSRuleList> gobjectResult = WTF::getPtr(item->rules());
     215    RefPtr<WebCore::CSSRuleList> gobjectResult = WTF::getPtr(item->cssRules());
    216216    return WebKit::kit(gobjectResult.get());
    217217}
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r276191 r276209  
     12021-04-17  Tyler Wilcock  <twilco.o@protonmail.com>
     2
     3        Consider making CSSStyleSheet::rules() just an alias of CSSStyleSheet::cssRules().
     4        https://bugs.webkit.org/show_bug.cgi?id=197725
     5
     6        Reviewed by Darin Adler.
     7
     8        CSSStyleSheet.rules has been changed to alias CSSStyleSheet.cssRulesForBindings.  Now,
     9        to access just the CSSRuleList, CSSStyleSheet.cssRules must be called.
     10
     11        * DOM/DOMCSSStyleSheet.mm:
     12        (-[DOMCSSStyleSheet rules]):
     13        Update this function to call IMPL->cssRules instead of IMPL->rules.
     14
    1152021-04-16  Ryosuke Niwa  <rniwa@webkit.org>
    216
  • trunk/Source/WebKitLegacy/mac/DOM/DOMCSSStyleSheet.mm

    r247570 r276209  
    6060{
    6161    WebCore::JSMainThreadNullState state;
    62     return kit(WTF::getPtr(IMPL->rules()));
     62    // Calling IMPL->cssRules (not IMPL->rules) is intentional, as `rules` should just be an alias for `cssRules`.
     63    // See https://bugs.webkit.org/show_bug.cgi?id=197725 for more information.
     64    return kit(WTF::getPtr(IMPL->cssRules()));
    6365}
    6466
Note: See TracChangeset for help on using the changeset viewer.