summaryrefslogtreecommitdiff
path: root/dom/base/nsINode.cpp
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-06-10 01:19:37 +0000
committerMoonchild <moonchild@palemoon.org>2020-06-10 01:19:37 +0000
commit8797b20746cd80c51cc56225f70ddea6c6b94f9d (patch)
tree5517d461c0c43f2927708c2c251fbba8e37dd757 /dom/base/nsINode.cpp
parent47db6b4b5e8ca41c93964e964238fe85bdd7e23b (diff)
downloaduxp-8797b20746cd80c51cc56225f70ddea6c6b94f9d.tar.gz
Issue #1585 - Replace node.rootNode with node.getRootNode()
This removes the (default disabled) node.rootNode readonly attribute and replaces it with a node.getRootNode() function per WhatWG spec discussion. Based on work by John Dai <jdai@mozilla.com>
Diffstat (limited to 'dom/base/nsINode.cpp')
-rw-r--r--dom/base/nsINode.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp
index d0cbdb454d..da30bed5c3 100644
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -107,6 +107,7 @@
#include "GeometryUtils.h"
#include "nsIAnimationObserver.h"
#include "nsChildContentList.h"
+#include "mozilla/dom/NodeBinding.h"
#ifdef ACCESSIBILITY
#include "mozilla/dom/AccessibleNode.h"
@@ -250,6 +251,30 @@ nsINode::GetTextEditorRootContent(nsIEditor** aEditor)
return nullptr;
}
+nsINode* nsINode::GetRootNode(const GetRootNodeOptions& aOptions)
+{
+ if (aOptions.mComposed) {
+ if (IsInComposedDoc() && GetComposedDoc()) {
+ return OwnerDoc();
+ }
+
+ nsINode* node = this;
+ ShadowRoot* shadowRootParent = nullptr;
+ while(node) {
+ node = node->SubtreeRoot();
+ shadowRootParent = ShadowRoot::FromNode(node);
+ if (!shadowRootParent) {
+ break;
+ }
+ node = shadowRootParent->GetHost();
+ }
+
+ return node;
+ }
+
+ return SubtreeRoot();
+}
+
nsINode*
nsINode::SubtreeRoot() const
{