Bug 1328420 Part 7: Uplift List debug method into StyleSheet. draft
authorBrad Werth <bwerth@mozilla.com>
Mon, 23 Jan 2017 16:40:28 -0800
changeset 465761 0de435311e27e471b0a5709a17b4fa661e877360
parent 465760 b37518330c0b7c69200cc343f9e4d1b3a71b7ba3
child 465762 418e201dcf9de9a82dc3d63ece4c2615d479530c
push id42704
push userbwerth@mozilla.com
push dateTue, 24 Jan 2017 20:34:08 +0000
bugs1328420
milestone53.0a1
Bug 1328420 Part 7: Uplift List debug method into StyleSheet. MozReview-Commit-ID: 7aqC6N6cZst
layout/style/CSSStyleSheet.cpp
layout/style/CSSStyleSheet.h
layout/style/ServoStyleSheet.cpp
layout/style/ServoStyleSheet.h
layout/style/StyleSheet.cpp
layout/style/StyleSheet.h
layout/style/StyleSheetInlines.h
--- a/layout/style/CSSStyleSheet.cpp
+++ b/layout/style/CSSStyleSheet.cpp
@@ -720,46 +720,17 @@ ListRules(const nsCOMArray<css::Rule>& a
   for (int32_t index = aRules.Count() - 1; index >= 0; --index) {
     aRules.ObjectAt(index)->List(aOut, aIndent);
   }
 }
 
 void
 CSSStyleSheet::List(FILE* out, int32_t aIndent) const
 {
-
-  int32_t index;
-
-  // Indent
-  nsAutoCString str;
-  for (index = aIndent; --index >= 0; ) {
-    str.AppendLiteral("  ");
-  }
-
-  str.AppendLiteral("CSS Style Sheet: ");
-  nsAutoCString urlSpec;
-  nsresult rv = mInner->mSheetURI->GetSpec(urlSpec);
-  if (NS_SUCCEEDED(rv) && !urlSpec.IsEmpty()) {
-    str.Append(urlSpec);
-  }
-
-  if (mMedia) {
-    str.AppendLiteral(" media: ");
-    nsAutoString  buffer;
-    mMedia->GetText(buffer);
-    AppendUTF16toUTF8(buffer, str);
-  }
-  str.Append('\n');
-  fprintf_stderr(out, "%s", str.get());
-
-  for (const StyleSheet* child = GetFirstChild();
-       child;
-       child = child->mNext) {
-    child->List(out, aIndent + 1);
-  }
+  StyleSheet::List(out, aIndent);
 
   fprintf_stderr(out, "%s", "Rules in source order:\n");
   ListRules(mInner->mOrderedRules, out, aIndent);
 }
 #endif
 
 void 
 CSSStyleSheet::ClearRuleCascades()
--- a/layout/style/CSSStyleSheet.h
+++ b/layout/style/CSSStyleSheet.h
@@ -109,17 +109,17 @@ public:
   bool HasRules() const;
 
   // style sheet owner info
   CSSStyleSheet* GetParentSheet() const;  // may be null
 
   // Find the ID of the owner inner window.
   uint64_t FindOwningWindowInnerID() const;
 #ifdef DEBUG
-  void List(FILE* out = stdout, int32_t aIndent = 0) const;
+  void List(FILE* out = stdout, int32_t aIndent = 0) const override;
 #endif
 
   // XXX do these belong here or are they generic?
   void AppendStyleRule(css::Rule* aRule);
 
   int32_t StyleRuleCount() const;
   css::Rule* GetStyleRuleAt(int32_t aIndex) const;
 
--- a/layout/style/ServoStyleSheet.cpp
+++ b/layout/style/ServoStyleSheet.cpp
@@ -110,24 +110,16 @@ ServoStyleSheet::DropRuleList()
 }
 
 size_t
 ServoStyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
 {
   MOZ_CRASH("stylo: not implemented");
 }
 
-#ifdef DEBUG
-void
-ServoStyleSheet::List(FILE* aOut, int32_t aIndex) const
-{
-  MOZ_CRASH("stylo: not implemented");
-}
-#endif
-
 css::Rule*
 ServoStyleSheet::GetDOMOwnerRule() const
 {
   NS_ERROR("stylo: Don't know how to get DOM owner rule for ServoStyleSheet");
   return nullptr;
 }
 
 CSSRuleList*
--- a/layout/style/ServoStyleSheet.h
+++ b/layout/style/ServoStyleSheet.h
@@ -50,20 +50,16 @@ public:
    * Called instead of ParseSheet to initialize the Servo stylesheet object
    * for a failed load. Either ParseSheet or LoadFailed must be called before
    * adding a ServoStyleSheet to a ServoStyleSet.
    */
   void LoadFailed();
 
   size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
 
-#ifdef DEBUG
-  void List(FILE* aOut = stdout, int32_t aIndex = 0) const;
-#endif
-
   RawServoStyleSheet* RawSheet() const { return mSheet; }
   void SetSheetForImport(RawServoStyleSheet* aSheet) {
     MOZ_ASSERT(!mSheet);
     mSheet = aSheet;
   }
 
   // WebIDL CSSStyleSheet API
   // Can't be inline because we can't include ImportRule here.  And can't be
--- a/layout/style/StyleSheet.cpp
+++ b/layout/style/StyleSheet.cpp
@@ -427,16 +427,52 @@ StyleSheet::AppendStyleSheet(StyleSheet*
 
   // This is not reference counted. Our parent tells us when
   // it's going away.
   aSheet->mParent = this;
   aSheet->mDocument = mDocument;
   DidDirty();
 }
 
+#ifdef DEBUG
+void
+StyleSheet::List(FILE* out, int32_t aIndent) const
+{
+  int32_t index;
+
+  // Indent
+  nsAutoCString str;
+  for (index = aIndent; --index >= 0; ) {
+    str.AppendLiteral("  ");
+  }
+
+  str.AppendLiteral("CSS Style Sheet: ");
+  nsAutoCString urlSpec;
+  nsresult rv = GetSheetURI()->GetSpec(urlSpec);
+  if (NS_SUCCEEDED(rv) && !urlSpec.IsEmpty()) {
+    str.Append(urlSpec);
+  }
+
+  if (mMedia) {
+    str.AppendLiteral(" media: ");
+    nsAutoString  buffer;
+    mMedia->GetText(buffer);
+    AppendUTF16toUTF8(buffer, str);
+  }
+  str.Append('\n');
+  fprintf_stderr(out, "%s", str.get());
+
+  for (const StyleSheet* child = GetFirstChild();
+       child;
+       child = child->mNext) {
+    child->List(out, aIndent + 1);
+  }
+}
+#endif
+
 void
 StyleSheet::SetMedia(nsMediaList* aMedia)
 {
   mMedia = aMedia;
 }
 
 void
 StyleSheet::DropMedia()
--- a/layout/style/StyleSheet.h
+++ b/layout/style/StyleSheet.h
@@ -151,17 +151,17 @@ public:
   inline CORSMode GetCORSMode() const;
   // Get this style sheet's Referrer Policy
   inline net::ReferrerPolicy GetReferrerPolicy() const;
   // Get this style sheet's integrity metadata
   inline void GetIntegrity(dom::SRIMetadata& aResult) const;
 
   inline size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
 #ifdef DEBUG
-  inline void List(FILE* aOut = stdout, int32_t aIndex = 0) const;
+  virtual void List(FILE* aOut = stdout, int32_t aIndex = 0) const;
 #endif
 
   // WebIDL StyleSheet API
   // The XPCOM GetType is fine for WebIDL.
   // The XPCOM GetHref is fine for WebIDL
   // GetOwnerNode is defined above.
   inline StyleSheet* GetParentStyleSheet() const;
   // The XPCOM GetTitle is fine for WebIDL.
--- a/layout/style/StyleSheetInlines.h
+++ b/layout/style/StyleSheetInlines.h
@@ -135,23 +135,15 @@ StyleSheet::GetIntegrity(dom::SRIMetadat
 }
 
 size_t
 StyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
 {
   MOZ_STYLO_FORWARD(SizeOfIncludingThis, (aMallocSizeOf))
 }
 
-#ifdef DEBUG
-void
-StyleSheet::List(FILE* aOut, int32_t aIndex) const
-{
-  MOZ_STYLO_FORWARD(List, (aOut, aIndex))
-}
-#endif
-
 void StyleSheet::WillDirty() { MOZ_STYLO_FORWARD(WillDirty, ()) }
 void StyleSheet::DidDirty() { MOZ_STYLO_FORWARD(DidDirty, ()) }
 
 
 }
 
 #endif // mozilla_StyleSheetInlines_h