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 {
|
nsIContent* nsIContent::FindFirstNonChromeOnlyAccessContent() const {
|
||||||
// This handles also nested native anonymous content.
|
// This handles also nested native anonymous content.
|
||||||
for (const nsIContent* content = this; content;
|
// Oops, this function signature allows casting const to non-const. (Then
|
||||||
content = content->GetChromeOnlyAccessSubtreeRootParent()) {
|
// again, so does GetFirstChild()->GetParent().)
|
||||||
|
for (nsIContent* content = const_cast<nsIContent*>(this); content;
|
||||||
|
content = content->GetClosestNativeAnonymousSubtreeRootParentOrHost()) {
|
||||||
if (!content->ChromeOnlyAccess()) {
|
if (!content->ChromeOnlyAccess()) {
|
||||||
// Oops, this function signature allows casting const to
|
return content;
|
||||||
// non-const. (Then again, so does GetFirstChild()->GetParent().)
|
|
||||||
return const_cast<nsIContent*>(content);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -739,7 +739,7 @@ static nsINode* FindChromeAccessOnlySubtreeOwnerForEvents(nsINode* aNode) {
|
|||||||
if (!aNode->ChromeOnlyAccessForEvents()) {
|
if (!aNode->ChromeOnlyAccessForEvents()) {
|
||||||
return aNode;
|
return aNode;
|
||||||
}
|
}
|
||||||
return const_cast<nsIContent*>(aNode->GetChromeOnlyAccessSubtreeRootParent());
|
return aNode->GetClosestNativeAnonymousSubtreeRootParentOrHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsINode* FindChromeAccessOnlySubtreeOwnerForEvents(EventTarget* aTarget) {
|
nsINode* FindChromeAccessOnlySubtreeOwnerForEvents(EventTarget* aTarget) {
|
||||||
|
|||||||
@@ -1634,10 +1634,6 @@ class nsINode : public mozilla::dom::EventTarget {
|
|||||||
return ChromeOnlyAccess() && !HasBeenInUAWidget();
|
return ChromeOnlyAccess() && !HasBeenInUAWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
const nsIContent* GetChromeOnlyAccessSubtreeRootParent() const {
|
|
||||||
return GetClosestNativeAnonymousSubtreeRootParentOrHost();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsInShadowTree() const { return HasFlag(NODE_IS_IN_SHADOW_TREE); }
|
bool IsInShadowTree() const { return HasFlag(NODE_IS_IN_SHADOW_TREE); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7522,10 +7522,12 @@ Element* HTMLEditor::ComputeEditingHostInternal(
|
|||||||
}
|
}
|
||||||
if (Element* focusedElementInWindow = innerWindow->GetFocusedElement()) {
|
if (Element* focusedElementInWindow = innerWindow->GetFocusedElement()) {
|
||||||
if (focusedElementInWindow->ChromeOnlyAccess()) {
|
if (focusedElementInWindow->ChromeOnlyAccess()) {
|
||||||
focusedElementInWindow =
|
focusedElementInWindow = Element::FromNodeOrNull(
|
||||||
Element::FromNodeOrNull(const_cast<nsIContent*>(
|
// XXX Should we use
|
||||||
|
// nsIContent::FindFirstNonChromeOnlyAccessContent() instead of
|
||||||
|
// nsINode::GetClosestNativeAnonymousSubtreeRootParentOrHost()?
|
||||||
focusedElementInWindow
|
focusedElementInWindow
|
||||||
->GetChromeOnlyAccessSubtreeRootParent()));
|
->GetClosestNativeAnonymousSubtreeRootParentOrHost());
|
||||||
}
|
}
|
||||||
if (focusedElementInWindow) {
|
if (focusedElementInWindow) {
|
||||||
return focusedElementInWindow->IsEditable() ? 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
|
// TODO: This is also a bit of an issue for delegated focus, see
|
||||||
// https://github.com/whatwg/html/issues/7033.
|
// https://github.com/whatwg/html/issues/7033.
|
||||||
if (aFrame->GetContent() && aFrame->GetContent()->ChromeOnlyAccess()) {
|
if (aFrame->GetContent() && aFrame->GetContent()->ChromeOnlyAccess()) {
|
||||||
|
// XXX Should we use nsIContent::FindFirstNonChromeOnlyAccessContent()
|
||||||
|
// instead of nsINode::GetClosestNativeAnonymousSubtreeRootParentOrHost()?
|
||||||
if (const nsIContent* userContent =
|
if (const nsIContent* userContent =
|
||||||
aFrame->GetContent()->GetChromeOnlyAccessSubtreeRootParent()) {
|
aFrame->GetContent()
|
||||||
|
->GetClosestNativeAnonymousSubtreeRootParentOrHost()) {
|
||||||
if (const nsIFrame* frame = userContent->GetPrimaryFrame()) {
|
if (const nsIFrame* frame = userContent->GetPrimaryFrame()) {
|
||||||
return frame->StyleMargin()->GetScrollMargin();
|
return frame->StyleMargin()->GetScrollMargin();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user