diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index d74cc63d93..f1c0ca43ec 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -72,8 +72,6 @@ #include "nsMemory.h" // includes needed for the prototype chain interfaces -#include "nsIDOMCSSKeyframeRule.h" -#include "nsIDOMCSSKeyframesRule.h" #include "nsIDOMCSSCounterStyleRule.h" #include "nsIDOMXULCommandDispatcher.h" #include "nsIControllers.h" @@ -219,10 +217,6 @@ static nsDOMClassInfoData sClassInfoData[] = { DOM_DEFAULT_SCRIPTABLE_FLAGS) - NS_DEFINE_CLASSINFO_DATA(CSSKeyframesRule, nsDOMGenericSH, - DOM_DEFAULT_SCRIPTABLE_FLAGS | - nsIXPCScriptable::WANT_PRECREATE) - NS_DEFINE_CLASSINFO_DATA(CSSCounterStyleRule, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS | nsIXPCScriptable::WANT_PRECREATE) @@ -543,11 +537,6 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_ENTRY(nsIMessageSender) DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(CSSKeyframesRule, nsIDOMCSSKeyframesRule) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRule) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSKeyframesRule) - DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(CSSCounterStyleRule, nsIDOMCSSCounterStyleRule) DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRule) DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSCounterStyleRule) diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index d6423723b6..ad96206cdb 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -27,8 +27,6 @@ DOMCI_CLASS(ContentProcessMessageManager) DOMCI_CLASS(ChromeMessageBroadcaster) DOMCI_CLASS(ChromeMessageSender) -DOMCI_CLASS(CSSKeyframesRule) - // @counter-style in CSS DOMCI_CLASS(CSSCounterStyleRule) diff --git a/dom/base/nsWrapperCache.h b/dom/base/nsWrapperCache.h index 65fddff476..3adaaa25e8 100644 --- a/dom/base/nsWrapperCache.h +++ b/dom/base/nsWrapperCache.h @@ -23,7 +23,6 @@ class ProcessGlobal; class SandboxPrivate; class nsInProcessTabChildGlobal; class nsWindowRoot; -class nsCSSKeyframesRule; class nsCSSCounterStyleRule; #define NS_WRAPPERCACHE_IID \ @@ -282,7 +281,6 @@ private: friend class SandboxPrivate; friend class nsInProcessTabChildGlobal; friend class nsWindowRoot; - friend class nsCSSKeyframesRule; friend class nsCSSCounterStyleRule; void SetIsNotDOMBinding() diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 4a527ca97a..fcc2727220 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -227,6 +227,11 @@ DOMInterfaces = { 'headerFile': 'nsCSSRules.h', }, +'CSSKeyframesRule': { + 'nativeType': 'nsCSSKeyframesRule', + 'headerFile': 'nsCSSRules.h', +}, + 'CSSLexer': { 'wrapperCache': False }, diff --git a/dom/webidl/CSSKeyframesRule.webidl b/dom/webidl/CSSKeyframesRule.webidl new file mode 100644 index 0000000000..d0ea978d03 --- /dev/null +++ b/dom/webidl/CSSKeyframesRule.webidl @@ -0,0 +1,18 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + * + * The origin of this IDL file is + * https://drafts.csswg.org/css-animations/#interface-csskeyframesrule + */ + +// https://drafts.csswg.org/css-animations/#interface-csskeyframesrule +interface CSSKeyframesRule : CSSRule { + attribute DOMString name; + readonly attribute CSSRuleList cssRules; + + void appendRule(DOMString rule); + void deleteRule(DOMString select); + CSSKeyframeRule? findRule(DOMString select); +}; diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 0b0c421135..18d4fdc2b5 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -96,6 +96,7 @@ WEBIDL_FILES = [ 'CSSGroupingRule.webidl', 'CSSImportRule.webidl', 'CSSKeyframeRule.webidl', + 'CSSKeyframesRule.webidl', 'CSSLexer.webidl', 'CSSMediaRule.webidl', 'CSSMozDocumentRule.webidl', diff --git a/layout/style/nsCSSRules.cpp b/layout/style/nsCSSRules.cpp index ecec902de5..5c99fbd37c 100644 --- a/layout/style/nsCSSRules.cpp +++ b/layout/style/nsCSSRules.cpp @@ -42,6 +42,7 @@ #include "mozilla/dom/CSSFontFaceRuleBinding.h" #include "mozilla/dom/CSSFontFeatureValuesRuleBinding.h" #include "mozilla/dom/CSSKeyframeRuleBinding.h" +#include "mozilla/dom/CSSKeyframesRuleBinding.h" #include "StyleRule.h" #include "nsFont.h" #include "nsIURI.h" @@ -2316,7 +2317,6 @@ nsCSSKeyframesRule::nsCSSKeyframesRule(const nsCSSKeyframesRule& aCopy) : GroupRule(aCopy), mName(aCopy.mName) { - SetIsNotDOMBinding(); } nsCSSKeyframesRule::~nsCSSKeyframesRule() @@ -2336,7 +2336,6 @@ NS_IMPL_RELEASE_INHERITED(nsCSSKeyframesRule, css::GroupRule) // QueryInterface implementation for nsCSSKeyframesRule NS_INTERFACE_MAP_BEGIN(nsCSSKeyframesRule) NS_INTERFACE_MAP_ENTRY(nsIDOMCSSKeyframesRule) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSKeyframesRule) NS_INTERFACE_MAP_END_INHERITING(GroupRule) #ifdef DEBUG @@ -2501,14 +2500,19 @@ nsCSSKeyframesRule::DeleteRule(const nsAString& aKey) NS_IMETHODIMP nsCSSKeyframesRule::FindRule(const nsAString& aKey, nsIDOMCSSKeyframeRule** aResult) +{ + NS_IF_ADDREF(*aResult = FindRule(aKey)); + return NS_OK; +} + +nsCSSKeyframeRule* +nsCSSKeyframesRule::FindRule(const nsAString& aKey) { uint32_t index = FindRuleIndexForKey(aKey); if (index == RULE_NOT_FOUND) { - *aResult = nullptr; - } else { - NS_ADDREF(*aResult = static_cast(mRules[index])); + return nullptr; } - return NS_OK; + return static_cast(mRules[index]); } // GroupRule interface @@ -2537,8 +2541,7 @@ nsCSSKeyframesRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const nsCSSKeyframesRule::WrapObject(JSContext* aCx, JS::Handle aGivenProto) { - NS_NOTREACHED("We called SetIsNotDOMBinding() in our constructor"); - return nullptr; + return CSSKeyframesRuleBinding::Wrap(aCx, this, aGivenProto); } // ------------------------------------------- diff --git a/layout/style/nsCSSRules.h b/layout/style/nsCSSRules.h index ceb20e5a1d..81e4f04cfb 100644 --- a/layout/style/nsCSSRules.h +++ b/layout/style/nsCSSRules.h @@ -470,7 +470,6 @@ public: : mozilla::css::GroupRule(aLineNumber, aColumnNumber) , mName(aName) { - SetIsNotDOMBinding(); } private: nsCSSKeyframesRule(const nsCSSKeyframesRule& aCopy); @@ -492,6 +491,12 @@ public: // WebIDL interface uint16_t Type() const override; void GetCssTextImpl(nsAString& aCssText) const override; + // The XPCOM GetName is OK + // The XPCOM SetName is OK + using mozilla::css::GroupRule::CssRules; + // The XPCOM appendRule is OK, since it never throws + // The XPCOM deleteRule is OK, since it never throws + nsCSSKeyframeRule* FindRule(const nsAString& aKey); // rest of GroupRule virtual bool UseForPresentation(nsPresContext* aPresContext,