From 50f8c187574c1bfbbb17b0d78f96129539d1568a Mon Sep 17 00:00:00 2001 From: Moonchild Date: Thu, 4 Apr 2024 10:02:17 +0200 Subject: [PATCH] Issue #2490 - Part 15: Convert CSSFontFaceRule to WebIDL. The .style PutForwards bit is coming along for the ride here as a new feature. --- dom/base/nsDOMClassInfo.cpp | 10 ---------- dom/base/nsDOMClassInfoClasses.h | 3 --- dom/base/nsWrapperCache.h | 2 -- dom/bindings/Bindings.conf | 5 +++++ dom/webidl/CSSFontFaceRule.webidl | 15 +++++++++++++++ dom/webidl/moz.build | 1 + layout/style/nsCSSRules.cpp | 11 ++++++++--- layout/style/nsCSSRules.h | 3 +-- 8 files changed, 30 insertions(+), 20 deletions(-) create mode 100644 dom/webidl/CSSFontFaceRule.webidl diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 080862c43f..d6634f0504 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -74,7 +74,6 @@ // includes needed for the prototype chain interfaces #include "nsIDOMCSSKeyframeRule.h" #include "nsIDOMCSSKeyframesRule.h" -#include "nsIDOMCSSFontFaceRule.h" #include "nsIDOMCSSCounterStyleRule.h" #include "nsIDOMXULCommandDispatcher.h" #include "nsIControllers.h" @@ -204,10 +203,6 @@ static nsDOMClassInfoData sClassInfoData[] = { DEFAULT_SCRIPTABLE_FLAGS) #endif - NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH, - DOM_DEFAULT_SCRIPTABLE_FLAGS | - nsIXPCScriptable::WANT_PRECREATE) - NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ContentFrameMessageManager, nsMessageManagerSH, DOM_DEFAULT_SCRIPTABLE_FLAGS | @@ -524,11 +519,6 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_END #endif - DOM_CLASSINFO_MAP_BEGIN(CSSFontFaceRule, nsIDOMCSSFontFaceRule) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRule) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSFontFaceRule) - DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ContentFrameMessageManager, nsISupports) DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) DOM_CLASSINFO_MAP_ENTRY(nsIMessageListenerManager) diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index db869ce41d..d280c47ce6 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -22,9 +22,6 @@ DOMCI_CLASS(XULTemplateBuilder) DOMCI_CLASS(XULTreeBuilder) #endif -// @font-face in CSS -DOMCI_CLASS(CSSFontFaceRule) - DOMCI_CLASS(ContentFrameMessageManager) DOMCI_CLASS(ContentProcessMessageManager) DOMCI_CLASS(ChromeMessageBroadcaster) diff --git a/dom/base/nsWrapperCache.h b/dom/base/nsWrapperCache.h index c994768e35..cedda8ba79 100644 --- a/dom/base/nsWrapperCache.h +++ b/dom/base/nsWrapperCache.h @@ -23,7 +23,6 @@ class ProcessGlobal; class SandboxPrivate; class nsInProcessTabChildGlobal; class nsWindowRoot; -class nsCSSFontFaceRule; class nsCSSFontFeatureValuesRule; class nsCSSKeyframeRule; class nsCSSKeyframesRule; @@ -285,7 +284,6 @@ private: friend class SandboxPrivate; friend class nsInProcessTabChildGlobal; friend class nsWindowRoot; - friend class nsCSSFontFaceRule; friend class nsCSSFontFeatureValuesRule; friend class nsCSSKeyframeRule; friend class nsCSSKeyframesRule; diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 96f634130b..9b8c826cc0 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -203,6 +203,11 @@ DOMInterfaces = { 'headerFile': 'mozilla/css/GroupRule.h', }, +'CSSFontFaceRule': { + 'nativeType': 'nsCSSFontFaceRule', + 'headerFile': 'nsCSSRules.h', +}, + 'CSSGroupingRule': { 'concrete': False, 'nativeType': 'mozilla::css::GroupRule', diff --git a/dom/webidl/CSSFontFaceRule.webidl b/dom/webidl/CSSFontFaceRule.webidl new file mode 100644 index 0000000000..221dd26aec --- /dev/null +++ b/dom/webidl/CSSFontFaceRule.webidl @@ -0,0 +1,15 @@ +/* -*- 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-fonts/#om-fontface + */ + +// https://drafts.csswg.org/css-fonts/#om-fontface +// But we implement a very old draft, apparently.... +// See bug 1058408 for implementing the current spec. +interface CSSFontFaceRule : CSSRule { + [SameObject] readonly attribute CSSStyleDeclaration style; +}; diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index da060f2fcf..bbadc6655a 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -91,6 +91,7 @@ WEBIDL_FILES = [ 'CSS.webidl', 'CSSAnimation.webidl', 'CSSConditionRule.webidl', + 'CSSFontFaceRule.webidl', 'CSSGroupingRule.webidl', 'CSSImportRule.webidl', 'CSSLexer.webidl', diff --git a/layout/style/nsCSSRules.cpp b/layout/style/nsCSSRules.cpp index fe76715d9c..799dac42be 100644 --- a/layout/style/nsCSSRules.cpp +++ b/layout/style/nsCSSRules.cpp @@ -39,6 +39,7 @@ #include "mozilla/dom/CSSSupportsRuleBinding.h" #include "mozilla/dom/CSSMozDocumentRuleBinding.h" #include "mozilla/dom/CSSPageRuleBinding.h" +#include "mozilla/dom/CSSFontFaceRuleBinding.h" #include "StyleRule.h" #include "nsFont.h" #include "nsIURI.h" @@ -1668,7 +1669,6 @@ nsCSSFontFaceRule::IsCCLeaf() const // QueryInterface implementation for nsCSSFontFaceRule NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsCSSFontFaceRule) NS_INTERFACE_MAP_ENTRY(nsIDOMCSSFontFaceRule) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSFontFaceRule) NS_INTERFACE_MAP_END_INHERITING(Rule) #ifdef DEBUG @@ -1724,6 +1724,12 @@ nsCSSFontFaceRule::GetCssTextImpl(nsAString& aCssText) const aCssText.Append('}'); } +nsICSSDeclaration* +nsCSSFontFaceRule::Style() +{ + return &mDecl; +} + NS_IMETHODIMP nsCSSFontFaceRule::GetStyle(nsIDOMCSSStyleDeclaration** aStyle) { @@ -1768,8 +1774,7 @@ nsCSSFontFaceRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const nsCSSFontFaceRule::WrapObject(JSContext* aCx, JS::Handle aGivenProto) { - NS_NOTREACHED("We called SetIsNotDOMBinding() in our constructor"); - return nullptr; + return CSSFontFaceRuleBinding::Wrap(aCx, this, aGivenProto); } // ----------------------------------- diff --git a/layout/style/nsCSSRules.h b/layout/style/nsCSSRules.h index 01097c3f64..5dfe10af39 100644 --- a/layout/style/nsCSSRules.h +++ b/layout/style/nsCSSRules.h @@ -248,7 +248,6 @@ public: nsCSSFontFaceRule(uint32_t aLineNumber, uint32_t aColumnNumber) : mozilla::css::Rule(aLineNumber, aColumnNumber) { - SetIsNotDOMBinding(); } nsCSSFontFaceRule(const nsCSSFontFaceRule& aCopy) @@ -256,7 +255,6 @@ public: : mozilla::css::Rule(aCopy) , mDecl(aCopy.mDecl) { - SetIsNotDOMBinding(); } NS_DECL_ISUPPORTS_INHERITED @@ -279,6 +277,7 @@ public: // WebIDL interface uint16_t Type() const override; void GetCssTextImpl(nsAString& aCssText) const override; + nsICSSDeclaration* Style(); virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;