Slightly improve handling of positioned kids of MathML. Bug 322625, r=rbs, sr=roc

This commit is contained in:
bzbarsky%mit.edu 2006-10-08 22:04:09 +00:00
parent 7f145058c1
commit 493b90fbf3
3 changed files with 31 additions and 9 deletions

View File

@ -1222,6 +1222,10 @@ static nsIFrame*
AdjustAbsoluteContainingBlock(nsPresContext* aPresContext, AdjustAbsoluteContainingBlock(nsPresContext* aPresContext,
nsIFrame* aContainingBlockIn) nsIFrame* aContainingBlockIn)
{ {
if (!aContainingBlockIn) {
return nsnull;
}
// Always use the container's first in flow. // Always use the container's first in flow.
return aContainingBlockIn->GetFirstInFlow(); return aContainingBlockIn->GetFirstInFlow();
} }
@ -7223,8 +7227,13 @@ nsCSSFrameConstructor::ConstructMathMLFrame(nsFrameConstructorState& aState,
} }
// Push a null float containing block to disable floating within mathml // Push a null float containing block to disable floating within mathml
nsFrameConstructorSaveState saveState; nsFrameConstructorSaveState floatSaveState;
aState.PushFloatContainingBlock(nsnull, saveState, PR_FALSE, PR_FALSE); 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 // MathML frames are inline frames, so just process their kids
nsFrameItems childItems; nsFrameItems childItems;
@ -8037,6 +8046,14 @@ nsCSSFrameConstructor::GetAbsoluteContainingBlock(nsIFrame* aFrame)
nsIFrame* containingBlock = nsnull; nsIFrame* containingBlock = nsnull;
for (nsIFrame* frame = aFrame; frame && !containingBlock; for (nsIFrame* frame = aFrame; frame && !containingBlock;
frame = frame->GetParent()) { 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? // Is it positioned?
// If it's table-related then ignore it, because for the time // If it's table-related then ignore it, because for the time
// being table-related frames are not containers for absolutely // being table-related frames are not containers for absolutely
@ -8081,7 +8098,9 @@ nsCSSFrameConstructor::GetFloatContainingBlock(nsIFrame* aFrame)
{ {
NS_PRECONDITION(mInitialContainingBlock, "no initial containing block"); 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; for (nsIFrame* containingBlock = aFrame;
containingBlock && !containingBlock->IsFrameOfType(nsIFrame::eMathML); containingBlock && !containingBlock->IsFrameOfType(nsIFrame::eMathML);
containingBlock = containingBlock->GetParent()) { containingBlock = containingBlock->GetParent()) {
@ -12562,7 +12581,7 @@ nsCSSFrameConstructor::ConstructBlock(nsFrameConstructorState& aState,
// children. So use the block and try to compensate with hacks // children. So use the block and try to compensate with hacks
// in nsBlockFrame::CalculateContainingBlockSizeForAbsolutes. // in nsBlockFrame::CalculateContainingBlockSizeForAbsolutes.
nsFrameConstructorSaveState absoluteSaveState; nsFrameConstructorSaveState absoluteSaveState;
if (aAbsPosContainer || !aState.mAbsoluteItems.containingBlock) { if (aAbsPosContainer) {
// NS_ASSERTION(aRelPos, "should have made area frame for this"); // NS_ASSERTION(aRelPos, "should have made area frame for this");
aState.PushAbsoluteContainingBlock(blockFrame, absoluteSaveState); aState.PushAbsoluteContainingBlock(blockFrame, absoluteSaveState);
} }

View File

@ -378,6 +378,10 @@ public:
return rv; return rv;
} }
virtual PRBool IsFrameOfType(PRUint32 aFlags) const {
return !(aFlags & ~nsIFrame::eMathML);
}
protected: protected:
nsMathMLmathBlockFrame(nsStyleContext* aContext) : nsBlockFrame(aContext) { nsMathMLmathBlockFrame(nsStyleContext* aContext) : nsBlockFrame(aContext) {
// We should always have a space manager. Not that things can really try // We should always have a space manager. Not that things can really try
@ -457,6 +461,10 @@ public:
return rv; return rv;
} }
virtual PRBool IsFrameOfType(PRUint32 aFlags) const {
return !(aFlags & ~nsIFrame::eMathML);
}
protected: protected:
nsMathMLmathInlineFrame(nsStyleContext* aContext) : nsInlineFrame(aContext) {} nsMathMLmathInlineFrame(nsStyleContext* aContext) : nsInlineFrame(aContext) {}
virtual ~nsMathMLmathInlineFrame() {} virtual ~nsMathMLmathInlineFrame() {}

View File

@ -42,11 +42,6 @@
@namespace url(http://www.w3.org/1998/Math/MathML); @namespace url(http://www.w3.org/1998/Math/MathML);
/* MathML doesn't permit positioning */
*, * > *|* {
position: static !important;
}
/**************************************************************************/ /**************************************************************************/
/* <math> - outermost math element */ /* <math> - outermost math element */
/**************************************************************************/ /**************************************************************************/