Wrap table in a protective block frame when used in the mathml context. b=78389 r=waterson

This commit is contained in:
rbs%maths.uq.edu.au 2001-05-19 10:02:11 +00:00
Родитель 49f75d792f
Коммит 7e18623010
2 изменённых файлов: 114 добавлений и 68 удалений

Просмотреть файл

@ -803,8 +803,8 @@ nsMathMLmtableCreator::CreateTableOuterFrame(nsIFrame** aNewFrame)
nsresult nsresult
nsMathMLmtableCreator::CreateTableCellInnerFrame(nsIFrame** aNewFrame) nsMathMLmtableCreator::CreateTableCellInnerFrame(nsIFrame** aNewFrame)
{ {
// only works if aNewFrame is an AreaFrame (to take care of the lineLayout logic) // only works if aNewFrame can take care of the lineLayout logic
return NS_NewMathMLmtdFrame(mPresShell, aNewFrame); return NS_NewMathMLmtdInnerFrame(mPresShell, aNewFrame);
} }
#endif // MOZ_MATHML #endif // MOZ_MATHML
@ -1701,9 +1701,11 @@ nsCSSFrameConstructor::CreateInputFrame(nsIPresShell *aPresShell,
PRBool IsOnlyWhiteSpace(nsIContent* aContent) PRBool IsOnlyWhiteSpace(nsIContent* aContent)
{ {
PRBool onlyWhiteSpace = PR_FALSE; PRBool onlyWhiteSpace = PR_FALSE;
nsCOMPtr<nsITextContent> textContent = do_QueryInterface(aContent); if (aContent->IsContentOfType(nsIContent::eTEXT)) {
if (textContent) { nsCOMPtr<nsITextContent> textContent = do_QueryInterface(aContent);
textContent->IsOnlyWhitespace(&onlyWhiteSpace); if (textContent) {
textContent->IsOnlyWhitespace(&onlyWhiteSpace);
}
} }
return onlyWhiteSpace; return onlyWhiteSpace;
} }
@ -6879,7 +6881,6 @@ nsCSSFrameConstructor::ConstructMathMLFrame(nsIPresShell* aPresShell,
// Initialize the new frame // Initialize the new frame
nsIFrame* newFrame = nsnull; nsIFrame* newFrame = nsnull;
nsMathMLmtableCreator mathTableCreator(aPresShell); // Used to make table views.
// See if the element is absolute or fixed positioned // See if the element is absolute or fixed positioned
const nsStylePosition* position = (const nsStylePosition*) const nsStylePosition* position = (const nsStylePosition*)
@ -6939,44 +6940,66 @@ nsCSSFrameConstructor::ConstructMathMLFrame(nsIPresShell* aPresShell,
rv = NS_NewMathMLmrowFrame(aPresShell, &newFrame); rv = NS_NewMathMLmrowFrame(aPresShell, &newFrame);
// CONSTRUCTION of MTABLE elements // CONSTRUCTION of MTABLE elements
else if (aTag == nsMathMLAtoms::mtable_) { else if (aTag == nsMathMLAtoms::mtable_) {
// <mtable> is an inline-table, for the moment, we just do what // <mtable> is an inline-table -- but this isn't yet supported.
// <table> does, and wait until nsLineLayout::TreatFrameAsBlock // What we do here is to wrap the table in an anonymous containing
// can handle NS_STYLE_DISPLAY_INLINE_TABLE. // block so that it can mix better with other surrounding MathML markups
nsIFrame* geometricParent = aParentFrame;
if (isAbsolutelyPositioned) { nsCOMPtr<nsIStyleContext> parentContext;
aParentFrame = aState.mAbsoluteItems.containingBlock; aParentFrame->GetStyleContext(getter_AddRefs(parentContext));
}
else if (isFixedPositioned) { // first, create a MathML mrow frame that will wrap the block frame
aParentFrame = aState.mFixedItems.containingBlock; rv = NS_NewMathMLmrowFrame(aPresShell, &newFrame);
} if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIStyleContext> mrowContext;
aPresContext->ResolvePseudoStyleContextFor(aContent,
nsMathMLAtoms::mozMathInline,
parentContext, PR_FALSE,
getter_AddRefs(mrowContext));
InitAndRestoreFrame(aPresContext, aState, aContent, aParentFrame,
mrowContext, nsnull, newFrame);
// add it to the flow
aFrameItems.AddChild(newFrame);
// then, create a block frame that will wrap the table frame
nsIFrame* blockFrame;
rv = NS_NewBlockFrame(aPresShell, &blockFrame);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIStyleContext> blockContext;
aPresContext->ResolvePseudoStyleContextFor(aContent,
nsHTMLAtoms::mozAnonymousBlock,
mrowContext, PR_FALSE,
getter_AddRefs(blockContext));
InitAndRestoreFrame(aPresContext, aState, aContent, newFrame,
blockContext, nsnull, blockFrame);
// set the block frame as the initial child of the mrow frame
newFrame->SetInitialChildList(aPresContext, nsnull, blockFrame);
// then, create the table frame itself
nsCOMPtr<nsIStyleContext> tableContext;
aPresContext->ResolvePseudoStyleContextFor(aContent,
nsMathMLAtoms::mozMathTable,
blockContext, PR_FALSE,
getter_AddRefs(tableContext));
nsFrameItems tempItems;
nsIFrame* outerTable;
nsIFrame* innerTable; nsIFrame* innerTable;
PRBool pseudoParent; PRBool pseudoParent;
nsMathMLmtableCreator mathTableCreator(aPresShell);
rv = ConstructTableFrame(aPresShell, aPresContext, aState, aContent, rv = ConstructTableFrame(aPresShell, aPresContext, aState, aContent,
geometricParent, aStyleContext, mathTableCreator, blockFrame, tableContext, mathTableCreator,
PR_FALSE, aFrameItems, newFrame, innerTable, pseudoParent); PR_FALSE, tempItems, outerTable, innerTable, pseudoParent);
// Note: table construction function takes care of initializing the frame, // Note: table construction function takes care of initializing the frame,
// processing children, and setting the initial child list // processing children, and setting the initial child list
if (isAbsolutelyPositioned || isFixedPositioned) {
nsIFrame* placeholderFrame; // set the outerTable as the initial child of the anonymous block
CreatePlaceholderFrameFor(aPresShell, aPresContext, aState.mFrameManager, aContent, newFrame, blockFrame->SetInitialChildList(aPresContext, nsnull, outerTable);
aStyleContext, aParentFrame, &placeholderFrame);
// Add the positioned frame to its containing block's list of child frames
if (isAbsolutelyPositioned) {
aState.mAbsoluteItems.AddChild(newFrame);
} else {
aState.mFixedItems.AddChild(newFrame);
}
// Add the placeholder frame to the flow
aFrameItems.AddChild(placeholderFrame);
} else if (!pseudoParent) {
// Add the table frame to the flow
aFrameItems.AddChild(newFrame);
}
return rv; return rv;
} }
else if (aTag == nsMathMLAtoms::mtd_) { else if (aTag == nsMathMLAtoms::mtd_) {
nsIFrame* innerCell; nsIFrame* innerCell;
PRBool pseudoParent; PRBool pseudoParent;
nsMathMLmtableCreator mathTableCreator(aPresShell);
rv = ConstructTableCellFrame(aPresShell, aPresContext, aState, aContent, rv = ConstructTableCellFrame(aPresShell, aPresContext, aState, aContent,
aParentFrame, aStyleContext, mathTableCreator, aParentFrame, aStyleContext, mathTableCreator,
PR_FALSE, aFrameItems, newFrame, innerCell, pseudoParent); PR_FALSE, aFrameItems, newFrame, innerCell, pseudoParent);

Просмотреть файл

@ -803,8 +803,8 @@ nsMathMLmtableCreator::CreateTableOuterFrame(nsIFrame** aNewFrame)
nsresult nsresult
nsMathMLmtableCreator::CreateTableCellInnerFrame(nsIFrame** aNewFrame) nsMathMLmtableCreator::CreateTableCellInnerFrame(nsIFrame** aNewFrame)
{ {
// only works if aNewFrame is an AreaFrame (to take care of the lineLayout logic) // only works if aNewFrame can take care of the lineLayout logic
return NS_NewMathMLmtdFrame(mPresShell, aNewFrame); return NS_NewMathMLmtdInnerFrame(mPresShell, aNewFrame);
} }
#endif // MOZ_MATHML #endif // MOZ_MATHML
@ -1701,9 +1701,11 @@ nsCSSFrameConstructor::CreateInputFrame(nsIPresShell *aPresShell,
PRBool IsOnlyWhiteSpace(nsIContent* aContent) PRBool IsOnlyWhiteSpace(nsIContent* aContent)
{ {
PRBool onlyWhiteSpace = PR_FALSE; PRBool onlyWhiteSpace = PR_FALSE;
nsCOMPtr<nsITextContent> textContent = do_QueryInterface(aContent); if (aContent->IsContentOfType(nsIContent::eTEXT)) {
if (textContent) { nsCOMPtr<nsITextContent> textContent = do_QueryInterface(aContent);
textContent->IsOnlyWhitespace(&onlyWhiteSpace); if (textContent) {
textContent->IsOnlyWhitespace(&onlyWhiteSpace);
}
} }
return onlyWhiteSpace; return onlyWhiteSpace;
} }
@ -6879,7 +6881,6 @@ nsCSSFrameConstructor::ConstructMathMLFrame(nsIPresShell* aPresShell,
// Initialize the new frame // Initialize the new frame
nsIFrame* newFrame = nsnull; nsIFrame* newFrame = nsnull;
nsMathMLmtableCreator mathTableCreator(aPresShell); // Used to make table views.
// See if the element is absolute or fixed positioned // See if the element is absolute or fixed positioned
const nsStylePosition* position = (const nsStylePosition*) const nsStylePosition* position = (const nsStylePosition*)
@ -6939,44 +6940,66 @@ nsCSSFrameConstructor::ConstructMathMLFrame(nsIPresShell* aPresShell,
rv = NS_NewMathMLmrowFrame(aPresShell, &newFrame); rv = NS_NewMathMLmrowFrame(aPresShell, &newFrame);
// CONSTRUCTION of MTABLE elements // CONSTRUCTION of MTABLE elements
else if (aTag == nsMathMLAtoms::mtable_) { else if (aTag == nsMathMLAtoms::mtable_) {
// <mtable> is an inline-table, for the moment, we just do what // <mtable> is an inline-table -- but this isn't yet supported.
// <table> does, and wait until nsLineLayout::TreatFrameAsBlock // What we do here is to wrap the table in an anonymous containing
// can handle NS_STYLE_DISPLAY_INLINE_TABLE. // block so that it can mix better with other surrounding MathML markups
nsIFrame* geometricParent = aParentFrame;
if (isAbsolutelyPositioned) { nsCOMPtr<nsIStyleContext> parentContext;
aParentFrame = aState.mAbsoluteItems.containingBlock; aParentFrame->GetStyleContext(getter_AddRefs(parentContext));
}
else if (isFixedPositioned) { // first, create a MathML mrow frame that will wrap the block frame
aParentFrame = aState.mFixedItems.containingBlock; rv = NS_NewMathMLmrowFrame(aPresShell, &newFrame);
} if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIStyleContext> mrowContext;
aPresContext->ResolvePseudoStyleContextFor(aContent,
nsMathMLAtoms::mozMathInline,
parentContext, PR_FALSE,
getter_AddRefs(mrowContext));
InitAndRestoreFrame(aPresContext, aState, aContent, aParentFrame,
mrowContext, nsnull, newFrame);
// add it to the flow
aFrameItems.AddChild(newFrame);
// then, create a block frame that will wrap the table frame
nsIFrame* blockFrame;
rv = NS_NewBlockFrame(aPresShell, &blockFrame);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIStyleContext> blockContext;
aPresContext->ResolvePseudoStyleContextFor(aContent,
nsHTMLAtoms::mozAnonymousBlock,
mrowContext, PR_FALSE,
getter_AddRefs(blockContext));
InitAndRestoreFrame(aPresContext, aState, aContent, newFrame,
blockContext, nsnull, blockFrame);
// set the block frame as the initial child of the mrow frame
newFrame->SetInitialChildList(aPresContext, nsnull, blockFrame);
// then, create the table frame itself
nsCOMPtr<nsIStyleContext> tableContext;
aPresContext->ResolvePseudoStyleContextFor(aContent,
nsMathMLAtoms::mozMathTable,
blockContext, PR_FALSE,
getter_AddRefs(tableContext));
nsFrameItems tempItems;
nsIFrame* outerTable;
nsIFrame* innerTable; nsIFrame* innerTable;
PRBool pseudoParent; PRBool pseudoParent;
nsMathMLmtableCreator mathTableCreator(aPresShell);
rv = ConstructTableFrame(aPresShell, aPresContext, aState, aContent, rv = ConstructTableFrame(aPresShell, aPresContext, aState, aContent,
geometricParent, aStyleContext, mathTableCreator, blockFrame, tableContext, mathTableCreator,
PR_FALSE, aFrameItems, newFrame, innerTable, pseudoParent); PR_FALSE, tempItems, outerTable, innerTable, pseudoParent);
// Note: table construction function takes care of initializing the frame, // Note: table construction function takes care of initializing the frame,
// processing children, and setting the initial child list // processing children, and setting the initial child list
if (isAbsolutelyPositioned || isFixedPositioned) {
nsIFrame* placeholderFrame; // set the outerTable as the initial child of the anonymous block
CreatePlaceholderFrameFor(aPresShell, aPresContext, aState.mFrameManager, aContent, newFrame, blockFrame->SetInitialChildList(aPresContext, nsnull, outerTable);
aStyleContext, aParentFrame, &placeholderFrame);
// Add the positioned frame to its containing block's list of child frames
if (isAbsolutelyPositioned) {
aState.mAbsoluteItems.AddChild(newFrame);
} else {
aState.mFixedItems.AddChild(newFrame);
}
// Add the placeholder frame to the flow
aFrameItems.AddChild(placeholderFrame);
} else if (!pseudoParent) {
// Add the table frame to the flow
aFrameItems.AddChild(newFrame);
}
return rv; return rv;
} }
else if (aTag == nsMathMLAtoms::mtd_) { else if (aTag == nsMathMLAtoms::mtd_) {
nsIFrame* innerCell; nsIFrame* innerCell;
PRBool pseudoParent; PRBool pseudoParent;
nsMathMLmtableCreator mathTableCreator(aPresShell);
rv = ConstructTableCellFrame(aPresShell, aPresContext, aState, aContent, rv = ConstructTableCellFrame(aPresShell, aPresContext, aState, aContent,
aParentFrame, aStyleContext, mathTableCreator, aParentFrame, aStyleContext, mathTableCreator,
PR_FALSE, aFrameItems, newFrame, innerCell, pseudoParent); PR_FALSE, aFrameItems, newFrame, innerCell, pseudoParent);