Bug 958596 - Print ScrollableLayerGuids of APZCs when printing the tree. r=kats
☠☠ backed out by c9f4f70e46e1 ☠ ☠
authorBotond Ballo <botond@mozilla.com>
Tue, 25 Feb 2014 19:35:06 -0500
changeset 170933 e4c0e3d3a76857f6b92ef8df7d4d17bfdbd9ffe6
parent 170932 7bc4f48d6b055cf6aaf75e37684bc1c244e01543
child 170934 59f6a07a619a71cce1f32442277a2c3b24f2fc34
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewerskats
bugs958596
milestone30.0a1
Bug 958596 - Print ScrollableLayerGuids of APZCs when printing the tree. r=kats
gfx/layers/FrameMetrics.h
gfx/layers/composite/APZCTreeManager.cpp
--- a/gfx/layers/FrameMetrics.h
+++ b/gfx/layers/FrameMetrics.h
@@ -7,16 +7,17 @@
 #define GFX_FRAMEMETRICS_H
 
 #include <stdint.h>                     // for uint32_t, uint64_t
 #include <string>                       // for std::string
 #include "Units.h"                      // for CSSRect, CSSPixel, etc
 #include "mozilla/gfx/BasePoint.h"      // for BasePoint
 #include "mozilla/gfx/Rect.h"           // for RoundedIn
 #include "mozilla/gfx/ScaleFactor.h"    // for ScaleFactor
+#include "mozilla/gfx/Logging.h"        // for Log
 
 namespace IPC {
 template <typename T> struct ParamTraits;
 } // namespace IPC
 
 namespace mozilla {
 namespace layers {
 
@@ -420,16 +421,21 @@ struct ScrollableLayerGuid {
   }
 
   bool operator!=(const ScrollableLayerGuid& other) const
   {
     return !(*this == other);
   }
 };
 
+template <int LogLevel>
+gfx::Log<LogLevel>& operator<<(gfx::Log<LogLevel>& log, const ScrollableLayerGuid& aGuid) {
+  return log << '(' << aGuid.mLayersId << ',' << aGuid.mPresShellId << ',' << aGuid.mScrollId << ')';
+}
+
 struct ZoomConstraints {
   bool mAllowZoom;
   bool mAllowDoubleTapZoom;
   CSSToScreenScale mMinZoom;
   CSSToScreenScale mMaxZoom;
 
   ZoomConstraints()
     : mAllowZoom(true)
--- a/gfx/layers/composite/APZCTreeManager.cpp
+++ b/gfx/layers/composite/APZCTreeManager.cpp
@@ -165,30 +165,30 @@ APZCTreeManager::UpdatePanZoomController
         // it has an APZC instance to manage its scrolling.
 
         apzc = container->GetAsyncPanZoomController();
 
         // If the content represented by the container layer has changed (which may
         // be possible because of DLBI heuristics) then we don't want to keep using
         // the same old APZC for the new content. Null it out so we run through the
         // code to find another one or create one.
-        if (apzc && !apzc->Matches(ScrollableLayerGuid(aLayersId, container->GetFrameMetrics()))) {
+        ScrollableLayerGuid guid(aLayersId, container->GetFrameMetrics());
+        if (apzc && !apzc->Matches(guid)) {
           apzc = nullptr;
         }
 
         // If the container doesn't have an APZC already, try to find one of our
         // pre-existing ones that matches. In particular, if we find an APZC whose
         // ScrollableLayerGuid is the same, then we know what happened is that the
         // layout of the page changed causing the layer tree to be rebuilt, but the
         // underlying content for which the APZC was originally created is still
         // there. So it makes sense to pick up that APZC instance again and use it here.
         if (apzc == nullptr) {
-          ScrollableLayerGuid target(aLayersId, container->GetFrameMetrics());
           for (size_t i = 0; i < aApzcsToDestroy->Length(); i++) {
-            if (aApzcsToDestroy->ElementAt(i)->Matches(target)) {
+            if (aApzcsToDestroy->ElementAt(i)->Matches(guid)) {
               apzc = aApzcsToDestroy->ElementAt(i);
               break;
             }
           }
         }
 
         // The APZC we get off the layer may have been destroyed previously if the layer was inactive
         // or omitted from the layer tree for whatever reason from a layers update. If it later comes
@@ -229,17 +229,17 @@ APZCTreeManager::UpdatePanZoomController
         gfx3DMatrix transform;
         gfx::To3DMatrix(aLayer->GetTransform(), transform);
 
         apzc->SetLayerHitTestData(visible, aTransform, transform);
         APZC_LOG("Setting rect(%f %f %f %f) as visible region for APZC %p\n", visible.x, visible.y,
                                                                               visible.width, visible.height,
                                                                               apzc);
 
-        sApzcTreeLog << "APZC "
+        sApzcTreeLog << "APZC " << guid
                      << "\tcb=" << visible
                      << "\tsr=" << container->GetFrameMetrics().mScrollableRect
                      << "\t" << container->GetFrameMetrics().GetContentDescription();
 
         // Bind the APZC instance into the tree of APZCs
         if (aNextSibling) {
           aNextSibling->SetPrevSibling(apzc);
         } else if (aParent) {