Bug 1451289 - Part 10: Merge ServoImportRule and CSSImportRule r=emilio
authorNazım Can Altınova <canaltinova@gmail.com>
Wed, 06 Jun 2018 15:31:33 +0200
changeset 422510 abddd543387934eecdcab5e84637d91bccadad90
parent 422509 d570b529fedd52f3770fccaf107c00929ab49156
child 422511 bd47a1b3d97b2e0576f6268f8b308452169ab158
push id104281
push userncsoregi@mozilla.com
push dateThu, 14 Jun 2018 09:47:16 +0000
treeherdermozilla-inbound@3c88a15bdd51 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1451289
milestone62.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 1451289 - Part 10: Merge ServoImportRule and CSSImportRule r=emilio MozReview-Commit-ID: JvHNGoX4AUF
layout/inspector/ServoStyleRuleMap.cpp
layout/style/CSSImportRule.cpp
layout/style/CSSImportRule.h
layout/style/ServoCSSRuleList.cpp
layout/style/ServoImportRule.cpp
layout/style/ServoImportRule.h
layout/style/moz.build
layout/style/nsCSSProps.cpp
layout/style/nsDOMCSSRect.h
--- a/layout/inspector/ServoStyleRuleMap.cpp
+++ b/layout/inspector/ServoStyleRuleMap.cpp
@@ -2,21 +2,21 @@
 /* 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/ServoStyleRuleMap.h"
 
 #include "mozilla/css/GroupRule.h"
+#include "mozilla/dom/CSSImportRule.h"
 #include "mozilla/dom/CSSRuleBinding.h"
 #include "mozilla/dom/CSSStyleRule.h"
 #include "mozilla/IntegerRange.h"
 #include "mozilla/ServoStyleSet.h"
-#include "mozilla/ServoImportRule.h"
 #include "mozilla/StyleSheetInlines.h"
 #include "nsDocument.h"
 #include "nsStyleSheetService.h"
 
 namespace mozilla {
 
 void
 ServoStyleRuleMap::EnsureTable(ServoStyleSet& aStyleSet)
@@ -138,17 +138,17 @@ ServoStyleRuleMap::FillTableFromRule(css
     case CSSRuleBinding::SUPPORTS_RULE:
     case CSSRuleBinding::DOCUMENT_RULE: {
       auto& rule = static_cast<css::GroupRule&>(aRule);
       auto ruleList = static_cast<ServoCSSRuleList*>(rule.CssRules());
       FillTableFromRuleList(*ruleList);
       break;
     }
     case CSSRuleBinding::IMPORT_RULE: {
-      auto& rule = static_cast<ServoImportRule&>(aRule);
+      auto& rule = static_cast<CSSImportRule&>(aRule);
       MOZ_ASSERT(aRule.GetStyleSheet());
       FillTableFromStyleSheet(*rule.GetStyleSheet());
       break;
     }
   }
 }
 
 void
--- a/layout/style/CSSImportRule.cpp
+++ b/layout/style/CSSImportRule.cpp
@@ -3,20 +3,109 @@
 /* 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/CSSImportRule.h"
 
 #include "mozilla/dom/CSSImportRuleBinding.h"
 #include "mozilla/dom/MediaList.h"
+#include "mozilla/ServoBindings.h"
+#include "mozilla/StyleSheet.h"
 
 namespace mozilla {
 namespace dom {
 
+CSSImportRule::CSSImportRule(RefPtr<RawServoImportRule> aRawRule,
+                             uint32_t aLine,
+                             uint32_t aColumn)
+  : Rule(aLine, aColumn)
+  , mRawRule(std::move(aRawRule))
+{
+  const auto* sheet = Servo_ImportRule_GetSheet(mRawRule.get());
+  MOZ_ASSERT(sheet);
+  mChildSheet = const_cast<StyleSheet*>(sheet);
+  mChildSheet->SetOwnerRule(this);
+}
+
+CSSImportRule::~CSSImportRule()
+{
+  if (mChildSheet) {
+    mChildSheet->SetOwnerRule(nullptr);
+  }
+}
+
+// QueryInterface implementation for CSSImportRule
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CSSImportRule)
+NS_INTERFACE_MAP_END_INHERITING(css::Rule)
+
+NS_IMPL_CYCLE_COLLECTION_CLASS(CSSImportRule)
+
+NS_IMPL_ADDREF_INHERITED(CSSImportRule, css::Rule)
+NS_IMPL_RELEASE_INHERITED(CSSImportRule, css::Rule)
+
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(CSSImportRule,
+                                                  css::Rule)
+  // Note the child sheet twice, since the Servo rule also holds a strong
+  // reference to it.
+  NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mChildSheet");
+  cb.NoteXPCOMChild(tmp->mChildSheet);
+  MOZ_ASSERT_IF(tmp->mRawRule,
+                Servo_ImportRule_GetSheet(tmp->mRawRule) == tmp->mChildSheet);
+  cb.NoteXPCOMChild(tmp->mChildSheet);
+  NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mRawRule.stylesheet");
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(CSSImportRule)
+  if (tmp->mChildSheet) {
+    tmp->mChildSheet->SetOwnerRule(nullptr);
+    tmp->mChildSheet = nullptr;
+  }
+  tmp->mRawRule = nullptr;
+NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(css::Rule)
+
+#ifdef DEBUG
+/* virtual */ void
+CSSImportRule::List(FILE* out, int32_t aIndent) const
+{
+  nsAutoCString str;
+  for (int32_t i = 0; i < aIndent; i++) {
+    str.AppendLiteral("  ");
+  }
+  Servo_ImportRule_Debug(mRawRule, &str);
+  fprintf_stderr(out, "%s\n", str.get());
+}
+#endif
+
+dom::MediaList*
+CSSImportRule::GetMedia() const
+{
+  // When Bug 1326509 is fixed, we can assert mChildSheet instead.
+  return mChildSheet ? mChildSheet->Media() : nullptr;
+}
+
+void
+CSSImportRule::GetHref(nsAString& aHref) const
+{
+  Servo_ImportRule_GetHref(mRawRule, &aHref);
+}
+
+/* virtual */ void
+CSSImportRule::GetCssText(nsAString& aCssText) const
+{
+  Servo_ImportRule_GetCssText(mRawRule, &aCssText);
+}
+
+/* virtual */ size_t
+CSSImportRule::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
+{
+  // TODO Implement this!
+  return aMallocSizeOf(this);
+}
+
 bool
 CSSImportRule::IsCCLeaf() const
 {
   // We're not a leaf.
   return false;
 }
 
 /* virtual */ JSObject*
--- a/layout/style/CSSImportRule.h
+++ b/layout/style/CSSImportRule.h
@@ -5,36 +5,52 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_CSSImportRule_h
 #define mozilla_dom_CSSImportRule_h
 
 #include "mozilla/css/Rule.h"
 
 namespace mozilla {
+
+class StyleSheet;
+
 namespace dom {
 
-class CSSImportRule : public css::Rule
+class CSSImportRule final : public css::Rule
 {
-protected:
-  using Rule::Rule;
-  virtual ~CSSImportRule() {}
+public:
+  CSSImportRule(RefPtr<RawServoImportRule> aRawRule,
+                uint32_t aLine, uint32_t aColumn);
 
-public:
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CSSImportRule, css::Rule)
+
   bool IsCCLeaf() const final;
 
+#ifdef DEBUG
+  void List(FILE* out = stdout, int32_t aIndent = 0) const final;
+#endif
+
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
-    const override = 0;
+    const override;
 
   // WebIDL interface
   uint16_t Type() const final { return CSSRuleBinding::IMPORT_RULE; }
-  virtual void GetHref(nsAString& aHref) const = 0;
-  virtual dom::MediaList* GetMedia() const = 0;
-  virtual StyleSheet* GetStyleSheet() const = 0;
+  void GetCssText(nsAString& aCssText) const override;
+  void GetHref(nsAString& aHref) const;
+  dom::MediaList* GetMedia() const;
+  StyleSheet* GetStyleSheet() const { return mChildSheet; }
 
   JSObject* WrapObject(JSContext* aCx,
                        JS::Handle<JSObject*> aGivenProto) override;
+
+private:
+  ~CSSImportRule();
+
+  RefPtr<RawServoImportRule> mRawRule;
+  RefPtr<StyleSheet> mChildSheet;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_CSSImportRule_h
--- a/layout/style/ServoCSSRuleList.cpp
+++ b/layout/style/ServoCSSRuleList.cpp
@@ -5,26 +5,26 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* representation of CSSRuleList for stylo */
 
 #include "mozilla/ServoCSSRuleList.h"
 
 #include "mozilla/dom/CSSCounterStyleRule.h"
 #include "mozilla/dom/CSSFontFaceRule.h"
+#include "mozilla/dom/CSSImportRule.h"
 #include "mozilla/dom/CSSKeyframesRule.h"
 #include "mozilla/dom/CSSMediaRule.h"
 #include "mozilla/dom/CSSMozDocumentRule.h"
 #include "mozilla/dom/CSSNamespaceRule.h"
 #include "mozilla/dom/CSSPageRule.h"
 #include "mozilla/dom/CSSStyleRule.h"
 #include "mozilla/dom/CSSSupportsRule.h"
 #include "mozilla/IntegerRange.h"
 #include "mozilla/ServoBindings.h"
-#include "mozilla/ServoImportRule.h"
 #include "mozilla/ServoFontFeatureValuesRule.h"
 #include "mozilla/StyleSheet.h"
 
 using namespace mozilla::dom;
 
 namespace mozilla {
 
 ServoCSSRuleList::ServoCSSRuleList(already_AddRefed<ServoCssRules> aRawRules,
@@ -106,17 +106,17 @@ ServoCSSRuleList::GetRule(uint32_t aInde
       }
       CASE_RULE_CSS(STYLE, Style)
       CASE_RULE_CSS(KEYFRAMES, Keyframes)
       CASE_RULE_CSS(MEDIA, Media)
       CASE_RULE_CSS(NAMESPACE, Namespace)
       CASE_RULE_CSS(PAGE, Page)
       CASE_RULE_CSS(SUPPORTS, Supports)
       CASE_RULE_CSS(DOCUMENT, MozDocument)
-      CASE_RULE(IMPORT, Import)
+      CASE_RULE_CSS(IMPORT, Import)
       CASE_RULE(FONT_FEATURE_VALUES, FontFeatureValues)
       CASE_RULE_CSS(FONT_FACE, FontFace)
       CASE_RULE_CSS(COUNTER_STYLE, CounterStyle)
 #undef CASE_RULE
       case CSSRuleBinding::KEYFRAME_RULE:
         MOZ_ASSERT_UNREACHABLE("keyframe rule cannot be here");
         return nullptr;
       default:
deleted file mode 100644
--- a/layout/style/ServoImportRule.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/* -*- 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/. */
-
-/* representation of CSSImportRule for stylo */
-
-#include "mozilla/ServoImportRule.h"
-
-#include "mozilla/ServoBindings.h"
-#include "mozilla/StyleSheet.h"
-
-namespace mozilla {
-
-ServoImportRule::ServoImportRule(RefPtr<RawServoImportRule> aRawRule,
-                                 uint32_t aLine,
-                                 uint32_t aColumn)
-  : CSSImportRule(aLine, aColumn)
-  , mRawRule(std::move(aRawRule))
-{
-  const auto* sheet = Servo_ImportRule_GetSheet(mRawRule.get());
-  MOZ_ASSERT(sheet);
-  mChildSheet = const_cast<StyleSheet*>(sheet);
-  mChildSheet->SetOwnerRule(this);
-}
-
-ServoImportRule::~ServoImportRule()
-{
-  if (mChildSheet) {
-    mChildSheet->SetOwnerRule(nullptr);
-  }
-}
-
-// QueryInterface implementation for ServoImportRule
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ServoImportRule)
-NS_INTERFACE_MAP_END_INHERITING(dom::CSSImportRule)
-
-NS_IMPL_CYCLE_COLLECTION_CLASS(ServoImportRule)
-
-NS_IMPL_ADDREF_INHERITED(ServoImportRule, dom::CSSImportRule)
-NS_IMPL_RELEASE_INHERITED(ServoImportRule, dom::CSSImportRule)
-
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ServoImportRule,
-                                                  dom::CSSImportRule)
-  // Note the child sheet twice, since the Servo rule also holds a strong
-  // reference to it.
-  NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mChildSheet");
-  cb.NoteXPCOMChild(tmp->mChildSheet);
-  MOZ_ASSERT_IF(tmp->mRawRule,
-                Servo_ImportRule_GetSheet(tmp->mRawRule) == tmp->mChildSheet);
-  cb.NoteXPCOMChild(tmp->mChildSheet);
-  NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mRawRule.stylesheet");
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ServoImportRule)
-  if (tmp->mChildSheet) {
-    tmp->mChildSheet->SetOwnerRule(nullptr);
-    tmp->mChildSheet = nullptr;
-  }
-  tmp->mRawRule = nullptr;
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(dom::CSSImportRule)
-
-#ifdef DEBUG
-/* virtual */ void
-ServoImportRule::List(FILE* out, int32_t aIndent) const
-{
-  nsAutoCString str;
-  for (int32_t i = 0; i < aIndent; i++) {
-    str.AppendLiteral("  ");
-  }
-  Servo_ImportRule_Debug(mRawRule, &str);
-  fprintf_stderr(out, "%s\n", str.get());
-}
-#endif
-
-dom::MediaList*
-ServoImportRule::GetMedia() const
-{
-  // When Bug 1326509 is fixed, we can assert mChildSheet instead.
-  return mChildSheet ? mChildSheet->Media() : nullptr;
-}
-
-StyleSheet*
-ServoImportRule::GetStyleSheet() const
-{
-  return mChildSheet;
-}
-
-void
-ServoImportRule::GetHref(nsAString& aHref) const
-{
-  Servo_ImportRule_GetHref(mRawRule, &aHref);
-}
-
-/* virtual */ void
-ServoImportRule::GetCssText(nsAString& aCssText) const
-{
-  Servo_ImportRule_GetCssText(mRawRule, &aCssText);
-}
-
-/* virtual */ size_t
-ServoImportRule::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
-{
-  // TODO Implement this!
-  return aMallocSizeOf(this);
-}
-
-} // namespace mozilla
deleted file mode 100644
--- a/layout/style/ServoImportRule.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- 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/. */
-
-/* representation of CSSImportRule for stylo */
-
-#ifndef mozilla_ServoImportRule_h
-#define mozilla_ServoImportRule_h
-
-#include "mozilla/dom/CSSImportRule.h"
-#include "mozilla/ServoBindingTypes.h"
-
-namespace mozilla {
-
-class ServoMediaList;
-class StyleSheet;
-
-class ServoImportRule final : public dom::CSSImportRule
-{
-public:
-  ServoImportRule(RefPtr<RawServoImportRule> aRawRule,
-                  uint32_t aLine, uint32_t aColumn);
-
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ServoImportRule, dom::CSSImportRule)
-
-#ifdef DEBUG
-  void List(FILE* out = stdout, int32_t aIndent = 0) const final;
-#endif
-  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const final;
-
-  // WebIDL interface
-  void GetCssText(nsAString& aCssText) const override;
-  void GetHref(nsAString& aHref) const final;
-  dom::MediaList* GetMedia() const final;
-  StyleSheet* GetStyleSheet() const final;
-
-private:
-  ~ServoImportRule();
-
-  RefPtr<RawServoImportRule> mRawRule;
-  RefPtr<StyleSheet> mChildSheet;
-};
-
-} // namespace mozilla
-
-#endif // mozilla_ServoImportRule_h
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -82,17 +82,16 @@ EXPORTS.mozilla += [
     'ServoBindingTypes.h',
     'ServoComputedData.h',
     'ServoComputedDataInlines.h',
     'ServoCSSParser.h',
     'ServoCSSRuleList.h',
     'ServoElementSnapshot.h',
     'ServoElementSnapshotTable.h',
     'ServoFontFeatureValuesRule.h',
-    'ServoImportRule.h',
     'ServoSpecifiedValues.h',
     'ServoStyleSet.h',
     'ServoStyleSetInlines.h',
     'ServoTraversalStatistics.h',
     'ServoTypes.h',
     'ServoUtils.h',
     'SheetType.h',
     'StyleAnimationValue.h',
@@ -198,17 +197,16 @@ UNIFIED_SOURCES += [
     'PostTraversalTask.cpp',
     'PreloadedStyleSheet.cpp',
     'Rule.cpp',
     'ServoBindings.cpp',
     'ServoCSSParser.cpp',
     'ServoCSSRuleList.cpp',
     'ServoElementSnapshot.cpp',
     'ServoFontFeatureValuesRule.cpp',
-    'ServoImportRule.cpp',
     'ServoSpecifiedValues.cpp',
     'ServoStyleSet.cpp',
     'StreamLoader.cpp',
     'StyleAnimationValue.cpp',
     'StyleComplexColor.cpp',
     'StyleSheet.cpp',
     'URLExtraData.cpp',
 ]
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -15,16 +15,17 @@
 #include "mozilla/Casting.h"
 
 #include "nsCSSKeywords.h"
 #include "nsLayoutUtils.h"
 #include "nsStyleConsts.h"
 #include "nsIWidget.h"
 #include "nsThemeConstants.h"  // For system widget appearance types
 
+#include "mozilla/dom/Animation.h"
 #include "mozilla/dom/AnimationEffectBinding.h" // for PlaybackDirection
 #include "mozilla/LookAndFeel.h" // for system colors
 
 #include "nsString.h"
 #include "nsStaticNameTable.h"
 
 #include "mozilla/Preferences.h"
 #include "mozilla/StaticPrefs.h"
--- a/layout/style/nsDOMCSSRect.h
+++ b/layout/style/nsDOMCSSRect.h
@@ -9,17 +9,17 @@
 #ifndef nsDOMCSSRect_h_
 #define nsDOMCSSRect_h_
 
 #include "mozilla/Attributes.h"
 #include "mozilla/RefPtr.h"
 
 class nsROCSSPrimitiveValue;
 
-class nsDOMCSSRect final : public RefCounted<nsDOMCSSRect>
+class nsDOMCSSRect final : public mozilla::RefCounted<nsDOMCSSRect>
 {
 public:
   MOZ_DECLARE_REFCOUNTED_TYPENAME(nsDOMCSSRect);
 
   nsDOMCSSRect(nsROCSSPrimitiveValue* aTop,
                nsROCSSPrimitiveValue* aRight,
                nsROCSSPrimitiveValue* aBottom,
                nsROCSSPrimitiveValue* aLeft);