diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index a4009c701573..42bbb873c6bf 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -141,12 +141,12 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE_AND_DESTROY(nsIContent, nsIContent* nsIContent::FindFirstNonChromeOnlyAccessContent() const { // This handles also nested native anonymous content. - for (const nsIContent* content = this; content; - content = content->GetChromeOnlyAccessSubtreeRootParent()) { + // Oops, this function signature allows casting const to non-const. (Then + // again, so does GetFirstChild()->GetParent().) + for (nsIContent* content = const_cast(this); content; + content = content->GetClosestNativeAnonymousSubtreeRootParentOrHost()) { if (!content->ChromeOnlyAccess()) { - // Oops, this function signature allows casting const to - // non-const. (Then again, so does GetFirstChild()->GetParent().) - return const_cast(content); + return content; } } return nullptr; @@ -739,7 +739,7 @@ static nsINode* FindChromeAccessOnlySubtreeOwnerForEvents(nsINode* aNode) { if (!aNode->ChromeOnlyAccessForEvents()) { return aNode; } - return const_cast(aNode->GetChromeOnlyAccessSubtreeRootParent()); + return aNode->GetClosestNativeAnonymousSubtreeRootParentOrHost(); } nsINode* FindChromeAccessOnlySubtreeOwnerForEvents(EventTarget* aTarget) { diff --git a/dom/base/nsINode.h b/dom/base/nsINode.h index 0ec15ddd9763..0993eb46f406 100644 --- a/dom/base/nsINode.h +++ b/dom/base/nsINode.h @@ -1634,10 +1634,6 @@ class nsINode : public mozilla::dom::EventTarget { return ChromeOnlyAccess() && !HasBeenInUAWidget(); } - const nsIContent* GetChromeOnlyAccessSubtreeRootParent() const { - return GetClosestNativeAnonymousSubtreeRootParentOrHost(); - } - bool IsInShadowTree() const { return HasFlag(NODE_IS_IN_SHADOW_TREE); } /** diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp index cc9dd08c4500..354136d59031 100644 --- a/editor/libeditor/HTMLEditor.cpp +++ b/editor/libeditor/HTMLEditor.cpp @@ -7522,10 +7522,12 @@ Element* HTMLEditor::ComputeEditingHostInternal( } if (Element* focusedElementInWindow = innerWindow->GetFocusedElement()) { if (focusedElementInWindow->ChromeOnlyAccess()) { - focusedElementInWindow = - Element::FromNodeOrNull(const_cast( - focusedElementInWindow - ->GetChromeOnlyAccessSubtreeRootParent())); + focusedElementInWindow = Element::FromNodeOrNull( + // XXX Should we use + // nsIContent::FindFirstNonChromeOnlyAccessContent() instead of + // nsINode::GetClosestNativeAnonymousSubtreeRootParentOrHost()? + focusedElementInWindow + ->GetClosestNativeAnonymousSubtreeRootParentOrHost()); } if (focusedElementInWindow) { return focusedElementInWindow->IsEditable() ? focusedElementInWindow diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index 448ba8097eaa..d96fd36e0020 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -3727,8 +3727,11 @@ static nsMargin GetScrollMargin(const nsIFrame* aFrame) { // TODO: This is also a bit of an issue for delegated focus, see // https://github.com/whatwg/html/issues/7033. if (aFrame->GetContent() && aFrame->GetContent()->ChromeOnlyAccess()) { + // XXX Should we use nsIContent::FindFirstNonChromeOnlyAccessContent() + // instead of nsINode::GetClosestNativeAnonymousSubtreeRootParentOrHost()? if (const nsIContent* userContent = - aFrame->GetContent()->GetChromeOnlyAccessSubtreeRootParent()) { + aFrame->GetContent() + ->GetClosestNativeAnonymousSubtreeRootParentOrHost()) { if (const nsIFrame* frame = userContent->GetPrimaryFrame()) { return frame->StyleMargin()->GetScrollMargin(); }