fixed crash in bug 5190, allowing a table to be the top level XML element.

This commit is contained in:
karnaze%netscape.com 1999-04-30 19:51:59 +00:00
Родитель 291058d2b5
Коммит fabb6dffc4
4 изменённых файлов: 254 добавлений и 124 удалений

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

@ -1559,13 +1559,7 @@ nsCSSFrameConstructor::TableProcessChild(nsIPresContext* aPresContext,
getter_AddRefs(childStyleContext));
const nsStyleDisplay* childDisplay = (const nsStyleDisplay*)
childStyleContext->GetStyleData(eStyleStruct_Display);
if ( (childDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE) ||
(childDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_HEADER_GROUP) ||
(childDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_ROW_GROUP) ||
(childDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP) ||
(childDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_ROW) ||
(childDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_COLUMN) ||
(childDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_CELL) ) {
if (IsTableRelated(childDisplay->mDisplay)) {
nsAbsoluteItems floaterList(nsnull);
rv = ConstructFrame(aPresContext, aState, aChildContent, aParentFrame,
PR_FALSE, aChildItems);
@ -1751,10 +1745,36 @@ nsCSSFrameConstructor:: GetDisplay(nsIFrame* aFrame)
return display;
}
nsCSSFrameConstructor::IsTableRelated(PRUint8 aDisplay)
{
return (aDisplay == NS_STYLE_DISPLAY_TABLE) ||
(aDisplay == NS_STYLE_DISPLAY_TABLE_HEADER_GROUP) ||
(aDisplay == NS_STYLE_DISPLAY_TABLE_ROW_GROUP) ||
(aDisplay == NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP) ||
(aDisplay == NS_STYLE_DISPLAY_TABLE_ROW) ||
(aDisplay == NS_STYLE_DISPLAY_TABLE_COLUMN) ||
(aDisplay == NS_STYLE_DISPLAY_TABLE_CELL);
}
/***********************************************
* END TABLE SECTION
***********************************************/
nsresult
nsCSSFrameConstructor::ConstructDocElementTableFrame(nsIPresContext* aPresContext,
nsIContent* aDocElement,
nsIFrame* aParentFrame,
nsIFrame*& aNewTableFrame)
{
nsFrameConstructorState state(nsnull, nsnull, nsnull);
nsFrameItems frameItems;
ConstructFrame(aPresContext, state, aDocElement, aParentFrame, PR_FALSE, frameItems);
aNewTableFrame = frameItems.childList;
return NS_OK;
}
nsresult
nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresContext,
nsFrameConstructorState& aState,
@ -1769,13 +1789,24 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresCo
PR_FALSE,
getter_AddRefs(styleContext));
const nsStyleDisplay* display =
(const nsStyleDisplay*)styleContext->GetStyleData(eStyleStruct_Display);
PRBool docElemIsTable = IsTableRelated(display->mDisplay);
// See if we're paginated
PRBool isPaginated;
aPresContext->IsPaginated(&isPaginated);
if (isPaginated) {
if (docElemIsTable) {
nsIFrame* tableFrame;
ConstructDocElementTableFrame(aPresContext, aDocElement, aParentFrame, tableFrame);
mInitialContainingBlock = tableFrame;
aNewFrame = tableFrame;
return NS_OK;
}
// Create an area frame for the document element
nsIFrame* areaFrame;
NS_NewAreaFrame(areaFrame, 0);
areaFrame->Init(*aPresContext, aDocElement, aParentFrame, styleContext, nsnull);
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, areaFrame,
@ -1815,9 +1846,6 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresCo
// scroll frame.
nsIFrame* scrollFrame = nsnull;
const nsStyleDisplay* display = (const nsStyleDisplay*)
styleContext->GetStyleData(eStyleStruct_Display);
if (IsScrollable(aPresContext, display)) {
NS_NewScrollFrame(scrollFrame);
scrollFrame->Init(*aPresContext, aDocElement, aParentFrame, styleContext,
@ -1832,16 +1860,24 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresCo
getter_AddRefs(scrolledPseudoStyle));
styleContext = scrolledPseudoStyle;
}
nsIFrame* parFrame = scrollFrame ? scrollFrame : aParentFrame;
nsIFrame* areaFrame;
if (docElemIsTable) {
nsIFrame* tableFrame;
ConstructDocElementTableFrame(aPresContext, aDocElement, parFrame, tableFrame);
mInitialContainingBlock = tableFrame;
aNewFrame = tableFrame;
return NS_OK;
}
// Create an area frame for the document element. This serves as the
// "initial containing block"
nsIFrame* areaFrame;
// XXX Until we clean up how painting damage is handled, we need to use the
// flag that says that this is the body...
NS_NewAreaFrame(areaFrame, NS_BLOCK_DOCUMENT_ROOT|NS_BLOCK_MARGIN_ROOT);
areaFrame->Init(*aPresContext, aDocElement, scrollFrame ? scrollFrame :
aParentFrame, styleContext, nsnull);
areaFrame->Init(*aPresContext, aDocElement, parFrame, styleContext, nsnull);
if (scrollFrame) {
// If the document element is scrollable, then it needs a view. Otherwise,
// don't bother, because the root frame has a view and the extra view is
@ -1852,7 +1888,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresCo
// The area frame is the "initial containing block"
mInitialContainingBlock = areaFrame;
// Process the child content
nsFrameConstructorSaveState absoluteSaveState;
nsFrameConstructorSaveState floaterSaveState;
@ -3398,53 +3434,6 @@ nsCSSFrameConstructor::ConstructFrame(nsIPresContext* aPresContext,
nsCOMPtr<nsIStyleContext> styleContext;
rv = ResolveStyleContext(aPresContext, aParentFrame, aContent, tag, getter_AddRefs(styleContext));
#ifdef chris_needs_to_remove_this
// Resolve the style context based on the content object and the parent
// style context
nsCOMPtr<nsIStyleContext> styleContext;
nsCOMPtr<nsIStyleContext> parentStyleContext;
aParentFrame->GetStyleContext(getter_AddRefs(parentStyleContext));
if (nsLayoutAtoms::textTagName == tag) {
// Use a special pseudo element style context for text
nsCOMPtr<nsIContent> parentContent;
if (nsnull != aParentFrame) {
aParentFrame->GetContent(getter_AddRefs(parentContent));
}
rv = aPresContext->ResolvePseudoStyleContextFor(parentContent,
nsHTMLAtoms::textPseudo,
parentStyleContext,
PR_FALSE,
getter_AddRefs(styleContext));
} else if (nsLayoutAtoms::commentTagName == tag) {
// Use a special pseudo element style context for comments
nsCOMPtr<nsIContent> parentContent;
if (nsnull != aParentFrame) {
aParentFrame->GetContent(getter_AddRefs(parentContent));
}
rv = aPresContext->ResolvePseudoStyleContextFor(parentContent,
nsHTMLAtoms::commentPseudo,
parentStyleContext,
PR_FALSE,
getter_AddRefs(styleContext));
} else if (nsLayoutAtoms::processingInstructionTagName == tag) {
// Use a special pseudo element style context for comments
nsCOMPtr<nsIContent> parentContent;
if (nsnull != aParentFrame) {
aParentFrame->GetContent(getter_AddRefs(parentContent));
}
rv = aPresContext->ResolvePseudoStyleContextFor(parentContent,
nsHTMLAtoms::processingInstructionPseudo,
parentStyleContext,
PR_FALSE,
getter_AddRefs(styleContext));
} else {
rv = aPresContext->ResolveStyleContextFor(aContent, parentStyleContext,
PR_FALSE,
getter_AddRefs(styleContext));
}
#endif
if (NS_SUCCEEDED(rv)) {
// Pre-check for display "none" - if we find that, don't create
// any frame at all

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

@ -134,6 +134,11 @@ protected:
nsIStyleContext* aParentStyleContext,
nsIFrame*& aNewFrame);
nsresult ConstructDocElementTableFrame(nsIPresContext* aPresContext,
nsIContent* aDocElement,
nsIFrame* aParentFrame,
nsIFrame*& aNewTableFrame);
nsresult CreateGeneratedFrameFor(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIContent* aContent,
@ -276,6 +281,75 @@ protected:
nsFrameItems& aChildItems,
nsTableCreator& aTableCreator);
nsresult ConstructTableRowFrameOnly(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsAbsoluteItems& aAbsoluteItems,
PRBool aProcessChildren,
nsIFrame*& aNewRowFrame,
nsAbsoluteItems& aFixedItems,
nsTableCreator& aTableCreator);
nsresult ConstructTableColFrame(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsAbsoluteItems& aAbsoluteItems,
nsIFrame*& aNewTopMostFrame,
nsIFrame*& aNewColFrame,
nsAbsoluteItems& aFixedItems,
nsTableCreator& aTableCreator);
nsresult ConstructTableColFrameOnly(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsAbsoluteItems& aAbsoluteItems,
nsIFrame*& aNewColFrame,
nsAbsoluteItems& aFixedItems,
nsTableCreator& aTableCreator);
nsresult ConstructTableCellFrame(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsAbsoluteItems& aAbsoluteItems,
nsIFrame*& aNewTopMostFrame,
nsIFrame*& aNewCellFrame,
nsIFrame*& aNewCellBodyFrame,
nsAbsoluteItems& aFixedItems,
nsTableCreator& aTableCreator,
PRBool aProcessChildren = PR_TRUE);
nsresult ConstructTableCellFrameOnly(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsAbsoluteItems& aAbsoluteItems,
nsIFrame*& aNewCellFrame,
nsIFrame*& aNewCellBodyFrame,
nsAbsoluteItems& aFixedItems,
nsTableCreator& aTableCreator,
PRBool aProcessChildren);
nsresult TableProcessChildren(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsAbsoluteItems& aAbsoluteItems,
nsFrameItems& aChildList,
nsAbsoluteItems& aFixedItems,
nsTableCreator& aTableCreator);
nsresult TableProcessChild(nsIPresContext* aPresContext,
nsIContent* aChildContent,
nsIFrame* aParentFrame,
nsIStyleContext* aParentStyleContext,
nsAbsoluteItems& aAbsoluteItems,
nsFrameItems& aChildItems,
nsAbsoluteItems& aFixedItems,
nsTableCreator& aTableCreator);
nsresult TableProcessTableList(nsIPresContext* aPresContext,
nsTableList& aTableList);
@ -288,6 +362,8 @@ protected:
nsIContent* aContent);
const nsStyleDisplay* GetDisplay(nsIFrame* aFrame);
PRBool IsTableRelated(PRUint8 aDisplay);
// END TABLE SECTION

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

@ -1559,13 +1559,7 @@ nsCSSFrameConstructor::TableProcessChild(nsIPresContext* aPresContext,
getter_AddRefs(childStyleContext));
const nsStyleDisplay* childDisplay = (const nsStyleDisplay*)
childStyleContext->GetStyleData(eStyleStruct_Display);
if ( (childDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE) ||
(childDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_HEADER_GROUP) ||
(childDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_ROW_GROUP) ||
(childDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP) ||
(childDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_ROW) ||
(childDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_COLUMN) ||
(childDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_CELL) ) {
if (IsTableRelated(childDisplay->mDisplay)) {
nsAbsoluteItems floaterList(nsnull);
rv = ConstructFrame(aPresContext, aState, aChildContent, aParentFrame,
PR_FALSE, aChildItems);
@ -1751,10 +1745,36 @@ nsCSSFrameConstructor:: GetDisplay(nsIFrame* aFrame)
return display;
}
nsCSSFrameConstructor::IsTableRelated(PRUint8 aDisplay)
{
return (aDisplay == NS_STYLE_DISPLAY_TABLE) ||
(aDisplay == NS_STYLE_DISPLAY_TABLE_HEADER_GROUP) ||
(aDisplay == NS_STYLE_DISPLAY_TABLE_ROW_GROUP) ||
(aDisplay == NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP) ||
(aDisplay == NS_STYLE_DISPLAY_TABLE_ROW) ||
(aDisplay == NS_STYLE_DISPLAY_TABLE_COLUMN) ||
(aDisplay == NS_STYLE_DISPLAY_TABLE_CELL);
}
/***********************************************
* END TABLE SECTION
***********************************************/
nsresult
nsCSSFrameConstructor::ConstructDocElementTableFrame(nsIPresContext* aPresContext,
nsIContent* aDocElement,
nsIFrame* aParentFrame,
nsIFrame*& aNewTableFrame)
{
nsFrameConstructorState state(nsnull, nsnull, nsnull);
nsFrameItems frameItems;
ConstructFrame(aPresContext, state, aDocElement, aParentFrame, PR_FALSE, frameItems);
aNewTableFrame = frameItems.childList;
return NS_OK;
}
nsresult
nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresContext,
nsFrameConstructorState& aState,
@ -1769,13 +1789,24 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresCo
PR_FALSE,
getter_AddRefs(styleContext));
const nsStyleDisplay* display =
(const nsStyleDisplay*)styleContext->GetStyleData(eStyleStruct_Display);
PRBool docElemIsTable = IsTableRelated(display->mDisplay);
// See if we're paginated
PRBool isPaginated;
aPresContext->IsPaginated(&isPaginated);
if (isPaginated) {
if (docElemIsTable) {
nsIFrame* tableFrame;
ConstructDocElementTableFrame(aPresContext, aDocElement, aParentFrame, tableFrame);
mInitialContainingBlock = tableFrame;
aNewFrame = tableFrame;
return NS_OK;
}
// Create an area frame for the document element
nsIFrame* areaFrame;
NS_NewAreaFrame(areaFrame, 0);
areaFrame->Init(*aPresContext, aDocElement, aParentFrame, styleContext, nsnull);
nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, areaFrame,
@ -1815,9 +1846,6 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresCo
// scroll frame.
nsIFrame* scrollFrame = nsnull;
const nsStyleDisplay* display = (const nsStyleDisplay*)
styleContext->GetStyleData(eStyleStruct_Display);
if (IsScrollable(aPresContext, display)) {
NS_NewScrollFrame(scrollFrame);
scrollFrame->Init(*aPresContext, aDocElement, aParentFrame, styleContext,
@ -1832,16 +1860,24 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresCo
getter_AddRefs(scrolledPseudoStyle));
styleContext = scrolledPseudoStyle;
}
nsIFrame* parFrame = scrollFrame ? scrollFrame : aParentFrame;
nsIFrame* areaFrame;
if (docElemIsTable) {
nsIFrame* tableFrame;
ConstructDocElementTableFrame(aPresContext, aDocElement, parFrame, tableFrame);
mInitialContainingBlock = tableFrame;
aNewFrame = tableFrame;
return NS_OK;
}
// Create an area frame for the document element. This serves as the
// "initial containing block"
nsIFrame* areaFrame;
// XXX Until we clean up how painting damage is handled, we need to use the
// flag that says that this is the body...
NS_NewAreaFrame(areaFrame, NS_BLOCK_DOCUMENT_ROOT|NS_BLOCK_MARGIN_ROOT);
areaFrame->Init(*aPresContext, aDocElement, scrollFrame ? scrollFrame :
aParentFrame, styleContext, nsnull);
areaFrame->Init(*aPresContext, aDocElement, parFrame, styleContext, nsnull);
if (scrollFrame) {
// If the document element is scrollable, then it needs a view. Otherwise,
// don't bother, because the root frame has a view and the extra view is
@ -1852,7 +1888,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresCo
// The area frame is the "initial containing block"
mInitialContainingBlock = areaFrame;
// Process the child content
nsFrameConstructorSaveState absoluteSaveState;
nsFrameConstructorSaveState floaterSaveState;
@ -3398,53 +3434,6 @@ nsCSSFrameConstructor::ConstructFrame(nsIPresContext* aPresContext,
nsCOMPtr<nsIStyleContext> styleContext;
rv = ResolveStyleContext(aPresContext, aParentFrame, aContent, tag, getter_AddRefs(styleContext));
#ifdef chris_needs_to_remove_this
// Resolve the style context based on the content object and the parent
// style context
nsCOMPtr<nsIStyleContext> styleContext;
nsCOMPtr<nsIStyleContext> parentStyleContext;
aParentFrame->GetStyleContext(getter_AddRefs(parentStyleContext));
if (nsLayoutAtoms::textTagName == tag) {
// Use a special pseudo element style context for text
nsCOMPtr<nsIContent> parentContent;
if (nsnull != aParentFrame) {
aParentFrame->GetContent(getter_AddRefs(parentContent));
}
rv = aPresContext->ResolvePseudoStyleContextFor(parentContent,
nsHTMLAtoms::textPseudo,
parentStyleContext,
PR_FALSE,
getter_AddRefs(styleContext));
} else if (nsLayoutAtoms::commentTagName == tag) {
// Use a special pseudo element style context for comments
nsCOMPtr<nsIContent> parentContent;
if (nsnull != aParentFrame) {
aParentFrame->GetContent(getter_AddRefs(parentContent));
}
rv = aPresContext->ResolvePseudoStyleContextFor(parentContent,
nsHTMLAtoms::commentPseudo,
parentStyleContext,
PR_FALSE,
getter_AddRefs(styleContext));
} else if (nsLayoutAtoms::processingInstructionTagName == tag) {
// Use a special pseudo element style context for comments
nsCOMPtr<nsIContent> parentContent;
if (nsnull != aParentFrame) {
aParentFrame->GetContent(getter_AddRefs(parentContent));
}
rv = aPresContext->ResolvePseudoStyleContextFor(parentContent,
nsHTMLAtoms::processingInstructionPseudo,
parentStyleContext,
PR_FALSE,
getter_AddRefs(styleContext));
} else {
rv = aPresContext->ResolveStyleContextFor(aContent, parentStyleContext,
PR_FALSE,
getter_AddRefs(styleContext));
}
#endif
if (NS_SUCCEEDED(rv)) {
// Pre-check for display "none" - if we find that, don't create
// any frame at all

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

@ -134,6 +134,11 @@ protected:
nsIStyleContext* aParentStyleContext,
nsIFrame*& aNewFrame);
nsresult ConstructDocElementTableFrame(nsIPresContext* aPresContext,
nsIContent* aDocElement,
nsIFrame* aParentFrame,
nsIFrame*& aNewTableFrame);
nsresult CreateGeneratedFrameFor(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
nsIContent* aContent,
@ -276,6 +281,75 @@ protected:
nsFrameItems& aChildItems,
nsTableCreator& aTableCreator);
nsresult ConstructTableRowFrameOnly(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsAbsoluteItems& aAbsoluteItems,
PRBool aProcessChildren,
nsIFrame*& aNewRowFrame,
nsAbsoluteItems& aFixedItems,
nsTableCreator& aTableCreator);
nsresult ConstructTableColFrame(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aStyleContext,
nsAbsoluteItems& aAbsoluteItems,
nsIFrame*& aNewTopMostFrame,
nsIFrame*& aNewColFrame,
nsAbsoluteItems& aFixedItems,
nsTableCreator& aTableCreator);
nsresult ConstructTableColFrameOnly(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsAbsoluteItems& aAbsoluteItems,
nsIFrame*& aNewColFrame,
nsAbsoluteItems& aFixedItems,
nsTableCreator& aTableCreator);
nsresult ConstructTableCellFrame(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsAbsoluteItems& aAbsoluteItems,
nsIFrame*& aNewTopMostFrame,
nsIFrame*& aNewCellFrame,
nsIFrame*& aNewCellBodyFrame,
nsAbsoluteItems& aFixedItems,
nsTableCreator& aTableCreator,
PRBool aProcessChildren = PR_TRUE);
nsresult ConstructTableCellFrameOnly(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsAbsoluteItems& aAbsoluteItems,
nsIFrame*& aNewCellFrame,
nsIFrame*& aNewCellBodyFrame,
nsAbsoluteItems& aFixedItems,
nsTableCreator& aTableCreator,
PRBool aProcessChildren);
nsresult TableProcessChildren(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsAbsoluteItems& aAbsoluteItems,
nsFrameItems& aChildList,
nsAbsoluteItems& aFixedItems,
nsTableCreator& aTableCreator);
nsresult TableProcessChild(nsIPresContext* aPresContext,
nsIContent* aChildContent,
nsIFrame* aParentFrame,
nsIStyleContext* aParentStyleContext,
nsAbsoluteItems& aAbsoluteItems,
nsFrameItems& aChildItems,
nsAbsoluteItems& aFixedItems,
nsTableCreator& aTableCreator);
nsresult TableProcessTableList(nsIPresContext* aPresContext,
nsTableList& aTableList);
@ -288,6 +362,8 @@ protected:
nsIContent* aContent);
const nsStyleDisplay* GetDisplay(nsIFrame* aFrame);
PRBool IsTableRelated(PRUint8 aDisplay);
// END TABLE SECTION