From 89d96e02265f00e959aa04939fd4458a7dfd1ac4 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Thu, 4 Apr 2024 14:00:59 +0200 Subject: [PATCH] Issue #2490 - Part 17: Convert CSSKeyframeRule to WebIDL. --- dom/base/nsDOMClassInfo.cpp | 8 -------- dom/base/nsDOMClassInfoClasses.h | 1 - dom/base/nsWrapperCache.h | 2 -- dom/bindings/Bindings.conf | 5 +++++ dom/webidl/CSSKeyframeRule.webidl | 14 ++++++++++++++ dom/webidl/moz.build | 1 + layout/style/nsCSSRules.cpp | 16 ++++++++++------ layout/style/nsCSSRules.h | 4 +++- 8 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 dom/webidl/CSSKeyframeRule.webidl diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 2962ec2a26..d74cc63d93 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -219,9 +219,6 @@ static nsDOMClassInfoData sClassInfoData[] = { DOM_DEFAULT_SCRIPTABLE_FLAGS) - NS_DEFINE_CLASSINFO_DATA(CSSKeyframeRule, nsDOMGenericSH, - DOM_DEFAULT_SCRIPTABLE_FLAGS | - nsIXPCScriptable::WANT_PRECREATE) NS_DEFINE_CLASSINFO_DATA(CSSKeyframesRule, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS | nsIXPCScriptable::WANT_PRECREATE) @@ -546,11 +543,6 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_ENTRY(nsIMessageSender) DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(CSSKeyframeRule, nsIDOMCSSKeyframeRule) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRule) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSKeyframeRule) - DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(CSSKeyframesRule, nsIDOMCSSKeyframesRule) DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRule) DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSKeyframesRule) diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index dadebcbb76..d6423723b6 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -27,7 +27,6 @@ DOMCI_CLASS(ContentProcessMessageManager) DOMCI_CLASS(ChromeMessageBroadcaster) DOMCI_CLASS(ChromeMessageSender) -DOMCI_CLASS(CSSKeyframeRule) DOMCI_CLASS(CSSKeyframesRule) // @counter-style in CSS diff --git a/dom/base/nsWrapperCache.h b/dom/base/nsWrapperCache.h index 78fff8fc58..65fddff476 100644 --- a/dom/base/nsWrapperCache.h +++ b/dom/base/nsWrapperCache.h @@ -23,7 +23,6 @@ class ProcessGlobal; class SandboxPrivate; class nsInProcessTabChildGlobal; class nsWindowRoot; -class nsCSSKeyframeRule; class nsCSSKeyframesRule; class nsCSSCounterStyleRule; @@ -283,7 +282,6 @@ private: friend class SandboxPrivate; friend class nsInProcessTabChildGlobal; friend class nsWindowRoot; - friend class nsCSSKeyframeRule; friend class nsCSSKeyframesRule; friend class nsCSSCounterStyleRule; diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index b3e4cb4e65..4a527ca97a 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -222,6 +222,11 @@ DOMInterfaces = { 'nativeType': 'mozilla::css::ImportRule', }, +'CSSKeyframeRule': { + 'nativeType': 'nsCSSKeyframeRule', + 'headerFile': 'nsCSSRules.h', +}, + 'CSSLexer': { 'wrapperCache': False }, diff --git a/dom/webidl/CSSKeyframeRule.webidl b/dom/webidl/CSSKeyframeRule.webidl new file mode 100644 index 0000000000..25d8965f2a --- /dev/null +++ b/dom/webidl/CSSKeyframeRule.webidl @@ -0,0 +1,14 @@ +/* -*- 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-csskeyframerule + */ + +// https://drafts.csswg.org/css-animations/#interface-csskeyframerule +interface CSSKeyframeRule : CSSRule { + attribute DOMString keyText; + readonly attribute CSSStyleDeclaration style; +}; diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 6c51b04f0e..0b0c421135 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -95,6 +95,7 @@ WEBIDL_FILES = [ 'CSSFontFeatureValuesRule.webidl', 'CSSGroupingRule.webidl', 'CSSImportRule.webidl', + 'CSSKeyframeRule.webidl', 'CSSLexer.webidl', 'CSSMediaRule.webidl', 'CSSMozDocumentRule.webidl', diff --git a/layout/style/nsCSSRules.cpp b/layout/style/nsCSSRules.cpp index ea80b6ffe2..ecec902de5 100644 --- a/layout/style/nsCSSRules.cpp +++ b/layout/style/nsCSSRules.cpp @@ -41,6 +41,7 @@ #include "mozilla/dom/CSSPageRuleBinding.h" #include "mozilla/dom/CSSFontFaceRuleBinding.h" #include "mozilla/dom/CSSFontFeatureValuesRuleBinding.h" +#include "mozilla/dom/CSSKeyframeRuleBinding.h" #include "StyleRule.h" #include "nsFont.h" #include "nsIURI.h" @@ -2103,7 +2104,6 @@ nsCSSKeyframeRule::nsCSSKeyframeRule(const nsCSSKeyframeRule& aCopy) , mKeys(aCopy.mKeys) , mDeclaration(new css::Declaration(*aCopy.mDeclaration)) { - SetIsNotDOMBinding(); mDeclaration->SetOwningRule(this); } @@ -2148,7 +2148,6 @@ nsCSSKeyframeRule::IsCCLeaf() const // QueryInterface implementation for nsCSSKeyframeRule NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsCSSKeyframeRule) NS_INTERFACE_MAP_ENTRY(nsIDOMCSSKeyframeRule) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSKeyframeRule) NS_INTERFACE_MAP_END_INHERITING(mozilla::css::Rule) #ifdef DEBUG @@ -2248,12 +2247,18 @@ nsCSSKeyframeRule::SetKeyText(const nsAString& aKeyText) NS_IMETHODIMP nsCSSKeyframeRule::GetStyle(nsIDOMCSSStyleDeclaration** aStyle) +{ + NS_ADDREF(*aStyle = Style()); + return NS_OK; +} + +nsICSSDeclaration* +nsCSSKeyframeRule::Style() { if (!mDOMDeclaration) { mDOMDeclaration = new nsCSSKeyframeStyleDeclaration(this); } - NS_ADDREF(*aStyle = mDOMDeclaration); - return NS_OK; + return mDOMDeclaration; } void @@ -2297,8 +2302,7 @@ nsCSSKeyframeRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const nsCSSKeyframeRule::WrapObject(JSContext* aCx, JS::Handle aGivenProto) { - NS_NOTREACHED("We called SetIsNotDOMBinding() in our constructor"); - return nullptr; + return CSSKeyframeRuleBinding::Wrap(aCx, this, aGivenProto); } // ------------------------------------------- diff --git a/layout/style/nsCSSRules.h b/layout/style/nsCSSRules.h index 3e7e6fe4b8..ceb20e5a1d 100644 --- a/layout/style/nsCSSRules.h +++ b/layout/style/nsCSSRules.h @@ -416,7 +416,6 @@ public: , mKeys(mozilla::Move(aKeys)) , mDeclaration(mozilla::Move(aDeclaration)) { - SetIsNotDOMBinding(); mDeclaration->SetOwningRule(this); } private: @@ -440,6 +439,9 @@ public: // WebIDL interface uint16_t Type() const override; void GetCssTextImpl(nsAString& aCssText) const override; + // Our XPCOM GetKeyText is OK. + // Our XPCOM SetKeyText is OK. + nsICSSDeclaration* Style(); const nsTArray& GetKeys() const { return mKeys; } mozilla::css::Declaration* Declaration() { return mDeclaration; }