Bug 1640605 - Remove IsInAnonymousSubtree / IsRootOfAnonymousSubtree. r=edgar

In favor of the NativeAnonymous versions which they forward to.

Done automatically with:

  rg -l 'IsInAnonymousSubtree' | xargs sed -i 's/IsInAnonymousSubtree/IsInNativeAnonymousSubtree/g'

And removing the function definitions afterwards.

Differential Revision: https://phabricator.services.mozilla.com/D76681
This commit is contained in:
Emilio Cobos Álvarez 2020-05-25 11:43:51 +00:00
Родитель de03967deb
Коммит 89958b377a
27 изменённых файлов: 48 добавлений и 68 удалений

Просмотреть файл

@ -246,7 +246,7 @@ dom::Element* IDRefsIterator::GetElem(nsIContent* aContent,
const nsAString& aID) {
// Get elements in DOM tree by ID attribute if this is an explicit content.
// In case of bound element check its anonymous subtree.
if (!aContent->IsInAnonymousSubtree()) {
if (!aContent->IsInNativeAnonymousSubtree()) {
dom::DocumentOrShadowRoot* docOrShadowRoot =
aContent->GetUncomposedDocOrConnectedShadowRoot();
if (docOrShadowRoot) {

Просмотреть файл

@ -66,7 +66,7 @@ MARKUPMAP(
[](Element* aElement, Accessible* aContext) -> Accessible* {
// Never create an accessible if we're part of an anonymous
// subtree.
if (aElement->IsInAnonymousSubtree()) {
if (aElement->IsInNativeAnonymousSubtree()) {
return nullptr;
}
// Always create an accessible if the div has an id.

Просмотреть файл

@ -101,7 +101,7 @@ void FlattenedChildIterator::Init(bool aIgnoreXBL) {
bool ExplicitChildIterator::Seek(const nsIContent* aChildToFind) {
if (aChildToFind->GetParent() == mParent &&
!aChildToFind->IsRootOfAnonymousSubtree()) {
!aChildToFind->IsRootOfNativeAnonymousSubtree()) {
// Fast path: just point ourselves to aChildToFind, which is a
// normal DOM child of ours.
mChild = const_cast<nsIContent*>(aChildToFind);

Просмотреть файл

@ -285,7 +285,7 @@ static bool DoesNotParticipateInAutoDirection(const nsIContent* aContent) {
nodeInfo->Equals(nsGkAtoms::style) ||
nodeInfo->Equals(nsGkAtoms::input) ||
nodeInfo->Equals(nsGkAtoms::textarea) ||
aContent->IsInAnonymousSubtree())) &&
aContent->IsInNativeAnonymousSubtree())) &&
!aContent->IsShadowRoot();
}
@ -320,7 +320,7 @@ inline static bool NodeAffectsDirAutoAncestor(nsIContent* aTextNode) {
nsIContent* parent = GetParentOrHostOrSlot(aTextNode);
return (parent && !DoesNotParticipateInAutoDirection(parent) &&
parent->NodeOrAncestorHasDirAuto() &&
!aTextNode->IsInAnonymousSubtree());
!aTextNode->IsInNativeAnonymousSubtree());
}
Directionality GetDirectionFromText(const char16_t* aText,

Просмотреть файл

@ -9273,7 +9273,7 @@ nsINode* Document::AdoptNode(nsINode& aAdoptedNode, ErrorResult& rv) {
case COMMENT_NODE:
case DOCUMENT_TYPE_NODE: {
// Don't allow adopting a node's anonymous subtree out from under it.
if (adoptedNode->AsContent()->IsRootOfAnonymousSubtree()) {
if (adoptedNode->AsContent()->IsRootOfNativeAnonymousSubtree()) {
rv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return nullptr;
}
@ -10706,7 +10706,7 @@ nsIContent* Document::GetContentInThisDocument(nsIFrame* aFrame) const {
for (nsIFrame* f = aFrame; f;
f = nsLayoutUtils::GetParentOrPlaceholderForCrossDoc(f)) {
nsIContent* content = f->GetContent();
if (!content || content->IsInAnonymousSubtree()) continue;
if (!content || content->IsInNativeAnonymousSubtree()) continue;
if (content->OwnerDoc() == this) {
return content;

Просмотреть файл

@ -922,7 +922,7 @@ void Element::AddToIdTable(nsAtom* aId) {
containingShadow->AddToIdTable(this, aId);
} else {
Document* doc = GetUncomposedDoc();
if (doc && !IsInAnonymousSubtree()) {
if (doc && !IsInNativeAnonymousSubtree()) {
doc->AddToIdTable(this, aId);
}
}
@ -943,7 +943,7 @@ void Element::RemoveFromIdTable() {
}
} else {
Document* doc = GetUncomposedDoc();
if (doc && !IsInAnonymousSubtree()) {
if (doc && !IsInNativeAnonymousSubtree()) {
doc->RemoveFromIdTable(this, id);
}
}
@ -1707,7 +1707,7 @@ void Element::UnbindFromTree(bool aNullParent) {
if (HasServoData()) {
MOZ_ASSERT(document);
MOZ_ASSERT(IsInAnonymousSubtree());
MOZ_ASSERT(IsInNativeAnonymousSubtree());
}
if (document) {

Просмотреть файл

@ -663,7 +663,7 @@ void ShadowRoot::MaybeUnslotHostChild(nsIContent& aChild) {
return;
}
MOZ_DIAGNOSTIC_ASSERT(!aChild.IsRootOfAnonymousSubtree(),
MOZ_DIAGNOSTIC_ASSERT(!aChild.IsRootOfNativeAnonymousSubtree(),
"How did aChild end up assigned to a slot?");
// If the slot is going to start showing fallback content, we need to tell
// layout about it.
@ -679,7 +679,7 @@ void ShadowRoot::MaybeSlotHostChild(nsIContent& aChild) {
MOZ_ASSERT(aChild.GetParent() == GetHost());
// Check to ensure that the child not an anonymous subtree root because even
// though its parent could be the host it may not be in the host's child list.
if (aChild.IsRootOfAnonymousSubtree()) {
if (aChild.IsRootOfNativeAnonymousSubtree()) {
return;
}

Просмотреть файл

@ -2700,7 +2700,7 @@ void nsContentUtils::GenerateStateKey(nsIContent* aContent, Document* aDocument,
uint32_t partID = aDocument ? aDocument->GetPartID() : 0;
// Don't capture state for anonymous content
if (aContent->IsInAnonymousSubtree()) {
if (aContent->IsInNativeAnonymousSubtree()) {
return;
}

Просмотреть файл

@ -68,7 +68,7 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsDOMMutationRecord, mTarget,
bool nsMutationReceiverBase::IsObservable(nsIContent* aContent) {
return !aContent->ChromeOnlyAccess() &&
(Observer()->IsChrome() || !aContent->IsInAnonymousSubtree());
(Observer()->IsChrome() || !aContent->IsInNativeAnonymousSubtree());
}
NS_IMPL_ADDREF(nsMutationReceiver)

Просмотреть файл

@ -187,16 +187,6 @@ class nsIContent : public nsINode {
*/
nsIContent* FindFirstNonChromeOnlyAccessContent() const;
/**
* Returns true if and only if this node has a parent, but is not in
* its parent's child list.
*
* FIXME(emilio): Remove along nsINode::IsInAnonymousSubtree.
*/
bool IsRootOfAnonymousSubtree() const {
return IsRootOfNativeAnonymousSubtree();
}
/**
* Return true iff this node is in an HTML document (in the HTML5 sense of
* the term, i.e. not in an XHTML/XML document).

Просмотреть файл

@ -94,7 +94,7 @@ static inline nsINode* GetFlattenedTreeParentNode(const nsINode* aNode) {
return docLevel ? content->OwnerDocAsNode() : parent;
}
if (content->IsRootOfAnonymousSubtree()) {
if (content->IsRootOfNativeAnonymousSubtree()) {
return parent;
}
@ -171,7 +171,7 @@ inline void nsIContent::HandleInsertionToOrRemovalFromSlot() {
using mozilla::dom::HTMLSlotElement;
MOZ_ASSERT(GetParentElement());
if (!IsInShadowTree() || IsRootOfAnonymousSubtree()) {
if (!IsInShadowTree() || IsRootOfNativeAnonymousSubtree()) {
return;
}
HTMLSlotElement* slot = HTMLSlotElement::FromNode(mParent);

Просмотреть файл

@ -774,7 +774,7 @@ nsINode* nsINode::RemoveChild(nsINode& aOldChild, ErrorResult& aError) {
// Check again, we may not be the child's parent anymore.
// Can be triggered by dom/base/crashtests/293388-1.html
if (aOldChild.AsContent()->IsRootOfAnonymousSubtree() ||
if (aOldChild.AsContent()->IsRootOfNativeAnonymousSubtree() ||
aOldChild.GetParentNode() != this) {
// aOldChild isn't one of our children.
aError.ThrowNotFoundError(
@ -2302,7 +2302,7 @@ void nsINode::EnsurePreInsertionValidity2(bool aReplace, nsINode& aNewChild,
nsINode* aRefChild,
ErrorResult& aError) {
if (aNewChild.IsContent() &&
aNewChild.AsContent()->IsRootOfAnonymousSubtree()) {
aNewChild.AsContent()->IsRootOfNativeAnonymousSubtree()) {
// This is anonymous content. Don't allow its insertion
// anywhere, since it might have UnbindFromTree calls coming
// its way.
@ -2748,7 +2748,7 @@ bool nsINode::Contains(const nsINode* aOther) const {
// document.contains(aOther) returns true if aOther is in the document,
// but is not in any anonymous subtree.
// IsInUncomposedDoc() check is done already before this.
return !aOther->IsInAnonymousSubtree();
return !aOther->IsInNativeAnonymousSubtree();
}
if (!IsElement() && !IsDocumentFragment()) {

Просмотреть файл

@ -1295,16 +1295,6 @@ class nsINode : public mozilla::dom::EventTarget {
return HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE);
}
/**
* Returns true if there is NOT a path through child lists
* from the top of this node's parent chain back to this node or
* if the node is in native anonymous subtree without a parent.
*
* TODO(emilio):: Remove this function, and use just
* IsInNativeAnonymousSubtree, or something?
*/
bool IsInAnonymousSubtree() const { return IsInNativeAnonymousSubtree(); }
/**
* If |this| or any ancestor is native anonymous, return the root of the
* native anonymous subtree. Note that in case of nested native anonymous

Просмотреть файл

@ -102,7 +102,7 @@ void Event::InitPresContextData(nsPresContext* aPresContext) {
{
nsCOMPtr<nsIContent> content = GetTargetFromFrame();
mExplicitOriginalTarget = content;
if (content && content->IsInAnonymousSubtree()) {
if (content && content->IsInNativeAnonymousSubtree()) {
mExplicitOriginalTarget = nullptr;
}
}

Просмотреть файл

@ -892,7 +892,7 @@ nsresult EventDispatcher::Dispatch(nsISupports* aTarget,
bool clearTargets = false;
nsCOMPtr<nsIContent> content = do_QueryInterface(aEvent->mOriginalTarget);
bool isInAnon = content && content->IsInAnonymousSubtree();
bool isInAnon = content && content->IsInNativeAnonymousSubtree();
aEvent->mFlags.mIsBeingDispatched = true;

Просмотреть файл

@ -2862,7 +2862,7 @@ nsIRadioGroupContainer* HTMLInputElement::GetRadioGroupContainer() const {
return mForm;
}
if (IsInAnonymousSubtree()) {
if (IsInNativeAnonymousSubtree()) {
return nullptr;
}
@ -6059,8 +6059,8 @@ bool HTMLInputElement::AllowDrop() {
void HTMLInputElement::AddedToRadioGroup() {
// If the element is neither in a form nor a document, there is no group so we
// should just stop here.
if (!mForm &&
(!GetUncomposedDocOrConnectedShadowRoot() || IsInAnonymousSubtree())) {
if (!mForm && (!GetUncomposedDocOrConnectedShadowRoot() ||
IsInNativeAnonymousSubtree())) {
return;
}

Просмотреть файл

@ -146,7 +146,7 @@ static const nsAttrValue::EnumTable kDirTable[] = {
void nsGenericHTMLElement::AddToNameTable(nsAtom* aName) {
MOZ_ASSERT(HasName(), "Node doesn't have name?");
Document* doc = GetUncomposedDoc();
if (doc && !IsInAnonymousSubtree()) {
if (doc && !IsInNativeAnonymousSubtree()) {
doc->AddToNameTable(this, aName);
}
}

Просмотреть файл

@ -248,7 +248,7 @@ void HTMLEditor::DeleteRefToAnonymousNode(ManualNACPtr aContent,
// See bug 338129.
if (aContent->IsInComposedDoc() && aPresShell &&
!aPresShell->IsDestroying()) {
MOZ_ASSERT(aContent->IsRootOfAnonymousSubtree());
MOZ_ASSERT(aContent->IsRootOfNativeAnonymousSubtree());
MOZ_ASSERT(!aContent->GetPreviousSibling(), "NAC has no siblings");
// FIXME(emilio): This is the only caller to PresShell::ContentRemoved that

Просмотреть файл

@ -1082,7 +1082,7 @@ bool mozInlineSpellChecker::ShouldSpellCheckNode(TextEditor* aTextEditor,
// Make sure that we can always turn on spell checking for inputs/textareas.
// Note that because of the previous check, at this point we know that the
// node is editable.
if (content->IsInAnonymousSubtree()) {
if (content->IsInNativeAnonymousSubtree()) {
nsIContent* node = content->GetParent();
while (node && node->IsInNativeAnonymousSubtree()) {
node = node->GetParent();

Просмотреть файл

@ -43,7 +43,7 @@ static already_AddRefed<dom::Element> ElementFromPoint(
RelativeTo{rootFrame, ViewportType::Visual}, CSSPoint::ToAppUnits(aPoint),
{FrameForPointOption::IgnorePaintSuppression});
while (frame && (!frame->GetContent() ||
frame->GetContent()->IsInAnonymousSubtree())) {
frame->GetContent()->IsInNativeAnonymousSubtree())) {
frame = nsLayoutUtils::GetParentOrPlaceholderFor(frame);
}
if (!frame) {

Просмотреть файл

@ -4402,7 +4402,7 @@ MOZ_CAN_RUN_SCRIPT_BOUNDARY void PresShell::ContentRemoved(
// Editor calls into here with NAC via HTMLEditor::DeleteRefToAnonymousNode.
// This could be asserted if that caller is fixed.
if (MOZ_LIKELY(!aChild->IsRootOfAnonymousSubtree())) {
if (MOZ_LIKELY(!aChild->IsRootOfNativeAnonymousSubtree())) {
oldNextSibling = aPreviousSibling ? aPreviousSibling->GetNextSibling()
: container->GetFirstChild();
}

Просмотреть файл

@ -90,7 +90,7 @@ void RestyleManager::ContentAppended(nsIContent* aFirstNewContent) {
#ifdef DEBUG
{
for (nsIContent* cur = aFirstNewContent; cur; cur = cur->GetNextSibling()) {
NS_ASSERTION(!cur->IsRootOfAnonymousSubtree(),
NS_ASSERTION(!cur->IsRootOfNativeAnonymousSubtree(),
"anonymous nodes should not be in child lists");
}
}
@ -265,7 +265,7 @@ void RestyleManager::CharacterDataChanged(
return;
}
if (MOZ_UNLIKELY(aContent->IsRootOfAnonymousSubtree())) {
if (MOZ_UNLIKELY(aContent->IsRootOfNativeAnonymousSubtree())) {
// This is an anonymous node and thus isn't in child lists, so isn't taken
// into account for selector matching the relevant selectors here.
return;
@ -333,7 +333,7 @@ void RestyleManager::RestyleForInsertOrChange(nsIContent* aChild) {
}
Element* container = parentNode->AsElement();
NS_ASSERTION(!aChild->IsRootOfAnonymousSubtree(),
NS_ASSERTION(!aChild->IsRootOfNativeAnonymousSubtree(),
"anonymous nodes should not be in child lists");
uint32_t selectorFlags = container->GetFlags() & NODE_ALL_SELECTOR_FLAGS;
if (selectorFlags == 0) return;
@ -383,7 +383,7 @@ void RestyleManager::ContentRemoved(nsIContent* aOldChild,
}
Element* container = aOldChild->GetParentNode()->AsElement();
if (aOldChild->IsRootOfAnonymousSubtree()) {
if (aOldChild->IsRootOfNativeAnonymousSubtree()) {
// This should be an assert, but this is called incorrectly in
// HTMLEditor::DeleteRefToAnonymousNode and the assertions were clogging
// up the logs. Make it an assert again when that's fixed.

Просмотреть файл

@ -5176,7 +5176,7 @@ static bool ShouldSuppressFrameInSelect(const nsIContent* aParent,
// Options with labels have their label text added in ::before by forms.css.
// Suppress frames for their child text.
if (aParent->IsHTMLElement(nsGkAtoms::option) &&
!aChild.IsRootOfAnonymousSubtree()) {
!aChild.IsRootOfNativeAnonymousSubtree()) {
return aParent->AsElement()->HasNonEmptyAttr(nsGkAtoms::label);
}
@ -5200,7 +5200,7 @@ static bool ShouldSuppressFrameInSelect(const nsIContent* aParent,
}
// Allow native anonymous content no matter what.
if (aChild.IsRootOfAnonymousSubtree()) {
if (aChild.IsRootOfNativeAnonymousSubtree()) {
return false;
}
@ -5224,7 +5224,7 @@ static bool ShouldSuppressFrameInNonOpenDetails(
}
// Don't suppress NAC, unless it's a ::before, inside ::marker, or ::after.
if (aChild.IsRootOfAnonymousSubtree() &&
if (aChild.IsRootOfNativeAnonymousSubtree() &&
!(aChild.IsGeneratedContentContainerForMarker() &&
aComputedStyle->StyleList()->mListStylePosition ==
NS_STYLE_LIST_STYLE_POSITION_INSIDE) &&
@ -6209,8 +6209,8 @@ nsIFrame* nsCSSFrameConstructor::GetInsertionPrevSibling(
// XBL insertion point is involved, we'll need to use _that_ to find
// the preceding frame.
FlattenedChildIterator iter(aInsertion->mContainer);
if (iter.ShadowDOMInvolved() || !aChild->IsRootOfAnonymousSubtree()) {
// The check for IsRootOfAnonymousSubtree() is because editor is
if (iter.ShadowDOMInvolved() || !aChild->IsRootOfNativeAnonymousSubtree()) {
// The check for IsRootOfNativeAnonymousSubtree() is because editor is
// severely broken and calls us directly for native anonymous
// nodes that it creates.
if (aStartSkipChild) {
@ -7136,7 +7136,7 @@ void nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aStartChild,
if (isSingleInsert) {
AddFrameConstructionItems(state, aStartChild,
aStartChild->IsRootOfAnonymousSubtree(),
aStartChild->IsRootOfNativeAnonymousSubtree(),
insertion, items);
} else {
for (nsIContent* child = aStartChild; child != aEndChild;
@ -7301,7 +7301,7 @@ bool nsCSSFrameConstructor::ContentRemoved(nsIContent* aChild,
nsIContent* aOldNextSibling,
RemoveFlags aFlags) {
MOZ_ASSERT(aChild);
MOZ_ASSERT(!aChild->IsRootOfAnonymousSubtree() || !aOldNextSibling,
MOZ_ASSERT(!aChild->IsRootOfNativeAnonymousSubtree() || !aOldNextSibling,
"Anonymous roots don't have siblings");
AUTO_PROFILER_LABEL("nsCSSFrameConstructor::ContentRemoved",
LAYOUT_FrameConstruction);
@ -8557,7 +8557,7 @@ void nsCSSFrameConstructor::RecreateFramesForContent(
MOZ_ASSERT(aContent->GetParentNode());
// Remove the frames associated with the content object.
nsIContent* nextSibling = aContent->IsRootOfAnonymousSubtree()
nsIContent* nextSibling = aContent->IsRootOfNativeAnonymousSubtree()
? nullptr
: aContent->GetNextSibling();
bool didReconstruct =
@ -8587,7 +8587,7 @@ void nsCSSFrameConstructor::RecreateFramesForContent(
bool nsCSSFrameConstructor::DestroyFramesFor(Element* aElement) {
MOZ_ASSERT(aElement && aElement->GetParentNode());
nsIContent* nextSibling = aElement->IsRootOfAnonymousSubtree()
nsIContent* nextSibling = aElement->IsRootOfNativeAnonymousSubtree()
? nullptr
: aElement->GetNextSibling();
@ -9531,7 +9531,7 @@ void nsCSSFrameConstructor::ProcessChildren(
GetAnonymousContent(aContent, aPossiblyLeafFrame, anonymousItems);
#ifdef DEBUG
for (uint32_t i = 0; i < anonymousItems.Length(); ++i) {
MOZ_ASSERT(anonymousItems[i].mContent->IsRootOfAnonymousSubtree(),
MOZ_ASSERT(anonymousItems[i].mContent->IsRootOfNativeAnonymousSubtree(),
"Content should know it's an anonymous subtree");
}
#endif

Просмотреть файл

@ -154,7 +154,7 @@ void nsTextControlFrame::DestroyFrom(nsIFrame* aDestructRoot,
if (mClass == kClassID) {
aPostDestroyData.AddAnonymousContent(mRootNode.forget());
} else {
MOZ_ASSERT(!mRootNode || !mRootNode->IsRootOfAnonymousSubtree());
MOZ_ASSERT(!mRootNode || !mRootNode->IsRootOfNativeAnonymousSubtree());
mRootNode = nullptr;
}

Просмотреть файл

@ -5306,7 +5306,7 @@ static FrameContentRange GetRangeForFrame(nsIFrame* aFrame) {
return FrameContentRange(parent, beginOffset, beginOffset);
}
while (content->IsRootOfAnonymousSubtree()) {
while (content->IsRootOfNativeAnonymousSubtree()) {
content = content->GetParent();
}
@ -10206,7 +10206,7 @@ static nsIFrame* GetCorrectedParent(const nsIFrame* aFrame) {
if (element && !element->IsRootOfNativeAnonymousSubtree() &&
element->GetPseudoElementType() == aFrame->Style()->GetPseudoType()) {
while (parent->GetContent() &&
!parent->GetContent()->IsRootOfAnonymousSubtree()) {
!parent->GetContent()->IsRootOfNativeAnonymousSubtree()) {
parent = parent->GetInFlowParent();
}
parent = parent->GetInFlowParent();

Просмотреть файл

@ -1379,7 +1379,7 @@ static bool IsFocused(nsIContent* aContent) {
// for a text input field, are inside anonymous subtrees, but the focus
// manager always reports a non-anonymous element as the focused one, so
// walk up the tree until we reach a non-anonymous element.
while (aContent && aContent->IsInAnonymousSubtree()) {
while (aContent && aContent->IsInNativeAnonymousSubtree()) {
aContent = aContent->GetParent();
}

Просмотреть файл

@ -70,7 +70,7 @@ static nsINode* GetCorrespondingNodeInDocument(const nsINode* aOrigNode,
MOZ_ASSERT(aOrigNode);
// Selections in anonymous subtrees aren't supported.
if (aOrigNode->IsInAnonymousSubtree() || aOrigNode->IsInShadowTree()) {
if (aOrigNode->IsInNativeAnonymousSubtree() || aOrigNode->IsInShadowTree()) {
return nullptr;
}