Bug 1954413 - Get rid of nsINode::GetChromeOnlyAccessSubtreeRootParent() r=smaug
It's an alias of `nsINode::GetClosestNativeAnonymousSubtreeRootParentOrHost()` and oddly it returns `const nsIContent*` rather than `nsIContent*`. Therefore, some callers need to use `const_cast`. Differential Revision: https://phabricator.services.mozilla.com/D241776
This commit is contained in:
@@ -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<nsIContent*>(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<nsIContent*>(content);
|
||||
return content;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
@@ -739,7 +739,7 @@ static nsINode* FindChromeAccessOnlySubtreeOwnerForEvents(nsINode* aNode) {
|
||||
if (!aNode->ChromeOnlyAccessForEvents()) {
|
||||
return aNode;
|
||||
}
|
||||
return const_cast<nsIContent*>(aNode->GetChromeOnlyAccessSubtreeRootParent());
|
||||
return aNode->GetClosestNativeAnonymousSubtreeRootParentOrHost();
|
||||
}
|
||||
|
||||
nsINode* FindChromeAccessOnlySubtreeOwnerForEvents(EventTarget* aTarget) {
|
||||
|
||||
@@ -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); }
|
||||
|
||||
/**
|
||||
|
||||
@@ -7522,10 +7522,12 @@ Element* HTMLEditor::ComputeEditingHostInternal(
|
||||
}
|
||||
if (Element* focusedElementInWindow = innerWindow->GetFocusedElement()) {
|
||||
if (focusedElementInWindow->ChromeOnlyAccess()) {
|
||||
focusedElementInWindow =
|
||||
Element::FromNodeOrNull(const_cast<nsIContent*>(
|
||||
focusedElementInWindow
|
||||
->GetChromeOnlyAccessSubtreeRootParent()));
|
||||
focusedElementInWindow = Element::FromNodeOrNull(
|
||||
// XXX Should we use
|
||||
// nsIContent::FindFirstNonChromeOnlyAccessContent() instead of
|
||||
// nsINode::GetClosestNativeAnonymousSubtreeRootParentOrHost()?
|
||||
focusedElementInWindow
|
||||
->GetClosestNativeAnonymousSubtreeRootParentOrHost());
|
||||
}
|
||||
if (focusedElementInWindow) {
|
||||
return focusedElementInWindow->IsEditable() ? focusedElementInWindow
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user