Bug 1345696 part 2 - Move nsCSSFontFaceRule to a separate header. r=heycam draft
authorXidorn Quan <me@upsuper.org>
Wed, 29 Mar 2017 10:20:40 +1100
changeset 553416 48ed07a86666fd313786ca03818947b10ca7a2ce
parent 553415 cef91018964b5488c5031df8aada90aa7fa0ad51
child 553417 bc4542e87a72d896fcfcf6c0cfc2093f9af718c1
push id51629
push userxquan@mozilla.com
push dateThu, 30 Mar 2017 01:13:04 +0000
reviewersheycam
bugs1345696
milestone55.0a1
Bug 1345696 part 2 - Move nsCSSFontFaceRule to a separate header. r=heycam MozReview-Commit-ID: 5UsODlVQV7a
dom/bindings/Bindings.conf
layout/style/FontFace.cpp
layout/style/FontFaceSet.h
layout/style/moz.build
layout/style/nsCSSFontFaceRule.h
layout/style/nsCSSParser.cpp
layout/style/nsCSSRuleProcessor.cpp
layout/style/nsCSSRules.cpp
layout/style/nsCSSRules.h
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -200,17 +200,17 @@ DOMInterfaces = {
 
 'CSSCounterStyleRule': {
     'nativeType': 'nsCSSCounterStyleRule',
     'headerFile': 'nsCSSRules.h',
 },
 
 'CSSFontFaceRule': {
     'nativeType': 'nsCSSFontFaceRule',
-    'headerFile': 'nsCSSRules.h',
+    'headerFile': 'nsCSSFontFaceRule.h',
 },
 
 'CSSFontFeatureValuesRule': {
     'nativeType': 'nsCSSFontFeatureValuesRule',
     'headerFile': 'nsCSSRules.h',
 },
 
 'CSSGroupingRule': {
--- a/layout/style/FontFace.cpp
+++ b/layout/style/FontFace.cpp
@@ -7,18 +7,18 @@
 
 #include <algorithm>
 #include "mozilla/dom/FontFaceBinding.h"
 #include "mozilla/dom/FontFaceSet.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/dom/TypedArray.h"
 #include "mozilla/dom/UnionTypes.h"
 #include "mozilla/CycleCollectedJSContext.h"
+#include "nsCSSFontFaceRule.h"
 #include "nsCSSParser.h"
-#include "nsCSSRules.h"
 #include "nsIDocument.h"
 #include "nsStyleUtil.h"
 
 namespace mozilla {
 namespace dom {
 
 // -- FontFaceBufferSource ---------------------------------------------------
 
--- a/layout/style/FontFaceSet.h
+++ b/layout/style/FontFaceSet.h
@@ -5,17 +5,17 @@
 
 #ifndef mozilla_dom_FontFaceSet_h
 #define mozilla_dom_FontFaceSet_h
 
 #include "mozilla/dom/FontFace.h"
 #include "mozilla/dom/FontFaceSetBinding.h"
 #include "mozilla/DOMEventTargetHelper.h"
 #include "gfxUserFontSet.h"
-#include "nsCSSRules.h"
+#include "nsCSSFontFaceRule.h"
 #include "nsICSSLoaderObserver.h"
 
 struct gfxFontFaceSrc;
 class gfxUserFontEntry;
 class nsFontFaceLoader;
 class nsIPrincipal;
 class nsPIDOMWindowInner;
 
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -27,16 +27,17 @@ EXPORTS += [
     'AnimationCommon.h',
     'CounterStyleManager.h',
     'nsAnimationManager.h',
     'nsComputedDOMStylePropertyList.h',
     'nsCSSAnonBoxes.h',
     'nsCSSAnonBoxList.h',
     'nsCSSCounterDescList.h',
     'nsCSSFontDescList.h',
+    'nsCSSFontFaceRule.h',
     'nsCSSKeywordList.h',
     'nsCSSKeywords.h',
     'nsCSSParser.h',
     'nsCSSPropAliasList.h',
     'nsCSSPropertyID.h',
     'nsCSSPropertyIDSet.h',
     'nsCSSPropList.h',
     'nsCSSPropLogicalGroupList.h',
new file mode 100644
--- /dev/null
+++ b/layout/style/nsCSSFontFaceRule.h
@@ -0,0 +1,147 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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/. */
+
+#ifndef nsCSSFontFaceRule_h
+#define nsCSSFontFaceRule_h
+
+#include "mozilla/css/Rule.h"
+#include "nsCSSValue.h"
+#include "nsICSSDeclaration.h"
+#include "nsIDOMCSSFontFaceRule.h"
+
+namespace mozilla {
+
+struct CSSFontFaceDescriptors
+{
+#define CSS_FONT_DESC(name_, method_) nsCSSValue m##method_;
+#include "nsCSSFontDescList.h"
+#undef CSS_FONT_DESC
+
+  const nsCSSValue& Get(nsCSSFontDesc aFontDescID) const;
+  nsCSSValue& Get(nsCSSFontDesc aFontDescID);
+
+private:
+  static nsCSSValue CSSFontFaceDescriptors::* const Fields[];
+};
+
+} // namespace mozilla
+
+// A nsCSSFontFaceStyleDecl is always embedded in a nsCSSFontFaceRule.
+class nsCSSFontFaceRule;
+class nsCSSFontFaceStyleDecl final : public nsICSSDeclaration
+{
+public:
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER
+  NS_DECL_NSICSSDECLARATION
+  virtual already_AddRefed<mozilla::dom::CSSValue>
+  GetPropertyCSSValue(const nsAString& aProp, mozilla::ErrorResult& aRv)
+    override;
+  using nsICSSDeclaration::GetPropertyCSSValue;
+
+  virtual nsINode *GetParentObject() override;
+  virtual void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName) override;
+
+  nsresult GetPropertyValue(nsCSSFontDesc aFontDescID,
+                            nsAString & aResult) const;
+
+  virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
+
+protected:
+  ~nsCSSFontFaceStyleDecl() {}
+
+  friend class nsCSSFontFaceRule;
+
+  inline nsCSSFontFaceRule* ContainingRule();
+  inline const nsCSSFontFaceRule* ContainingRule() const;
+
+  mozilla::CSSFontFaceDescriptors mDescriptors;
+
+  // The actual implementation of GetCssText, so we can make it const.
+  void GetCssTextImpl(nsAString& aCssText) const;
+
+private:
+  // NOT TO BE IMPLEMENTED
+  // This object cannot be allocated on its own, only as part of
+  // nsCSSFontFaceRule.
+  void* operator new(size_t size) CPP_THROW_NEW;
+};
+
+class nsCSSFontFaceRule final : public mozilla::css::Rule,
+                                public nsIDOMCSSFontFaceRule
+{
+public:
+  nsCSSFontFaceRule(uint32_t aLineNumber, uint32_t aColumnNumber)
+    : mozilla::css::Rule(aLineNumber, aColumnNumber)
+  {
+  }
+
+  nsCSSFontFaceRule(const nsCSSFontFaceRule& aCopy)
+    // copy everything except our reference count
+    : mozilla::css::Rule(aCopy), mDecl(aCopy.mDecl)
+  {
+  }
+
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsCSSFontFaceRule,
+                                                         mozilla::css::Rule)
+  virtual bool IsCCLeaf() const override;
+
+#ifdef DEBUG
+  virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
+#endif
+  virtual int32_t GetType() const override;
+  using Rule::GetType;
+  virtual already_AddRefed<mozilla::css::Rule> Clone() const override;
+
+  // nsIDOMCSSFontFaceRule interface
+  NS_DECL_NSIDOMCSSFONTFACERULE
+
+  void SetDesc(nsCSSFontDesc aDescID, nsCSSValue const & aValue);
+  void GetDesc(nsCSSFontDesc aDescID, nsCSSValue & aValue);
+
+  // WebIDL interface
+  uint16_t Type() const override;
+  void GetCssTextImpl(nsAString& aCssText) const override;
+  nsICSSDeclaration* Style();
+
+  virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
+
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aGivenProto) override;
+
+  void GetDescriptors(mozilla::CSSFontFaceDescriptors& aDescriptors) const
+    { aDescriptors = mDecl.mDescriptors; }
+
+protected:
+  ~nsCSSFontFaceRule() {}
+
+  friend class nsCSSFontFaceStyleDecl;
+  nsCSSFontFaceStyleDecl mDecl;
+};
+
+// nsFontFaceRuleContainer - used for associating sheet type with
+// specific @font-face rules
+struct nsFontFaceRuleContainer {
+  RefPtr<nsCSSFontFaceRule> mRule;
+  mozilla::SheetType mSheetType;
+};
+
+inline nsCSSFontFaceRule*
+nsCSSFontFaceStyleDecl::ContainingRule()
+{
+  return reinterpret_cast<nsCSSFontFaceRule*>
+    (reinterpret_cast<char*>(this) - offsetof(nsCSSFontFaceRule, mDecl));
+}
+
+inline const nsCSSFontFaceRule*
+nsCSSFontFaceStyleDecl::ContainingRule() const
+{
+  return reinterpret_cast<const nsCSSFontFaceRule*>
+    (reinterpret_cast<const char*>(this) - offsetof(nsCSSFontFaceRule, mDecl));
+}
+
+#endif // nsCSSFontFaceRule_h
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -24,16 +24,17 @@
 #include "nsCSSProps.h"
 #include "nsCSSKeywords.h"
 #include "nsCSSScanner.h"
 #include "mozilla/css/ErrorReporter.h"
 #include "mozilla/css/Loader.h"
 #include "mozilla/css/StyleRule.h"
 #include "mozilla/css/ImportRule.h"
 #include "nsCSSRules.h"
+#include "nsCSSFontFaceRule.h"
 #include "mozilla/css/NameSpaceRule.h"
 #include "nsTArray.h"
 #include "mozilla/StyleSheetInlines.h"
 #include "mozilla/css/Declaration.h"
 #include "nsStyleConsts.h"
 #include "nsNetUtil.h"
 #include "nsCOMPtr.h"
 #include "nsString.h"
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -42,16 +42,17 @@
 #include "nsQuickSort.h"
 #include "nsAttrValue.h"
 #include "nsAttrValueInlines.h"
 #include "nsAttrName.h"
 #include "nsTArray.h"
 #include "nsContentUtils.h"
 #include "nsMediaList.h"
 #include "nsCSSRules.h"
+#include "nsCSSFontFaceRule.h"
 #include "nsStyleSet.h"
 #include "mozilla/dom/Element.h"
 #include "nsNthIndexCache.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/LookAndFeel.h"
 #include "mozilla/Likely.h"
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; 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/. */
 
 /* rules in a CSS stylesheet other than style rules (e.g., @import rules) */
 
 #include "nsCSSRules.h"
+#include "nsCSSFontFaceRule.h"
 
 #include "mozilla/Attributes.h"
 
 #include "nsCSSValue.h"
 #include "mozilla/StyleSheetInlines.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/css/ImportRule.h"
 #include "mozilla/css/NameSpaceRule.h"
--- a/layout/style/nsCSSRules.h
+++ b/layout/style/nsCSSRules.h
@@ -13,24 +13,22 @@
 #include "StyleRule.h"
 #include "gfxFontFeatures.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Move.h"
 #include "mozilla/SheetType.h"
 #include "mozilla/css/GroupRule.h"
 #include "mozilla/dom/CSSMediaRule.h"
-#include "mozilla/dom/FontFace.h"
 #include "nsAutoPtr.h"
 #include "nsCSSPropertyID.h"
 #include "nsCSSValue.h"
 #include "nsDOMCSSDeclaration.h"
 #include "nsIDOMCSSConditionRule.h"
 #include "nsIDOMCSSCounterStyleRule.h"
-#include "nsIDOMCSSFontFaceRule.h"
 #include "nsIDOMCSSFontFeatureValuesRule.h"
 #include "nsIDOMCSSGroupingRule.h"
 #include "nsIDOMCSSMozDocumentRule.h"
 #include "nsIDOMCSSPageRule.h"
 #include "nsIDOMCSSSupportsRule.h"
 #include "nsIDOMCSSKeyframeRule.h"
 #include "nsIDOMCSSKeyframesRule.h"
 #include "nsTArray.h"
@@ -169,146 +167,18 @@ public:
 protected:
   void AppendConditionText(nsAString& aOutput) const;
 
   nsAutoPtr<URL> mURLs; // linked list of |struct URL| above.
 };
 
 } // namespace css
 
-struct CSSFontFaceDescriptors
-{
-#define CSS_FONT_DESC(name_, method_) nsCSSValue m##method_;
-#include "nsCSSFontDescList.h"
-#undef CSS_FONT_DESC
-
-  const nsCSSValue& Get(nsCSSFontDesc aFontDescID) const;
-  nsCSSValue& Get(nsCSSFontDesc aFontDescID);
-
-private:
-  static nsCSSValue CSSFontFaceDescriptors::* const Fields[];
-};
-
 } // namespace mozilla
 
-// A nsCSSFontFaceStyleDecl is always embedded in a nsCSSFontFaceRule.
-class nsCSSFontFaceRule;
-class nsCSSFontFaceStyleDecl final : public nsICSSDeclaration
-{
-public:
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER
-  NS_DECL_NSICSSDECLARATION
-  virtual already_AddRefed<mozilla::dom::CSSValue>
-  GetPropertyCSSValue(const nsAString& aProp, mozilla::ErrorResult& aRv)
-    override;
-  using nsICSSDeclaration::GetPropertyCSSValue;
-
-  virtual nsINode *GetParentObject() override;
-  virtual void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName) override;
-
-  nsresult GetPropertyValue(nsCSSFontDesc aFontDescID,
-                            nsAString & aResult) const;
-
-  virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
-
-protected:
-  ~nsCSSFontFaceStyleDecl() {}
-
-  friend class nsCSSFontFaceRule;
-
-  inline nsCSSFontFaceRule* ContainingRule();
-  inline const nsCSSFontFaceRule* ContainingRule() const;
-
-  mozilla::CSSFontFaceDescriptors mDescriptors;
-
-  // The actual implementation of GetCssText, so we can make it const.
-  void GetCssTextImpl(nsAString& aCssText) const;
-
-private:
-  // NOT TO BE IMPLEMENTED
-  // This object cannot be allocated on its own, only as part of
-  // nsCSSFontFaceRule.
-  void* operator new(size_t size) CPP_THROW_NEW;
-};
-
-class nsCSSFontFaceRule final : public mozilla::css::Rule,
-                                public nsIDOMCSSFontFaceRule
-{
-public:
-  nsCSSFontFaceRule(uint32_t aLineNumber, uint32_t aColumnNumber)
-    : mozilla::css::Rule(aLineNumber, aColumnNumber)
-  {
-  }
-
-  nsCSSFontFaceRule(const nsCSSFontFaceRule& aCopy)
-    // copy everything except our reference count
-    : mozilla::css::Rule(aCopy), mDecl(aCopy.mDecl)
-  {
-  }
-
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsCSSFontFaceRule,
-                                                         mozilla::css::Rule)
-  virtual bool IsCCLeaf() const override;
-
-#ifdef DEBUG
-  virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
-#endif
-  virtual int32_t GetType() const override;
-  using Rule::GetType;
-  virtual already_AddRefed<mozilla::css::Rule> Clone() const override;
-
-  // nsIDOMCSSFontFaceRule interface
-  NS_DECL_NSIDOMCSSFONTFACERULE
-
-  void SetDesc(nsCSSFontDesc aDescID, nsCSSValue const & aValue);
-  void GetDesc(nsCSSFontDesc aDescID, nsCSSValue & aValue);
-
-  // WebIDL interface
-  uint16_t Type() const override;
-  void GetCssTextImpl(nsAString& aCssText) const override;
-  nsICSSDeclaration* Style();
-
-  virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
-
-  virtual JSObject* WrapObject(JSContext* aCx,
-                               JS::Handle<JSObject*> aGivenProto) override;
-
-  void GetDescriptors(mozilla::CSSFontFaceDescriptors& aDescriptors) const
-    { aDescriptors = mDecl.mDescriptors; }
-
-protected:
-  ~nsCSSFontFaceRule() {}
-
-  friend class nsCSSFontFaceStyleDecl;
-  nsCSSFontFaceStyleDecl mDecl;
-};
-
-// nsFontFaceRuleContainer - used for associating sheet type with
-// specific @font-face rules
-struct nsFontFaceRuleContainer {
-  RefPtr<nsCSSFontFaceRule> mRule;
-  mozilla::SheetType mSheetType;
-};
-
-inline nsCSSFontFaceRule*
-nsCSSFontFaceStyleDecl::ContainingRule()
-{
-  return reinterpret_cast<nsCSSFontFaceRule*>
-    (reinterpret_cast<char*>(this) - offsetof(nsCSSFontFaceRule, mDecl));
-}
-
-inline const nsCSSFontFaceRule*
-nsCSSFontFaceStyleDecl::ContainingRule() const
-{
-  return reinterpret_cast<const nsCSSFontFaceRule*>
-    (reinterpret_cast<const char*>(this) - offsetof(nsCSSFontFaceRule, mDecl));
-}
-
 class nsCSSFontFeatureValuesRule final : public mozilla::css::Rule,
                                          public nsIDOMCSSFontFeatureValuesRule
 {
 public:
   nsCSSFontFeatureValuesRule(uint32_t aLineNumber, uint32_t aColumnNumber)
     : mozilla::css::Rule(aLineNumber, aColumnNumber)
   {
   }