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

Changeset 267576 in webkit


Ignore:
Timestamp:
Sep 25, 2020, 10:19:48 AM (6 years ago)
Author:
Darin Adler
Message:

Add CSSConditionRule and CSSGroupingRule
https://bugs.webkit.org/show_bug.cgi?id=216855

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

  • web-platform-tests/css/conditional/idlharness-expected.txt:
  • web-platform-tests/css/cssom/MediaList-expected.txt:
  • web-platform-tests/css/cssom/cssimportrule-expected.txt:
  • web-platform-tests/css/cssom/idlharness-expected.txt:

Updated expectations to expect more tests to pass.

Source/WebCore:

  • CMakeLists.txt: Added CSSConditionRule.idl and CSSGroupingRule.idl.
  • DerivedSources-input.xcfilelist: Updated.
  • DerivedSources-output.xcfilelist: Updated.
  • DerivedSources.make: Added CSSConditionRule.idl and CSSGroupingRule.idl.
  • Headers.cmake: Added CSSConditionRule.h.
  • Sources.txt: Add CSSConditionRule.cpp, JSCSSConditioRule.cpp,

and JSCSSGroupingRule.cpp.

  • WebCore.xcodeproj/project.pbxproj: Added all the files.
  • css/CSSConditionRule.cpp: Added.
  • css/CSSConditionRule.h: Added.
  • css/CSSConditionRule.idl: Added.
  • css/CSSGroupingRule.cpp:

(WebCore::CSSGroupingRule::~CSSGroupingRule): Use a range-based for loop
and nullptr.
(WebCore::CSSGroupingRule::appendCSSTextForItems const): Use variadic
append to clean this up a bit.
(WebCore::CSSGroupingRule::item const): Use auto.

  • css/CSSGroupingRule.h: Made m_groupRule private instead of protected.

Did some other tweaks.

  • css/CSSGroupingRule.idl: Added.
  • css/CSSImportRule.idl: Added [Exposed=Window], changed href to be a

USVString, added [SameObject, PutForwards=mediaText] to media
and [SameObject] to styleSheet.

  • css/CSSMediaRule.cpp:

(WebCore::CSSMediaRule::CSSMediaRule): Derive from CSSConditionRule.
(WebCore::CSSMediaRule::mediaQueries const): Return a reference.
(WebCore::CSSMediaRule::cssText const): Streamline since we don't need a
null check.
(WebCore::CSSMediaRule::conditionText const): Added.
(WebCore::CSSMediaRule::setConditionText): Added.
(WebCore::CSSMediaRule::media const): Streamline since we don't need a
null check.
(WebCore::CSSMediaRule::reattach): Ditto.

  • css/CSSMediaRule.h: Derive from CSSConditionRule.
  • css/CSSMediaRule.idl: Derive from CSSConditionRule. Added

[Exposed=Window]. Added [SameObject, PutForwards=mediaText] to media.
Removed insertRule and deleteRule since they are now inherited from
CSSGroupingRule.

  • css/CSSRule.h: Added MARGIN_RULE constant even though we don't have

that rule type. Moved inline functions out of the class body to help
clarity a bit.

  • css/CSSRule.idl: Added [Exposed=Window], changed a few things to match

the specification.

  • css/CSSStyleRule.idl: Added [Exposed=Window]. Added [SameObject]

to style.

  • css/CSSStyleSheet.idl: Added [Exposed=Window].
  • css/CSSSupportsRule.cpp:

(WebCore::CSSSupportsRule::CSSSupportsRule): Derive from CSSConditionRule.
(WebCore::CSSSupportsRule::create): Added.
(WebCore::CSSSupportsRule::cssText const): Use variadic append.
(WebCore::CSSSupportsRule::conditionText const): Updated to use groupRule.
(WebCore::CSSSupportsRule::setConditionText): Added. Not implemented yet.

  • css/CSSSupportsRule.h: Derive from CSSConditionRule.
  • css/CSSSupportsRule.idl: Derive from CSSConditionRule.

Added [Exposed=Window].

  • css/MediaList.cpp:

(WebCore::MediaQuerySet::set): Use move instead of swap.

  • css/MediaList.idl: Added [Exposed=Window] and marked mediaText as

the stringifier.

  • css/StyleRule.cpp:

(WebCore::StyleRule::create): Moved here from the header.
(WebCore::StyleRule::copy const): Ditto.
(WebCore::StyleRulePage::create): Ditto.
(WebCore::StyleRuleGroup::StyleRuleGroup): Use move instead of swap.
(WebCore::StyleRuleMedia::create): Use move instead of swap.
(WebCore::StyleRuleMedia::copy const): Moved out of the header.
(WebCore::StyleRuleSupports::StyleRuleSupports): Ditto.
(WebCore::StyleRuleSupports::create): Ditto.
(WebCore::StyleRuleNamespace::StyleRuleNamespace): Ditto.
(WebCore::StyleRuleNamespace::create): Ditto.

  • css/StyleRule.h: Moved function bodies out of the class

defintiion for clarity.

  • css/StyleSheet.idl: Added [Exposed=Window] and

[SameObject, PutForwards=mediaText] for media.

  • css/StyleSheetContents.cpp:

(WebCore::StyleSheetContents::parserAppendRule): Updated since
mediaQueries returns a reference.

  • css/StyleSheetList.idl: Added [Exposed=Window].
  • css/parser/CSSParserImpl.cpp:

(WebCore::CSSParserImpl::consumeMediaRule): Use WTFMove since
the create function now takes an rvalue reference.
(WebCore::CSSParserImpl::consumeSupportsRule): Ditto.

  • style/RuleSet.cpp:

(WebCore::Style::RuleSet::addChildRules): Updated since mediaQueries
returns a reference.

  • style/UserAgentStyle.cpp:

(WebCore::Style::UserAgentStyle::addToDefaultStyle): Ditto.

Source/WebKitLegacy/mac:

  • DOM/DOMCSS.mm:

(kitClass): Added a default case since we don't intend to list every single rule type here.

LayoutTests:

  • fast/dom/domListEnumeration-expected.txt:
  • fast/dom/domListEnumeration.html:

Updated since toString is now implemented and enumerable.

  • fast/dom/non-numeric-values-numeric-parameters-expected.txt:
  • fast/dom/non-numeric-values-numeric-parameters.html:

Updated test and expectations since CSSMediaRule's deleteRule no longer allows omitting
the index to delete rule 0 (both non-standard and inconsistent with CSSStyleSheet).

Location:
trunk
Files:
4 added
43 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r267574 r267576  
     12020-09-24  Darin Adler  <darin@apple.com>
     2
     3        Add CSSConditionRule and CSSGroupingRule
     4        https://bugs.webkit.org/show_bug.cgi?id=216855
     5
     6        Reviewed by Sam Weinig.
     7
     8        * fast/dom/domListEnumeration-expected.txt:
     9        * fast/dom/domListEnumeration.html:
     10        Updated since toString is now implemented and enumerable.
     11
     12        * fast/dom/non-numeric-values-numeric-parameters-expected.txt:
     13        * fast/dom/non-numeric-values-numeric-parameters.html:
     14        Updated test and expectations since CSSMediaRule's deleteRule no longer allows omitting
     15        the index to delete rule 0 (both non-standard and inconsistent with CSSStyleSheet).
     16
    1172020-09-25  Ryan Haddad  <ryanhaddad@apple.com>
    218
  • trunk/LayoutTests/fast/dom/domListEnumeration-expected.txt

    r202307 r267576  
    8282
    8383[object MediaList]
    84 PASS resultArray.length is 8
     84PASS resultArray.length is 9
    8585PASS resultArray[0].i is '0'
    8686PASS resultArray[0].item is mediaList.item(0)
  • trunk/LayoutTests/fast/dom/domListEnumeration.html

    r217390 r267576  
    201201var mediaList = document.styleSheets[3].cssRules[0].media;
    202202resultArray = iterateList(mediaList);
    203 shouldBe("resultArray.length", "8");
     203shouldBe("resultArray.length", "9");
    204204shouldBe("resultArray[0].i", "'0'");
    205205shouldBe("resultArray[0].item", "mediaList.item(0)");
  • trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt

    r235893 r267576  
    1212PASS nonNumericPolicy('document.createTextNode("a").replaceData(0, x, "b")') is 'any type allowed'
    1313PASS nonNumericPolicy('createCSSMediaRule().insertRule(ruleText, x)') is 'any type allowed'
    14 PASS nonNumericPolicy('createCSSMediaRule().deleteRule(x)') is 'any type allowed'
     14PASS nonNumericPolicy('createCSSMediaRule().deleteRule(x)') is 'any type allowed (but not omitted)'
    1515PASS nonNumericPolicy('createCSSRuleList().item(x)') is 'any type allowed (but not omitted)'
    1616PASS nonNumericPolicy('createCSSStyleDeclaration().item(x)') is 'any type allowed (but not omitted)'
  • trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters.html

    r235893 r267576  
    204204
    205205shouldBe("nonNumericPolicy('createCSSMediaRule().insertRule(ruleText, x)')", "'any type allowed'");
    206 shouldBe("nonNumericPolicy('createCSSMediaRule().deleteRule(x)')", "'any type allowed'");
     206shouldBe("nonNumericPolicy('createCSSMediaRule().deleteRule(x)')", "'any type allowed (but not omitted)'");
    207207
    208208// CSSRuleList
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r267571 r267576  
     12020-09-24  Darin Adler  <darin@apple.com>
     2
     3        Add CSSConditionRule and CSSGroupingRule
     4        https://bugs.webkit.org/show_bug.cgi?id=216855
     5
     6        Reviewed by Sam Weinig.
     7
     8        * web-platform-tests/css/conditional/idlharness-expected.txt:
     9        * web-platform-tests/css/cssom/MediaList-expected.txt:
     10        * web-platform-tests/css/cssom/cssimportrule-expected.txt:
     11        * web-platform-tests/css/cssom/idlharness-expected.txt:
     12        Updated expectations to expect more tests to pass.
     13
    1142020-09-25  Antoine Quint  <graouts@webkit.org>
    215
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/conditional/idlharness-expected.txt

    r266356 r267576  
    66PASS Partial namespace CSS: original namespace defined
    77PASS Partial namespace CSS: member names are unique
    8 FAIL CSSConditionRule interface: existence and properties of interface object assert_own_property: self does not have own property "CSSConditionRule" expected property "CSSConditionRule" missing
    9 FAIL CSSConditionRule interface object length assert_own_property: self does not have own property "CSSConditionRule" expected property "CSSConditionRule" missing
    10 FAIL CSSConditionRule interface object name assert_own_property: self does not have own property "CSSConditionRule" expected property "CSSConditionRule" missing
    11 FAIL CSSConditionRule interface: existence and properties of interface prototype object assert_own_property: self does not have own property "CSSConditionRule" expected property "CSSConditionRule" missing
    12 FAIL CSSConditionRule interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "CSSConditionRule" expected property "CSSConditionRule" missing
    13 FAIL CSSConditionRule interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "CSSConditionRule" expected property "CSSConditionRule" missing
    14 FAIL CSSConditionRule interface: attribute conditionText assert_own_property: self does not have own property "CSSConditionRule" expected property "CSSConditionRule" missing
    15 FAIL CSSMediaRule interface: existence and properties of interface object assert_own_property: self does not have own property "CSSConditionRule" expected property "CSSConditionRule" missing
     8PASS CSSConditionRule interface: existence and properties of interface object
     9PASS CSSConditionRule interface object length
     10PASS CSSConditionRule interface object name
     11PASS CSSConditionRule interface: existence and properties of interface prototype object
     12PASS CSSConditionRule interface: existence and properties of interface prototype object's "constructor" property
     13PASS CSSConditionRule interface: existence and properties of interface prototype object's @@unscopables property
     14PASS CSSConditionRule interface: attribute conditionText
     15PASS CSSMediaRule interface: existence and properties of interface object
    1616PASS CSSMediaRule interface object length
    1717PASS CSSMediaRule interface object name
    18 FAIL CSSMediaRule interface: existence and properties of interface prototype object assert_own_property: self does not have own property "CSSConditionRule" expected property "CSSConditionRule" missing
     18PASS CSSMediaRule interface: existence and properties of interface prototype object
    1919PASS CSSMediaRule interface: existence and properties of interface prototype object's "constructor" property
    2020PASS CSSMediaRule interface: existence and properties of interface prototype object's @@unscopables property
    21 FAIL CSSMediaRule interface: attribute media assert_equals: setter must be function for PutForwards, Replaceable, or non-readonly attributes expected "function" but got "undefined"
     21PASS CSSMediaRule interface: attribute media
    2222PASS CSSMediaRule must be primary interface of cssMediaRule
    2323PASS Stringification of cssMediaRule
    2424PASS CSSMediaRule interface: cssMediaRule must inherit property "media" with the proper type
    25 FAIL CSSConditionRule interface: cssMediaRule must inherit property "conditionText" with the proper type assert_inherits: property "conditionText" not found in prototype chain
     25PASS CSSConditionRule interface: cssMediaRule must inherit property "conditionText" with the proper type
    2626PASS CSSRule interface: cssMediaRule must inherit property "SUPPORTS_RULE" with the proper type
    27 FAIL CSSSupportsRule interface: existence and properties of interface object assert_own_property: self does not have own property "CSSConditionRule" expected property "CSSConditionRule" missing
     27PASS CSSSupportsRule interface: existence and properties of interface object
    2828PASS CSSSupportsRule interface object length
    2929PASS CSSSupportsRule interface object name
    30 FAIL CSSSupportsRule interface: existence and properties of interface prototype object assert_own_property: self does not have own property "CSSConditionRule" expected property "CSSConditionRule" missing
     30PASS CSSSupportsRule interface: existence and properties of interface prototype object
    3131PASS CSSSupportsRule interface: existence and properties of interface prototype object's "constructor" property
    3232PASS CSSSupportsRule interface: existence and properties of interface prototype object's @@unscopables property
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom/MediaList-expected.txt

    r232005 r267576  
    11
    2 FAIL CSSOM - MediaList interface assert_equals: MediaList toString method expected "screen and (min-width: 480px), print, projection" but got "[object MediaList]"
     2PASS CSSOM - MediaList interface
    33
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom/cssimportrule-expected.txt

    r232005 r267576  
    66PASS Existence and writability of CSSImportRule attributes
    77PASS Values of CSSImportRule attributes
    8 FAIL CSSImportRule : MediaList mediaText attribute should be updated due to [PutForwards] assert_equals: expected "print" but got "screen"
     8PASS CSSImportRule : MediaList mediaText attribute should be updated due to [PutForwards]
    99PASS CSSStyleDeclaration cssText attribute should be updated due to [PutForwards]
    10 FAIL StyleSheet : MediaList mediaText attribute should be updated due to [PutForwards] assert_equals: expected "screen" but got ""
     10PASS StyleSheet : MediaList mediaText attribute should be updated due to [PutForwards]
    1111
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom/idlharness-expected.txt

    r264522 r267576  
    5454PASS MediaList interface: existence and properties of interface prototype object's @@unscopables property
    5555PASS MediaList interface: attribute mediaText
    56 FAIL MediaList interface: stringifier assert_own_property: interface prototype object missing non-static operation expected property "toString" missing
     56PASS MediaList interface: stringifier
    5757PASS MediaList interface: attribute length
    5858PASS MediaList interface: operation item(unsigned long)
     
    8080PASS StyleSheet interface: attribute parentStyleSheet
    8181PASS StyleSheet interface: attribute title
    82 FAIL StyleSheet interface: attribute media assert_equals: setter must be function for PutForwards, Replaceable, or non-readonly attributes expected "function" but got "undefined"
     82PASS StyleSheet interface: attribute media
    8383PASS StyleSheet interface: attribute disabled
    8484PASS CSSStyleSheet interface: existence and properties of interface object
     
    163163PASS CSSRule interface: constant PAGE_RULE on interface object
    164164PASS CSSRule interface: constant PAGE_RULE on interface prototype object
    165 FAIL CSSRule interface: constant MARGIN_RULE on interface object assert_own_property: expected property "MARGIN_RULE" missing
    166 FAIL CSSRule interface: constant MARGIN_RULE on interface prototype object assert_own_property: expected property "MARGIN_RULE" missing
     165PASS CSSRule interface: constant MARGIN_RULE on interface object
     166PASS CSSRule interface: constant MARGIN_RULE on interface prototype object
    167167PASS CSSRule interface: constant NAMESPACE_RULE on interface object
    168168PASS CSSRule interface: constant NAMESPACE_RULE on interface prototype object
     
    189189PASS CSSRule interface: sheet.cssRules[4] must inherit property "FONT_FACE_RULE" with the proper type
    190190PASS CSSRule interface: sheet.cssRules[4] must inherit property "PAGE_RULE" with the proper type
    191 FAIL CSSRule interface: sheet.cssRules[4] must inherit property "MARGIN_RULE" with the proper type assert_inherits: property "MARGIN_RULE" not found in prototype chain
     191PASS CSSRule interface: sheet.cssRules[4] must inherit property "MARGIN_RULE" with the proper type
    192192PASS CSSRule interface: sheet.cssRules[4] must inherit property "NAMESPACE_RULE" with the proper type
    193193PASS CSSImportRule interface: existence and properties of interface object
     
    198198PASS CSSImportRule interface: existence and properties of interface prototype object's @@unscopables property
    199199PASS CSSImportRule interface: attribute href
    200 FAIL CSSImportRule interface: attribute media assert_equals: setter must be function for PutForwards, Replaceable, or non-readonly attributes expected "function" but got "undefined"
     200PASS CSSImportRule interface: attribute media
    201201PASS CSSImportRule interface: attribute styleSheet
    202202PASS CSSImportRule must be primary interface of sheet.cssRules[0]
     
    215215PASS CSSRule interface: sheet.cssRules[0] must inherit property "FONT_FACE_RULE" with the proper type
    216216PASS CSSRule interface: sheet.cssRules[0] must inherit property "PAGE_RULE" with the proper type
    217 FAIL CSSRule interface: sheet.cssRules[0] must inherit property "MARGIN_RULE" with the proper type assert_inherits: property "MARGIN_RULE" not found in prototype chain
     217PASS CSSRule interface: sheet.cssRules[0] must inherit property "MARGIN_RULE" with the proper type
    218218PASS CSSRule interface: sheet.cssRules[0] must inherit property "NAMESPACE_RULE" with the proper type
    219 FAIL CSSGroupingRule interface: existence and properties of interface object assert_own_property: self does not have own property "CSSGroupingRule" expected property "CSSGroupingRule" missing
    220 FAIL CSSGroupingRule interface object length assert_own_property: self does not have own property "CSSGroupingRule" expected property "CSSGroupingRule" missing
    221 FAIL CSSGroupingRule interface object name assert_own_property: self does not have own property "CSSGroupingRule" expected property "CSSGroupingRule" missing
    222 FAIL CSSGroupingRule interface: existence and properties of interface prototype object assert_own_property: self does not have own property "CSSGroupingRule" expected property "CSSGroupingRule" missing
    223 FAIL CSSGroupingRule interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "CSSGroupingRule" expected property "CSSGroupingRule" missing
    224 FAIL CSSGroupingRule interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "CSSGroupingRule" expected property "CSSGroupingRule" missing
    225 FAIL CSSGroupingRule interface: attribute cssRules assert_own_property: self does not have own property "CSSGroupingRule" expected property "CSSGroupingRule" missing
    226 FAIL CSSGroupingRule interface: operation insertRule(CSSOMString, optional unsigned long) assert_own_property: self does not have own property "CSSGroupingRule" expected property "CSSGroupingRule" missing
    227 FAIL CSSGroupingRule interface: operation deleteRule(unsigned long) assert_own_property: self does not have own property "CSSGroupingRule" expected property "CSSGroupingRule" missing
    228 FAIL CSSPageRule interface: existence and properties of interface object assert_own_property: self does not have own property "CSSGroupingRule" expected property "CSSGroupingRule" missing
     219PASS CSSGroupingRule interface: existence and properties of interface object
     220PASS CSSGroupingRule interface object length
     221PASS CSSGroupingRule interface object name
     222PASS CSSGroupingRule interface: existence and properties of interface prototype object
     223PASS CSSGroupingRule interface: existence and properties of interface prototype object's "constructor" property
     224PASS CSSGroupingRule interface: existence and properties of interface prototype object's @@unscopables property
     225PASS CSSGroupingRule interface: attribute cssRules
     226PASS CSSGroupingRule interface: operation insertRule(CSSOMString, optional unsigned long)
     227PASS CSSGroupingRule interface: operation deleteRule(unsigned long)
     228FAIL CSSPageRule interface: existence and properties of interface object assert_equals: prototype of CSSPageRule is not CSSGroupingRule expected function "function CSSGroupingRule() {
     229    [native code]
     230}" but got function "function CSSRule() {
     231    [native code]
     232}"
    229233PASS CSSPageRule interface object length
    230234PASS CSSPageRule interface object name
    231 FAIL CSSPageRule interface: existence and properties of interface prototype object assert_own_property: self does not have own property "CSSGroupingRule" expected property "CSSGroupingRule" missing
     235FAIL CSSPageRule interface: existence and properties of interface prototype object assert_equals: prototype of CSSPageRule.prototype is not CSSGroupingRule.prototype expected object "[object CSSGroupingRule]" but got object "[object CSSRule]"
    232236PASS CSSPageRule interface: existence and properties of interface prototype object's "constructor" property
    233237PASS CSSPageRule interface: existence and properties of interface prototype object's @@unscopables property
     
    253257PASS CSSRule interface: sheet.cssRules[2] must inherit property "FONT_FACE_RULE" with the proper type
    254258PASS CSSRule interface: sheet.cssRules[2] must inherit property "PAGE_RULE" with the proper type
    255 FAIL CSSRule interface: sheet.cssRules[2] must inherit property "MARGIN_RULE" with the proper type assert_inherits: property "MARGIN_RULE" not found in prototype chain
     259PASS CSSRule interface: sheet.cssRules[2] must inherit property "MARGIN_RULE" with the proper type
    256260PASS CSSRule interface: sheet.cssRules[2] must inherit property "NAMESPACE_RULE" with the proper type
    257261FAIL CSSMarginRule interface: existence and properties of interface object assert_own_property: self does not have own property "CSSMarginRule" expected property "CSSMarginRule" missing
     
    301305PASS CSSRule interface: sheet.cssRules[1] must inherit property "FONT_FACE_RULE" with the proper type
    302306PASS CSSRule interface: sheet.cssRules[1] must inherit property "PAGE_RULE" with the proper type
    303 FAIL CSSRule interface: sheet.cssRules[1] must inherit property "MARGIN_RULE" with the proper type assert_inherits: property "MARGIN_RULE" not found in prototype chain
     307PASS CSSRule interface: sheet.cssRules[1] must inherit property "MARGIN_RULE" with the proper type
    304308PASS CSSRule interface: sheet.cssRules[1] must inherit property "NAMESPACE_RULE" with the proper type
    305309PASS CSSStyleDeclaration interface: existence and properties of interface object
  • trunk/Source/WebCore/CMakeLists.txt

    r267509 r267576  
    691691    crypto/parameters/RsaPssParams.idl
    692692
     693    css/CSSConditionRule.idl
    693694    css/CSSFontFaceRule.idl
     695    css/CSSGroupingRule.idl
    694696    css/CSSImportRule.idl
    695697    css/CSSKeyframeRule.idl
  • trunk/Source/WebCore/ChangeLog

    r267573 r267576  
     12020-09-24  Darin Adler  <darin@apple.com>
     2
     3        Add CSSConditionRule and CSSGroupingRule
     4        https://bugs.webkit.org/show_bug.cgi?id=216855
     5
     6        Reviewed by Sam Weinig.
     7
     8        * CMakeLists.txt: Added CSSConditionRule.idl and CSSGroupingRule.idl.
     9
     10        * DerivedSources-input.xcfilelist: Updated.
     11        * DerivedSources-output.xcfilelist: Updated.
     12
     13        * DerivedSources.make: Added CSSConditionRule.idl and CSSGroupingRule.idl.
     14        * Headers.cmake: Added CSSConditionRule.h.
     15        * Sources.txt: Add CSSConditionRule.cpp, JSCSSConditioRule.cpp,
     16        and JSCSSGroupingRule.cpp.
     17
     18        * WebCore.xcodeproj/project.pbxproj: Added all the files.
     19
     20        * css/CSSConditionRule.cpp: Added.
     21        * css/CSSConditionRule.h: Added.
     22        * css/CSSConditionRule.idl: Added.
     23
     24        * css/CSSGroupingRule.cpp:
     25        (WebCore::CSSGroupingRule::~CSSGroupingRule): Use a range-based for loop
     26        and nullptr.
     27        (WebCore::CSSGroupingRule::appendCSSTextForItems const): Use variadic
     28        append to clean this up a bit.
     29        (WebCore::CSSGroupingRule::item const): Use auto.
     30
     31        * css/CSSGroupingRule.h: Made m_groupRule private instead of protected.
     32        Did some other tweaks.
     33
     34        * css/CSSGroupingRule.idl: Added.
     35
     36        * css/CSSImportRule.idl: Added [Exposed=Window], changed href to be a
     37        USVString, added [SameObject, PutForwards=mediaText] to media
     38        and [SameObject] to styleSheet.
     39
     40        * css/CSSMediaRule.cpp:
     41        (WebCore::CSSMediaRule::CSSMediaRule): Derive from CSSConditionRule.
     42        (WebCore::CSSMediaRule::mediaQueries const): Return a reference.
     43        (WebCore::CSSMediaRule::cssText const): Streamline since we don't need a
     44        null check.
     45        (WebCore::CSSMediaRule::conditionText const): Added.
     46        (WebCore::CSSMediaRule::setConditionText): Added.
     47        (WebCore::CSSMediaRule::media const): Streamline since we don't need a
     48        null check.
     49        (WebCore::CSSMediaRule::reattach): Ditto.
     50
     51        * css/CSSMediaRule.h: Derive from CSSConditionRule.
     52
     53        * css/CSSMediaRule.idl: Derive from CSSConditionRule. Added
     54        [Exposed=Window]. Added [SameObject, PutForwards=mediaText] to media.
     55        Removed insertRule and deleteRule since they are now inherited from
     56        CSSGroupingRule.
     57
     58        * css/CSSRule.h: Added MARGIN_RULE constant even though we don't have
     59        that rule type. Moved inline functions out of the class body to help
     60        clarity a bit.
     61
     62        * css/CSSRule.idl: Added [Exposed=Window], changed a few things to match
     63        the specification.
     64
     65        * css/CSSStyleRule.idl: Added [Exposed=Window]. Added [SameObject]
     66        to style.
     67
     68        * css/CSSStyleSheet.idl: Added [Exposed=Window].
     69
     70        * css/CSSSupportsRule.cpp:
     71        (WebCore::CSSSupportsRule::CSSSupportsRule): Derive from CSSConditionRule.
     72        (WebCore::CSSSupportsRule::create): Added.
     73        (WebCore::CSSSupportsRule::cssText const): Use variadic append.
     74        (WebCore::CSSSupportsRule::conditionText const): Updated to use groupRule.
     75        (WebCore::CSSSupportsRule::setConditionText): Added. Not implemented yet.
     76
     77        * css/CSSSupportsRule.h: Derive from CSSConditionRule.
     78
     79        * css/CSSSupportsRule.idl: Derive from CSSConditionRule.
     80        Added [Exposed=Window].
     81
     82        * css/MediaList.cpp:
     83        (WebCore::MediaQuerySet::set): Use move instead of swap.
     84
     85        * css/MediaList.idl: Added [Exposed=Window] and marked mediaText as
     86        the stringifier.
     87
     88        * css/StyleRule.cpp:
     89        (WebCore::StyleRule::create): Moved here from the header.
     90        (WebCore::StyleRule::copy const): Ditto.
     91        (WebCore::StyleRulePage::create): Ditto.
     92        (WebCore::StyleRuleGroup::StyleRuleGroup): Use move instead of swap.
     93        (WebCore::StyleRuleMedia::create): Use move instead of swap.
     94        (WebCore::StyleRuleMedia::copy const): Moved out of the header.
     95        (WebCore::StyleRuleSupports::StyleRuleSupports): Ditto.
     96        (WebCore::StyleRuleSupports::create): Ditto.
     97        (WebCore::StyleRuleNamespace::StyleRuleNamespace): Ditto.
     98        (WebCore::StyleRuleNamespace::create): Ditto.
     99
     100        * css/StyleRule.h: Moved function bodies out of the class
     101        defintiion for clarity.
     102
     103        * css/StyleSheet.idl: Added [Exposed=Window] and
     104        [SameObject, PutForwards=mediaText] for media.
     105
     106        * css/StyleSheetContents.cpp:
     107        (WebCore::StyleSheetContents::parserAppendRule): Updated since
     108        mediaQueries returns a reference.
     109
     110        * css/StyleSheetList.idl: Added [Exposed=Window].
     111
     112        * css/parser/CSSParserImpl.cpp:
     113        (WebCore::CSSParserImpl::consumeMediaRule): Use WTFMove since
     114        the create function now takes an rvalue reference.
     115        (WebCore::CSSParserImpl::consumeSupportsRule): Ditto.
     116
     117        * style/RuleSet.cpp:
     118        (WebCore::Style::RuleSet::addChildRules): Updated since mediaQueries
     119        returns a reference.
     120        * style/UserAgentStyle.cpp:
     121        (WebCore::Style::UserAgentStyle::addToDefaultStyle): Ditto.
     122
    11232020-09-25  Peng Liu  <peng.liu6@apple.com>
    2124
  • trunk/Source/WebCore/DerivedSources-input.xcfilelist

    r267472 r267576  
    588588$(PROJECT_DIR)/crypto/parameters/RsaOaepParams.idl
    589589$(PROJECT_DIR)/crypto/parameters/RsaPssParams.idl
     590$(PROJECT_DIR)/css/CSSConditionRule.idl
    590591$(PROJECT_DIR)/css/CSSFontFaceRule.idl
     592$(PROJECT_DIR)/css/CSSGroupingRule.idl
    591593$(PROJECT_DIR)/css/CSSImportRule.idl
    592594$(PROJECT_DIR)/css/CSSKeyframeRule.idl
  • trunk/Source/WebCore/DerivedSources-output.xcfilelist

    r267472 r267576  
    246246$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSAnimation.cpp
    247247$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSAnimation.h
     248$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSConditionRule.cpp
     249$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSConditionRule.h
    248250$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSFontFaceRule.cpp
    249251$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSFontFaceRule.h
     252$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSGroupingRule.cpp
     253$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSGroupingRule.h
    250254$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSImportRule.cpp
    251255$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSImportRule.h
  • trunk/Source/WebCore/DerivedSources.make

    r267472 r267576  
    643643    $(WebCore)/crypto/parameters/RsaOaepParams.idl \
    644644    $(WebCore)/crypto/parameters/RsaPssParams.idl \
     645    $(WebCore)/css/CSSConditionRule.idl \
    645646    $(WebCore)/css/CSSFontFaceRule.idl \
     647    $(WebCore)/css/CSSGroupingRule.idl \
    646648    $(WebCore)/css/CSSImportRule.idl \
    647649    $(WebCore)/css/CSSKeyframeRule.idl \
  • trunk/Source/WebCore/Headers.cmake

    r267571 r267576  
    311311
    312312    css/CSSCalculationValue.h
     313    css/CSSConditionRule.h
    313314    css/CSSCustomPropertyValue.h
    314315    css/CSSFontFaceRule.h
  • trunk/Source/WebCore/Sources.txt

    r267565 r267576  
    664664css/CSSCanvasValue.cpp
    665665css/CSSComputedStyleDeclaration.cpp
     666css/CSSConditionRule.cpp
    666667css/CSSContentDistributionValue.cpp
    667668css/CSSCrossfadeValue.cpp
     
    26952696JSCDATASection.cpp
    26962697JSCSSAnimation.cpp
     2698JSCSSConditionRule.cpp
    26972699JSCSSFontFaceRule.cpp
     2700JSCSSGroupingRule.cpp
    26982701JSCSSImportRule.cpp
    26992702JSCSSKeyframeRule.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r267571 r267576  
    26532653                930841341CDDB15500B0958C /* JSDOMConvert.h in Headers */ = {isa = PBXBuildFile; fileRef = 930841331CDDB15500B0958C /* JSDOMConvert.h */; settings = {ATTRIBUTES = (Private, ); }; };
    26542654                930908910AF7EDE40081DF01 /* HitTestRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 930908900AF7EDE40081DF01 /* HitTestRequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2655                930AAC9A250EB8490013DA9F /* CSSConditionRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 930AAC98250EB8170013DA9F /* CSSConditionRule.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2656                930AAC9F250ED4090013DA9F /* JSCSSConditionRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 930AAC9D250ED4090013DA9F /* JSCSSConditionRule.h */; };
     2657                930AACA2250ED4110013DA9F /* JSCSSGroupingRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 930AACA0250ED4110013DA9F /* JSCSSGroupingRule.h */; };
    26552658                93153BDA14181F7A00FCF5BE /* missingImage@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 93153BD914181F7A00FCF5BE /* missingImage@2x.png */; };
    26562659                93153BDC141959BC00FCF5BE /* textAreaResizeCorner.png in Resources */ = {isa = PBXBuildFile; fileRef = 93153BDB141959BB00FCF5BE /* textAreaResizeCorner.png */; };
     
    1104111044                930841331CDDB15500B0958C /* JSDOMConvert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMConvert.h; sourceTree = "<group>"; };
    1104211045                930908900AF7EDE40081DF01 /* HitTestRequest.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HitTestRequest.h; sourceTree = "<group>"; };
     11046                930AAC96250EB8170013DA9F /* CSSConditionRule.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CSSConditionRule.cpp; sourceTree = "<group>"; };
     11047                930AAC98250EB8170013DA9F /* CSSConditionRule.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSSConditionRule.h; sourceTree = "<group>"; };
     11048                930AAC99250EB8180013DA9F /* CSSConditionRule.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = CSSConditionRule.idl; sourceTree = "<group>"; };
     11049                930AAC9B250EC2F30013DA9F /* CSSGroupingRule.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = CSSGroupingRule.idl; sourceTree = "<group>"; };
     11050                930AAC9C250ED4080013DA9F /* JSCSSConditionRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSConditionRule.cpp; sourceTree = "<group>"; };
     11051                930AAC9D250ED4090013DA9F /* JSCSSConditionRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCSSConditionRule.h; sourceTree = "<group>"; };
     11052                930AACA0250ED4110013DA9F /* JSCSSGroupingRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCSSGroupingRule.h; sourceTree = "<group>"; };
     11053                930AACA1250ED4110013DA9F /* JSCSSGroupingRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSGroupingRule.cpp; sourceTree = "<group>"; };
    1104311054                930C90DC19CF965300D6C21A /* InlineIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InlineIterator.cpp; sourceTree = "<group>"; };
    1104411055                93153BD914181F7A00FCF5BE /* missingImage@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "missingImage@2x.png"; sourceTree = "<group>"; };
     
    2483724848                        isa = PBXGroup;
    2483824849                        children = (
     24850                                930AAC9C250ED4080013DA9F /* JSCSSConditionRule.cpp */,
     24851                                930AAC9D250ED4090013DA9F /* JSCSSConditionRule.h */,
    2483924852                                BC46C1F20C0DDC8F0020CFC3 /* JSCSSFontFaceRule.cpp */,
    2484024853                                BC46C1F30C0DDC8F0020CFC3 /* JSCSSFontFaceRule.h */,
     24854                                930AACA1250ED4110013DA9F /* JSCSSGroupingRule.cpp */,
     24855                                930AACA0250ED4110013DA9F /* JSCSSGroupingRule.h */,
    2484124856                                BC46C1F40C0DDC8F0020CFC3 /* JSCSSImportRule.cpp */,
    2484224857                                BC46C1F50C0DDC8F0020CFC3 /* JSCSSImportRule.h */,
     
    2857828593                                BCEA477C097CAAC80094C9E4 /* CSSComputedStyleDeclaration.cpp */,
    2857928594                                BCEA477D097CAAC80094C9E4 /* CSSComputedStyleDeclaration.h */,
     28595                                930AAC96250EB8170013DA9F /* CSSConditionRule.cpp */,
     28596                                930AAC98250EB8170013DA9F /* CSSConditionRule.h */,
     28597                                930AAC99250EB8180013DA9F /* CSSConditionRule.idl */,
    2858028598                                9DAC7C521AF2CAA100437C44 /* CSSContentDistributionValue.cpp */,
    2858128599                                9DAC7C531AF2CAA100437C44 /* CSSContentDistributionValue.h */,
     
    2862828646                                FBF89044169E9F1F0052D86E /* CSSGroupingRule.cpp */,
    2862928647                                FB3056C1169E5DAC0096A232 /* CSSGroupingRule.h */,
     28648                                930AAC9B250EC2F30013DA9F /* CSSGroupingRule.idl */,
    2863028649                                BC772B360C4EA91E0083285F /* CSSHelper.h */,
    2863128650                                BC23E76B0DAE88A9009FDC91 /* CSSImageGeneratorValue.cpp */,
     
    3086630885                                BC6049CC0DB560C200204739 /* CSSCanvasValue.h in Headers */,
    3086730886                                BCEA4790097CAAC80094C9E4 /* CSSComputedStyleDeclaration.h in Headers */,
     30887                                930AAC9A250EB8490013DA9F /* CSSConditionRule.h in Headers */,
    3086830888                                9DAC7C551AF2CAA200437C44 /* CSSContentDistributionValue.h in Headers */,
    3086930889                                2D8FEBDD143E3EF70072502B /* CSSCrossfadeValue.h in Headers */,
     
    3197431994                                7C9ACAC21F3CF1AF00F3AA09 /* JSCryptoRsaKeyAlgorithm.h in Headers */,
    3197531995                                71B28427203CEC4C0036AA5D /* JSCSSAnimation.h in Headers */,
     31996                                930AAC9F250ED4090013DA9F /* JSCSSConditionRule.h in Headers */,
    3197631997                                BC46C1FD0C0DDC8F0020CFC3 /* JSCSSFontFaceRule.h in Headers */,
     31998                                930AACA2250ED4110013DA9F /* JSCSSGroupingRule.h in Headers */,
    3197731999                                BC46C1FF0C0DDC8F0020CFC3 /* JSCSSImportRule.h in Headers */,
    3197832000                                316FE0720E6CCBEE00BF6088 /* JSCSSKeyframeRule.h in Headers */,
  • trunk/Source/WebCore/css/CSSGroupingRule.cpp

    r248846 r267576  
    11/*
    22 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
    3  * Copyright (C) 2012 Apple Inc. All rights reserved.
     3 * Copyright (C) 2012-2020 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    3030
    3131#include "config.h"
    32 
    3332#include "CSSGroupingRule.h"
    3433
     
    5150{
    5251    ASSERT(m_childRuleCSSOMWrappers.size() == m_groupRule->childRules().size());
    53     for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) {
    54         if (m_childRuleCSSOMWrappers[i])
    55             m_childRuleCSSOMWrappers[i]->setParentRule(0);
     52    for (auto& wrapper : m_childRuleCSSOMWrappers) {
     53        if (wrapper)
     54            wrapper->setParentRule(nullptr);
    5655    }
    5756}
     
    112111}
    113112
    114 void CSSGroupingRule::appendCssTextForItems(StringBuilder& result) const
     113void CSSGroupingRule::appendCSSTextForItems(StringBuilder& result) const
    115114{
    116     unsigned size = length();
    117     for (unsigned i = 0; i < size; ++i) {
    118         result.appendLiteral("  ");
    119         result.append(item(i)->cssText());
    120         result.append('\n');
    121     }
     115    for (unsigned i = 0, size = length(); i < size; ++i)
     116        result.append("  ", item(i)->cssText(), '\n');
    122117}
    123118
     
    132127        return nullptr;
    133128    ASSERT(m_childRuleCSSOMWrappers.size() == m_groupRule->childRules().size());
    134     RefPtr<CSSRule>& rule = m_childRuleCSSOMWrappers[index];
     129    auto& rule = m_childRuleCSSOMWrappers[index];
    135130    if (!rule)
    136131        rule = m_groupRule->childRules()[index]->createCSSOMWrapper(const_cast<CSSGroupingRule*>(this));
  • trunk/Source/WebCore/css/CSSGroupingRule.h

    r207396 r267576  
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    33 * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
    4  * Copyright (C) 2002, 2006, 2008, 2012 Apple Inc. All rights reserved.
     4 * Copyright (C) 2002-2020 Apple Inc. All rights reserved.
    55 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org)
    66 *
     
    3737
    3838    WEBCORE_EXPORT CSSRuleList& cssRules() const;
    39 
    4039    WEBCORE_EXPORT ExceptionOr<unsigned> insertRule(const String& rule, unsigned index);
    4140    WEBCORE_EXPORT ExceptionOr<void> deleteRule(unsigned index);
    42        
    43     // For CSSRuleList
    4441    unsigned length() const;
    4542    CSSRule* item(unsigned index) const;
    4643
    4744protected:
    48     CSSGroupingRule(StyleRuleGroup& groupRule, CSSStyleSheet* parent);
    49    
     45    CSSGroupingRule(StyleRuleGroup&, CSSStyleSheet* parent);
     46    const StyleRuleGroup& groupRule() const { return m_groupRule; }
    5047    void reattach(StyleRuleBase&) override;
    51 
    52     void appendCssTextForItems(StringBuilder&) const;
    53 
    54     Ref<StyleRuleGroup> m_groupRule;
     48    void appendCSSTextForItems(StringBuilder&) const;
    5549
    5650private:
     51    Ref<StyleRuleGroup> m_groupRule;
    5752    mutable Vector<RefPtr<CSSRule>> m_childRuleCSSOMWrappers;
    5853    mutable std::unique_ptr<CSSRuleList> m_ruleListCSSOMWrapper;
  • trunk/Source/WebCore/css/CSSImportRule.idl

    r197060 r267576  
    11/*
    2  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
    33 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
    44 *
     
    1919 */
    2020
    21 // Introduced in DOM Level 2:
     21[Exposed=Window]
    2222interface CSSImportRule : CSSRule {
    23     readonly attribute DOMString? href;
    24     readonly attribute MediaList media;
    25     readonly attribute CSSStyleSheet styleSheet;
     23    readonly attribute USVString href;
     24    [SameObject, PutForwards=mediaText] readonly attribute MediaList media;
     25    [SameObject] readonly attribute CSSStyleSheet styleSheet;
    2626};
    2727
  • trunk/Source/WebCore/css/CSSMediaRule.cpp

    r249013 r267576  
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    33 * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
    4  * Copyright (C) 2002, 2005, 2006, 2012 Apple Inc.
     4 * Copyright (C) 2002-2020 Apple Inc.
    55 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org)
    66 *
     
    3232
    3333CSSMediaRule::CSSMediaRule(StyleRuleMedia& mediaRule, CSSStyleSheet* parent)
    34     : CSSGroupingRule(mediaRule, parent)
     34    : CSSConditionRule(mediaRule, parent)
    3535{
    3636}
     
    4242}
    4343
    44 MediaQuerySet* CSSMediaRule::mediaQueries() const
     44MediaQuerySet& CSSMediaRule::mediaQueries() const
    4545{
    46     return downcast<StyleRuleMedia>(m_groupRule.get()).mediaQueries();
     46    return downcast<StyleRuleMedia>(groupRule()).mediaQueries();
    4747}
    4848
     
    5050{
    5151    StringBuilder result;
    52     result.appendLiteral("@media ");
    53     if (mediaQueries()) {
    54         result.append(mediaQueries()->mediaText(), ' ');
    55     }
    56     result.appendLiteral("{ \n");
    57     appendCssTextForItems(result);
     52    result.append("@media ", conditionText(), " { \n");
     53    appendCSSTextForItems(result);
    5854    result.append('}');
    5955    return result.toString();
    6056}
    6157
     58String CSSMediaRule::conditionText() const
     59{
     60    return mediaQueries().mediaText();
     61}
     62
     63void CSSMediaRule::setConditionText(const String& text)
     64{
     65    mediaQueries().set(text);
     66}
     67
    6268MediaList* CSSMediaRule::media() const
    6369{
    64     if (!mediaQueries())
    65         return nullptr;
    6670    if (!m_mediaCSSOMWrapper)
    67         m_mediaCSSOMWrapper = MediaList::create(mediaQueries(), const_cast<CSSMediaRule*>(this));
     71        m_mediaCSSOMWrapper = MediaList::create(&mediaQueries(), const_cast<CSSMediaRule*>(this));
    6872    return m_mediaCSSOMWrapper.get();
    6973}
     
    7175void CSSMediaRule::reattach(StyleRuleBase& rule)
    7276{
    73     CSSGroupingRule::reattach(rule);
    74     if (m_mediaCSSOMWrapper && mediaQueries())
    75         m_mediaCSSOMWrapper->reattach(mediaQueries());
     77    CSSConditionRule::reattach(rule);
     78    if (m_mediaCSSOMWrapper)
     79        m_mediaCSSOMWrapper->reattach(&mediaQueries());
    7680}
    7781
  • trunk/Source/WebCore/css/CSSMediaRule.h

    r207396 r267576  
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    33 * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
    4  * Copyright (C) 2002, 2006, 2008, 2012 Apple Inc. All rights reserved.
     4 * Copyright (C) 2002-2020 Apple Inc. All rights reserved.
    55 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org)
    66 *
     
    2323#pragma once
    2424
    25 #include "CSSGroupingRule.h"
     25#include "CSSConditionRule.h"
    2626
    2727namespace WebCore {
     
    3131class StyleRuleMedia;
    3232
    33 class CSSMediaRule final : public CSSGroupingRule {
     33class CSSMediaRule final : public CSSConditionRule {
    3434public:
    3535    static Ref<CSSMediaRule> create(StyleRuleMedia& rule, CSSStyleSheet* sheet) { return adoptRef(*new CSSMediaRule(rule, sheet)); }
    36 
    3736    virtual ~CSSMediaRule();
    3837
     
    4544    void reattach(StyleRuleBase&) final;
    4645    String cssText() const final;
     46    String conditionText() const final;
     47    void setConditionText(const String&) final;
    4748
    48     MediaQuerySet* mediaQueries() const;
    49    
     49    MediaQuerySet& mediaQueries() const;
     50
    5051    mutable RefPtr<MediaList> m_mediaCSSOMWrapper;
    5152};
  • trunk/Source/WebCore/css/CSSMediaRule.idl

    r266311 r267576  
    11/*
    2  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
    33 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
    44 *
     
    1919 */
    2020
    21 interface CSSMediaRule : CSSRule {
    22     readonly attribute MediaList media;
    23     readonly attribute CSSRuleList cssRules;
    24 
    25     [MayThrowException] unsigned long insertRule(optional DOMString rule = "undefined", optional unsigned long index = 0);
    26     [MayThrowException] undefined deleteRule(optional unsigned long index = 0);
     21[Exposed=Window]
     22interface CSSMediaRule : CSSConditionRule {
     23    [SameObject, PutForwards=mediaText] readonly attribute MediaList media;
    2724};
  • trunk/Source/WebCore/css/CSSRule.h

    r256477 r267576  
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    33 * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
    4  * Copyright (C) 2002, 2006, 2007, 2012 Apple Inc. All rights reserved.
     4 * Copyright (C) 2002-2020 Apple Inc. All rights reserved.
    55 * Copyright (C) 2011 Andreas Kling (kling@webkit.org)
    66 *
     
    4545        FONT_FACE_RULE,
    4646        PAGE_RULE,
    47         // 7 was VARIABLES_RULE; we now match other browsers with 7 as
    48         // KEYFRAMES_RULE:
    49         // <https://bugs.webkit.org/show_bug.cgi?id=71293>.
    5047        KEYFRAMES_RULE,
    5148        KEYFRAME_RULE,
    52         NAMESPACE_RULE = 10, // Matches other browsers.
     49        MARGIN_RULE,
     50        NAMESPACE_RULE,
    5351        SUPPORTS_RULE = 12,
    5452    };
    5553
    5654    enum DeprecatedType {
    57         WEBKIT_KEYFRAMES_RULE = 7,
    58         WEBKIT_KEYFRAME_RULE = 8
     55        WEBKIT_KEYFRAMES_RULE = KEYFRAMES_RULE,
     56        WEBKIT_KEYFRAME_RULE = KEYFRAME_RULE
    5957    };
    6058
     
    6361    virtual void reattach(StyleRuleBase&) = 0;
    6462
    65     void setParentStyleSheet(CSSStyleSheet* styleSheet)
    66     {
    67         m_parentIsRule = false;
    68         m_parentStyleSheet = styleSheet;
    69     }
    70 
    71     void setParentRule(CSSRule* rule)
    72     {
    73         m_parentIsRule = true;
    74         m_parentRule = rule;
    75     }
    76 
    77     CSSStyleSheet* parentStyleSheet() const
    78     {
    79         if (m_parentIsRule)
    80             return m_parentRule ? m_parentRule->parentStyleSheet() : 0;
    81         return m_parentStyleSheet;
    82     }
    83 
    84     CSSRule* parentRule() const { return m_parentIsRule ? m_parentRule : 0; }
     63    void setParentStyleSheet(CSSStyleSheet*);
     64    void setParentRule(CSSRule*);
     65    CSSStyleSheet* parentStyleSheet() const;
     66    CSSRule* parentRule() const { return m_parentIsRule ? m_parentRule : nullptr; }
    8567
    8668    WEBCORE_EXPORT ExceptionOr<void> setCssText(const String&);
    8769
    8870protected:
    89     CSSRule(CSSStyleSheet* parent)
    90         : m_hasCachedSelectorText(false)
    91         , m_parentIsRule(false)
    92         , m_parentStyleSheet(parent)
    93     {
    94     }
     71    explicit CSSRule(CSSStyleSheet*);
    9572
    9673    bool hasCachedSelectorText() const { return m_hasCachedSelectorText; }
     
    10279    mutable unsigned char m_hasCachedSelectorText : 1;
    10380    unsigned char m_parentIsRule : 1;
    104 
    10581    union {
    10682        CSSRule* m_parentRule;
     
    10884    };
    10985};
     86
     87inline CSSRule::CSSRule(CSSStyleSheet* parent)
     88    : m_hasCachedSelectorText(false)
     89    , m_parentIsRule(false)
     90    , m_parentStyleSheet(parent)
     91{
     92}
     93
     94inline void CSSRule::setParentStyleSheet(CSSStyleSheet* styleSheet)
     95{
     96    m_parentIsRule = false;
     97    m_parentStyleSheet = styleSheet;
     98}
     99
     100inline void CSSRule::setParentRule(CSSRule* rule)
     101{
     102    m_parentIsRule = true;
     103    m_parentRule = rule;
     104}
     105
     106inline CSSStyleSheet* CSSRule::parentStyleSheet() const
     107{
     108    if (m_parentIsRule)
     109        return m_parentRule ? m_parentRule->parentStyleSheet() : nullptr;
     110    return m_parentStyleSheet;
     111}
    110112
    111113} // namespace WebCore
  • trunk/Source/WebCore/css/CSSRule.idl

    r256477 r267576  
    11/*
    2  * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
    33 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
    44 *
     
    2222    CustomToJSObject,
    2323    ExportToWrappedFunction,
     24    Exposed=Window,
    2425    GenerateIsReachable,
    2526    JSCustomHeader,
    2627    JSCustomMarkFunction,
    2728] interface CSSRule {
    28     // RuleType
     29    attribute DOMString? cssText;
     30    readonly attribute CSSRule? parentRule;
     31    readonly attribute CSSStyleSheet? parentStyleSheet;
     32
     33    readonly attribute unsigned short type;
    2934    const unsigned short UNKNOWN_RULE = 0;
    3035    const unsigned short STYLE_RULE = 1;
     
    3641    const unsigned short KEYFRAMES_RULE = 7;
    3742    const unsigned short KEYFRAME_RULE = 8;
     43    const unsigned short MARGIN_RULE = 9;
    3844    const unsigned short NAMESPACE_RULE = 10;
    3945    const unsigned short SUPPORTS_RULE = 12;
     
    4248    const unsigned short WEBKIT_KEYFRAMES_RULE = 7;
    4349    const unsigned short WEBKIT_KEYFRAME_RULE = 8;
    44 
    45     readonly attribute unsigned short type;
    46 
    47     attribute DOMString? cssText;
    48 
    49     readonly attribute CSSStyleSheet? parentStyleSheet;
    50     readonly attribute CSSRule? parentRule;
    5150};
  • trunk/Source/WebCore/css/CSSStyleRule.idl

    r217917 r267576  
    11/*
    2  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
    33 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
    44 *
     
    1919 */
    2020
    21 // Introduced in DOM Level 2:
     21[Exposed=Window]
    2222interface CSSStyleRule : CSSRule {
    2323    attribute DOMString? selectorText;
    24 
    25     [PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
     24    [SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
    2625};
    27 
  • trunk/Source/WebCore/css/CSSStyleSheet.idl

    r266311 r267576  
    11/*
    2  * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
    33 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
    44 *
     
    1919 */
    2020
     21[Exposed=Window]
    2122interface CSSStyleSheet : StyleSheet {
    2223    readonly attribute CSSRule ownerRule;
    2324    readonly attribute CSSRuleList cssRules;
    24 
    2525    [MayThrowException] unsigned long insertRule(DOMString rule, optional unsigned long index = 0);
    26 
    2726    [MayThrowException] undefined deleteRule(unsigned long index);
    2827
    2928    readonly attribute CSSRuleList rules;
    30 
    31     // The following two operations are WebKit-specific.
    3229    [MayThrowException] long addRule(optional DOMString selector = "undefined", optional DOMString style = "undefined", optional unsigned long index);
    3330    [MayThrowException] undefined removeRule(optional unsigned long index = 0);
  • trunk/Source/WebCore/css/CSSSupportsRule.cpp

    r218890 r267576  
    1 /* Copyright (C) 2012 Motorola Mobility Inc. All rights reserved.
     1/*
     2 * Copyright (C) 2012 Motorola Mobility Inc. All rights reserved.
     3 * Copyright (C) 2020 Apple Inc. All rights reserved.
    24 *
    35 * Redistribution and use in source and binary forms, with or without
     
    3638namespace WebCore {
    3739
    38 CSSSupportsRule::CSSSupportsRule(StyleRuleSupports& supportsRule, CSSStyleSheet* parent)
    39     : CSSGroupingRule(supportsRule, parent)
     40CSSSupportsRule::CSSSupportsRule(StyleRuleSupports& rule, CSSStyleSheet* parent)
     41    : CSSConditionRule(rule, parent)
    4042{
     43}
     44
     45Ref<CSSSupportsRule> CSSSupportsRule::create(StyleRuleSupports& rule, CSSStyleSheet* parent)
     46{
     47    return adoptRef(*new CSSSupportsRule(rule, parent));
    4148}
    4249
     
    4451{
    4552    StringBuilder result;
    46 
    47     result.appendLiteral("@supports ");
    48     result.append(conditionText());
    49     result.appendLiteral(" {\n");
    50     appendCssTextForItems(result);
     53    result.append("@supports ", conditionText(), " {\n");
     54    appendCSSTextForItems(result);
    5155    result.append('}');
    52 
    5356    return result.toString();
    5457}
     
    5659String CSSSupportsRule::conditionText() const
    5760{
    58     return downcast<StyleRuleSupports>(m_groupRule.get()).conditionText();
     61    return downcast<StyleRuleSupports>(groupRule()).conditionText();
     62}
     63
     64void CSSSupportsRule::setConditionText(const String&)
     65{
     66    // FIXME: Not implemented yet.
    5967}
    6068
  • trunk/Source/WebCore/css/CSSSupportsRule.h

    r223728 r267576  
    1 /* Copyright (C) 2012 Motorola Mobility Inc. All rights reserved.
     1/*
     2 * Copyright (C) 2012 Motorola Mobility Inc. All rights reserved.
     3 * Copyright (C) 2020 Apple Inc. All rights reserved.
    24 *
    35 * Redistribution and use in source and binary forms, with or without
     
    2931#pragma once
    3032
    31 #include "CSSGroupingRule.h"
     33#include "CSSConditionRule.h"
    3234
    3335namespace WebCore {
     
    3638class StyleRuleSupports;
    3739
    38 class CSSSupportsRule final : public CSSGroupingRule {
     40class CSSSupportsRule final : public CSSConditionRule {
    3941public:
    40     static Ref<CSSSupportsRule> create(StyleRuleSupports& rule, CSSStyleSheet* sheet)
    41     {
    42         return adoptRef(*new CSSSupportsRule(rule, sheet));
    43     }
    44 
    45     virtual ~CSSSupportsRule() = default;
     42    static Ref<CSSSupportsRule> create(StyleRuleSupports&, CSSStyleSheet* parent);
    4643
    4744    String cssText() const final;
    48 
    49     String conditionText() const;
     45    String conditionText() const final;
     46    void setConditionText(const String&) final;
    5047
    5148private:
    5249    CSSSupportsRule(StyleRuleSupports&, CSSStyleSheet*);
    53 
    5450    CSSRule::Type type() const final { return SUPPORTS_RULE; }
    5551};
  • trunk/Source/WebCore/css/CSSSupportsRule.idl

    r266311 r267576  
    1 /* Copyright (C) 2012 Motorola Mobility Inc. All rights reserved.
     1/*
     2 * Copyright (C) 2012 Motorola Mobility Inc. All rights reserved.
     3 * Copyright (C) 2020 Apple Inc. All rights reserved.
    24 *
    35 * Redistribution and use in source and binary forms, with or without
     
    2729 */
    2830
    29 interface CSSSupportsRule : CSSRule {
    30     readonly attribute CSSRuleList cssRules;
    31     readonly attribute DOMString conditionText;
    32 
    33     [MayThrowException] unsigned long insertRule(DOMString rule, optional unsigned long index = 0);
    34     [MayThrowException] undefined deleteRule(unsigned long index);
     31[Exposed=Window]
     32interface CSSSupportsRule : CSSConditionRule {
    3533};
  • trunk/Source/WebCore/css/MediaList.cpp

    r248602 r267576  
    11/*
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    3  * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
     3 * Copyright (C) 2004-2020 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    8383{
    8484    auto result = create(mediaString);
    85     m_queries.swap(result->m_queries);
     85    m_queries = WTFMove(result->m_queries);
    8686    return true;
    8787}
  • trunk/Source/WebCore/css/MediaList.idl

    r266662 r267576  
    11/*
    2  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626[
    2727    ExportToWrappedFunction,
     28    Exposed=Window,
    2829    GenerateIsReachable,
    2930    ImplementationLacksVTable,
    3031    JSCustomHeader,
    3132] interface MediaList {
    32     attribute [LegacyNullToEmptyString] DOMString mediaText;
     33    stringifier attribute [LegacyNullToEmptyString] DOMString mediaText;
    3334    readonly attribute unsigned long length;
    3435
  • trunk/Source/WebCore/css/StyleRule.cpp

    r257696 r267576  
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    33 * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
    4  * Copyright (C) 2002, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved.
     4 * Copyright (C) 2002-2020 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    188188StyleRule::~StyleRule() = default;
    189189
     190Ref<StyleRule> StyleRule::create(Ref<StylePropertiesBase>&& properties, bool hasDocumentSecurityOrigin, CSSSelectorList&& selectors)
     191{
     192    return adoptRef(*new StyleRule(WTFMove(properties), hasDocumentSecurityOrigin, WTFMove(selectors)));
     193}
     194
     195Ref<StyleRule> StyleRule::copy() const
     196{
     197    return adoptRef(*new StyleRule(*this));
     198}
     199
    190200const StyleProperties& StyleRule::properties() const
    191201{
     
    254264StyleRulePage::~StyleRulePage() = default;
    255265
     266Ref<StyleRulePage> StyleRulePage::create(Ref<StyleProperties>&& properties, CSSSelectorList&& selectors)
     267{
     268    return adoptRef(*new StyleRulePage(WTFMove(properties), WTFMove(selectors)));
     269}
     270
    256271MutableStyleProperties& StyleRulePage::mutableProperties()
    257272{
     
    300315}
    301316   
    302 StyleRuleGroup::StyleRuleGroup(StyleRuleType type, Vector<RefPtr<StyleRuleBase>>& adoptRule)
     317StyleRuleGroup::StyleRuleGroup(StyleRuleType type, Vector<RefPtr<StyleRuleBase>>&& rules)
    303318    : StyleRuleBase(type)
    304 {
    305     m_childRules.swap(adoptRule);
    306 }
    307 
    308 StyleRuleGroup::StyleRuleGroup(StyleRuleType type, std::unique_ptr<DeferredStyleGroupRuleList>&& deferredRules)
     319    , m_childRules(WTFMove(rules))
     320{
     321}
     322
     323StyleRuleGroup::StyleRuleGroup(StyleRuleType type, std::unique_ptr<DeferredStyleGroupRuleList>&& rules)
    309324    : StyleRuleBase(type)
    310     , m_deferredRules(WTFMove(deferredRules))
     325    , m_deferredRules(WTFMove(rules))
    311326{
    312327}
     
    347362}
    348363   
    349 StyleRuleMedia::StyleRuleMedia(Ref<MediaQuerySet>&& media, Vector<RefPtr<StyleRuleBase>>& adoptRules)
    350     : StyleRuleGroup(StyleRuleType::Media, adoptRules)
     364StyleRuleMedia::StyleRuleMedia(Ref<MediaQuerySet>&& media, Vector<RefPtr<StyleRuleBase>>&& rules)
     365    : StyleRuleGroup(StyleRuleType::Media, WTFMove(rules))
    351366    , m_mediaQueries(WTFMove(media))
    352367{
    353368}
    354369
    355 StyleRuleMedia::StyleRuleMedia(Ref<MediaQuerySet>&& media, std::unique_ptr<DeferredStyleGroupRuleList>&& deferredRules)
    356     : StyleRuleGroup(StyleRuleType::Media, WTFMove(deferredRules))
     370StyleRuleMedia::StyleRuleMedia(Ref<MediaQuerySet>&& media, std::unique_ptr<DeferredStyleGroupRuleList>&& rules)
     371    : StyleRuleGroup(StyleRuleType::Media, WTFMove(rules))
    357372    , m_mediaQueries(WTFMove(media))
    358373{
    359374}
    360375
    361 StyleRuleMedia::StyleRuleMedia(const StyleRuleMedia& o)
    362     : StyleRuleGroup(o)
    363 {
    364     if (o.m_mediaQueries)
    365         m_mediaQueries = o.m_mediaQueries->copy();
    366 }
    367 
    368 
    369 StyleRuleSupports::StyleRuleSupports(const String& conditionText, bool conditionIsSupported, Vector<RefPtr<StyleRuleBase>>& adoptRules)
    370     : StyleRuleGroup(StyleRuleType::Supports, adoptRules)
     376StyleRuleMedia::StyleRuleMedia(const StyleRuleMedia& other)
     377    : StyleRuleGroup(other)
     378    , m_mediaQueries(other.m_mediaQueries->copy())
     379{
     380}
     381
     382Ref<StyleRuleMedia> StyleRuleMedia::create(Ref<MediaQuerySet>&& media, Vector<RefPtr<StyleRuleBase>>&& rules)
     383{
     384    return adoptRef(*new StyleRuleMedia(WTFMove(media), WTFMove(rules)));
     385}
     386
     387Ref<StyleRuleMedia> StyleRuleMedia::create(Ref<MediaQuerySet>&& media, std::unique_ptr<DeferredStyleGroupRuleList>&& deferredChildRules)
     388{
     389    return adoptRef(*new StyleRuleMedia(WTFMove(media), WTFMove(deferredChildRules)));
     390}
     391
     392Ref<StyleRuleMedia> StyleRuleMedia::copy() const
     393{
     394    return adoptRef(*new StyleRuleMedia(*this));
     395}
     396
     397StyleRuleSupports::StyleRuleSupports(const String& conditionText, bool conditionIsSupported, Vector<RefPtr<StyleRuleBase>>&& rules)
     398    : StyleRuleGroup(StyleRuleType::Supports, WTFMove(rules))
    371399    , m_conditionText(conditionText)
    372400    , m_conditionIsSupported(conditionIsSupported)
     
    374402}
    375403
    376 StyleRuleSupports::StyleRuleSupports(const String& conditionText, bool conditionIsSupported, std::unique_ptr<DeferredStyleGroupRuleList>&& deferredRules)
    377     : StyleRuleGroup(StyleRuleType::Supports, WTFMove(deferredRules))
     404StyleRuleSupports::StyleRuleSupports(const String& conditionText, bool conditionIsSupported, std::unique_ptr<DeferredStyleGroupRuleList>&& rules)
     405    : StyleRuleGroup(StyleRuleType::Supports, WTFMove(rules))
    378406    , m_conditionText(conditionText)
    379407    , m_conditionIsSupported(conditionIsSupported)
     
    388416}
    389417
     418Ref<StyleRuleSupports> StyleRuleSupports::create(const String& conditionText, bool conditionIsSupported, Vector<RefPtr<StyleRuleBase>>&& rules)
     419{
     420    return adoptRef(*new StyleRuleSupports(conditionText, conditionIsSupported, WTFMove(rules)));
     421}
     422
     423Ref<StyleRuleSupports> StyleRuleSupports::create(const String& conditionText, bool conditionIsSupported, std::unique_ptr<DeferredStyleGroupRuleList>&& rules)
     424{
     425    return adoptRef(*new StyleRuleSupports(conditionText, conditionIsSupported, WTFMove(rules)));
     426}
     427
    390428StyleRuleCharset::StyleRuleCharset()
    391429    : StyleRuleBase(StyleRuleType::Charset)
     
    398436}
    399437
    400 StyleRuleCharset::~StyleRuleCharset() = default;
    401 
    402 StyleRuleNamespace::StyleRuleNamespace(AtomString prefix, AtomString uri)
     438StyleRuleNamespace::StyleRuleNamespace(const AtomString& prefix, const AtomString& uri)
    403439    : StyleRuleBase(StyleRuleType::Namespace)
    404440    , m_prefix(prefix)
     
    416452StyleRuleNamespace::~StyleRuleNamespace() = default;
    417453
     454Ref<StyleRuleNamespace> StyleRuleNamespace::create(const AtomString& prefix, const AtomString& uri)
     455{
     456    return adoptRef(*new StyleRuleNamespace(prefix, uri));
     457}
     458
    418459} // namespace WebCore
  • trunk/Source/WebCore/css/StyleRule.h

    r256477 r267576  
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    33 * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
    4  * Copyright (C) 2002, 2006, 2008, 2012, 2013 Apple Inc. All rights reserved.
     4 * Copyright (C) 2002-2020 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    6060    Ref<StyleRuleBase> copy() const;
    6161
    62     void deref() const
    63     {
    64         if (derefBase())
    65             const_cast<StyleRuleBase&>(*this).destroy();
    66     }
     62    void deref() const;
    6763
    6864    // FIXME: There shouldn't be any need for the null parent version.
     
    7167
    7268protected:
    73     StyleRuleBase(StyleRuleType type, bool hasDocumentSecurityOrigin = false)
    74         : m_type(static_cast<unsigned>(type))
    75         , m_hasDocumentSecurityOrigin(hasDocumentSecurityOrigin)
    76     {
    77     }
    78 
    79     StyleRuleBase(const StyleRuleBase& o)
    80         : WTF::RefCountedBase()
    81         , m_type(o.m_type)
    82         , m_hasDocumentSecurityOrigin(o.m_hasDocumentSecurityOrigin)
    83     {
    84     }
    85 
     69    explicit StyleRuleBase(StyleRuleType, bool hasDocumentSecurityOrigin = false);
     70    StyleRuleBase(const StyleRuleBase&);
    8671    ~StyleRuleBase() = default;
    8772
     
    10287    WTF_MAKE_STRUCT_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(StyleRule);
    10388public:
    104     static Ref<StyleRule> create(Ref<StylePropertiesBase>&& properties, bool hasDocumentSecurityOrigin, CSSSelectorList&& selectors)
    105     {
    106         return adoptRef(*new StyleRule(WTFMove(properties), hasDocumentSecurityOrigin, WTFMove(selectors)));
    107     }
    108    
     89    static Ref<StyleRule> create(Ref<StylePropertiesBase>&&, bool hasDocumentSecurityOrigin, CSSSelectorList&&);
     90    Ref<StyleRule> copy() const;
    10991    ~StyleRule();
    11092
    11193    const CSSSelectorList& selectorList() const { return m_selectorList; }
    112    
     94
    11395    const StyleProperties& properties() const;
    11496    MutableStyleProperties& mutableProperties();
     
    11799    using StyleRuleBase::hasDocumentSecurityOrigin;
    118100
    119     void wrapperAdoptSelectorList(CSSSelectorList&& selectors)
    120     {
    121         m_selectorList = WTFMove(selectors);
     101    void wrapperAdoptSelectorList(CSSSelectorList&&);
     102
     103    Vector<RefPtr<StyleRule>> splitIntoMultipleRulesWithMaximumSelectorComponentCount(unsigned) const;
     104
    122105#if ENABLE(CSS_SELECTOR_JIT)
    123         m_compiledSelectors = nullptr;
    124 #endif
    125     }
    126 
    127     Ref<StyleRule> copy() const { return adoptRef(*new StyleRule(*this)); }
    128 
    129     Vector<RefPtr<StyleRule>> splitIntoMultipleRulesWithMaximumSelectorComponentCount(unsigned) const;
    130 
    131 #if ENABLE(CSS_SELECTOR_JIT)
    132     CompiledSelector& compiledSelectorForListIndex(unsigned index) const
    133     {
    134         if (!m_compiledSelectors)
    135             m_compiledSelectors = makeUniqueArray<CompiledSelector>(m_selectorList.listSize());
    136         return m_compiledSelectors[index];
    137     }
    138     void releaseCompiledSelectors() const
    139     {
    140         m_compiledSelectors = nullptr;
    141     }
     106    CompiledSelector& compiledSelectorForListIndex(unsigned index) const;
     107    void releaseCompiledSelectors() const { m_compiledSelectors = nullptr; }
    142108#endif
    143109
     
    158124};
    159125
    160 inline const StyleProperties* StyleRule::propertiesWithoutDeferredParsing() const
    161 {
    162     return m_properties->type() != DeferredPropertiesType ? &downcast<StyleProperties>(m_properties.get()) : nullptr;
    163 }
    164 
    165126class StyleRuleFontFace final : public StyleRuleBase {
    166127public:
     
    183144class StyleRulePage final : public StyleRuleBase {
    184145public:
    185     static Ref<StyleRulePage> create(Ref<StyleProperties>&& properties, CSSSelectorList&& selectors) { return adoptRef(*new StyleRulePage(WTFMove(properties), WTFMove(selectors))); }
     146    static Ref<StyleRulePage> create(Ref<StyleProperties>&&, CSSSelectorList&&);
    186147
    187148    ~StyleRulePage();
     
    225186   
    226187protected:
    227     StyleRuleGroup(StyleRuleType, Vector<RefPtr<StyleRuleBase>>&);
     188    StyleRuleGroup(StyleRuleType, Vector<RefPtr<StyleRuleBase>>&&);
    228189    StyleRuleGroup(StyleRuleType, std::unique_ptr<DeferredStyleGroupRuleList>&&);
    229190    StyleRuleGroup(const StyleRuleGroup&);
     
    236197};
    237198
    238 inline const Vector<RefPtr<StyleRuleBase>>* StyleRuleGroup::childRulesWithoutDeferredParsing() const
    239 {
    240     return !m_deferredRules ? &m_childRules : nullptr;
    241 }
    242 
    243199class StyleRuleMedia final : public StyleRuleGroup {
    244200public:
    245     static Ref<StyleRuleMedia> create(Ref<MediaQuerySet>&& media, Vector<RefPtr<StyleRuleBase>>& adoptRules)
    246     {
    247         return adoptRef(*new StyleRuleMedia(WTFMove(media), adoptRules));
    248     }
    249 
    250     static Ref<StyleRuleMedia> create(Ref<MediaQuerySet>&& media, std::unique_ptr<DeferredStyleGroupRuleList>&& deferredChildRules)
    251     {
    252         return adoptRef(*new StyleRuleMedia(WTFMove(media), WTFMove(deferredChildRules)));
    253     }
    254 
    255     MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); }
    256 
    257     Ref<StyleRuleMedia> copy() const { return adoptRef(*new StyleRuleMedia(*this)); }
    258 
    259 private:
    260     StyleRuleMedia(Ref<MediaQuerySet>&&, Vector<RefPtr<StyleRuleBase>>& adoptRules);
     201    static Ref<StyleRuleMedia> create(Ref<MediaQuerySet>&&, Vector<RefPtr<StyleRuleBase>>&&);
     202    static Ref<StyleRuleMedia> create(Ref<MediaQuerySet>&&, std::unique_ptr<DeferredStyleGroupRuleList>&&);
     203    Ref<StyleRuleMedia> copy() const;
     204
     205    MediaQuerySet& mediaQueries() const { return m_mediaQueries; }
     206
     207private:
     208    StyleRuleMedia(Ref<MediaQuerySet>&&, Vector<RefPtr<StyleRuleBase>>&&);
    261209    StyleRuleMedia(Ref<MediaQuerySet>&&, std::unique_ptr<DeferredStyleGroupRuleList>&&);
    262210    StyleRuleMedia(const StyleRuleMedia&);
    263211
    264     RefPtr<MediaQuerySet> m_mediaQueries;
     212    Ref<MediaQuerySet> m_mediaQueries;
    265213};
    266214
    267215class StyleRuleSupports final : public StyleRuleGroup {
    268216public:
    269     static Ref<StyleRuleSupports> create(const String& conditionText, bool conditionIsSupported, Vector<RefPtr<StyleRuleBase>>& adoptRules)
    270     {
    271         return adoptRef(*new StyleRuleSupports(conditionText, conditionIsSupported, adoptRules));
    272     }
    273    
    274     static Ref<StyleRuleSupports> create(const String& conditionText, bool conditionIsSupported, std::unique_ptr<DeferredStyleGroupRuleList>&& deferredChildRules)
    275     {
    276         return adoptRef(*new StyleRuleSupports(conditionText, conditionIsSupported, WTFMove(deferredChildRules)));
    277     }
     217    static Ref<StyleRuleSupports> create(const String& conditionText, bool conditionIsSupported, Vector<RefPtr<StyleRuleBase>>&&);
     218    static Ref<StyleRuleSupports> create(const String& conditionText, bool conditionIsSupported, std::unique_ptr<DeferredStyleGroupRuleList>&&);
     219    Ref<StyleRuleSupports> copy() const { return adoptRef(*new StyleRuleSupports(*this)); }
    278220
    279221    String conditionText() const { return m_conditionText; }
    280222    bool conditionIsSupported() const { return m_conditionIsSupported; }
    281     Ref<StyleRuleSupports> copy() const { return adoptRef(*new StyleRuleSupports(*this)); }
    282 
    283 private:
    284     StyleRuleSupports(const String& conditionText, bool conditionIsSupported, Vector<RefPtr<StyleRuleBase>>& adoptRules);
     223
     224private:
     225    StyleRuleSupports(const String& conditionText, bool conditionIsSupported, Vector<RefPtr<StyleRuleBase>>&&);
    285226    StyleRuleSupports(const String& conditionText, bool conditionIsSupported, std::unique_ptr<DeferredStyleGroupRuleList>&&);
    286    
    287227    StyleRuleSupports(const StyleRuleSupports&);
    288228
     
    294234class StyleRuleCharset final : public StyleRuleBase {
    295235public:
    296     static Ref<StyleRuleCharset> create() { return adoptRef(*new StyleRuleCharset()); }
    297    
    298     ~StyleRuleCharset();
    299    
     236    static Ref<StyleRuleCharset> create() { return adoptRef(*new StyleRuleCharset); }
    300237    Ref<StyleRuleCharset> copy() const { return adoptRef(*new StyleRuleCharset(*this)); }
    301238
    302239private:
    303     explicit StyleRuleCharset();
     240    StyleRuleCharset();
    304241    StyleRuleCharset(const StyleRuleCharset&);
    305242};
     
    307244class StyleRuleNamespace final : public StyleRuleBase {
    308245public:
    309     static Ref<StyleRuleNamespace> create(AtomString prefix, AtomString uri)
    310     {
    311         return adoptRef(*new StyleRuleNamespace(prefix, uri));
    312     }
     246    static Ref<StyleRuleNamespace> create(const AtomString& prefix, const AtomString& uri);
    313247   
    314248    ~StyleRuleNamespace();
     
    320254
    321255private:
    322     StyleRuleNamespace(AtomString prefix, AtomString uri);
     256    StyleRuleNamespace(const AtomString& prefix, const AtomString& uri);
    323257    StyleRuleNamespace(const StyleRuleNamespace&);
    324    
     258
    325259    AtomString m_prefix;
    326260    AtomString m_uri;
    327261};
    328262   
     263inline StyleRuleBase::StyleRuleBase(StyleRuleType type, bool hasDocumentSecurityOrigin)
     264    : m_type(static_cast<unsigned>(type))
     265    , m_hasDocumentSecurityOrigin(hasDocumentSecurityOrigin)
     266{
     267}
     268
     269inline StyleRuleBase::StyleRuleBase(const StyleRuleBase& o)
     270    : WTF::RefCountedBase()
     271    , m_type(o.m_type)
     272    , m_hasDocumentSecurityOrigin(o.m_hasDocumentSecurityOrigin)
     273{
     274}
     275
     276inline void StyleRuleBase::deref() const
     277{
     278    if (derefBase())
     279        const_cast<StyleRuleBase&>(*this).destroy();
     280}
     281
     282inline void StyleRule::wrapperAdoptSelectorList(CSSSelectorList&& selectors)
     283{
     284    m_selectorList = WTFMove(selectors);
     285#if ENABLE(CSS_SELECTOR_JIT)
     286    m_compiledSelectors = nullptr;
     287#endif
     288}
     289
     290#if ENABLE(CSS_SELECTOR_JIT)
     291
     292inline CompiledSelector& StyleRule::compiledSelectorForListIndex(unsigned index) const
     293{
     294    if (!m_compiledSelectors)
     295        m_compiledSelectors = makeUniqueArray<CompiledSelector>(m_selectorList.listSize());
     296    return m_compiledSelectors[index];
     297}
     298
     299#endif
     300
     301inline const StyleProperties* StyleRule::propertiesWithoutDeferredParsing() const
     302{
     303    return m_properties->type() != DeferredPropertiesType ? &downcast<StyleProperties>(m_properties.get()) : nullptr;
     304}
     305
     306inline const Vector<RefPtr<StyleRuleBase>>* StyleRuleGroup::childRulesWithoutDeferredParsing() const
     307{
     308    return !m_deferredRules ? &m_childRules : nullptr;
     309}
     310
    329311} // namespace WebCore
    330312
     
    354336
    355337SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::StyleRuleKeyframe)
    356 static bool isType(const WebCore::StyleRuleBase& rule) { return rule.isKeyframeRule(); }
     338    static bool isType(const WebCore::StyleRuleBase& rule) { return rule.isKeyframeRule(); }
    357339SPECIALIZE_TYPE_TRAITS_END()
    358340
    359341SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::StyleRuleCharset)
    360 static bool isType(const WebCore::StyleRuleBase& rule) { return rule.isCharsetRule(); }
    361 SPECIALIZE_TYPE_TRAITS_END()
    362 
     342    static bool isType(const WebCore::StyleRuleBase& rule) { return rule.isCharsetRule(); }
     343SPECIALIZE_TYPE_TRAITS_END()
  • trunk/Source/WebCore/css/StyleSheet.idl

    r204717 r267576  
    11/*
    2  * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
    33 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
    44 *
     
    2222    CustomToJSObject,
    2323    ExportToWrappedFunction,
     24    Exposed=Window,
    2425    GenerateIsReachable,
    2526    JSCustomHeader,
     
    3233    readonly attribute DOMString? href;
    3334    readonly attribute DOMString? title;
    34     readonly attribute MediaList media;
     35    [SameObject, PutForwards=mediaText] readonly attribute MediaList media;
    3536};
  • trunk/Source/WebCore/css/StyleSheetContents.cpp

    r258789 r267576  
    153153
    154154    if (is<StyleRuleMedia>(rule))
    155         reportMediaQueryWarningIfNeeded(singleOwnerDocument(), downcast<StyleRuleMedia>(rule.get()).mediaQueries());
     155        reportMediaQueryWarningIfNeeded(singleOwnerDocument(), &downcast<StyleRuleMedia>(rule.get()).mediaQueries());
    156156
    157157    // NOTE: The selector list has to fit into RuleData. <http://webkit.org/b/118369>
  • trunk/Source/WebCore/css/StyleSheetList.idl

    r238758 r267576  
    11/*
    2  * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
    33 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
    44 *
     
    2121[
    2222    ExportToWrappedFunction,
     23    Exposed=Window,
    2324    GenerateIsReachable=ImplOwnerNodeRoot,
    2425    ImplementationLacksVTable,
  • trunk/Source/WebCore/css/parser/CSSParserImpl.cpp

    r263771 r267576  
    551551        m_observerWrapper->observer().endRuleBody(m_observerWrapper->endOffset(block));
    552552
    553     return StyleRuleMedia::create(MediaQueryParser::parseMediaQuerySet(prelude, MediaQueryParserContext(m_context)).releaseNonNull(), rules);
     553    return StyleRuleMedia::create(MediaQueryParser::parseMediaQuerySet(prelude, MediaQueryParserContext(m_context)).releaseNonNull(), WTFMove(rules));
    554554}
    555555
    556556RefPtr<StyleRuleSupports> CSSParserImpl::consumeSupportsRule(CSSParserTokenRange prelude, CSSParserTokenRange block)
    557557{
    558     CSSSupportsParser::SupportsResult supported = CSSSupportsParser::supportsCondition(prelude, *this, CSSSupportsParser::ForAtRule);
     558    auto supported = CSSSupportsParser::supportsCondition(prelude, *this, CSSSupportsParser::ForAtRule);
    559559    if (supported == CSSSupportsParser::Invalid)
    560560        return nullptr; // Parse error, invalid @supports condition
     
    578578        m_observerWrapper->observer().endRuleBody(m_observerWrapper->endOffset(block));
    579579
    580     return StyleRuleSupports::create(prelude.serialize().stripWhiteSpace(), supported, rules);
     580    return StyleRuleSupports::create(prelude.serialize().stripWhiteSpace(), supported, WTFMove(rules));
    581581}
    582582
  • trunk/Source/WebCore/style/RuleSet.cpp

    r264488 r267576  
    283283        if (is<StyleRuleMedia>(*rule)) {
    284284            auto& mediaRule = downcast<StyleRuleMedia>(*rule);
    285             if (mediaQueryCollector.pushAndEvaluate(mediaRule.mediaQueries()))
     285            if (mediaQueryCollector.pushAndEvaluate(&mediaRule.mediaQueries()))
    286286                addChildRules(mediaRule.childRules(), mediaQueryCollector, resolver, mode);
    287             mediaQueryCollector.pop(mediaRule.mediaQueries());
     287            mediaQueryCollector.pop(&mediaRule.mediaQueries());
    288288            continue;
    289289        }
  • trunk/Source/WebCore/style/UserAgentStyle.cpp

    r263977 r267576  
    169169            continue;
    170170        auto& mediaRule = downcast<StyleRuleMedia>(*rule);
    171         auto* mediaQuery = mediaRule.mediaQueries();
    172         if (!mediaQuery)
     171        auto& mediaQuery = mediaRule.mediaQueries();
     172        if (screenEval().evaluate(mediaQuery, nullptr))
    173173            continue;
    174         if (screenEval().evaluate(*mediaQuery, nullptr))
    175             continue;
    176         if (printEval().evaluate(*mediaQuery, nullptr))
     174        if (printEval().evaluate(mediaQuery, nullptr))
    177175            continue;
    178176        mediaQueryStyleSheet->parserAppendRule(mediaRule.copy());
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r267575 r267576  
     12020-09-24  Darin Adler  <darin@apple.com>
     2
     3        Add CSSConditionRule and CSSGroupingRule
     4        https://bugs.webkit.org/show_bug.cgi?id=216855
     5
     6        Reviewed by Sam Weinig.
     7
     8        * DOM/DOMCSS.mm:
     9        (kitClass): Added a default case since we don't intend to list every single rule type here.
     10
    1112020-09-25  Sam Weinig  <weinig@apple.com>
    212
  • trunk/Source/WebKitLegacy/mac/DOM/DOMCSS.mm

    r256477 r267576  
    7676    case WebCore::CSSRule::PAGE_RULE:
    7777        return [DOMCSSPageRule class];
    78     case WebCore::CSSRule::KEYFRAMES_RULE:
    79     case WebCore::CSSRule::NAMESPACE_RULE:
    80     case WebCore::CSSRule::KEYFRAME_RULE:
    81     case WebCore::CSSRule::SUPPORTS_RULE:
     78    default:
    8279        return [DOMCSSRule class];
    8380    }
    84     ASSERT_NOT_REACHED();
    85     return nil;
    8681}
    8782
     
    9691    case WebCore::DeprecatedCSSOMValue::CSS_VALUE_LIST:
    9792        return [DOMCSSValueList class];
    98     case WebCore::DeprecatedCSSOMValue::CSS_INHERIT:
    99     case WebCore::DeprecatedCSSOMValue::CSS_CUSTOM:
     93    default:
    10094        return [DOMCSSValue class];
    10195    }
    102     ASSERT_NOT_REACHED();
    103     return nil;
    10496}
    10597
Note: See TracChangeset for help on using the changeset viewer.