Bug 1450717: Remove unneeded / inconsistent arguments from nsCSSFrameConstructor. r=mats

Much in the spirit of bug 1442207.

They're not only unneeded, and cheap to get, but also we call them
inconsistently with the light DOM and flattened tree parent (like ContentRemoved
for display: contents), so they're really confusing, and kind of a footgun.

MozReview-Commit-ID: 9u3Kp8Kpp5i
This commit is contained in:
Emilio Cobos Álvarez
2018-04-02 05:30:51 +02:00
parent 5bfce6ebda
commit 65cd27d492
8 changed files with 197 additions and 232 deletions

View File

@@ -6738,23 +6738,20 @@ InvalidateCanvasIfNeeded(nsIPresShell* presShell, nsIContent* node);
#ifdef MOZ_XUL
static
bool
static bool
IsXULListBox(nsIContent* aContainer)
{
return (aContainer->IsXULElement(nsGkAtoms::listbox));
return aContainer->IsXULElement(nsGkAtoms::listbox);
}
static
nsListBoxBodyFrame*
MaybeGetListBoxBodyFrame(nsIContent* aContainer, nsIContent* aChild)
MaybeGetListBoxBodyFrame(nsIContent* aChild)
{
if (!aContainer)
return nullptr;
if (IsXULListBox(aContainer) &&
aChild->IsXULElement(nsGkAtoms::listitem)) {
RefPtr<nsXULElement> xulElement = nsXULElement::FromNode(aContainer);
if (aChild->IsXULElement(nsGkAtoms::listitem) && aChild->GetParent() &&
IsXULListBox(aChild->GetParent())) {
RefPtr<nsXULElement> xulElement =
nsXULElement::FromNode(aChild->GetParent());
nsCOMPtr<nsIBoxObject> boxObject = xulElement->GetBoxObject(IgnoreErrors());
nsCOMPtr<nsPIListBoxObject> listBoxObject = do_QueryInterface(boxObject);
if (listBoxObject) {
@@ -6788,8 +6785,7 @@ nsCSSFrameConstructor::AddTextItemIfNeeded(nsFrameConstructorState& aState,
}
void
nsCSSFrameConstructor::ReframeTextIfNeeded(nsIContent* aParentContent,
nsIContent* aContent)
nsCSSFrameConstructor::ReframeTextIfNeeded(nsIContent* aContent)
{
if (!aContent->IsNodeOfType(nsINode::eTEXT) ||
!aContent->HasFlag(NS_CREATE_FRAME_IF_NON_WHITESPACE) ||
@@ -6801,7 +6797,7 @@ nsCSSFrameConstructor::ReframeTextIfNeeded(nsIContent* aParentContent,
}
MOZ_ASSERT(!aContent->GetPrimaryFrame(),
"Text node has a frame and NS_CREATE_FRAME_IF_NON_WHITESPACE");
ContentInserted(aParentContent, aContent, nullptr, InsertionKind::Async);
ContentInserted(aContent, nullptr, InsertionKind::Async);
}
#ifdef DEBUG
@@ -6922,8 +6918,7 @@ nsCSSFrameConstructor::MaybeConstructLazily(Operation aOperation,
void
nsCSSFrameConstructor::IssueSingleInsertNofications(nsIContent* aContainer,
nsIContent* aStartChild,
nsCSSFrameConstructor::IssueSingleInsertNofications(nsIContent* aStartChild,
nsIContent* aEndChild,
InsertionKind aInsertionKind)
{
@@ -6931,11 +6926,10 @@ nsCSSFrameConstructor::IssueSingleInsertNofications(nsIContent* aContainer,
child != aEndChild;
child = child->GetNextSibling()) {
// listboxes suck.
MOZ_ASSERT(MaybeGetListBoxBodyFrame(aContainer, child) ||
!child->GetPrimaryFrame());
MOZ_ASSERT(MaybeGetListBoxBodyFrame(child) || !child->GetPrimaryFrame());
// Call ContentRangeInserted with this node.
ContentRangeInserted(aContainer, child, child->GetNextSibling(),
ContentRangeInserted(child, child->GetNextSibling(),
mTempFrameTreeState, aInsertionKind);
}
}
@@ -6963,19 +6957,20 @@ nsCSSFrameConstructor::InsertionPoint::IsMultiple() const
}
nsCSSFrameConstructor::InsertionPoint
nsCSSFrameConstructor::GetRangeInsertionPoint(nsIContent* aContainer,
nsIContent* aStartChild,
nsCSSFrameConstructor::GetRangeInsertionPoint(nsIContent* aStartChild,
nsIContent* aEndChild,
InsertionKind aInsertionKind)
{
MOZ_ASSERT(aStartChild);
MOZ_ASSERT(aStartChild->GetParent());
nsIContent* parent = aStartChild->GetParent();
// If the children of the container may be distributed to different insertion
// points, insert them separately and bail out, letting ContentInserted handle
// the mess.
if (aContainer->GetShadowRoot() || aContainer->GetXBLBinding()) {
IssueSingleInsertNofications(
aContainer, aStartChild, aEndChild, aInsertionKind);
if (parent->GetShadowRoot() || parent->GetXBLBinding()) {
IssueSingleInsertNofications(aStartChild, aEndChild, aInsertionKind);
return { };
}
@@ -6994,8 +6989,7 @@ nsCSSFrameConstructor::GetRangeInsertionPoint(nsIContent* aContainer,
// insertion point.
InsertionPoint ip = GetInsertionPoint(aStartChild);
if (ip.IsMultiple()) {
IssueSingleInsertNofications(
aContainer, aStartChild, aEndChild, aInsertionKind);
IssueSingleInsertNofications(aStartChild, aEndChild, aInsertionKind);
return { };
}
@@ -7073,8 +7067,7 @@ nsCSSFrameConstructor::StyleNewChildRange(nsIContent* aStartChild,
}
void
nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
nsIContent* aFirstNewContent,
nsCSSFrameConstructor::ContentAppended(nsIContent* aFirstNewContent,
InsertionKind aInsertionKind)
{
MOZ_ASSERT(aInsertionKind == InsertionKind::Sync ||
@@ -7086,15 +7079,14 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
if (gNoisyContentUpdates) {
printf("nsCSSFrameConstructor::ContentAppended container=%p "
"first-child=%p lazy=%d\n",
static_cast<void*>(aContainer), aFirstNewContent,
aFirstNewContent->GetParent(),
aFirstNewContent,
aInsertionKind == InsertionKind::Async);
if (gReallyNoisyContentUpdates && aContainer) {
aContainer->List(stdout, 0);
if (gReallyNoisyContentUpdates && aFirstNewContent->GetParent()) {
aFirstNewContent->GetParent()->List(stdout, 0);
}
}
#endif
#ifdef DEBUG
for (nsIContent* child = aFirstNewContent;
child;
child = child->GetNextSibling()) {
@@ -7108,7 +7100,7 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
LAYOUT_PHASE_TEMP_EXIT();
InsertionPoint insertion =
GetRangeInsertionPoint(aContainer, aFirstNewContent, nullptr, aInsertionKind);
GetRangeInsertionPoint(aFirstNewContent, nullptr, aInsertionKind);
nsContainerFrame*& parentFrame = insertion.mParentFrame;
LAYOUT_PHASE_TEMP_REENTER();
if (!parentFrame) {
@@ -7227,7 +7219,7 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
LayoutFrameType frameType = parentFrame->Type();
FlattenedChildIterator iter(aContainer);
FlattenedChildIterator iter(insertion.mContainer);
const bool haveNoXBLChildren = !iter.XBLInvolved() || !iter.GetNextChild();
AutoFrameConstructionItemList items(this);
@@ -7245,8 +7237,10 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
// (text in an XBL binding is not suppressed) or generated content
// (and bare text nodes are not generated). Native anonymous content
// generated by frames never participates in inline layout.
AddTextItemIfNeeded(state, insertion,
aFirstNewContent->GetPreviousSibling(), items);
AddTextItemIfNeeded(state,
insertion,
aFirstNewContent->GetPreviousSibling(),
items);
}
for (nsIContent* child = aFirstNewContent;
child;
@@ -7357,8 +7351,7 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
#ifdef ACCESSIBILITY
if (nsAccessibilityService* accService = nsIPresShell::AccService()) {
accService->ContentRangeInserted(mPresShell, aContainer,
aFirstNewContent, nullptr);
accService->ContentRangeInserted(mPresShell, aFirstNewContent, nullptr);
}
#endif
}
@@ -7373,23 +7366,21 @@ enum content_operation
// Helper function to lookup the listbox body frame and send a notification
// for insertion or removal of content
static
bool NotifyListBoxBody(nsPresContext* aPresContext,
nsIContent* aContainer,
nsIContent* aChild,
// Only used for the removed notification
nsIContent* aOldNextSibling,
nsIFrame* aChildFrame,
content_operation aOperation)
static bool
NotifyListBoxBody(nsPresContext* aPresContext,
nsIContent* aChild,
// Only used for the removed notification
nsIContent* aOldNextSibling,
nsIFrame* aChildFrame,
content_operation aOperation)
{
nsListBoxBodyFrame* listBoxBodyFrame =
MaybeGetListBoxBodyFrame(aContainer, aChild);
nsListBoxBodyFrame* listBoxBodyFrame = MaybeGetListBoxBodyFrame(aChild);
if (listBoxBodyFrame) {
if (aOperation == CONTENT_REMOVED) {
// Except if we have an aChildFrame and its parent is not the right
// thing, then we don't do this. Pseudo frames are so much fun....
if (!aChildFrame || aChildFrame->GetParent() == listBoxBodyFrame) {
listBoxBodyFrame->OnContentRemoved(aPresContext, aContainer,
listBoxBodyFrame->OnContentRemoved(aPresContext, aChild->GetParent(),
aChildFrame, aOldNextSibling);
return true;
}
@@ -7404,13 +7395,11 @@ bool NotifyListBoxBody(nsPresContext* aPresContext,
#endif // MOZ_XUL
void
nsCSSFrameConstructor::ContentInserted(nsIContent* aContainer,
nsIContent* aChild,
nsCSSFrameConstructor::ContentInserted(nsIContent* aChild,
nsILayoutHistoryState* aFrameState,
InsertionKind aInsertionKind)
{
ContentRangeInserted(aContainer,
aChild,
ContentRangeInserted(aChild,
aChild->GetNextSibling(),
aFrameState,
aInsertionKind);
@@ -7435,8 +7424,7 @@ nsCSSFrameConstructor::ContentInserted(nsIContent* aContainer,
// (because when we treat the caption frames the other nodes have had their
// frames constructed but not yet inserted into the frame tree).
void
nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
nsIContent* aStartChild,
nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aStartChild,
nsIContent* aEndChild,
nsILayoutHistoryState* aFrameState,
InsertionKind aInsertionKind)
@@ -7452,12 +7440,13 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
if (gNoisyContentUpdates) {
printf("nsCSSFrameConstructor::ContentRangeInserted container=%p "
"start-child=%p end-child=%p lazy=%d\n",
static_cast<void*>(aContainer),
static_cast<void*>(aStartChild), static_cast<void*>(aEndChild),
aStartChild->GetParent(),
aStartChild,
aEndChild,
aInsertionKind == InsertionKind::Async);
if (gReallyNoisyContentUpdates) {
if (aContainer) {
aContainer->List(stdout,0);
if (aStartChild->GetParent()) {
aStartChild->GetParent()->List(stdout,0);
} else {
aStartChild->List(stdout, 0);
}
@@ -7492,13 +7481,12 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
"range should not include all nodes after aStartChild");
#ifdef MOZ_XUL
if (aContainer && IsXULListBox(aContainer)) {
if (aStartChild->GetParent() && IsXULListBox(aStartChild->GetParent())) {
// For XUL list box, we need to style the new children eagerly.
styleNewChildRangeEagerly();
if (isSingleInsert) {
if (NotifyListBoxBody(mPresShell->GetPresContext(), aContainer,
// The insert case in NotifyListBoxBody
// doesn't use "old next sibling".
// The insert case in NotifyListBoxBody doesn't use "old next sibling".
if (NotifyListBoxBody(mPresShell->GetPresContext(),
aStartChild, nullptr, nullptr, CONTENT_INSERTED)) {
return;
}
@@ -7506,8 +7494,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
// We don't handle a range insert to a listbox parent, issue single
// ContertInserted calls for each node inserted.
LAYOUT_PHASE_TEMP_EXIT();
IssueSingleInsertNofications(
aContainer, aStartChild, aEndChild, InsertionKind::Sync);
IssueSingleInsertNofications(aStartChild, aEndChild, InsertionKind::Sync);
LAYOUT_PHASE_TEMP_REENTER();
return;
}
@@ -7517,9 +7504,9 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
// If we have a null parent, then this must be the document element being
// inserted, or some other child of the document in the DOM (might be a PI,
// say).
if (!aContainer) {
NS_ASSERTION(isSingleInsert,
"root node insertion should be a single insertion");
if (!aStartChild->GetParent()) {
MOZ_ASSERT(isSingleInsert,
"root node insertion should be a single insertion");
Element* docElement = mDocument->GetRootElement();
if (aStartChild != docElement) {
@@ -7527,7 +7514,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
return;
}
NS_PRECONDITION(!mRootElementFrame, "root element frame already created");
MOZ_ASSERT(!mRootElementFrame, "root element frame already created");
// Create frames for the document element and its child elements
if (ConstructDocElementFrame(docElement, aFrameState)) {
@@ -7550,8 +7537,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
#ifdef ACCESSIBILITY
if (nsAccessibilityService* accService = nsIPresShell::AccService()) {
accService->ContentRangeInserted(mPresShell, aContainer,
aStartChild, aEndChild);
accService->ContentRangeInserted(mPresShell, aStartChild, aEndChild);
}
#endif
@@ -7568,7 +7554,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
// Get our insertion point. If we need to issue single ContentInserteds
// GetRangeInsertionPoint will take care of that for us.
LAYOUT_PHASE_TEMP_EXIT();
insertion = GetRangeInsertionPoint(aContainer, aStartChild, aEndChild, aInsertionKind);
insertion = GetRangeInsertionPoint(aStartChild, aEndChild, aInsertionKind);
LAYOUT_PHASE_TEMP_REENTER();
}
@@ -7601,8 +7587,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
if (!isSingleInsert && !isRangeInsertSafe) {
// must fall back to a single ContertInserted for each child in the range
LAYOUT_PHASE_TEMP_EXIT();
IssueSingleInsertNofications(
aContainer, aStartChild, aEndChild, InsertionKind::Sync);
IssueSingleInsertNofications(aStartChild, aEndChild, InsertionKind::Sync);
LAYOUT_PHASE_TEMP_REENTER();
return;
}
@@ -7734,8 +7719,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
// must fall back to a single ContertInserted for each child in the range
LAYOUT_PHASE_TEMP_EXIT();
IssueSingleInsertNofications(
aContainer, aStartChild, aEndChild, InsertionKind::Sync);
IssueSingleInsertNofications(aStartChild, aEndChild, InsertionKind::Sync);
LAYOUT_PHASE_TEMP_REENTER();
return;
}
@@ -7746,7 +7730,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
AutoFrameConstructionItemList items(this);
ParentType parentType = GetParentType(frameType);
FlattenedChildIterator iter(aContainer);
FlattenedChildIterator iter(insertion.mContainer);
bool haveNoXBLChildren = (!iter.XBLInvolved() || !iter.GetNextChild());
if (aStartChild->GetPreviousSibling() &&
parentType == eTypeBlock && haveNoXBLChildren) {
@@ -7905,15 +7889,13 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
#ifdef ACCESSIBILITY
if (nsAccessibilityService* accService = nsIPresShell::AccService()) {
accService->ContentRangeInserted(mPresShell, aContainer,
aStartChild, aEndChild);
accService->ContentRangeInserted(mPresShell, aStartChild, aEndChild);
}
#endif
}
bool
nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
nsIContent* aChild,
nsCSSFrameConstructor::ContentRemoved(nsIContent* aChild,
nsIContent* aOldNextSibling,
RemoveFlags aFlags)
{
@@ -7932,7 +7914,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
// override element if the thing being removed is either the override element
// itself or the root element (which can be a parent of the override element).
if (aChild == presContext->GetViewportScrollbarStylesOverrideElement() ||
(!aContainer && aChild->IsElement())) {
(aChild->IsElement() && !aChild->GetParent())) {
// We might be removing the element that we propagated viewport scrollbar
// styles from. Recompute those. (This clause covers two of the three
// possible scrollbar-propagation sources: the <body> [as aChild or a
@@ -7945,11 +7927,10 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
Element* newOverrideElement =
presContext->UpdateViewportScrollbarStylesOverride();
// If aChild is the root (i.e. aContainer is null), then we don't
// need to do any reframing of newOverrideElement, because we're
// about to tear down the whole frame tree anyway. And we need to
// make sure we don't do any such reframing, because reframing the
// <body> can trigger a reframe of the <html> and then reenter
// If aChild is the root, then we don't need to do any reframing of
// newOverrideElement, because we're about to tear down the whole frame tree
// anyway. And we need to make sure we don't do any such reframing, because
// reframing the <body> can trigger a reframe of the <html> and then reenter
// here.
//
// But if aChild is not the root, and if newOverrideElement is not
@@ -7959,8 +7940,8 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
// (because its overflow was not "visible"), but now it will
// propagate its overflow to the viewport, so it should not need a
// scrollframe anymore.
if (aContainer && newOverrideElement && newOverrideElement->GetParent() &&
newOverrideElement != aChild) {
if (aChild->GetParent() && newOverrideElement &&
newOverrideElement->GetParent() && newOverrideElement != aChild) {
LAYOUT_PHASE_TEMP_EXIT();
RecreateFramesForContent(newOverrideElement, InsertionKind::Async);
LAYOUT_PHASE_TEMP_REENTER();
@@ -7971,11 +7952,11 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
if (gNoisyContentUpdates) {
printf("nsCSSFrameConstructor::ContentRemoved container=%p child=%p "
"old-next-sibling=%p\n",
static_cast<void*>(aContainer),
static_cast<void*>(aChild),
static_cast<void*>(aOldNextSibling));
aChild->GetParent(),
aChild,
aOldNextSibling);
if (gReallyNoisyContentUpdates) {
aContainer->List(stdout, 0);
aChild->GetParent()->List(stdout, 0);
}
}
#endif
@@ -7988,7 +7969,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
}
#ifdef MOZ_XUL
if (NotifyListBoxBody(presContext, aContainer, aChild, aOldNextSibling,
if (NotifyListBoxBody(presContext, aChild, aOldNextSibling,
childFrame, CONTENT_REMOVED)) {
return false;
}
@@ -7998,15 +7979,15 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
// the viewport's child instead of the primary frame (which might even be
// null if the root had an XBL binding or display:none, even though the
// frames above it got created). Detecting removal of a root is a little
// exciting; in particular, having a null aContainer is necessary but NOT
// sufficient. Due to how we process reframes, the content node might not
// even be in our document by now. So explicitly check whether the viewport's
// first kid's content node is aChild.
// exciting; in particular, having no parent is necessary but NOT sufficient.
// Due to how we process reframes, the content node might not even be in our
// document by now. So explicitly check whether the viewport's first kid's
// content node is aChild.
//
// FIXME(emilio): I think the "might not be in our document" bit is impossible
// now.
bool isRoot = false;
if (!aContainer) {
if (!aChild->GetParent()) {
if (nsIFrame* viewport = GetRootFrame()) {
nsIFrame* firstChild = viewport->PrincipalChildList().FirstChild();
if (firstChild && firstChild->GetContent() == aChild) {
@@ -8045,7 +8026,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
if (c->GetPrimaryFrame() || CouldHaveBeenDisplayContents(aChild)) {
LAYOUT_PHASE_TEMP_EXIT();
bool didReconstruct =
ContentRemoved(aChild, c, nullptr, REMOVE_FOR_RECONSTRUCTION);
ContentRemoved(c, nullptr, REMOVE_FOR_RECONSTRUCTION);
LAYOUT_PHASE_TEMP_REENTER();
if (didReconstruct) {
return true;
@@ -8202,8 +8183,10 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
// to do this if the table parent type of our parent type is not
// eTypeBlock, though, because in that case the whitespace isn't
// being suppressed due to us anyway.
if (aContainer && aOldNextSibling && aFlags == REMOVE_CONTENT &&
if (aOldNextSibling && aFlags == REMOVE_CONTENT &&
GetParentType(parentType) == eTypeBlock) {
MOZ_ASSERT(aChild->GetParent(),
"How did we have a sibling without a parent?");
// Adjacent whitespace-only text nodes might have been suppressed if
// this node does not have inline ends. Create frames for them now
// if necessary.
@@ -8220,7 +8203,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
nsIContent* prevSibling = aOldNextSibling->GetPreviousSibling();
if (prevSibling && prevSibling->GetPreviousSibling()) {
LAYOUT_PHASE_TEMP_EXIT();
ReframeTextIfNeeded(aContainer, prevSibling);
ReframeTextIfNeeded(prevSibling);
LAYOUT_PHASE_TEMP_REENTER();
}
// Reframe any text node just after the node being removed, if there is
@@ -8228,7 +8211,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
if (aOldNextSibling->GetNextSibling() &&
aOldNextSibling->GetPreviousSibling()) {
LAYOUT_PHASE_TEMP_EXIT();
ReframeTextIfNeeded(aContainer, aOldNextSibling);
ReframeTextIfNeeded(aOldNextSibling);
LAYOUT_PHASE_TEMP_REENTER();
}
}
@@ -9214,44 +9197,38 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIContent* aContent,
return;
}
nsINode* containerNode = aContent->GetParentNode();
// XXXbz how can containerNode be null here?
if (containerNode) {
// Before removing the frames associated with the content object,
// ask them to save their state onto a temporary state object.
CaptureStateForFramesOf(aContent, mTempFrameTreeState);
MOZ_ASSERT(aContent->GetParentNode());
// Need the nsIContent parent, which might be null here, since we need to
// pass it to ContentInserted and ContentRemoved.
nsIContent* container = aContent->GetParent();
// Before removing the frames associated with the content object,
// ask them to save their state onto a temporary state object.
CaptureStateForFramesOf(aContent, mTempFrameTreeState);
// Remove the frames associated with the content object.
nsIContent* nextSibling = aContent->IsRootOfAnonymousSubtree() ?
nullptr : aContent->GetNextSibling();
bool didReconstruct =
ContentRemoved(container, aContent, nextSibling,
REMOVE_FOR_RECONSTRUCTION);
// Remove the frames associated with the content object.
nsIContent* nextSibling = aContent->IsRootOfAnonymousSubtree() ?
nullptr : aContent->GetNextSibling();
bool didReconstruct =
ContentRemoved(aContent, nextSibling, REMOVE_FOR_RECONSTRUCTION);
if (!didReconstruct) {
if (aInsertionKind == InsertionKind::Async && aContent->IsElement()) {
// FIXME(emilio, bug 1397239): There's nothing removing the frame state
// for elements that go away before we come back to the frame
// constructor.
//
// Also, it'd be nice to just use the `ContentRangeInserted` path for
// both elements and non-elements, but we need to make lazy frame
// construction to apply to all elements first.
RestyleManager()->PostRestyleEvent(aContent->AsElement(),
nsRestyleHint(0),
nsChangeHint_ReconstructFrame);
} else {
// Now, recreate the frames associated with this content object. If
// ContentRemoved triggered reconstruction, then we don't need to do this
// because the frames will already have been built.
ContentRangeInserted(container, aContent, aContent->GetNextSibling(),
mTempFrameTreeState,
aInsertionKind);
}
if (!didReconstruct) {
if (aInsertionKind == InsertionKind::Async && aContent->IsElement()) {
// FIXME(emilio, bug 1397239): There's nothing removing the frame state
// for elements that go away before we come back to the frame
// constructor.
//
// Also, it'd be nice to just use the `ContentRangeInserted` path for
// both elements and non-elements, but we need to make lazy frame
// construction to apply to all elements first.
RestyleManager()->PostRestyleEvent(aContent->AsElement(),
nsRestyleHint(0),
nsChangeHint_ReconstructFrame);
} else {
// Now, recreate the frames associated with this content object. If
// ContentRemoved triggered reconstruction, then we don't need to do this
// because the frames will already have been built.
ContentRangeInserted(aContent,
aContent->GetNextSibling(),
mTempFrameTreeState,
aInsertionKind);
}
}
}
@@ -9265,8 +9242,7 @@ nsCSSFrameConstructor::DestroyFramesFor(Element* aElement)
aElement->IsRootOfAnonymousSubtree() ? nullptr : aElement->GetNextSibling();
CaptureStateForFramesOf(aElement, mTempFrameTreeState);
return ContentRemoved(aElement->GetParent(),
aElement,
return ContentRemoved(aElement,
nextSibling,
REMOVE_FOR_RECONSTRUCTION);
}
@@ -11218,8 +11194,9 @@ nsCSSFrameConstructor::CreateListBoxContent(nsContainerFrame* aParentFrame,
if (newFrame) {
nsAccessibilityService* accService = nsIPresShell::AccService();
if (accService) {
accService->ContentRangeInserted(mPresShell, aChild->GetParent(),
aChild, aChild->GetNextSibling());
accService->ContentRangeInserted(mPresShell,
aChild,
aChild->GetNextSibling());
}
}
#endif
@@ -11950,7 +11927,7 @@ nsCSSFrameConstructor::WipeContainingBlock(nsFrameConstructorState& aState,
#ifdef DEBUG
if (gNoisyContentUpdates) {
printf("nsCSSFrameConstructor::WipeContainingBlock: blockContent=%p\n",
static_cast<void*>(blockContent));
blockContent);
}
#endif
RecreateFramesForContent(blockContent, InsertionKind::Async);
@@ -11968,7 +11945,7 @@ nsCSSFrameConstructor::ReframeContainingBlock(nsIFrame* aFrame)
// very poorly
if (gNoisyContentUpdates) {
printf("nsCSSFrameConstructor::ReframeContainingBlock frame=%p\n",
static_cast<void*>(aFrame));
aFrame);
}
#endif
@@ -11997,7 +11974,7 @@ nsCSSFrameConstructor::ReframeContainingBlock(nsIFrame* aFrame)
if (nsIContent* blockContent = containingBlock->GetContent()) {
#ifdef DEBUG
if (gNoisyContentUpdates) {
printf(" ==> blockContent=%p\n", static_cast<void*>(blockContent));
printf(" ==> blockContent=%p\n", blockContent);
}
#endif
RecreateFramesForContent(blockContent->AsElement(), InsertionKind::Async);
@@ -12028,12 +12005,9 @@ nsCSSFrameConstructor::GenerateChildFrames(nsContainerFrame* aFrame)
}
#ifdef ACCESSIBILITY
nsAccessibilityService* accService = nsIPresShell::AccService();
if (accService) {
nsIContent* container = aFrame->GetContent();
nsIContent* child = container->GetFirstChild();
if (child) {
accService->ContentRangeInserted(mPresShell, container, child, nullptr);
if (nsAccessibilityService* accService = nsIPresShell::AccService()) {
if (nsIContent* child = aFrame->GetContent()->GetFirstChild()) {
accService->ContentRangeInserted(mPresShell, child, nullptr);
}
}
#endif