When re-resolving style, re-resolve root in undisplayed map too. (Bug 473042) r+sr=bzbarsky

This commit is contained in:
L. David Baron 2009-01-16 13:32:09 -08:00
parent 4169a80855
commit 5293f77173
3 changed files with 42 additions and 4 deletions

View File

@ -4079,13 +4079,17 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsFrameConstructorState& aState,
// XXX this seems truly bogus, we wipe out mGfxScrollFrame below
if (mGfxScrollFrame) {
nsIFrame* gfxScrollbarFrame1 = mGfxScrollFrame->GetFirstChild(nsnull);
if (gfxScrollbarFrame1) {
// Check the frame type because when there aren't scrollbars, we'll
// get the canvas.
if (gfxScrollbarFrame1 &&
gfxScrollbarFrame1->GetType() == nsGkAtoms::scrollbarFrame) {
// XXX This works, but why?
aState.mFrameManager->
SetPrimaryFrameFor(gfxScrollbarFrame1->GetContent(), gfxScrollbarFrame1);
nsIFrame* gfxScrollbarFrame2 = gfxScrollbarFrame1->GetNextSibling();
if (gfxScrollbarFrame2) {
if (gfxScrollbarFrame2 &&
gfxScrollbarFrame2->GetType() == nsGkAtoms::scrollbarFrame) {
// XXX This works, but why?
aState.mFrameManager->
SetPrimaryFrameFor(gfxScrollbarFrame2->GetContent(), gfxScrollbarFrame2);
@ -7460,6 +7464,8 @@ nsCSSFrameConstructor::ReconstructDocElementHierarchyInternal()
// Destroy out-of-flow frames that might not be in the frame subtree
// rooted at docElementFrame
::DeletingFrameSubtree(state.mFrameManager, docElementFrame);
} else {
state.mFrameManager->ClearUndisplayedContentIn(rootContent, nsnull);
}
// Remove any existing fixed items: they are always on the

View File

@ -271,6 +271,10 @@ public:
nsIFrame* GetRootElementStyleFrame() { return mRootElementStyleFrame; }
nsIFrame* GetPageSequenceFrame() { return mPageSequenceFrame; }
// Get the frame that is the parent of the root element.
nsIFrame* GetDocElementContainingBlock()
{ return mDocElementContainingBlock; }
private:
nsresult ReconstructDocElementHierarchyInternal();

View File

@ -415,6 +415,16 @@ nsFrameManager::SetPrimaryFrameFor(nsIContent* aContent,
NS_ENSURE_ARG_POINTER(aContent);
NS_ASSERTION(aPrimaryFrame && aPrimaryFrame->GetParent(),
"BOGUS!");
#ifdef DEBUG
{
nsIFrame *docElementCB =
mPresShell->FrameConstructor()->GetDocElementContainingBlock();
NS_ASSERTION(aPrimaryFrame != docElementCB &&
!nsLayoutUtils::IsProperAncestorFrame(aPrimaryFrame,
docElementCB),
"too high in the frame tree to be a primary frame");
}
#endif
// This code should be used if/when we switch back to a 2-word entry
// in the primary frame map.
@ -1312,10 +1322,28 @@ nsFrameManager::ReResolveStyleContext(nsPresContext *aPresContext,
}
// now look for undisplayed child content and pseudos
if (!pseudoTag && localContent && mUndisplayedMap) {
// When the root element is display:none, we still construct *some*
// frames that have the root element as their mContent, down to the
// DocElementContainingBlock.
PRBool checkUndisplayed;
nsIContent *undisplayedParent;
if (pseudoTag) {
checkUndisplayed = aFrame == mPresShell->FrameConstructor()->
GetDocElementContainingBlock();
undisplayedParent = nsnull;
} else {
checkUndisplayed = !!localContent;
undisplayedParent = localContent;
}
if (checkUndisplayed && mUndisplayedMap) {
for (UndisplayedNode* undisplayed =
mUndisplayedMap->GetFirstNode(localContent);
mUndisplayedMap->GetFirstNode(undisplayedParent);
undisplayed; undisplayed = undisplayed->mNext) {
NS_ASSERTION(undisplayedParent ||
undisplayed->mContent ==
mPresShell->GetDocument()->GetRootContent(),
"undisplayed node child of null must be root");
nsRefPtr<nsStyleContext> undisplayedContext;
nsIAtom* const undisplayedPseudoTag = undisplayed->mStyle->GetPseudoType();
if (!undisplayedPseudoTag) { // child content