summaryrefslogtreecommitdiffstats
path: root/dom/base/nsContentUtils.cpp
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-09-16 13:30:35 +0000
committerMoonchild <moonchild@palemoon.org>2020-09-16 13:30:35 +0000
commitb4eda697ce275dbd2143e490d29e2664057b6315 (patch)
tree5e7ef7445f36495f5aa840929c6f2fc16cabc672 /dom/base/nsContentUtils.cpp
parent6f5cd8a5e7496d9b1c7b38d7572381b95a48aecc (diff)
downloadUXP-b4eda697ce275dbd2143e490d29e2664057b6315.tar
UXP-b4eda697ce275dbd2143e490d29e2664057b6315.tar.gz
UXP-b4eda697ce275dbd2143e490d29e2664057b6315.tar.lz
UXP-b4eda697ce275dbd2143e490d29e2664057b6315.tar.xz
UXP-b4eda697ce275dbd2143e490d29e2664057b6315.zip
Issue #1643 - Part 1: Add GetNodeDepth() to nsContentUtils.
Diffstat (limited to 'dom/base/nsContentUtils.cpp')
-rw-r--r--dom/base/nsContentUtils.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
index 3568ced90..20b6beffa 100644
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -9843,3 +9843,17 @@ nsContentUtils::GetClosestNonNativeAnonymousAncestor(Element* aElement)
}
return e;
}
+
+/* static */ uint32_t
+nsContentUtils::GetNodeDepth(nsINode* aNode)
+{
+ uint32_t depth = 1;
+
+ MOZ_ASSERT(aNode, "Node shouldn't be null");
+
+ while ((aNode = aNode->GetParentNode())) {
+ ++depth;
+ }
+
+ return depth;
+} \ No newline at end of file