Bug 1364622 - Add a helper function HitTestingTreeNode::IsAncestorOf(). r=kats
MozReview-Commit-ID: Et3dokACnMa
--- 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 */