Bug 846888. Part 1. Update the in popup frame state bits when we swap docshells. r=mattwoodrow

This commit is contained in:
Timothy Nikkel 2013-03-04 13:49:39 -06:00
parent 9229fd1990
commit 3184db306f
3 changed files with 28 additions and 21 deletions

View File

@ -8090,12 +8090,8 @@ nsFrame::BoxMetrics() const
return metrics;
}
/**
* Adds the NS_FRAME_IN_POPUP state bit to the current frame,
* and all descendant frames (including cross-doc ones).
*/
static void
AddInPopupStateBitToDescendants(nsIFrame* aFrame)
/* static */ void
nsIFrame::AddInPopupStateBitToDescendants(nsIFrame* aFrame)
{
aFrame->AddStateBits(NS_FRAME_IN_POPUP);
@ -8111,13 +8107,8 @@ AddInPopupStateBitToDescendants(nsIFrame* aFrame)
}
}
/**
* Removes the NS_FRAME_IN_POPUP state bit from the current
* frames and all descendant frames (including cross-doc ones),
* unless the frame is a popup itself.
*/
static void
RemoveInPopupStateBitFromDescendants(nsIFrame* aFrame)
/* static */ void
nsIFrame::RemoveInPopupStateBitFromDescendants(nsIFrame* aFrame)
{
if (!aFrame->HasAnyStateBits(NS_FRAME_IN_POPUP) ||
aFrame->GetType() == nsGkAtoms::listControlFrame ||

View File

@ -2955,6 +2955,18 @@ NS_PTR_TO_INT32(frame->Properties().Get(nsIFrame::ParagraphDepthProperty()))
void CreateOwnLayerIfNeeded(nsDisplayListBuilder* aBuilder, nsDisplayList* aList);
/**
* Adds the NS_FRAME_IN_POPUP state bit to aFrame, and
* all descendant frames (including cross-doc ones).
*/
static void AddInPopupStateBitToDescendants(nsIFrame* aFrame);
/**
* Removes the NS_FRAME_IN_POPUP state bit from aFrame and
* all descendant frames (including cross-doc ones), unless
* the frame is a popup itself.
*/
static void RemoveInPopupStateBitFromDescendants(nsIFrame* aFrame);
protected:
// Members
nsRect mRect;

View File

@ -1013,9 +1013,6 @@ nsSubDocumentFrame::BeginSwapDocShells(nsIFrame* aOther)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_ASSERTION(HasAnyStateBits(NS_FRAME_IN_POPUP) == other->HasAnyStateBits(NS_FRAME_IN_POPUP),
"Can't swap doc shells when only one is within a popup!");
if (mInnerView && other->mInnerView) {
nsView* ourSubdocViews = mInnerView->GetFirstChild();
nsView* ourRemovedViews = ::BeginSwapDocShellsForViews(ourSubdocViews);
@ -1071,14 +1068,21 @@ EndSwapDocShellsForViews(nsView* aSibling)
::EndSwapDocShellsForDocument(doc, nullptr);
}
nsIFrame *frame = aSibling->GetFrame();
if (frame && frame->HasInvalidFrameInSubtree()) {
nsIFrame *parent = nsLayoutUtils::GetCrossDocParentFrame(frame);
if (frame) {
nsIFrame* parent = nsLayoutUtils::GetCrossDocParentFrame(frame);
if (parent->HasAnyStateBits(NS_FRAME_IN_POPUP)) {
nsIFrame::AddInPopupStateBitToDescendants(frame);
} else {
nsIFrame::RemoveInPopupStateBitFromDescendants(frame);
}
if (frame->HasInvalidFrameInSubtree()) {
while (parent && !parent->HasAnyStateBits(NS_FRAME_DESCENDANT_NEEDS_PAINT)) {
parent->AddStateBits(NS_FRAME_DESCENDANT_NEEDS_PAINT);
parent = nsLayoutUtils::GetCrossDocParentFrame(parent);
}
}
}
}
}
void