Bug 1364622 - Add a helper function HitTestingTreeNode::IsAncestorOf(). r=kats
authorBotond Ballo <botond@mozilla.com>
Mon, 15 May 2017 20:18:05 -0400
changeset 579814 821ce1451940e97d87db99683cee9b3328124c42
parent 579736 c4f86883f3254617d6834b53f42050ee687d6b2e
child 579815 0f21e336171cc369ff9bb98caa484d5f64e87c5a
push id59376
push userbballo@mozilla.com
push dateWed, 17 May 2017 20:35:32 +0000
reviewerskats
bugs1364622
milestone55.0a1
Bug 1364622 - Add a helper function HitTestingTreeNode::IsAncestorOf(). r=kats MozReview-Commit-ID: Et3dokACnMa
gfx/layers/apz/src/HitTestingTreeNode.cpp
gfx/layers/apz/src/HitTestingTreeNode.h
--- a/gfx/layers/apz/src/HitTestingTreeNode.cpp
+++ b/gfx/layers/apz/src/HitTestingTreeNode.cpp
@@ -193,16 +193,27 @@ HitTestingTreeNode::GetPrevSibling() con
 }
 
 HitTestingTreeNode*
 HitTestingTreeNode::GetParent() const
 {
   return mParent;
 }
 
+bool
+HitTestingTreeNode::IsAncestorOf(const HitTestingTreeNode* aOther) const
+{
+  for (const HitTestingTreeNode* cur = aOther; cur; cur = cur->GetParent()) {
+    if (cur == this) {
+      return true;
+    }
+  }
+  return false;
+}
+
 AsyncPanZoomController*
 HitTestingTreeNode::GetApzc() const
 {
   return mApzc;
 }
 
 AsyncPanZoomController*
 HitTestingTreeNode::GetNearestContainingApzc() const
--- a/gfx/layers/apz/src/HitTestingTreeNode.h
+++ b/gfx/layers/apz/src/HitTestingTreeNode.h
@@ -69,16 +69,18 @@ public:
   /* Tree walking methods. GetFirstChild is O(n) in the number of children. The
    * other tree walking methods are all O(1). */
 
   HitTestingTreeNode* GetFirstChild() const;
   HitTestingTreeNode* GetLastChild() const;
   HitTestingTreeNode* GetPrevSibling() const;
   HitTestingTreeNode* GetParent() const;
 
+  bool IsAncestorOf(const HitTestingTreeNode* aOther) const;
+
   /* APZC related methods */
 
   AsyncPanZoomController* GetApzc() const;
   AsyncPanZoomController* GetNearestContainingApzc() const;
   bool IsPrimaryHolder() const;
   uint64_t GetLayersId() const;
 
   /* Hit test related methods */