diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 899e7bd98b2c..f83aa007f55a 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -258,11 +258,6 @@ DOMInterfaces = { 'binaryNames': { 'ownerRule': 'DOMOwnerRule' }, }, -'CSSSupportsRule': { - 'nativeType': 'mozilla::CSSSupportsRule', - 'headerFile': 'nsCSSRules.h', -}, - 'CSSValue': { 'concrete': False }, diff --git a/layout/style/CSSSupportsRule.cpp b/layout/style/CSSSupportsRule.cpp new file mode 100644 index 000000000000..0ee88b0ae146 --- /dev/null +++ b/layout/style/CSSSupportsRule.cpp @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/dom/CSSSupportsRule.h" + +#include "mozilla/dom/CSSSupportsRuleBinding.h" + +using namespace mozilla::css; + +namespace mozilla { +namespace dom { + +NS_IMPL_ADDREF_INHERITED(CSSSupportsRule, css::ConditionRule) +NS_IMPL_RELEASE_INHERITED(CSSSupportsRule, css::ConditionRule) + +// QueryInterface implementation for CSSSupportsRule +NS_INTERFACE_MAP_BEGIN(CSSSupportsRule) + NS_INTERFACE_MAP_ENTRY(nsIDOMCSSGroupingRule) + NS_INTERFACE_MAP_ENTRY(nsIDOMCSSConditionRule) + NS_INTERFACE_MAP_ENTRY(nsIDOMCSSSupportsRule) +NS_INTERFACE_MAP_END_INHERITING(ConditionRule) + +// nsIDOMCSSGroupingRule methods +NS_IMETHODIMP +CSSSupportsRule::GetCssRules(nsIDOMCSSRuleList** aRuleList) +{ + return GroupRule::GetCssRules(aRuleList); +} + +NS_IMETHODIMP +CSSSupportsRule::InsertRule(const nsAString & aRule, uint32_t aIndex, uint32_t* _retval) +{ + return GroupRule::InsertRule(aRule, aIndex, _retval); +} + +NS_IMETHODIMP +CSSSupportsRule::DeleteRule(uint32_t aIndex) +{ + return GroupRule::DeleteRule(aIndex); +} + +void +CSSSupportsRule::SetConditionText(const nsAString& aConditionText, + ErrorResult& aRv) +{ + aRv = SetConditionText(aConditionText); +} + +/* virtual */ JSObject* +CSSSupportsRule::WrapObject(JSContext* aCx, + JS::Handle aGivenProto) +{ + return CSSSupportsRuleBinding::Wrap(aCx, this, aGivenProto); +} + +} // namespace dom +} // namespace mozilla diff --git a/layout/style/CSSSupportsRule.h b/layout/style/CSSSupportsRule.h new file mode 100644 index 000000000000..d42bfe0a05a3 --- /dev/null +++ b/layout/style/CSSSupportsRule.h @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_CSSSupportsRule_h +#define mozilla_dom_CSSSupportsRule_h + +#include "mozilla/css/GroupRule.h" +#include "nsIDOMCSSSupportsRule.h" + +namespace mozilla { +namespace dom { + +class CSSSupportsRule : public css::ConditionRule + , public nsIDOMCSSSupportsRule +{ +protected: + using ConditionRule::ConditionRule; + virtual ~CSSSupportsRule() {} + +public: + NS_DECL_ISUPPORTS_INHERITED + + int32_t GetType() const override { return css::Rule::SUPPORTS_RULE; } + using Rule::GetType; + + // nsIDOMCSSGroupingRule interface + NS_DECL_NSIDOMCSSGROUPINGRULE + + // nsIDOMCSSConditionRule interface + NS_IMETHOD SetConditionText(const nsAString& aConditionText) override = 0; + + // nsIDOMCSSSupportsRule interface + NS_DECL_NSIDOMCSSSUPPORTSRULE + + // WebIDL interface + uint16_t Type() const override { return nsIDOMCSSRule::SUPPORTS_RULE; } + // Our XPCOM GetConditionText is OK + void SetConditionText(const nsAString& aConditionText, + ErrorResult& aRv) final; + + JSObject* WrapObject(JSContext* aCx, + JS::Handle aGivenProto) override; +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_CSSSupportsRule_h diff --git a/layout/style/moz.build b/layout/style/moz.build index 2bbe04134d93..0c8d67626542 100644 --- a/layout/style/moz.build +++ b/layout/style/moz.build @@ -134,6 +134,7 @@ EXPORTS.mozilla.dom += [ 'CSSNamespaceRule.h', 'CSSPageRule.h', 'CSSRuleList.h', + 'CSSSupportsRule.h', 'CSSValue.h', 'FontFace.h', 'FontFaceSet.h', @@ -165,6 +166,7 @@ UNIFIED_SOURCES += [ 'CSSPageRule.cpp', 'CSSRuleList.cpp', 'CSSStyleSheet.cpp', + 'CSSSupportsRule.cpp', 'CSSVariableDeclarations.cpp', 'CSSVariableResolver.cpp', 'CSSVariableValues.cpp', diff --git a/layout/style/nsCSSRules.cpp b/layout/style/nsCSSRules.cpp index 99ce9928c8f9..f012ff995f18 100644 --- a/layout/style/nsCSSRules.cpp +++ b/layout/style/nsCSSRules.cpp @@ -36,7 +36,6 @@ #include "nsDOMClassInfoID.h" #include "mozilla/dom/CSSStyleDeclarationBinding.h" #include "mozilla/dom/CSSImportRuleBinding.h" -#include "mozilla/dom/CSSSupportsRuleBinding.h" #include "mozilla/dom/CSSMozDocumentRuleBinding.h" #include "mozilla/dom/CSSFontFaceRuleBinding.h" #include "mozilla/dom/CSSFontFeatureValuesRuleBinding.h" @@ -2272,7 +2271,7 @@ namespace mozilla { CSSSupportsRule::CSSSupportsRule(bool aConditionMet, const nsString& aCondition, uint32_t aLineNumber, uint32_t aColumnNumber) - : css::ConditionRule(aLineNumber, aColumnNumber) + : dom::CSSSupportsRule(aLineNumber, aColumnNumber) , mUseGroup(aConditionMet) , mCondition(aCondition) { @@ -2283,7 +2282,7 @@ CSSSupportsRule::~CSSSupportsRule() } CSSSupportsRule::CSSSupportsRule(const CSSSupportsRule& aCopy) - : css::ConditionRule(aCopy), + : dom::CSSSupportsRule(aCopy), mUseGroup(aCopy.mUseGroup), mCondition(aCopy.mCondition) { @@ -2307,12 +2306,6 @@ CSSSupportsRule::List(FILE* out, int32_t aIndent) const } #endif -/* virtual */ int32_t -CSSSupportsRule::GetType() const -{ - return Rule::SUPPORTS_RULE; -} - /* virtual */ already_AddRefed CSSSupportsRule::Clone() const { @@ -2332,16 +2325,7 @@ NS_IMPL_RELEASE_INHERITED(CSSSupportsRule, css::ConditionRule) // QueryInterface implementation for CSSSupportsRule NS_INTERFACE_MAP_BEGIN(CSSSupportsRule) - NS_INTERFACE_MAP_ENTRY(nsIDOMCSSGroupingRule) - NS_INTERFACE_MAP_ENTRY(nsIDOMCSSConditionRule) - NS_INTERFACE_MAP_ENTRY(nsIDOMCSSSupportsRule) -NS_INTERFACE_MAP_END_INHERITING(ConditionRule) - -uint16_t -CSSSupportsRule::Type() const -{ - return nsIDOMCSSRule::SUPPORTS_RULE; -} +NS_INTERFACE_MAP_END_INHERITING(dom::CSSSupportsRule) void CSSSupportsRule::GetCssTextImpl(nsAString& aCssText) const @@ -2351,25 +2335,6 @@ CSSSupportsRule::GetCssTextImpl(nsAString& aCssText) const css::GroupRule::AppendRulesToCssText(aCssText); } -// nsIDOMCSSGroupingRule methods -NS_IMETHODIMP -CSSSupportsRule::GetCssRules(nsIDOMCSSRuleList* *aRuleList) -{ - return css::GroupRule::GetCssRules(aRuleList); -} - -NS_IMETHODIMP -CSSSupportsRule::InsertRule(const nsAString & aRule, uint32_t aIndex, uint32_t* _retval) -{ - return css::GroupRule::InsertRule(aRule, aIndex, _retval); -} - -NS_IMETHODIMP -CSSSupportsRule::DeleteRule(uint32_t aIndex) -{ - return css::GroupRule::DeleteRule(aIndex); -} - // nsIDOMCSSConditionRule methods NS_IMETHODIMP CSSSupportsRule::GetConditionText(nsAString& aConditionText) @@ -2384,13 +2349,6 @@ CSSSupportsRule::SetConditionText(const nsAString& aConditionText) return NS_ERROR_NOT_IMPLEMENTED; } -void -CSSSupportsRule::SetConditionText(const nsAString& aConditionText, - ErrorResult& aRv) -{ - aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); -} - /* virtual */ size_t CSSSupportsRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { @@ -2400,13 +2358,6 @@ CSSSupportsRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const return n; } -/* virtual */ JSObject* -CSSSupportsRule::WrapObject(JSContext* aCx, - JS::Handle aGivenProto) -{ - return CSSSupportsRuleBinding::Wrap(aCx, this, aGivenProto); -} - } // namespace mozilla // ------------------------------------------- diff --git a/layout/style/nsCSSRules.h b/layout/style/nsCSSRules.h index 0517458f95aa..0f34957c7cba 100644 --- a/layout/style/nsCSSRules.h +++ b/layout/style/nsCSSRules.h @@ -19,6 +19,7 @@ #include "mozilla/css/GroupRule.h" #include "mozilla/dom/CSSMediaRule.h" #include "mozilla/dom/CSSPageRule.h" +#include "mozilla/dom/CSSSupportsRule.h" #include "nsAutoPtr.h" #include "nsCSSPropertyID.h" #include "nsCSSValue.h" @@ -446,8 +447,7 @@ private: namespace mozilla { -class CSSSupportsRule final : public css::ConditionRule, - public nsIDOMCSSSupportsRule +class CSSSupportsRule final : public dom::CSSSupportsRule { public: CSSSupportsRule(bool aConditionMet, const nsString& aCondition, @@ -458,35 +458,21 @@ public: #ifdef DEBUG virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override; #endif - virtual int32_t GetType() const override; - using Rule::GetType; virtual already_AddRefed Clone() const override; virtual bool UseForPresentation(nsPresContext* aPresContext, nsMediaQueryResultCacheKey& aKey) override; NS_DECL_ISUPPORTS_INHERITED - // nsIDOMCSSGroupingRule interface - NS_DECL_NSIDOMCSSGROUPINGRULE - // nsIDOMCSSConditionRule interface NS_DECL_NSIDOMCSSCONDITIONRULE - // nsIDOMCSSSupportsRule interface - NS_DECL_NSIDOMCSSSUPPORTSRULE - // WebIDL interface - uint16_t Type() const override; void GetCssTextImpl(nsAString& aCssText) const override; - // Our XPCOM GetConditionText is OK - virtual void SetConditionText(const nsAString& aConditionText, - ErrorResult& aRv) override; + using dom::CSSSupportsRule::SetConditionText; virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override; - virtual JSObject* WrapObject(JSContext* aCx, - JS::Handle aGivenProto) override; - protected: virtual ~CSSSupportsRule();