From 493b90fbf3e87674d0f63d6a7207f26d0e80ad1c Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Sun, 8 Oct 2006 22:04:09 +0000 Subject: [PATCH] Slightly improve handling of positioned kids of MathML. Bug 322625, r=rbs, sr=roc --- layout/base/nsCSSFrameConstructor.cpp | 27 ++++++++++++++++--- .../mathml/base/src/nsMathMLContainerFrame.h | 8 ++++++ layout/mathml/content/src/mathml.css | 5 ---- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 55df5b6c2be4..d0dabaecf687 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -1222,6 +1222,10 @@ static nsIFrame* AdjustAbsoluteContainingBlock(nsPresContext* aPresContext, nsIFrame* aContainingBlockIn) { + if (!aContainingBlockIn) { + return nsnull; + } + // Always use the container's first in flow. return aContainingBlockIn->GetFirstInFlow(); } @@ -7223,8 +7227,13 @@ nsCSSFrameConstructor::ConstructMathMLFrame(nsFrameConstructorState& aState, } // Push a null float containing block to disable floating within mathml - nsFrameConstructorSaveState saveState; - aState.PushFloatContainingBlock(nsnull, saveState, PR_FALSE, PR_FALSE); + nsFrameConstructorSaveState floatSaveState; + aState.PushFloatContainingBlock(nsnull, floatSaveState, PR_FALSE, + PR_FALSE); + + // Same for absolute positioning + nsFrameConstructorSaveState absoluteSaveState; + aState.PushAbsoluteContainingBlock(nsnull, absoluteSaveState); // MathML frames are inline frames, so just process their kids nsFrameItems childItems; @@ -8037,6 +8046,14 @@ nsCSSFrameConstructor::GetAbsoluteContainingBlock(nsIFrame* aFrame) nsIFrame* containingBlock = nsnull; for (nsIFrame* frame = aFrame; frame && !containingBlock; frame = frame->GetParent()) { + if (frame->IsFrameOfType(nsIFrame::eMathML)) { + // If it's mathml, bail out -- no absolute positioning out from inside + // mathml frames. Note that we don't make this part of the loop + // condition because of the mInitialContainingBlock stuff at the + // end of this method... + return nsnull; + } + // Is it positioned? // If it's table-related then ignore it, because for the time // being table-related frames are not containers for absolutely @@ -8081,7 +8098,9 @@ nsCSSFrameConstructor::GetFloatContainingBlock(nsIFrame* aFrame) { NS_PRECONDITION(mInitialContainingBlock, "no initial containing block"); - // Starting with aFrame, look for a frame that is a float containing block + // Starting with aFrame, look for a frame that is a float containing block. + // IF we hit a mathml frame, bail out; we don't allow floating out of mathml + // frames, because they don't seem to be able to deal. for (nsIFrame* containingBlock = aFrame; containingBlock && !containingBlock->IsFrameOfType(nsIFrame::eMathML); containingBlock = containingBlock->GetParent()) { @@ -12562,7 +12581,7 @@ nsCSSFrameConstructor::ConstructBlock(nsFrameConstructorState& aState, // children. So use the block and try to compensate with hacks // in nsBlockFrame::CalculateContainingBlockSizeForAbsolutes. nsFrameConstructorSaveState absoluteSaveState; - if (aAbsPosContainer || !aState.mAbsoluteItems.containingBlock) { + if (aAbsPosContainer) { // NS_ASSERTION(aRelPos, "should have made area frame for this"); aState.PushAbsoluteContainingBlock(blockFrame, absoluteSaveState); } diff --git a/layout/mathml/base/src/nsMathMLContainerFrame.h b/layout/mathml/base/src/nsMathMLContainerFrame.h index 2d2605e6180d..419b57cda169 100644 --- a/layout/mathml/base/src/nsMathMLContainerFrame.h +++ b/layout/mathml/base/src/nsMathMLContainerFrame.h @@ -378,6 +378,10 @@ public: return rv; } + virtual PRBool IsFrameOfType(PRUint32 aFlags) const { + return !(aFlags & ~nsIFrame::eMathML); + } + protected: nsMathMLmathBlockFrame(nsStyleContext* aContext) : nsBlockFrame(aContext) { // We should always have a space manager. Not that things can really try @@ -457,6 +461,10 @@ public: return rv; } + virtual PRBool IsFrameOfType(PRUint32 aFlags) const { + return !(aFlags & ~nsIFrame::eMathML); + } + protected: nsMathMLmathInlineFrame(nsStyleContext* aContext) : nsInlineFrame(aContext) {} virtual ~nsMathMLmathInlineFrame() {} diff --git a/layout/mathml/content/src/mathml.css b/layout/mathml/content/src/mathml.css index 06d62e7584a3..8547d1d8b215 100644 --- a/layout/mathml/content/src/mathml.css +++ b/layout/mathml/content/src/mathml.css @@ -42,11 +42,6 @@ @namespace url(http://www.w3.org/1998/Math/MathML); -/* MathML doesn't permit positioning */ -*, * > *|* { - position: static !important; -} - /**************************************************************************/ /* - outermost math element */ /**************************************************************************/