From 367081293739c73f350c41c14343c1548feb413d Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Sun, 31 May 2015 14:44:41 -0500 Subject: [PATCH] Bug 1168630. Part 4. Rename AsyncPanZoomController::IsRootForLayersId to HasNoParentWithSameLayersId. r=botond The function did not tell you if the APZC was the root for the layers id. It just told you if it had no parent. Which are different things. Since IsRootForLayersId didn't do what it was expected to, the users of HasNoParentWithSameLayersId will be audited and then removed or changed to be correct by bug 1158424. --- gfx/layers/apz/src/APZCTreeManager.cpp | 16 ++++++++-------- gfx/layers/apz/src/AsyncPanZoomController.h | 5 +++-- gfx/layers/apz/test/apz_test_utils.js | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index 786ec5ec494a..d193d851468b 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -453,9 +453,9 @@ APZCTreeManager::PrepareNodeForLayer(const LayerMetricsWrapper& aLayer, // we are logging about APZCs is the scroll id, and otherwise we could // confuse APZCs from different layer trees with the same scroll id. if (aLayersId == aState.mOriginatingLayersId) { - if (apzc->IsRootForLayersId()) { + if (apzc->HasNoParentWithSameLayersId()) { aState.mPaintLogger.LogTestData(aMetrics.GetScrollId(), - "isRootForLayersId", true); + "hasNoParentWithSameLayersId", true); } else { MOZ_ASSERT(apzc->GetParent()); aState.mPaintLogger.LogTestData(aMetrics.GetScrollId(), @@ -464,7 +464,7 @@ APZCTreeManager::PrepareNodeForLayer(const LayerMetricsWrapper& aLayer, } if (newApzc) { - if (apzc->IsRootForLayersId()) { + if (apzc->HasNoParentWithSameLayersId()) { // If we just created a new apzc that is the root for its layers ID, then // we need to update its zoom constraints which might have arrived before this // was created @@ -1040,7 +1040,7 @@ APZCTreeManager::UpdateZoomConstraints(const ScrollableLayerGuid& aGuid, // For a given layers id, non-root APZCs inherit the zoom constraints // of their root. - if (node && node->GetApzc()->IsRootForLayersId()) { + if (node && node->GetApzc()->HasNoParentWithSameLayersId()) { UpdateZoomConstraintsRecursively(node.get(), aConstraints); } } @@ -1057,7 +1057,7 @@ APZCTreeManager::UpdateZoomConstraintsRecursively(HitTestingTreeNode* aNode, } for (HitTestingTreeNode* child = aNode->GetLastChild(); child; child = child->GetPrevSibling()) { // We can have subtrees with their own layers id - leave those alone. - if (child->GetApzc() && child->GetApzc()->IsRootForLayersId()) { + if (child->GetApzc() && child->GetApzc()->HasNoParentWithSameLayersId()) { continue; } UpdateZoomConstraintsRecursively(child, aConstraints); @@ -1344,7 +1344,7 @@ APZCTreeManager::BuildOverscrollHandoffChain(const nsRefPtrAdd(apzc); if (apzc->GetScrollHandoffParentId() == FrameMetrics::NULL_SCROLL_ID) { - if (!apzc->IsRootForLayersId()) { + if (!apzc->HasNoParentWithSameLayersId()) { // This probably indicates a bug or missed case in layout code NS_WARNING("Found a non-root APZ with no handoff parent"); } @@ -1362,7 +1362,7 @@ APZCTreeManager::BuildOverscrollHandoffChain(const nsRefPtrIsRootForLayersId()) { + while (!parent->HasNoParentWithSameLayersId()) { parent = parent->GetParent(); // While walking up to find the root of the subtree, if we encounter the // handoff parent, we don't actually need to do the search so we can @@ -1705,7 +1705,7 @@ APZCTreeManager::RootAPZCForLayersId(AsyncPanZoomController* aApzc) const { MonitorAutoLock lock(mTreeLock); nsRefPtr apzc = aApzc; - while (apzc && !apzc->IsRootForLayersId()) { + while (apzc && !apzc->HasNoParentWithSameLayersId()) { apzc = apzc->GetParent(); } return apzc.forget(); diff --git a/gfx/layers/apz/src/AsyncPanZoomController.h b/gfx/layers/apz/src/AsyncPanZoomController.h index 0f3f17c474e9..691f297cec46 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.h +++ b/gfx/layers/apz/src/AsyncPanZoomController.h @@ -899,9 +899,10 @@ public: } /* Returns true if there is no APZC higher in the tree with the same - * layers id. + * layers id. Deprecated. New code shouldn't use this. Old code should be + * updated to not use this. */ - bool IsRootForLayersId() const { + bool HasNoParentWithSameLayersId() const { return !mParent || (mParent->mLayersId != mLayersId); } diff --git a/gfx/layers/apz/test/apz_test_utils.js b/gfx/layers/apz/test/apz_test_utils.js index a4ae85ce5a8e..834afd8970e5 100644 --- a/gfx/layers/apz/test/apz_test_utils.js +++ b/gfx/layers/apz/test/apz_test_utils.js @@ -91,7 +91,7 @@ function buildApzcTree(paint) { // This 'root' does not correspond to an APZC. var root = makeNode(-1); for (var scrollId in paint) { - if ("isRootForLayersId" in paint[scrollId]) { + if ("hasNoParentWithSameLayersId" in paint[scrollId]) { addRoot(root, scrollId); } else if ("parentScrollId" in paint[scrollId]) { addLink(root, scrollId, paint[scrollId]["parentScrollId"]);