Bug 1345697 part 2 - Add CSSKeyframesRule and CSSKeyframeRule base class. r?heycam draft
authorXidorn Quan <me@upsuper.org>
Wed, 17 May 2017 19:54:25 +1000
changeset 579509 684c2a54e5b21d3f627b3cc3f7ff7868d0a7f9c6
parent 579508 3652d4bed9fbc8c37607d075fedc8e3f624dd2d8
child 579510 04978df41909e84b840e44a6e6e4ac5732f25075
push id59271
push userxquan@mozilla.com
push dateWed, 17 May 2017 11:06:52 +0000
reviewersheycam
bugs1345697
milestone55.0a1
Bug 1345697 part 2 - Add CSSKeyframesRule and CSSKeyframeRule base class. r?heycam MozReview-Commit-ID: GZzZIV3eYgo
dom/bindings/Bindings.conf
layout/style/CSSKeyframeRule.cpp
layout/style/CSSKeyframeRule.h
layout/style/CSSKeyframesRule.cpp
layout/style/CSSKeyframesRule.h
layout/style/moz.build
layout/style/nsCSSRules.cpp
layout/style/nsCSSRules.h
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -212,26 +212,16 @@ DOMInterfaces = {
     'concrete': False,
     'nativeType': 'mozilla::css::GroupRule',
 },
 
 'CSSImportRule': {
     'nativeType': 'mozilla::css::ImportRule',
 },
 
-'CSSKeyframeRule': {
-    'nativeType': 'nsCSSKeyframeRule',
-    'headerFile': 'nsCSSRules.h',
-},
-
-'CSSKeyframesRule': {
-    'nativeType': 'nsCSSKeyframesRule',
-    'headerFile': 'nsCSSRules.h',
-},
-
 'CSSLexer': {
     'wrapperCache': False
 },
 
 'CSSPrimitiveValue': {
     'nativeType': 'nsROCSSPrimitiveValue',
 },
 
new file mode 100644
--- /dev/null
+++ b/layout/style/CSSKeyframeRule.cpp
@@ -0,0 +1,38 @@
+/* -*- 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/CSSKeyframeRule.h"
+
+#include "mozilla/dom/CSSKeyframeRuleBinding.h"
+#include "nsICSSDeclaration.h"
+
+namespace mozilla {
+namespace dom {
+
+NS_IMPL_ADDREF_INHERITED(CSSKeyframeRule, mozilla::css::Rule)
+NS_IMPL_RELEASE_INHERITED(CSSKeyframeRule, mozilla::css::Rule)
+
+// QueryInterface implementation for CSSKeyframeRule
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(CSSKeyframeRule)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMCSSKeyframeRule)
+NS_INTERFACE_MAP_END_INHERITING(mozilla::css::Rule)
+
+NS_IMETHODIMP
+CSSKeyframeRule::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
+{
+  NS_ADDREF(*aStyle = Style());
+  return NS_OK;
+}
+
+/* virtual */ JSObject*
+CSSKeyframeRule::WrapObject(JSContext* aCx,
+                            JS::Handle<JSObject*> aGivenProto)
+{
+  return CSSKeyframeRuleBinding::Wrap(aCx, this, aGivenProto);
+}
+
+} // namespace dom
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/layout/style/CSSKeyframeRule.h
@@ -0,0 +1,47 @@
+/* -*- 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_CSSKeyframeRule_h
+#define mozilla_dom_CSSKeyframeRule_h
+
+#include "mozilla/css/Rule.h"
+#include "nsIDOMCSSKeyframeRule.h"
+
+namespace mozilla {
+namespace dom {
+
+class CSSKeyframeRule : public css::Rule
+                      , public nsIDOMCSSKeyframeRule
+{
+protected:
+  using css::Rule::Rule;
+  virtual ~CSSKeyframeRule() {}
+
+public:
+  NS_DECL_ISUPPORTS_INHERITED
+
+  int32_t GetType() const final { return Rule::KEYFRAME_RULE; }
+  using Rule::GetType;
+  using Rule::IsCCLeaf;
+
+  // nsIDOMCSSKeyframeRule
+  NS_IMETHOD GetStyle(nsIDOMCSSStyleDeclaration** aStyle) final;
+
+  // WebIDL interface
+  uint16_t Type() const final { return nsIDOMCSSRule::KEYFRAME_RULE; }
+  // The XPCOM GetKeyText is fine.
+  // The XPCOM SetKeyText is fine.
+  virtual nsICSSDeclaration* Style() = 0;
+
+  size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override = 0;
+
+  JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
+};
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_CSSKeyframeRule_h
new file mode 100644
--- /dev/null
+++ b/layout/style/CSSKeyframesRule.cpp
@@ -0,0 +1,52 @@
+/* -*- 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/CSSKeyframesRule.h"
+
+#include "mozilla/dom/CSSKeyframesRuleBinding.h"
+
+namespace mozilla {
+namespace dom {
+
+NS_IMPL_ADDREF_INHERITED(CSSKeyframesRule, css::GroupRule)
+NS_IMPL_RELEASE_INHERITED(CSSKeyframesRule, css::GroupRule)
+
+// QueryInterface implementation for CSSKeyframesRule
+NS_INTERFACE_MAP_BEGIN(CSSKeyframesRule)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMCSSKeyframesRule)
+NS_INTERFACE_MAP_END_INHERITING(GroupRule)
+
+NS_IMETHODIMP
+CSSKeyframesRule::GetCssRules(nsIDOMCSSRuleList** aRuleList)
+{
+  NS_ADDREF(*aRuleList = CssRules());
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+CSSKeyframesRule::FindRule(const nsAString& aKey,
+                           nsIDOMCSSKeyframeRule** aResult)
+{
+  NS_IF_ADDREF(*aResult = FindRule(aKey));
+  return NS_OK;
+}
+
+/* virtual */ bool
+CSSKeyframesRule::UseForPresentation(nsPresContext* aPresContext,
+                                     nsMediaQueryResultCacheKey& aKey)
+{
+  MOZ_ASSERT_UNREACHABLE("should not be called");
+  return false;
+}
+
+/* virtual */ JSObject*
+CSSKeyframesRule::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
+{
+  return CSSKeyframesRuleBinding::Wrap(aCx, this, aGivenProto);
+}
+
+} // namespace dom
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/layout/style/CSSKeyframesRule.h
@@ -0,0 +1,57 @@
+/* -*- 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_CSSKeyframesRule_h
+#define mozilla_dom_CSSKeyframesRule_h
+
+#include "mozilla/css/GroupRule.h"
+#include "nsIDOMCSSKeyframesRule.h"
+
+#include "mozilla/dom/CSSKeyframeRule.h"
+
+namespace mozilla {
+namespace dom {
+
+class CSSKeyframesRule : public css::GroupRule
+                       , public nsIDOMCSSKeyframesRule
+{
+protected:
+  using css::GroupRule::GroupRule;
+  virtual ~CSSKeyframesRule() {}
+
+public:
+  NS_DECL_ISUPPORTS_INHERITED
+
+  int32_t GetType() const final { return Rule::KEYFRAMES_RULE; }
+  using Rule::GetType;
+  using GroupRule::IsCCLeaf;
+
+  // nsIDOMCSSKeyframesRule interface
+  NS_IMETHOD GetCssRules(nsIDOMCSSRuleList** aRuleList) final;
+  NS_IMETHOD FindRule(const nsAString& aKey,
+                      nsIDOMCSSKeyframeRule** aResult) final;
+
+  // WebIDL interface
+  uint16_t Type() const final { return nsIDOMCSSRule::KEYFRAMES_RULE; }
+  // The XPCOM GetName is OK
+  // The XPCOM SetName is OK
+  virtual CSSRuleList* CssRules() = 0;
+  // The XPCOM appendRule is OK, since it never throws
+  using nsIDOMCSSKeyframesRule::DeleteRule;
+  virtual CSSKeyframeRule* FindRule(const nsAString& aKey) = 0;
+
+  bool UseForPresentation(nsPresContext* aPresContext,
+                          nsMediaQueryResultCacheKey& aKey) final;
+
+  size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override = 0;
+
+  JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
+};
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_CSSKeyframesRule_h
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -129,16 +129,18 @@ EXPORTS.mozilla += [
     'StyleSheet.h',
     'StyleSheetInfo.h',
     'StyleSheetInlines.h',
     'URLExtraData.h',
 ]
 
 EXPORTS.mozilla.dom += [
     'CSS.h',
+    'CSSKeyframeRule.h',
+    'CSSKeyframesRule.h',
     'CSSLexer.h',
     'CSSMediaRule.h',
     'CSSMozDocumentRule.h',
     'CSSNamespaceRule.h',
     'CSSPageRule.h',
     'CSSRuleList.h',
     'CSSSupportsRule.h',
     'CSSValue.h',
@@ -163,16 +165,18 @@ EXPORTS.mozilla.css += [
     'URLMatchingFunction.h',
 ]
 
 UNIFIED_SOURCES += [
     'AnimationCollection.cpp',
     'BindingStyleRule.cpp',
     'CounterStyleManager.cpp',
     'CSS.cpp',
+    'CSSKeyframeRule.cpp',
+    'CSSKeyframesRule.cpp',
     'CSSLexer.cpp',
     'CSSMediaRule.cpp',
     'CSSMozDocumentRule.cpp',
     'CSSPageRule.cpp',
     'CSSRuleList.cpp',
     'CSSStyleSheet.cpp',
     'CSSSupportsRule.cpp',
     'CSSVariableDeclarations.cpp',
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -34,18 +34,16 @@
 #include "nsStyleUtil.h"
 #include "mozilla/DeclarationBlockInlines.h"
 #include "nsCSSParser.h"
 #include "nsDOMClassInfoID.h"
 #include "mozilla/dom/CSSStyleDeclarationBinding.h"
 #include "mozilla/dom/CSSImportRuleBinding.h"
 #include "mozilla/dom/CSSFontFaceRuleBinding.h"
 #include "mozilla/dom/CSSFontFeatureValuesRuleBinding.h"
-#include "mozilla/dom/CSSKeyframeRuleBinding.h"
-#include "mozilla/dom/CSSKeyframesRuleBinding.h"
 #include "mozilla/dom/CSSCounterStyleRuleBinding.h"
 #include "StyleRule.h"
 #include "nsFont.h"
 #include "nsIURI.h"
 #include "mozAutoDocUpdate.h"
 #include "nsCCUncollectableMarker.h"
 #include "nsWrapperCacheInlines.h"
 
@@ -1613,17 +1611,17 @@ nsCSSKeyframeStyleDeclaration::GetParent
 }
 
 // -------------------------------------------
 // nsCSSKeyframeRule
 //
 
 nsCSSKeyframeRule::nsCSSKeyframeRule(const nsCSSKeyframeRule& aCopy)
   // copy everything except our reference count and mDOMDeclaration
-  : Rule(aCopy)
+  : dom::CSSKeyframeRule(aCopy)
   , mKeys(aCopy.mKeys)
   , mDeclaration(new css::Declaration(*aCopy.mDeclaration))
 {
   mDeclaration->SetOwningRule(this);
 }
 
 nsCSSKeyframeRule::~nsCSSKeyframeRule()
 {
@@ -1635,44 +1633,43 @@ nsCSSKeyframeRule::~nsCSSKeyframeRule()
 
 /* virtual */ already_AddRefed<css::Rule>
 nsCSSKeyframeRule::Clone() const
 {
   RefPtr<css::Rule> clone = new nsCSSKeyframeRule(*this);
   return clone.forget();
 }
 
-NS_IMPL_ADDREF_INHERITED(nsCSSKeyframeRule, mozilla::css::Rule)
-NS_IMPL_RELEASE_INHERITED(nsCSSKeyframeRule, mozilla::css::Rule)
+NS_IMPL_ADDREF_INHERITED(nsCSSKeyframeRule, dom::CSSKeyframeRule)
+NS_IMPL_RELEASE_INHERITED(nsCSSKeyframeRule, dom::CSSKeyframeRule)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsCSSKeyframeRule)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsCSSKeyframeRule,
-                                                mozilla::css::Rule)
+                                                dom::CSSKeyframeRule)
   if (tmp->mDOMDeclaration) {
     tmp->mDOMDeclaration->DropReference();
     tmp->mDOMDeclaration = nullptr;
   }
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsCSSKeyframeRule,
-                                                  mozilla::css::Rule)
+                                                  dom::CSSKeyframeRule)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDOMDeclaration)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 bool
 nsCSSKeyframeRule::IsCCLeaf() const
 {
   // Let's not worry about figuring out whether we're a leaf or not.
   return false;
 }
 
 // QueryInterface implementation for nsCSSKeyframeRule
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsCSSKeyframeRule)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMCSSKeyframeRule)
-NS_INTERFACE_MAP_END_INHERITING(mozilla::css::Rule)
+NS_INTERFACE_MAP_END_INHERITING(dom::CSSKeyframeRule)
 
 #ifdef DEBUG
 void
 nsCSSKeyframeRule::List(FILE* out, int32_t aIndent) const
 {
   nsAutoCString str;
   for (int32_t index = aIndent; --index >= 0; ) {
     str.AppendLiteral("  ");
@@ -1684,28 +1681,16 @@ nsCSSKeyframeRule::List(FILE* out, int32
   str.AppendLiteral(" { ");
   mDeclaration->ToString(tmp);
   AppendUTF16toUTF8(tmp, str);
   str.AppendLiteral("}\n");
   fprintf_stderr(out, "%s", str.get());
 }
 #endif
 
-/* virtual */ int32_t
-nsCSSKeyframeRule::GetType() const
-{
-  return Rule::KEYFRAME_RULE;
-}
-
-uint16_t
-nsCSSKeyframeRule::Type() const
-{
-  return nsIDOMCSSRule::KEYFRAME_RULE;
-}
-
 void
 nsCSSKeyframeRule::GetCssTextImpl(nsAString& aCssText) const
 {
   DoGetKeyText(aCssText);
   aCssText.AppendLiteral(" { ");
   nsAutoString tmp;
   mDeclaration->ToString(tmp);
   aCssText.Append(tmp);
@@ -1757,23 +1742,16 @@ nsCSSKeyframeRule::SetKeyText(const nsAS
     if (doc) {
       doc->StyleRuleChanged(sheet, this);
     }
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsCSSKeyframeRule::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
-{
-  NS_ADDREF(*aStyle = Style());
-  return NS_OK;
-}
-
 nsICSSDeclaration*
 nsCSSKeyframeRule::Style()
 {
   if (!mDOMDeclaration) {
     mDOMDeclaration = new nsCSSKeyframeStyleDeclaration(this);
   }
   return mDOMDeclaration;
 }
@@ -1808,54 +1786,46 @@ nsCSSKeyframeRule::SizeOfIncludingThis(M
 
   // Measurement of the following members may be added later if DMD finds it is
   // worthwhile:
   // - mKeys
   // - mDeclaration
   // - mDOMDeclaration
 }
 
-/* virtual */ JSObject*
-nsCSSKeyframeRule::WrapObject(JSContext* aCx,
-                              JS::Handle<JSObject*> aGivenProto)
-{
-  return CSSKeyframeRuleBinding::Wrap(aCx, this, aGivenProto);
-}
-
 // -------------------------------------------
 // nsCSSKeyframesRule
 //
 
 nsCSSKeyframesRule::nsCSSKeyframesRule(const nsCSSKeyframesRule& aCopy)
   // copy everything except our reference count.  GroupRule's copy
   // constructor also doesn't copy the lazily-constructed
   // mRuleCollection.
-  : GroupRule(aCopy),
+  : dom::CSSKeyframesRule(aCopy),
     mName(aCopy.mName)
 {
 }
 
 nsCSSKeyframesRule::~nsCSSKeyframesRule()
 {
 }
 
 /* virtual */ already_AddRefed<css::Rule>
 nsCSSKeyframesRule::Clone() const
 {
   RefPtr<css::Rule> clone = new nsCSSKeyframesRule(*this);
   return clone.forget();
 }
 
-NS_IMPL_ADDREF_INHERITED(nsCSSKeyframesRule, css::GroupRule)
-NS_IMPL_RELEASE_INHERITED(nsCSSKeyframesRule, css::GroupRule)
+NS_IMPL_ADDREF_INHERITED(nsCSSKeyframesRule, dom::CSSKeyframesRule)
+NS_IMPL_RELEASE_INHERITED(nsCSSKeyframesRule, dom::CSSKeyframesRule)
 
 // QueryInterface implementation for nsCSSKeyframesRule
 NS_INTERFACE_MAP_BEGIN(nsCSSKeyframesRule)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMCSSKeyframesRule)
-NS_INTERFACE_MAP_END_INHERITING(GroupRule)
+NS_INTERFACE_MAP_END_INHERITING(dom::CSSKeyframesRule)
 
 #ifdef DEBUG
 void
 nsCSSKeyframesRule::List(FILE* out, int32_t aIndent) const
 {
   nsAutoCString indentStr;
   for (int32_t indent = aIndent; --indent >= 0; ) {
     indentStr.AppendLiteral("  ");
@@ -1865,28 +1835,16 @@ nsCSSKeyframesRule::List(FILE* out, int3
                  indentStr.get(), NS_ConvertUTF16toUTF8(mName).get());
 
   GroupRule::List(out, aIndent);
 
   fprintf_stderr(out, "%s}\n", indentStr.get());
 }
 #endif
 
-/* virtual */ int32_t
-nsCSSKeyframesRule::GetType() const
-{
-  return Rule::KEYFRAMES_RULE;
-}
-
-uint16_t
-nsCSSKeyframesRule::Type() const
-{
-  return nsIDOMCSSRule::KEYFRAMES_RULE;
-}
-
 void
 nsCSSKeyframesRule::GetCssTextImpl(nsAString& aCssText) const
 {
   aCssText.AssignLiteral("@keyframes ");
   aCssText.Append(mName);
   aCssText.AppendLiteral(" {\n");
   nsAutoString tmp;
   for (const Rule* rule : GeckoRules()) {
@@ -1922,22 +1880,16 @@ nsCSSKeyframesRule::SetName(const nsAStr
       doc->StyleRuleChanged(sheet, this);
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsCSSKeyframesRule::GetCssRules(nsIDOMCSSRuleList* *aRuleList)
-{
-  return GroupRule::GetCssRules(aRuleList);
-}
-
-NS_IMETHODIMP
 nsCSSKeyframesRule::AppendRule(const nsAString& aRule)
 {
   // The spec is confusing, and I think we should just append the rule,
   // which also turns out to match WebKit:
   // http://lists.w3.org/Archives/Public/www-style/2011Apr/0034.html
   nsCSSParser parser;
 
   // FIXME: pass filename and line number
@@ -2002,63 +1954,39 @@ nsCSSKeyframesRule::DeleteRule(const nsA
       if (doc) {
         doc->StyleRuleChanged(sheet, this);
       }
     }
   }
   return NS_OK;
 }
 
-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) {
     return nullptr;
   }
   return static_cast<nsCSSKeyframeRule*>(GeckoRules()[index]);
 }
 
-// GroupRule interface
-/* virtual */ bool
-nsCSSKeyframesRule::UseForPresentation(nsPresContext* aPresContext,
-                                       nsMediaQueryResultCacheKey& aKey)
-{
-  MOZ_ASSERT(false, "should not be called");
-  return false;
-}
-
 /* virtual */ size_t
 nsCSSKeyframesRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
 {
   size_t n = aMallocSizeOf(this);
   n += GroupRule::SizeOfExcludingThis(aMallocSizeOf);
 
   // Measurement of the following members may be added later if DMD finds it is
   // worthwhile:
   // - mName
 
   return n;
 }
 
-/* virtual */ JSObject*
-nsCSSKeyframesRule::WrapObject(JSContext* aCx,
-                               JS::Handle<JSObject*> aGivenProto)
-{
-  return CSSKeyframesRuleBinding::Wrap(aCx, this, aGivenProto);
-}
-
 // -------------------------------------------
 // nsCSSPageStyleDeclaration
 //
 
 nsCSSPageStyleDeclaration::nsCSSPageStyleDeclaration(nsCSSPageRule* aRule)
   : mRule(aRule)
 {
 }
--- a/layout/style/nsCSSRules.h
+++ b/layout/style/nsCSSRules.h
@@ -13,31 +13,31 @@
 #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/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"
 #include "nsCSSValue.h"
 #include "nsDOMCSSDeclaration.h"
 #include "nsIDOMCSSConditionRule.h"
 #include "nsIDOMCSSFontFeatureValuesRule.h"
 #include "nsIDOMCSSGroupingRule.h"
 #include "nsIDOMCSSMozDocumentRule.h"
 #include "nsIDOMCSSSupportsRule.h"
-#include "nsIDOMCSSKeyframeRule.h"
-#include "nsIDOMCSSKeyframesRule.h"
 #include "nsTArray.h"
 
 class nsMediaList;
 
 namespace mozilla {
 
 class ErrorResult;
 
@@ -245,122 +245,104 @@ public:
 protected:
   virtual ~nsCSSKeyframeStyleDeclaration();
 
   // This reference is not reference-counted. The rule object tells us
   // when it's about to go away.
   nsCSSKeyframeRule* MOZ_NON_OWNING_REF mRule;
 };
 
-class nsCSSKeyframeRule final : public mozilla::css::Rule,
-                                public nsIDOMCSSKeyframeRule
+class nsCSSKeyframeRule final : public mozilla::dom::CSSKeyframeRule
 {
 public:
   // Steals the contents of aKeys, and takes the reference in Declaration
   nsCSSKeyframeRule(InfallibleTArray<float>&& aKeys,
                     already_AddRefed<mozilla::css::Declaration>&& aDeclaration,
                     uint32_t aLineNumber, uint32_t aColumnNumber)
-    : mozilla::css::Rule(aLineNumber, aColumnNumber)
+    : mozilla::dom::CSSKeyframeRule(aLineNumber, aColumnNumber)
     , mKeys(mozilla::Move(aKeys))
     , mDeclaration(mozilla::Move(aDeclaration))
   {
     mDeclaration->SetOwningRule(this);
   }
 private:
   nsCSSKeyframeRule(const nsCSSKeyframeRule& aCopy);
   ~nsCSSKeyframeRule();
 public:
   NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsCSSKeyframeRule, mozilla::css::Rule)
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsCSSKeyframeRule,
+                                           mozilla::dom::CSSKeyframeRule)
   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;
 
   // nsIDOMCSSKeyframeRule interface
-  NS_DECL_NSIDOMCSSKEYFRAMERULE
+  NS_IMETHOD GetKeyText(nsAString& aKeyText) final;
+  NS_IMETHOD SetKeyText(const nsAString& aKeyText) final;
 
   // WebIDL interface
-  uint16_t Type() const override;
-  void GetCssTextImpl(nsAString& aCssText) const override;
-  // The XPCOM GetKeyText is fine.
-  // The XPCOM SetKeyText is fine.
-  nsICSSDeclaration* Style();
+  void GetCssTextImpl(nsAString& aCssText) const final;
+  nsICSSDeclaration* Style() final;
 
   const nsTArray<float>& GetKeys() const     { return mKeys; }
   mozilla::css::Declaration* Declaration()   { return mDeclaration; }
 
   void ChangeDeclaration(mozilla::css::Declaration* aDeclaration);
 
   virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
 
-  virtual JSObject* WrapObject(JSContext* aCx,
-                               JS::Handle<JSObject*> aGivenProto) override;
-
   void DoGetKeyText(nsAString &aKeyText) const;
 
 private:
   nsTArray<float>                            mKeys;
   RefPtr<mozilla::css::Declaration>          mDeclaration;
   // lazily created when needed:
   RefPtr<nsCSSKeyframeStyleDeclaration>    mDOMDeclaration;
 };
 
-class nsCSSKeyframesRule final : public mozilla::css::GroupRule,
-                                 public nsIDOMCSSKeyframesRule
+class nsCSSKeyframesRule final : public mozilla::dom::CSSKeyframesRule
 {
 public:
   nsCSSKeyframesRule(const nsSubstring& aName,
                      uint32_t aLineNumber, uint32_t aColumnNumber)
-    : mozilla::css::GroupRule(aLineNumber, aColumnNumber)
+    : mozilla::dom::CSSKeyframesRule(aLineNumber, aColumnNumber)
     , mName(aName)
   {
   }
 private:
   nsCSSKeyframesRule(const nsCSSKeyframesRule& aCopy);
   ~nsCSSKeyframesRule();
 public:
   NS_DECL_ISUPPORTS_INHERITED
 
   // Rule methods
 #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;
 
   // nsIDOMCSSKeyframesRule interface
-  NS_DECL_NSIDOMCSSKEYFRAMESRULE
+  NS_IMETHOD GetName(nsAString& aName) final;
+  NS_IMETHOD SetName(const nsAString& aName) final;
+  NS_IMETHOD AppendRule(const nsAString& aRule) final;
+  NS_IMETHOD DeleteRule(const nsAString& aKey) final;
+  using nsIDOMCSSKeyframesRule::FindRule;
 
   // 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,
-                                    nsMediaQueryResultCacheKey& aKey) override;
+  void GetCssTextImpl(nsAString& aCssText) const final;
+  mozilla::dom::CSSRuleList* CssRules() final { return GroupRule::CssRules(); }
+  nsCSSKeyframeRule* FindRule(const nsAString& aKey) final;
 
   const nsString& GetName() { return mName; }
 
   virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
 
-  virtual JSObject* WrapObject(JSContext* aCx,
-                               JS::Handle<JSObject*> aGivenProto) override;
-
 private:
   uint32_t FindRuleIndexForKey(const nsAString& aKey);
 
   nsString                                   mName;
 };
 
 class nsCSSPageRule;