Bug 963771. Add a debug dump function to print a single display item (and not just an entire display list). r=mats
authorTimothy Nikkel <tnikkel@gmail.com>
Sun, 26 Jan 2014 16:09:14 -0600
changeset 181284 39ca54c48ec46cc33a2abe2514246a48275527c7
parent 181283 bd61bfb42d02d62796e27269a83b41935b868122
child 181285 72bcdad2b539a318d0370b06f7c19a46a495c171
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs963771
milestone29.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 963771. Add a debug dump function to print a single display item (and not just an entire display list). r=mats
layout/base/nsLayoutDebugger.cpp
layout/generic/nsFrame.h
layout/generic/nsGfxScrollFrame.cpp
--- a/layout/base/nsLayoutDebugger.cpp
+++ b/layout/base/nsLayoutDebugger.cpp
@@ -116,124 +116,141 @@ nsLayoutDebugger::GetStyleSize(nsIPresSh
                                int32_t* aSizeInBytesResult)
 {
   *aSizeInBytesResult = 0;
   return NS_ERROR_FAILURE;
 }
 #endif
 
 #ifdef MOZ_DUMP_PAINTING
-static int sPrintDisplayListIndent = 0;
+static void
+PrintDisplayListTo(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList,
+                   FILE* aOutput, uint32_t aIndent, bool aDumpHtml);
+
+static void
+PrintDisplayItemTo(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem,
+                   FILE* aOutput, uint32_t aIndent, bool aDumpSublist, bool aDumpHtml)
+{
+  nsCString str;
+  if (!aDumpHtml) {
+    for (uint32_t indent = 0; indent < aIndent; indent++) {
+      str += "  ";
+    }
+  }
+  nsIFrame* f = aItem->Frame();
+  nsAutoString fName;
+#ifdef DEBUG
+  f->GetFrameName(fName);
+#endif
+  bool snap;
+  nsRect rect = aItem->GetBounds(aBuilder, &snap);
+  nscolor color;
+  nsRect vis = aItem->GetVisibleRect();
+  nsRect component = aItem->GetComponentAlphaBounds(aBuilder);
+  nsDisplayList* list = aItem->GetChildren();
+  const DisplayItemClip& clip = aItem->GetClip();
+  nsRegion opaque;
+#ifdef DEBUG
+  if (!list || list->DidComputeVisibility()) {
+    opaque = aItem->GetOpaqueRegion(aBuilder, &snap);
+  }
+#endif
+  if (aDumpHtml && aItem->Painted()) {
+    nsCString string(aItem->Name());
+    string.Append("-");
+    string.AppendInt((uint64_t)aItem);
+    str += nsPrintfCString("<a href=\"javascript:ViewImage('%s')\">", string.BeginReading());
+  }
+  str += nsPrintfCString("%s %p(%s) bounds(%d,%d,%d,%d) visible(%d,%d,%d,%d) componentAlpha(%d,%d,%d,%d) clip(%s) %s",
+          aItem->Name(), (void*)f, NS_ConvertUTF16toUTF8(fName).get(),
+          rect.x, rect.y, rect.width, rect.height,
+          vis.x, vis.y, vis.width, vis.height,
+          component.x, component.y, component.width, component.height,
+          clip.ToString().get(),
+          aItem->IsUniform(aBuilder, &color) ? " uniform" : "");
+  nsRegionRectIterator iter(opaque);
+  for (const nsRect* r = iter.Next(); r; r = iter.Next()) {
+    str += nsPrintfCString(" (opaque %d,%d,%d,%d)", r->x, r->y, r->width, r->height);
+  }
+  aItem->WriteDebugInfo(str);
+  if (aDumpHtml && aItem->Painted()) {
+    str += "</a>";
+  }
+  uint32_t key = aItem->GetPerFrameKey();
+  Layer* layer = mozilla::FrameLayerBuilder::GetDebugOldLayerFor(f, key);
+  if (layer) {
+    if (aDumpHtml) {
+      str += nsPrintfCString(" <a href=\"#%p\">layer=%p</a>", layer, layer);
+    } else {
+      str += nsPrintfCString(" layer=%p", layer);
+    }
+  }
+  if (aItem->GetType() == nsDisplayItem::TYPE_SVG_EFFECTS) {
+    (static_cast<nsDisplaySVGEffects*>(aItem))->PrintEffects(str);
+  }
+  fprintf_stderr(aOutput, "%s\n", str.get());
+  if (aDumpSublist && list) {
+    PrintDisplayListTo(aBuilder, *list, aOutput, aIndent+1, aDumpHtml);
+  }
+}
 
 static void
 PrintDisplayListTo(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList,
-                   FILE* aOutput, bool aDumpHtml)
+                   FILE* aOutput, uint32_t aIndent, bool aDumpHtml)
 {
   if (aDumpHtml) {
     fprintf_stderr(aOutput, "<ul>");
   }
 
   for (nsDisplayItem* i = aList.GetBottom(); i != nullptr; i = i->GetAbove()) {
-    nsCString str;
     if (aDumpHtml) {
       fprintf_stderr(aOutput, "<li>");
-    } else {
-      sPrintDisplayListIndent ++;
-      for (int indent = 0; indent < sPrintDisplayListIndent; indent++) {
-        str += "  ";
-      }
     }
-    nsIFrame* f = i->Frame();
-    nsAutoString fName;
-#ifdef DEBUG
-    f->GetFrameName(fName);
-#endif
-    bool snap;
-    nsRect rect = i->GetBounds(aBuilder, &snap);
-    nscolor color;
-    nsRect vis = i->GetVisibleRect();
-    nsRect component = i->GetComponentAlphaBounds(aBuilder);
-    nsDisplayList* list = i->GetChildren();
-    const DisplayItemClip& clip = i->GetClip();
-    nsRegion opaque;
-#ifdef DEBUG
-    if (!list || list->DidComputeVisibility()) {
-      opaque = i->GetOpaqueRegion(aBuilder, &snap);
-    }
-#endif
-    if (aDumpHtml && i->Painted()) {
-      nsCString string(i->Name());
-      string.Append("-");
-      string.AppendInt((uint64_t)i);
-      str += nsPrintfCString("<a href=\"javascript:ViewImage('%s')\">", string.BeginReading());
-    }
-    str += nsPrintfCString("%s %p(%s) bounds(%d,%d,%d,%d) visible(%d,%d,%d,%d) componentAlpha(%d,%d,%d,%d) clip(%s) %s",
-            i->Name(), (void*)f, NS_ConvertUTF16toUTF8(fName).get(),
-            rect.x, rect.y, rect.width, rect.height,
-            vis.x, vis.y, vis.width, vis.height,
-            component.x, component.y, component.width, component.height,
-            clip.ToString().get(),
-            i->IsUniform(aBuilder, &color) ? " uniform" : "");
-    nsRegionRectIterator iter(opaque);
-    for (const nsRect* r = iter.Next(); r; r = iter.Next()) {
-      str += nsPrintfCString(" (opaque %d,%d,%d,%d)", r->x, r->y, r->width, r->height);
-    }
-    i->WriteDebugInfo(str);
-    if (aDumpHtml && i->Painted()) {
-      str += "</a>";
-    }
-    uint32_t key = i->GetPerFrameKey();
-    Layer* layer = mozilla::FrameLayerBuilder::GetDebugOldLayerFor(f, key);
-    if (layer) {
-      if (aDumpHtml) {
-        str += nsPrintfCString(" <a href=\"#%p\">layer=%p</a>", layer, layer);
-      } else {
-        str += nsPrintfCString(" layer=%p", layer);
-      }
-    }
-    if (i->GetType() == nsDisplayItem::TYPE_SVG_EFFECTS) {
-      (static_cast<nsDisplaySVGEffects*>(i))->PrintEffects(str);
-    }
-    fprintf_stderr(aOutput, "%s\n", str.get());
-    if (list) {
-      PrintDisplayListTo(aBuilder, *list, aOutput, aDumpHtml);
-    }
+    PrintDisplayItemTo(aBuilder, i, aOutput, aIndent, true, aDumpHtml);
     if (aDumpHtml) {
       fprintf_stderr(aOutput, "</li>");
-    } else {
-      sPrintDisplayListIndent --;
     }
   }
 
   if (aDumpHtml) {
     fprintf_stderr(aOutput, "</ul>");
   }
 }
 
 void
+nsFrame::PrintDisplayItem(nsDisplayListBuilder* aBuilder,
+                          nsDisplayItem* aItem,
+                          FILE* aFile,
+                          bool aDumpSublist,
+                          bool aDumpHtml)
+{
+  PrintDisplayItemTo(aBuilder, aItem, aFile, 0, aDumpSublist, aDumpHtml);
+}
+
+void
 nsFrame::PrintDisplayList(nsDisplayListBuilder* aBuilder,
                           const nsDisplayList& aList,
                           FILE* aFile,
                           bool aDumpHtml)
 {
-  PrintDisplayListTo(aBuilder, aList, aFile, aDumpHtml);
+  PrintDisplayListTo(aBuilder, aList, aFile, 0, aDumpHtml);
 }
 
 static void
 PrintDisplayListSetItem(nsDisplayListBuilder* aBuilder,
                         const char* aItemName,
                         const nsDisplayList& aList,
                         FILE* aFile,
                         bool aDumpHtml)
 {
   if (aDumpHtml) {
     fprintf_stderr(aFile, "<li>");
   }
   fprintf_stderr(aFile, "%s", aItemName);
-  PrintDisplayListTo(aBuilder, aList, aFile, aDumpHtml);
+  PrintDisplayListTo(aBuilder, aList, aFile, 0, aDumpHtml);
   if (aDumpHtml) {
     fprintf_stderr(aFile, "</li>");
   }
 }
 
 void
 nsFrame::PrintDisplayListSet(nsDisplayListBuilder* aBuilder,
                              const nsDisplayListSet& aSet,
--- a/layout/generic/nsFrame.h
+++ b/layout/generic/nsFrame.h
@@ -706,16 +706,22 @@ public:
   // Show frame border of event target
   static void ShowEventTargetFrameBorder(bool aEnable);
   static bool GetShowEventTargetFrameBorder();
 
 #endif
 #ifdef MOZ_DUMP_PAINTING
 public:
 
+  static void PrintDisplayItem(nsDisplayListBuilder* aBuilder,
+                               nsDisplayItem* aItem,
+                               FILE* aFile = stdout,
+                               bool aDumpSublist = false,
+                               bool aDumpHtml = false);
+
   static void PrintDisplayList(nsDisplayListBuilder* aBuilder,
                                const nsDisplayList& aList,
                                FILE* aFile = stdout,
                                bool aDumpHtml = false);
   static void PrintDisplayListSet(nsDisplayListBuilder* aBuilder,
                                   const nsDisplayListSet& aList,
                                   FILE* aFile = stdout,
                                   bool aDumpHtml = false);
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -2395,17 +2395,17 @@ ScrollFrameHelper::BuildDisplayList(nsDi
   // if the area is scrollable and we're the content process (unless we're on
   // B2G, where we support async scrolling for scrollable elements in the
   // parent process as well).
   // When a displayport is being used, force building of a layer so that
   // CompositorParent can always find the scrollable layer for the root content
   // document.
   // If the element is marked 'scrollgrab', also force building of a layer
   // so that APZ can implement scroll grabbing.
-  mShouldBuildScrollableLayer = usingDisplayport || nsContentUtils::HasScrollgrab(mOuter->GetContent());
+  mShouldBuildScrollableLayer = usingDisplayport || nsContentUtils::HasScrollgrab(mOuter->GetContent()) || !mOuter->PresContext()->IsChrome();
   bool shouldBuildLayer = false;
   if (mShouldBuildScrollableLayer) {
     shouldBuildLayer = true;
   } else {
     nsRect scrollRange = GetScrollRange();
     ScrollbarStyles styles = GetScrollbarStylesFromFrame();
     bool isFocused = IsFocused(mOuter->GetContent());
     bool isVScrollable = (scrollRange.height > 0)