Bug 1410895: Multiple cleanups on top. r?bz
MozReview-Commit-ID: GX3dfmWL083
--- a/dom/base/FragmentOrElement.cpp
+++ b/dom/base/FragmentOrElement.cpp
@@ -201,31 +201,31 @@ nsIContent::GetFlattenedTreeParentNodeIn
}
#endif
if (isDocLevelNAC) {
return OwnerDoc();
}
}
- if (parent && nsContentUtils::HasDistributedChildren(parent) &&
+ if (nsContentUtils::HasDistributedChildren(parent) &&
nsContentUtils::IsInSameAnonymousTree(parent, this)) {
// This node is distributed to insertion points, thus we
// need to consult the destination insertion points list to
// figure out where this node was inserted in the flattened tree.
// It may be the case that |parent| distributes its children
// but the child does not match any insertion points, thus
// the flattened tree parent is nullptr.
nsTArray<nsIContent*>* destInsertionPoints = GetExistingDestInsertionPoints();
parent = destInsertionPoints && !destInsertionPoints->IsEmpty() ?
destInsertionPoints->LastElement()->GetParent() : nullptr;
} else if (HasFlag(NODE_MAY_BE_IN_BINDING_MNGR)) {
- nsIContent* insertionParent = GetXBLInsertionParent();
- if (insertionParent) {
- parent = insertionParent;
+ if (nsIContent* insertionPoint = GetXBLInsertionPoint()) {
+ parent = insertionPoint->GetParent();
+ MOZ_ASSERT(parent);
}
}
// Shadow roots never shows up in the flattened tree. Return the host
// instead.
if (parent && parent->IsInShadowTree()) {
ShadowRoot* parentShadowRoot = ShadowRoot::FromNode(parent);
if (parentShadowRoot) {
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -4800,18 +4800,17 @@ nsContentUtils::HasMutationListeners(nsI
// global object will be null for documents that don't have windows.
nsPIDOMWindowInner* window = doc->GetInnerWindow();
// This relies on EventListenerManager::AddEventListener, which sets
// all mutation bits when there is a listener for DOMSubtreeModified event.
if (window && !window->HasMutationListeners(aType)) {
return false;
}
- if (aNode->IsNodeOfType(nsINode::eCONTENT) &&
- static_cast<nsIContent*>(aNode)->ChromeOnlyAccess()) {
+ if (aNode->IsContent() && aNode->AsContent()->ChromeOnlyAccess()) {
return false;
}
doc->MayDispatchMutationEvent(aTargetForSubtreeModified);
// If we have a window, we can check it for mutation listeners now.
if (aNode->IsInUncomposedDoc()) {
nsCOMPtr<EventTarget> piTarget(do_QueryInterface(window));
@@ -4827,21 +4826,21 @@ nsContentUtils::HasMutationListeners(nsI
// might not be in our chain. If we don't have a window, we might have a
// mutation listener. Check quickly to see.
while (aNode) {
EventListenerManager* manager = aNode->GetExistingListenerManager();
if (manager && manager->HasMutationListeners()) {
return true;
}
- if (aNode->IsNodeOfType(nsINode::eCONTENT)) {
- nsIContent* content = static_cast<nsIContent*>(aNode);
- nsIContent* insertionParent = content->GetXBLInsertionParent();
- if (insertionParent) {
- aNode = insertionParent;
+ if (aNode->IsContent()) {
+ nsIContent* insertionPoint = aNode->AsContent()->GetXBLInsertionPoint();
+ if (insertionPoint) {
+ aNode = insertionPoint->GetParent();
+ MOZ_ASSERT(aNode);
continue;
}
}
aNode = aNode->GetParentNode();
}
return false;
}
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -7486,27 +7486,17 @@ nsCSSFrameConstructor::GetRangeInsertion
// See if we have an XBL insertion point. If so, then that's our
// real parent frame; if not, then the frame hasn't been built yet
// and we just bail.
InsertionPoint insertionPoint = GetInsertionPoint(aContainer, nullptr);
if (!insertionPoint.mParentFrame && !insertionPoint.mMultiple) {
return insertionPoint; // Don't build the frames.
}
- bool hasInsertion = false;
- if (!insertionPoint.mMultiple) {
- // XXXbz XBL2/sXBL issue
- nsIDocument* document = aStartChild->GetComposedDoc();
- // XXXbz how would |document| be null here?
- if (document && aStartChild->GetXBLInsertionParent()) {
- hasInsertion = true;
- }
- }
-
- if (insertionPoint.mMultiple || hasInsertion) {
+ if (insertionPoint.mMultiple || aStartChild->GetXBLInsertionPoint()) {
// We have an insertion point. There are some additional tests we need to do
// in order to ensure that an append is a safe operation.
uint32_t childCount = 0;
if (!insertionPoint.mMultiple) {
// We may need to make multiple ContentInserted calls instead. A
// reasonable heuristic to employ (in order to maintain good performance)
// is to find out if the insertion point's content node contains any