Issue #2490 - Part 18: Convert CSSKeyframesRule to WebIDL.

This commit is contained in:
Moonchild 2024-04-04 14:13:43 +02:00 committed by roytam1
commit b984856d8f
8 changed files with 41 additions and 24 deletions

View file

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

View file

@ -27,8 +27,6 @@ DOMCI_CLASS(ContentProcessMessageManager)
DOMCI_CLASS(ChromeMessageBroadcaster)
DOMCI_CLASS(ChromeMessageSender)
DOMCI_CLASS(CSSKeyframesRule)
// @counter-style in CSS
DOMCI_CLASS(CSSCounterStyleRule)

View file

@ -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()

View file

@ -227,6 +227,11 @@ DOMInterfaces = {
'headerFile': 'nsCSSRules.h',
},
'CSSKeyframesRule': {
'nativeType': 'nsCSSKeyframesRule',
'headerFile': 'nsCSSRules.h',
},
'CSSLexer': {
'wrapperCache': False
},

View file

@ -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);
};

View file

@ -96,6 +96,7 @@ WEBIDL_FILES = [
'CSSGroupingRule.webidl',
'CSSImportRule.webidl',
'CSSKeyframeRule.webidl',
'CSSKeyframesRule.webidl',
'CSSLexer.webidl',
'CSSMediaRule.webidl',
'CSSMozDocumentRule.webidl',

View file

@ -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<nsCSSKeyframeRule*>(mRules[index]));
return nullptr;
}
return NS_OK;
return static_cast<nsCSSKeyframeRule*>(mRules[index]);
}
// GroupRule interface
@ -2537,8 +2541,7 @@ nsCSSKeyframesRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
nsCSSKeyframesRule::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto)
{
NS_NOTREACHED("We called SetIsNotDOMBinding() in our constructor");
return nullptr;
return CSSKeyframesRuleBinding::Wrap(aCx, this, aGivenProto);
}
// -------------------------------------------

View file

@ -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,