Bug 1365900 - Extract CSSFontFeatureValuesRule base class r=xidorn
authorNazım Can Altınova <canaltinova@gmail.com>
Mon, 24 Jul 2017 16:12:57 -0700
changeset 420209 b5451544fbeef393e4db58da5a4b7a1e5a3746c8
parent 420208 4538ef25253032a5624b4610e402f4e85c1fecc7
child 420210 63810d7a059ce4bd462db414343f4fe04f7ac4f7
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1365900
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1365900 - Extract CSSFontFeatureValuesRule base class r=xidorn Extract CSSFontFeatureValuesRule from nsCSSFontFeatureValuesRule class. This is necessary because we will create a FontFeatureValues rule for Servo side. MozReview-Commit-ID: GKy5wa6JLv9
dom/bindings/Bindings.conf
layout/style/CSSFontFeatureValuesRule.cpp
layout/style/CSSFontFeatureValuesRule.h
layout/style/moz.build
layout/style/nsCSSRules.cpp
layout/style/nsCSSRules.h
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -198,21 +198,16 @@ DOMInterfaces = {
     'headerFile': 'nsCSSCounterStyleRule.h',
 },
 
 'CSSFontFaceRule': {
     'nativeType': 'nsCSSFontFaceRule',
     'headerFile': 'nsCSSFontFaceRule.h',
 },
 
-'CSSFontFeatureValuesRule': {
-    'nativeType': 'nsCSSFontFeatureValuesRule',
-    'headerFile': 'nsCSSRules.h',
-},
-
 'CSSGroupingRule': {
     'concrete': False,
     'nativeType': 'mozilla::css::GroupRule',
 },
 
 'CSSLexer': {
     'wrapperCache': False
 },
new file mode 100644
--- /dev/null
+++ b/layout/style/CSSFontFeatureValuesRule.cpp
@@ -0,0 +1,51 @@
+/* -*- 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/. */
+
+#include "mozilla/dom/CSSFontFeatureValuesRule.h"
+#include "mozilla/dom/CSSFontFeatureValuesRuleBinding.h"
+
+namespace mozilla {
+namespace dom {
+
+NS_IMPL_ADDREF_INHERITED(CSSFontFeatureValuesRule, css::Rule)
+NS_IMPL_RELEASE_INHERITED(CSSFontFeatureValuesRule, css::Rule)
+
+// QueryInterface implementation for CSSFontFeatureValuesRule
+// If this ever gets its own cycle-collection bits, reevaluate our IsCCLeaf
+// implementation.
+NS_INTERFACE_MAP_BEGIN(CSSFontFeatureValuesRule)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMCSSFontFeatureValuesRule)
+NS_INTERFACE_MAP_END_INHERITING(mozilla::css::Rule)
+
+void
+CSSFontFeatureValuesRule::SetFontFamily(const nsAString& aFamily,
+                                              ErrorResult& aRv)
+{
+  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
+}
+
+void
+CSSFontFeatureValuesRule::SetValueText(const nsAString& aFamily,
+                                             ErrorResult& aRv)
+{
+  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
+}
+
+bool
+CSSFontFeatureValuesRule::IsCCLeaf() const
+{
+  return Rule::IsCCLeaf();
+}
+
+/* virtual */ JSObject*
+CSSFontFeatureValuesRule::WrapObject(JSContext* aCx,
+                                       JS::Handle<JSObject*> aGivenProto)
+{
+  return CSSFontFeatureValuesRuleBinding::Wrap(aCx, this, aGivenProto);
+}
+
+} // namespace dom
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/layout/style/CSSFontFeatureValuesRule.h
@@ -0,0 +1,56 @@
+/* -*- 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 mozilla_dom_CSSFontFeatureValuesRule_h
+#define mozilla_dom_CSSFontFeatureValuesRule_h
+
+#include "mozilla/css/Rule.h"
+
+#include "nsICSSDeclaration.h"
+#include "nsIDOMCSSFontFeatureValuesRule.h"
+#include "nsIDOMCSSStyleDeclaration.h"
+
+namespace mozilla {
+namespace dom {
+
+class CSSFontFeatureValuesRule : public css::Rule
+                               , public nsIDOMCSSFontFeatureValuesRule
+{
+public:
+  NS_DECL_ISUPPORTS_INHERITED
+
+  virtual bool IsCCLeaf() const override;
+
+  int32_t GetType() const final { return Rule::FONT_FEATURE_VALUES_RULE; }
+  using Rule::GetType;
+  virtual already_AddRefed<mozilla::css::Rule> Clone() const override = 0;
+
+  using nsIDOMCSSFontFeatureValuesRule::SetFontFamily;
+  using nsIDOMCSSFontFeatureValuesRule::SetValueText;
+  // WebIDL interfaces
+  uint16_t Type() const final { return nsIDOMCSSRule::FONT_FEATURE_VALUES_RULE; }
+  virtual void GetCssTextImpl(nsAString& aCssText) const override = 0;
+  // The XPCOM GetFontFamily is fine
+  void SetFontFamily(const nsAString& aFamily, mozilla::ErrorResult& aRv);
+  // The XPCOM GetValueText is fine
+  void SetValueText(const nsAString& aFamily, mozilla::ErrorResult& aRv);
+
+  virtual size_t
+  SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override = 0;
+
+  JSObject*
+  WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+
+protected:
+  using Rule::Rule;
+
+  virtual ~CSSFontFeatureValuesRule() {};
+};
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_CSSFontFeatureValuesRule_h
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -135,16 +135,17 @@ EXPORTS.mozilla += [
     'StyleSheet.h',
     'StyleSheetInfo.h',
     'StyleSheetInlines.h',
     'URLExtraData.h',
 ]
 
 EXPORTS.mozilla.dom += [
     'CSS.h',
+    'CSSFontFeatureValuesRule.h',
     'CSSImportRule.h',
     'CSSKeyframeRule.h',
     'CSSKeyframesRule.h',
     'CSSLexer.h',
     'CSSMediaRule.h',
     'CSSMozDocumentRule.h',
     'CSSNamespaceRule.h',
     'CSSPageRule.h',
@@ -172,16 +173,17 @@ EXPORTS.mozilla.css += [
     'URLMatchingFunction.h',
 ]
 
 UNIFIED_SOURCES += [
     'AnimationCollection.cpp',
     'BindingStyleRule.cpp',
     'CounterStyleManager.cpp',
     'CSS.cpp',
+    'CSSFontFeatureValuesRule.cpp',
     'CSSImportRule.cpp',
     'CSSKeyframeRule.cpp',
     'CSSKeyframesRule.cpp',
     'CSSLexer.cpp',
     'CSSMediaRule.cpp',
     'CSSMozDocumentRule.cpp',
     'CSSPageRule.cpp',
     'CSSRuleList.cpp',
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -1260,31 +1260,24 @@ nsCSSFontFaceRule::WrapObject(JSContext*
 
 /* virtual */ already_AddRefed<css::Rule>
 nsCSSFontFeatureValuesRule::Clone() const
 {
   RefPtr<css::Rule> clone = new nsCSSFontFeatureValuesRule(*this);
   return clone.forget();
 }
 
-NS_IMPL_ADDREF_INHERITED(nsCSSFontFeatureValuesRule, mozilla::css::Rule)
-NS_IMPL_RELEASE_INHERITED(nsCSSFontFeatureValuesRule, mozilla::css::Rule)
+NS_IMPL_ADDREF_INHERITED(nsCSSFontFeatureValuesRule, dom::CSSFontFeatureValuesRule)
+NS_IMPL_RELEASE_INHERITED(nsCSSFontFeatureValuesRule, dom::CSSFontFeatureValuesRule)
 
 // QueryInterface implementation for nsCSSFontFeatureValuesRule
 // If this ever gets its own cycle-collection bits, reevaluate our IsCCLeaf
 // implementation.
 NS_INTERFACE_MAP_BEGIN(nsCSSFontFeatureValuesRule)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMCSSFontFeatureValuesRule)
-NS_INTERFACE_MAP_END_INHERITING(mozilla::css::Rule)
-
-bool
-nsCSSFontFeatureValuesRule::IsCCLeaf() const
-{
-  return Rule::IsCCLeaf();
-}
+NS_INTERFACE_MAP_END_INHERITING(dom::CSSFontFeatureValuesRule)
 
 static void
 FeatureValuesToString(
   const nsTArray<gfxFontFeatureValueSet::FeatureValues>& aFeatureValues,
   nsAString& aOutStr)
 {
   uint32_t i, n;
 
@@ -1358,74 +1351,48 @@ nsCSSFontFeatureValuesRule::List(FILE* o
   nsAutoCString indentStr;
   for (i = aIndent; --i >= 0; ) {
     indentStr.AppendLiteral("  ");
   }
   fprintf_stderr(out, "%s%s\n", indentStr.get(), utf8.get());
 }
 #endif
 
-/* virtual */ int32_t
-nsCSSFontFeatureValuesRule::GetType() const
-{
-  return Rule::FONT_FEATURE_VALUES_RULE;
-}
-
-uint16_t
-nsCSSFontFeatureValuesRule::Type() const
-{
-  return nsIDOMCSSRule::FONT_FEATURE_VALUES_RULE;
-}
-
-void
-nsCSSFontFeatureValuesRule::GetCssTextImpl(nsAString& aCssText) const
-{
-  FontFeatureValuesRuleToString(mFamilyList, mFeatureValues, aCssText);
-}
-
-void
-nsCSSFontFeatureValuesRule::SetFontFamily(const nsAString& aFamily,
-                                          ErrorResult& aRv)
-{
-  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
-}
-
-void
-nsCSSFontFeatureValuesRule::SetValueText(const nsAString& aFamily,
-                                         ErrorResult& aRv)
-{
-  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
-}
-
 NS_IMETHODIMP
 nsCSSFontFeatureValuesRule::GetFontFamily(nsAString& aFamilyListStr)
 {
   nsStyleUtil::AppendEscapedCSSFontFamilyList(mFamilyList, aFamilyListStr);
   return NS_OK;
 }
 
 NS_IMETHODIMP
+nsCSSFontFeatureValuesRule::GetValueText(nsAString& aValueText)
+{
+  FeatureValuesToString(mFeatureValues, aValueText);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsCSSFontFeatureValuesRule::SetFontFamily(const nsAString& aFontFamily)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
-nsCSSFontFeatureValuesRule::GetValueText(nsAString& aValueText)
-{
-  FeatureValuesToString(mFeatureValues, aValueText);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 nsCSSFontFeatureValuesRule::SetValueText(const nsAString& aValueText)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
+void
+nsCSSFontFeatureValuesRule::GetCssTextImpl(nsAString& aCssText) const
+{
+  FontFeatureValuesRuleToString(mFamilyList, mFeatureValues, aCssText);
+}
+
 struct MakeFamilyArray {
   explicit MakeFamilyArray(nsTArray<nsString>& aFamilyArray)
     : familyArray(aFamilyArray), hasGeneric(false)
   {}
 
   static bool
   AddFamily(const nsString& aFamily, bool aGeneric, void* aData)
   {
@@ -1478,23 +1445,16 @@ nsCSSFontFeatureValuesRule::AddValueList
 
 size_t
 nsCSSFontFeatureValuesRule::SizeOfIncludingThis(
   MallocSizeOf aMallocSizeOf) const
 {
   return aMallocSizeOf(this);
 }
 
-/* virtual */ JSObject*
-nsCSSFontFeatureValuesRule::WrapObject(JSContext* aCx,
-                                       JS::Handle<JSObject*> aGivenProto)
-{
-  return CSSFontFeatureValuesRuleBinding::Wrap(aCx, this, aGivenProto);
-}
-
 // -------------------------------------------
 // nsCSSKeyframeStyleDeclaration
 //
 
 nsCSSKeyframeStyleDeclaration::nsCSSKeyframeStyleDeclaration(nsCSSKeyframeRule *aRule)
   : mRule(aRule)
 {
 }
--- a/layout/style/nsCSSRules.h
+++ b/layout/style/nsCSSRules.h
@@ -13,16 +13,17 @@
 #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/css/URLMatchingFunction.h"
+#include "mozilla/dom/CSSFontFeatureValuesRule.h"
 #include "mozilla/dom/CSSKeyframeRule.h"
 #include "mozilla/dom/CSSKeyframesRule.h"
 #include "mozilla/dom/CSSMediaRule.h"
 #include "mozilla/dom/CSSPageRule.h"
 #include "mozilla/dom/CSSSupportsRule.h"
 #include "mozilla/dom/CSSMozDocumentRule.h"
 #include "nsAutoPtr.h"
 #include "nsCSSPropertyID.h"
@@ -155,70 +156,58 @@ protected:
 
   nsAutoPtr<URL> mURLs; // linked list of |struct URL| above.
 };
 
 } // namespace css
 
 } // namespace mozilla
 
-class nsCSSFontFeatureValuesRule final : public mozilla::css::Rule,
-                                         public nsIDOMCSSFontFeatureValuesRule
+class nsCSSFontFeatureValuesRule final : public mozilla::dom::CSSFontFeatureValuesRule
 {
 public:
   nsCSSFontFeatureValuesRule(uint32_t aLineNumber, uint32_t aColumnNumber)
-    : mozilla::css::Rule(aLineNumber, aColumnNumber)
+    : mozilla::dom::CSSFontFeatureValuesRule(aLineNumber, aColumnNumber)
   {
   }
 
   nsCSSFontFeatureValuesRule(const nsCSSFontFeatureValuesRule& aCopy)
     // copy everything except our reference count
-    : mozilla::css::Rule(aCopy),
+    : mozilla::dom::CSSFontFeatureValuesRule(aCopy),
       mFamilyList(aCopy.mFamilyList),
       mFeatureValues(aCopy.mFeatureValues)
   {
   }
 
   NS_DECL_ISUPPORTS_INHERITED
-  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
+  // nsIDOMCSSFontFeatureValuesRule interface
   NS_DECL_NSIDOMCSSFONTFEATUREVALUESRULE
 
   // WebIDL interface
-  uint16_t Type() const override;
-  void GetCssTextImpl(nsAString& aCssText) const override;
-  // The XPCOM GetFontFamily is fine
-  void SetFontFamily(const nsAString& aFamily, mozilla::ErrorResult& aRv);
-  // The XPCOM GetValueText is fine
-  void SetValueText(const nsAString& aFamily, mozilla::ErrorResult& aRv);
+  void GetCssTextImpl(nsAString& aCssText) const final;
 
   const mozilla::FontFamilyList& GetFamilyList() { return mFamilyList; }
   void SetFamilyList(const mozilla::FontFamilyList& aFamilyList);
 
   void AddValueList(int32_t aVariantAlternate,
                     nsTArray<gfxFontFeatureValueSet::ValueList>& aValueList);
 
   const nsTArray<gfxFontFeatureValueSet::FeatureValues>& GetFeatureValues()
   {
     return mFeatureValues;
   }
 
   virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
 
-  virtual JSObject* WrapObject(JSContext* aCx,
-                               JS::Handle<JSObject*> aGivenProto) override;
-
 protected:
   ~nsCSSFontFeatureValuesRule() {}
 
   mozilla::FontFamilyList mFamilyList;
   nsTArray<gfxFontFeatureValueSet::FeatureValues> mFeatureValues;
 };
 
 class nsCSSKeyframeRule;