mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 685154 - Cleanup nsIFrame::GetParentStyleContextFrame and related code. r=roc
Make nsCSSFrameConstructor::ConstructTable return a null frame if creating the inner table frame fails. Simplify some code since we can now depend on the invariant that a properly created outer table frame always has a non-null inner table frame.
This commit is contained in:
parent
4a82c200c1
commit
ba8355dd94
@ -1909,7 +1909,12 @@ nsCSSFrameConstructor::ConstructTable(nsFrameConstructorState& aState,
|
||||
innerFrame = NS_NewMathMLmtableFrame(mPresShell, styleContext);
|
||||
else
|
||||
innerFrame = NS_NewTableFrame(mPresShell, styleContext);
|
||||
|
||||
|
||||
if (!innerFrame) {
|
||||
newFrame->Destroy();
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
InitAndRestoreFrame(aState, content, newFrame, nsnull, innerFrame);
|
||||
|
||||
// Put the newly created frames into the right child list
|
||||
@ -6675,10 +6680,8 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
|
||||
if (captionItems.NotEmpty()) { // append the caption to the outer table
|
||||
NS_ASSERTION(nsGkAtoms::tableFrame == frameType, "how did that happen?");
|
||||
nsIFrame* outerTable = parentFrame->GetParent();
|
||||
if (outerTable) {
|
||||
state.mFrameManager->AppendFrames(outerTable, nsIFrame::kCaptionList,
|
||||
captionItems);
|
||||
}
|
||||
state.mFrameManager->AppendFrames(outerTable, nsIFrame::kCaptionList,
|
||||
captionItems);
|
||||
}
|
||||
|
||||
if (frameItems.NotEmpty()) { // append the in-flow kids
|
||||
|
@ -458,8 +458,8 @@ nsMathMLmtableOuterFrame::AttributeChanged(PRInt32 aNameSpaceID,
|
||||
|
||||
// mtable is simple and only has one (pseudo) row-group inside our inner-table
|
||||
nsIFrame* tableFrame = mFrames.FirstChild();
|
||||
if (!tableFrame || tableFrame->GetType() != nsGkAtoms::tableFrame)
|
||||
return NS_OK;
|
||||
NS_ASSERTION(tableFrame && tableFrame->GetType() == nsGkAtoms::tableFrame,
|
||||
"should always have an inner table frame");
|
||||
nsIFrame* rgFrame = tableFrame->GetFirstPrincipalChild();
|
||||
if (!rgFrame || rgFrame->GetType() != nsGkAtoms::tableRowGroupFrame)
|
||||
return NS_OK;
|
||||
@ -548,8 +548,8 @@ nsMathMLmtableOuterFrame::GetRowFrameAt(nsPresContext* aPresContext,
|
||||
// if our inner table says that the index is valid, find the row now
|
||||
if (0 <= aRowIndex && aRowIndex <= rowCount) {
|
||||
nsIFrame* tableFrame = mFrames.FirstChild();
|
||||
if (!tableFrame || tableFrame->GetType() != nsGkAtoms::tableFrame)
|
||||
return nsnull;
|
||||
NS_ASSERTION(tableFrame && tableFrame->GetType() == nsGkAtoms::tableFrame,
|
||||
"should always have an inner table frame");
|
||||
nsIFrame* rgFrame = tableFrame->GetFirstPrincipalChild();
|
||||
if (!rgFrame || rgFrame->GetType() != nsGkAtoms::tableRowGroupFrame)
|
||||
return nsnull;
|
||||
|
@ -244,17 +244,11 @@ nsTableOuterFrame::SetInitialChildList(ChildListID aListID,
|
||||
else {
|
||||
NS_ASSERTION(aListID == kPrincipalList, "wrong childlist");
|
||||
NS_ASSERTION(mFrames.IsEmpty(), "Frame leak!");
|
||||
mInnerTableFrame = nsnull;
|
||||
if (aChildList.NotEmpty()) {
|
||||
if (nsGkAtoms::tableFrame == aChildList.FirstChild()->GetType()) {
|
||||
mInnerTableFrame = (nsTableFrame*)aChildList.FirstChild();
|
||||
mFrames.SetFrames(aChildList);
|
||||
}
|
||||
else {
|
||||
NS_ERROR("expected a table frame");
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
NS_ASSERTION(aChildList.FirstChild() &&
|
||||
nsGkAtoms::tableFrame == aChildList.FirstChild()->GetType(),
|
||||
"expected a table frame");
|
||||
mInnerTableFrame = static_cast<nsTableFrame*>(aChildList.FirstChild());
|
||||
mFrames.SetFrames(aChildList);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -394,9 +388,7 @@ nsTableOuterFrame::SetSelected(PRBool aSelected,
|
||||
SelectionType aType)
|
||||
{
|
||||
nsFrame::SetSelected(aSelected, aType);
|
||||
if (mInnerTableFrame) {
|
||||
mInnerTableFrame->SetSelected(aSelected, aType);
|
||||
}
|
||||
mInnerTableFrame->SetSelected(aSelected, aType);
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
@ -412,9 +404,6 @@ nsTableOuterFrame::GetParentStyleContextFrame()
|
||||
// children of the table inherit directly from the inner table, and
|
||||
// the outer table's style context is a leaf.
|
||||
|
||||
if (!mInnerTableFrame) {
|
||||
return this;
|
||||
}
|
||||
return mInnerTableFrame;
|
||||
}
|
||||
|
||||
@ -429,7 +418,8 @@ nsTableOuterFrame::InitChildReflowState(nsPresContext& aPresContext,
|
||||
nsMargin collapsePadding(0,0,0,0);
|
||||
nsMargin* pCollapseBorder = nsnull;
|
||||
nsMargin* pCollapsePadding = nsnull;
|
||||
if ((aReflowState.frame == mInnerTableFrame) && (mInnerTableFrame->IsBorderCollapse())) {
|
||||
if (aReflowState.frame == mInnerTableFrame &&
|
||||
mInnerTableFrame->IsBorderCollapse()) {
|
||||
collapseBorder = mInnerTableFrame->GetIncludedOuterBCBorder();
|
||||
pCollapseBorder = &collapseBorder;
|
||||
pCollapsePadding = &collapsePadding;
|
||||
@ -958,12 +948,6 @@ NS_METHOD nsTableOuterFrame::Reflow(nsPresContext* aPresContext,
|
||||
DO_GLOBAL_REFLOW_COUNT("nsTableOuterFrame");
|
||||
DISPLAY_REFLOW(aPresContext, this, aOuterRS, aDesiredSize, aStatus);
|
||||
|
||||
// We desperately need an inner table frame,
|
||||
// if this fails fix the frame constructor
|
||||
if (mFrames.IsEmpty() || !mInnerTableFrame) {
|
||||
NS_ERROR("incomplete children");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsresult rv = NS_OK;
|
||||
PRUint8 captionSide = GetCaptionSide();
|
||||
|
||||
@ -1169,8 +1153,6 @@ nsTableOuterFrame::GetCellDataAt(PRInt32 aRowIndex, PRInt32 aColIndex,
|
||||
PRInt32& aActualRowSpan, PRInt32& aActualColSpan,
|
||||
PRBool& aIsSelected)
|
||||
{
|
||||
NS_ASSERTION(mInnerTableFrame, "no inner table frame yet?");
|
||||
|
||||
return mInnerTableFrame->GetCellDataAt(aRowIndex, aColIndex, aCell,
|
||||
aStartRowIndex, aStartColIndex,
|
||||
aRowSpan, aColSpan, aActualRowSpan,
|
||||
@ -1180,8 +1162,6 @@ nsTableOuterFrame::GetCellDataAt(PRInt32 aRowIndex, PRInt32 aColIndex,
|
||||
NS_IMETHODIMP
|
||||
nsTableOuterFrame::GetTableSize(PRInt32& aRowCount, PRInt32& aColCount)
|
||||
{
|
||||
NS_ASSERTION(mInnerTableFrame, "no inner table frame yet?");
|
||||
|
||||
return mInnerTableFrame->GetTableSize(aRowCount, aColCount);
|
||||
}
|
||||
|
||||
@ -1190,8 +1170,6 @@ nsTableOuterFrame::GetIndexByRowAndColumn(PRInt32 aRow, PRInt32 aColumn,
|
||||
PRInt32 *aIndex)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aIndex);
|
||||
|
||||
NS_ASSERTION(mInnerTableFrame, "no inner table frame yet?");
|
||||
return mInnerTableFrame->GetIndexByRowAndColumn(aRow, aColumn, aIndex);
|
||||
}
|
||||
|
||||
@ -1201,8 +1179,6 @@ nsTableOuterFrame::GetRowAndColumnByIndex(PRInt32 aIndex,
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRow);
|
||||
NS_ENSURE_ARG_POINTER(aColumn);
|
||||
|
||||
NS_ASSERTION(mInnerTableFrame, "no inner table frame yet?");
|
||||
return mInnerTableFrame->GetRowAndColumnByIndex(aIndex, aRow, aColumn);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user