haikuwebkit/Source/WebCore/css/CSSConditionRule.h

46 lines
1.6 KiB
C
Raw Permalink Normal View History

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). Canonical link: https://commits.webkit.org/229755@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267576 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-25 17:19:48 +00:00
/*
* Copyright (C) 2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#pragma once
#include "CSSGroupingRule.h"
namespace WebCore {
class CSSConditionRule : public CSSGroupingRule {
public:
virtual String conditionText() const = 0;
virtual void setConditionText(const String&) = 0;
protected:
CSSConditionRule(StyleRuleGroup&, CSSStyleSheet* parent);
};
} // namespace WebCore