source: webkit/trunk/Source/WebCore/css/CSSConditionRule.cpp

Last change on this file was 267576, checked in by Darin Adler, 5 years ago

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).

File size: 1.5 KB
Line 
1/*
2 * Copyright (C) 2020 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer.
11 * 2. Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following
13 * disclaimer in the documentation and/or other materials
14 * provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include "config.h"
31#include "CSSConditionRule.h"
32
33namespace WebCore {
34
35CSSConditionRule::CSSConditionRule(StyleRuleGroup& group, CSSStyleSheet* parent)
36 : CSSGroupingRule(group, parent)
37{
38}
39
40} // namespace WebCore
Note: See TracBrowser for help on using the repository browser.