diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index f594dc822f7..0badf8bd81f 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -3219,14 +3219,15 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, nsFrameConstructorSaveState floaterSaveState; nsFrameItems childItems; - // XXX these next lines are wrong for BoxFrame - PRBool haveFirstLetterStyle, haveFirstLineStyle; - HaveSpecialBlockStyle(aPresContext, aDocElement, styleContext, - &haveFirstLetterStyle, &haveFirstLineStyle); - aState.PushAbsoluteContainingBlock(contentFrame, absoluteSaveState); - aState.PushFloaterContainingBlock(contentFrame, floaterSaveState, - haveFirstLetterStyle, - haveFirstLineStyle); + if (isBlockFrame) { + PRBool haveFirstLetterStyle, haveFirstLineStyle; + HaveSpecialBlockStyle(aPresContext, aDocElement, styleContext, + &haveFirstLetterStyle, &haveFirstLineStyle); + aState.PushAbsoluteContainingBlock(contentFrame, absoluteSaveState); + aState.PushFloaterContainingBlock(contentFrame, floaterSaveState, + haveFirstLetterStyle, + haveFirstLineStyle); + } // Create any anonymous frames the doc element frame requires // This must happen before ProcessChildren to ensure that popups are @@ -13154,6 +13155,21 @@ nsCSSFrameConstructor::ConstructBlock(nsIPresShell* aPresShell, nsHTMLContainerFrame::CreateViewForFrame(aPresContext, aNewFrame, aStyleContext, nsnull, PR_FALSE); + // If we're the first block to be created (e.g., because we're + // contained inside a XUL document), then make sure that we've got a + // space manager so we can handle floaters... + if (! aState.mFloatedItems.containingBlock) { + nsFrameState state; + aNewFrame->GetFrameState(&state); + state |= NS_BLOCK_SPACE_MGR | NS_BLOCK_MARGIN_ROOT; + aNewFrame->SetFrameState(state); + } + + // ...and that we're the absolute containing block. + nsFrameConstructorSaveState absoluteSaveState; + if (! aState.mAbsoluteItems.containingBlock) + aState.PushAbsoluteContainingBlock(aNewFrame, absoluteSaveState); + // See if the block has first-letter style applied to it... PRBool haveFirstLetterStyle, haveFirstLineStyle; HaveSpecialBlockStyle(aPresContext, aContent, aStyleContext, diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index f594dc822f7..0badf8bd81f 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -3219,14 +3219,15 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, nsFrameConstructorSaveState floaterSaveState; nsFrameItems childItems; - // XXX these next lines are wrong for BoxFrame - PRBool haveFirstLetterStyle, haveFirstLineStyle; - HaveSpecialBlockStyle(aPresContext, aDocElement, styleContext, - &haveFirstLetterStyle, &haveFirstLineStyle); - aState.PushAbsoluteContainingBlock(contentFrame, absoluteSaveState); - aState.PushFloaterContainingBlock(contentFrame, floaterSaveState, - haveFirstLetterStyle, - haveFirstLineStyle); + if (isBlockFrame) { + PRBool haveFirstLetterStyle, haveFirstLineStyle; + HaveSpecialBlockStyle(aPresContext, aDocElement, styleContext, + &haveFirstLetterStyle, &haveFirstLineStyle); + aState.PushAbsoluteContainingBlock(contentFrame, absoluteSaveState); + aState.PushFloaterContainingBlock(contentFrame, floaterSaveState, + haveFirstLetterStyle, + haveFirstLineStyle); + } // Create any anonymous frames the doc element frame requires // This must happen before ProcessChildren to ensure that popups are @@ -13154,6 +13155,21 @@ nsCSSFrameConstructor::ConstructBlock(nsIPresShell* aPresShell, nsHTMLContainerFrame::CreateViewForFrame(aPresContext, aNewFrame, aStyleContext, nsnull, PR_FALSE); + // If we're the first block to be created (e.g., because we're + // contained inside a XUL document), then make sure that we've got a + // space manager so we can handle floaters... + if (! aState.mFloatedItems.containingBlock) { + nsFrameState state; + aNewFrame->GetFrameState(&state); + state |= NS_BLOCK_SPACE_MGR | NS_BLOCK_MARGIN_ROOT; + aNewFrame->SetFrameState(state); + } + + // ...and that we're the absolute containing block. + nsFrameConstructorSaveState absoluteSaveState; + if (! aState.mAbsoluteItems.containingBlock) + aState.PushAbsoluteContainingBlock(aNewFrame, absoluteSaveState); + // See if the block has first-letter style applied to it... PRBool haveFirstLetterStyle, haveFirstLineStyle; HaveSpecialBlockStyle(aPresContext, aContent, aStyleContext,