From 631e3a73e30844bd3998ed825452182499e5b7fd Mon Sep 17 00:00:00 2001 From: Moonchild Date: Apr 04 2024 08:02:17 +0000 Subject: Issue #2490 - Part 15: Convert CSSFontFaceRule to WebIDL. The .style PutForwards bit is coming along for the ride here as a new feature. --- diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index dfebbaf..1d32381 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" @@ -196,10 +195,6 @@ static nsDOMClassInfoData sClassInfoData[] = { NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULTreeBuilder, nsDOMGenericSH, DEFAULT_SCRIPTABLE_FLAGS) - 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 | @@ -510,11 +505,6 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_ENTRY(nsITreeView) DOM_CLASSINFO_MAP_END - 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 13a1631..299105f 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -15,9 +15,6 @@ DOMCI_CLASS(TreeContentView) DOMCI_CLASS(XULTemplateBuilder) DOMCI_CLASS(XULTreeBuilder) -// @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 c994768..cedda8b 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 7a4e3d7..c525020 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -186,6 +186,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 0000000..221dd26 --- /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 71e1eab..18dfba2 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -92,6 +92,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 e7128c5..fc009eb 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 0a21587..1b25991 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;