Bug 1083855 - part 2, Add a REMOVE_DESTROY_FRAMES value to RemoveFlags. Make RecreateFramesForContent skip recreating the frames when aFlags has that value. r=bz

This commit is contained in:
Mats Palmgren 2014-10-23 13:19:25 +00:00
parent 250b34decf
commit 565da376d4
2 changed files with 38 additions and 10 deletions

View File

@ -7715,8 +7715,12 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
#ifdef MOZ_XUL
if (NotifyListBoxBody(presContext, aContainer, aChild, aOldNextSibling,
mDocument, childFrame, CONTENT_REMOVED))
mDocument, childFrame, CONTENT_REMOVED)) {
if (aFlags == REMOVE_DESTROY_FRAMES) {
CaptureStateForFramesOf(aChild, mTempFrameTreeState);
}
return NS_OK;
}
#endif // MOZ_XUL
@ -7759,6 +7763,10 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
return rv;
}
if (aFlags == REMOVE_DESTROY_FRAMES) {
CaptureStateForFramesOf(aChild, mTempFrameTreeState);
}
if (childFrame) {
InvalidateCanvasIfNeeded(mPresShell, aChild);
@ -7916,7 +7924,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
// eTypeBlock, though, because in that case the whitespace isn't
// being suppressed due to us anyway.
if (aContainer && !aChild->IsRootOfAnonymousSubtree() &&
aFlags != REMOVE_FOR_RECONSTRUCTION &&
aFlags == REMOVE_CONTENT &&
GetParentType(parentType) == eTypeBlock) {
// Adjacent whitespace-only text nodes might have been suppressed if
// this node does not have inline ends. Create frames for them now
@ -8999,13 +9007,16 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIContent* aContent,
// Remove the frames associated with the content object.
bool didReconstruct;
rv = ContentRemoved(container, aContent,
aContent->IsRootOfAnonymousSubtree() ?
nullptr :
aContent->GetNextSibling(),
REMOVE_FOR_RECONSTRUCTION, &didReconstruct,
aDestroyedFramesFor);
if (NS_SUCCEEDED(rv) && !didReconstruct) {
nsIContent* nextSibling = aContent->IsRootOfAnonymousSubtree() ?
nullptr : aContent->GetNextSibling();
const bool reconstruct = aFlags != REMOVE_DESTROY_FRAMES;
RemoveFlags flags = reconstruct ? REMOVE_FOR_RECONSTRUCTION : aFlags;
rv = ContentRemoved(container, aContent, nextSibling, flags,
&didReconstruct, aDestroyedFramesFor);
if (NS_FAILED(rv)) {
return rv;
}
if (reconstruct && !didReconstruct) {
// 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.

View File

@ -193,7 +193,24 @@ public:
nsILayoutHistoryState* aFrameState,
bool aAllowLazyConstruction);
enum RemoveFlags { REMOVE_CONTENT, REMOVE_FOR_RECONSTRUCTION };
enum RemoveFlags {
REMOVE_CONTENT, REMOVE_FOR_RECONSTRUCTION, REMOVE_DESTROY_FRAMES };
/**
* Recreate or destroy frames for aChild in aContainer.
* aFlags == REMOVE_CONTENT means aChild has been removed from the document.
* aFlags == REMOVE_FOR_RECONSTRUCTION means the caller will reconstruct the
* frames later.
* In both the above cases, this method will in some cases try to reconstruct
* the frames (aDidReconstruct is then set to true), it's just that in the
* former case aChild isn't in the document so no frames will be created for
* it. Ancestors may have been reframed though.
* aFlags == REMOVE_DESTROY_FRAMES is the same as REMOVE_FOR_RECONSTRUCTION
* except it will never try to reconstruct frames. Instead, the caller is
* responsible for doing that, on the content returned in aDestroyedFramesFor.
* The layout frame state is guarranted to be captured for the removed frames
* only when aFlags == REMOVE_DESTROY_FRAMES, otherwise it will only be
* captured if we reconstructed frames for an ancestor.
*/
nsresult ContentRemoved(nsIContent* aContainer,
nsIContent* aChild,
nsIContent* aOldNextSibling,