tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 929a7c31cb5bfc39754b2d98cd4b027f50e3fc70
parent dd7f2c0bc67952e0c9310d4f7512105a591d4a70
Author: Sebastian Hengst <aryx.github@gmx-topmail.de>
Date:   Thu,  8 Jan 2026 10:54:10 +0100

Revert "Bug 2008949 - Make nsINode::GetShadowRoot faster. r=dom-core,smaug" for causing merge conflict

This reverts commit 91721a390fcffde5d6e7da27c98fbc3829ab6560.

Diffstat:
Mdom/base/Element.h | 4----
Mdom/base/nsIContent.h | 7+++++++
Mdom/base/nsIContentInlines.h | 8++++++++
Mdom/base/nsINode.cpp | 4++++
Mdom/base/nsINode.h | 2+-
5 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/dom/base/Element.h b/dom/base/Element.h @@ -2582,10 +2582,6 @@ inline mozilla::dom::Element* nsINode::GetPreviousElementSibling() const { return nullptr; } -inline mozilla::dom::ShadowRoot* nsINode::GetShadowRoot() const { - return IsElement() ? AsElement()->GetShadowRoot() : nullptr; -} - inline mozilla::dom::Element* nsINode::GetAsElementOrParentElement() const { return IsElement() ? const_cast<mozilla::dom::Element*>(AsElement()) : GetParentElement(); diff --git a/dom/base/nsIContent.h b/dom/base/nsIContent.h @@ -301,6 +301,13 @@ class nsIContent : public nsINode { virtual IMEState GetDesiredIMEState(); /** + * Gets the ShadowRoot binding for this element. + * + * @return The ShadowRoot currently bound to this element. + */ + inline mozilla::dom::ShadowRoot* GetShadowRoot() const; + + /** * Gets the root of the node tree for this content if it is in a shadow tree. * * @return The ShadowRoot that is the root of the node tree. diff --git a/dom/base/nsIContentInlines.h b/dom/base/nsIContentInlines.h @@ -48,6 +48,14 @@ inline void nsIContent::SetPrimaryFrame(nsIFrame* aFrame) { mPrimaryFrame = aFrame; } +inline mozilla::dom::ShadowRoot* nsIContent::GetShadowRoot() const { + if (!IsElement()) { + return nullptr; + } + + return AsElement()->GetShadowRoot(); +} + template <nsINode::FlattenedParentType aType> static inline nsINode* GetFlattenedTreeParentNode(const nsINode* aNode) { if (!aNode->IsContent()) { diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp @@ -4149,6 +4149,10 @@ void nsINode::NotifyDevToolsOfRemovalsOfChildren() { } } +ShadowRoot* nsINode::GetShadowRoot() const { + return IsContent() ? AsContent()->GetShadowRoot() : nullptr; +} + ShadowRoot* nsINode::GetShadowRootForSelection() const { if (!StaticPrefs::dom_shadowdom_selection_across_boundary_enabled()) { return nullptr; diff --git a/dom/base/nsINode.h b/dom/base/nsINode.h @@ -2279,7 +2279,7 @@ class nsINode : public mozilla::dom::EventTarget { ClearBoolFlag(ElementCreatedFromPrototypeAndHasUnmodifiedL10n); } - inline mozilla::dom::ShadowRoot* GetShadowRoot() const; + mozilla::dom::ShadowRoot* GetShadowRoot() const; // Return the shadow root of the node if it is a shadow host and // it meets the requirements for being a shadow host of a selection.