Bug 852501 part 9. Optimistically make ConstructFramesFromItemList infallible in the hope that this is the only thing that makes other things fallible. r=dholbert

This commit is contained in:
Boris Zbarsky
2013-03-19 21:47:51 -04:00
parent 64fe023b10
commit be3510a709
2 changed files with 25 additions and 38 deletions

View File

@@ -1963,8 +1963,8 @@ nsCSSFrameConstructor::ConstructTable(nsFrameConstructorState& aState,
aState.PushAbsoluteContainingBlock(newFrame, absoluteSaveState); aState.PushAbsoluteContainingBlock(newFrame, absoluteSaveState);
} }
if (aItem.mFCData->mBits & FCDATA_USE_CHILD_ITEMS) { if (aItem.mFCData->mBits & FCDATA_USE_CHILD_ITEMS) {
rv = ConstructFramesFromItemList(aState, aItem.mChildItems, ConstructFramesFromItemList(aState, aItem.mChildItems,
innerFrame, childItems); innerFrame, childItems);
} else { } else {
rv = ProcessChildren(aState, content, styleContext, innerFrame, rv = ProcessChildren(aState, content, styleContext, innerFrame,
true, childItems, false, aItem.mPendingBinding); true, childItems, false, aItem.mPendingBinding);
@@ -2010,10 +2010,10 @@ nsCSSFrameConstructor::ConstructTableRow(nsFrameConstructorState& aState,
InitAndRestoreFrame(aState, content, aParentFrame, nullptr, newFrame); InitAndRestoreFrame(aState, content, aParentFrame, nullptr, newFrame);
nsFrameItems childItems; nsFrameItems childItems;
nsresult rv; nsresult rv = NS_OK;
if (aItem.mFCData->mBits & FCDATA_USE_CHILD_ITEMS) { if (aItem.mFCData->mBits & FCDATA_USE_CHILD_ITEMS) {
rv = ConstructFramesFromItemList(aState, aItem.mChildItems, newFrame, ConstructFramesFromItemList(aState, aItem.mChildItems, newFrame,
childItems); childItems);
} else { } else {
rv = ProcessChildren(aState, content, styleContext, newFrame, rv = ProcessChildren(aState, content, styleContext, newFrame,
true, childItems, false, aItem.mPendingBinding); true, childItems, false, aItem.mPendingBinding);
@@ -2116,7 +2116,7 @@ nsCSSFrameConstructor::ConstructTableCell(nsFrameConstructorState& aState,
InitAndRestoreFrame(aState, content, newFrame, nullptr, cellInnerFrame); InitAndRestoreFrame(aState, content, newFrame, nullptr, cellInnerFrame);
nsFrameItems childItems; nsFrameItems childItems;
nsresult rv; nsresult rv = NS_OK;
if (aItem.mFCData->mBits & FCDATA_USE_CHILD_ITEMS) { if (aItem.mFCData->mBits & FCDATA_USE_CHILD_ITEMS) {
// Need to push ourselves as a float containing block. // Need to push ourselves as a float containing block.
// XXXbz it might be nice to work on getting the parent // XXXbz it might be nice to work on getting the parent
@@ -2129,8 +2129,8 @@ nsCSSFrameConstructor::ConstructTableCell(nsFrameConstructorState& aState,
aState.PushFloatContainingBlock(cellInnerFrame, floatSaveState); aState.PushFloatContainingBlock(cellInnerFrame, floatSaveState);
} }
rv = ConstructFramesFromItemList(aState, aItem.mChildItems, cellInnerFrame, ConstructFramesFromItemList(aState, aItem.mChildItems, cellInnerFrame,
childItems); childItems);
} else { } else {
// Process the child content // Process the child content
rv = ProcessChildren(aState, content, styleContext, cellInnerFrame, rv = ProcessChildren(aState, content, styleContext, cellInnerFrame,
@@ -3699,8 +3699,8 @@ nsCSSFrameConstructor::ConstructFrameFromItemInternal(FrameConstructionItem& aIt
if (newFrame->IsFloatContainingBlock()) { if (newFrame->IsFloatContainingBlock()) {
aState.PushFloatContainingBlock(newFrame, floatSaveState); aState.PushFloatContainingBlock(newFrame, floatSaveState);
} }
rv = ConstructFramesFromItemList(aState, aItem.mChildItems, newFrame, ConstructFramesFromItemList(aState, aItem.mChildItems, newFrame,
childItems); childItems);
} else { } else {
// Process the child frames. // Process the child frames.
rv = ProcessChildren(aState, content, styleContext, newFrame, rv = ProcessChildren(aState, content, styleContext, newFrame,
@@ -4728,8 +4728,8 @@ nsCSSFrameConstructor::ConstructOuterSVG(nsFrameConstructorState& aState,
// Process children // Process children
if (aItem.mFCData->mBits & FCDATA_USE_CHILD_ITEMS) { if (aItem.mFCData->mBits & FCDATA_USE_CHILD_ITEMS) {
rv = ConstructFramesFromItemList(aState, aItem.mChildItems, ConstructFramesFromItemList(aState, aItem.mChildItems,
innerFrame, childItems); innerFrame, childItems);
} else { } else {
rv = ProcessChildren(aState, content, styleContext, innerFrame, rv = ProcessChildren(aState, content, styleContext, innerFrame,
true, childItems, false, aItem.mPendingBinding); true, childItems, false, aItem.mPendingBinding);
@@ -9875,7 +9875,7 @@ nsCSSFrameConstructor::CreateNeededTablePseudos(nsFrameConstructorState& aState,
} while (!iter.IsDone()); } while (!iter.IsDone());
} }
inline nsresult inline void
nsCSSFrameConstructor::ConstructFramesFromItemList(nsFrameConstructorState& aState, nsCSSFrameConstructor::ConstructFramesFromItemList(nsFrameConstructorState& aState,
FrameConstructionItemList& aItems, FrameConstructionItemList& aItems,
nsIFrame* aParentFrame, nsIFrame* aParentFrame,
@@ -9900,13 +9900,13 @@ nsCSSFrameConstructor::ConstructFramesFromItemList(nsFrameConstructorState& aSta
for (FCItemIterator iter(aItems); !iter.IsDone(); iter.Next()) { for (FCItemIterator iter(aItems); !iter.IsDone(); iter.Next()) {
nsresult rv = ConstructFramesFromItem(aState, iter, aParentFrame, aFrameItems); nsresult rv = ConstructFramesFromItem(aState, iter, aParentFrame, aFrameItems);
NS_ENSURE_SUCCESS(rv, rv); if (NS_FAILED(rv)) {
NS_RUNTIMEABORT("Frame construction failure");
}
} }
NS_ASSERTION(!aState.mHavePendingPopupgroup, NS_ASSERTION(!aState.mHavePendingPopupgroup,
"Should have proccessed it by now"); "Should have proccessed it by now");
return NS_OK;
} }
nsresult nsresult
@@ -10045,9 +10045,7 @@ nsCSSFrameConstructor::ProcessChildren(nsFrameConstructorState& aState,
ClearLazyBits(aContent->GetFirstChild(), nullptr); ClearLazyBits(aContent->GetFirstChild(), nullptr);
} }
rv = ConstructFramesFromItemList(aState, itemsToConstruct, aFrame, ConstructFramesFromItemList(aState, itemsToConstruct, aFrame, aFrameItems);
aFrameItems);
NS_ENSURE_SUCCESS(rv, rv);
NS_ASSERTION(!aAllowBlockStyles || !aFrame->IsBoxFrame(), NS_ASSERTION(!aAllowBlockStyles || !aFrame->IsBoxFrame(),
"can't be both block and box"); "can't be both block and box");
@@ -11149,16 +11147,7 @@ nsCSSFrameConstructor::ConstructInline(nsFrameConstructorState& aState,
// Process the child content // Process the child content
nsFrameItems childItems; nsFrameItems childItems;
nsresult rv = ConstructFramesFromItemList(aState, aItem.mChildItems, newFrame, ConstructFramesFromItemList(aState, aItem.mChildItems, newFrame, childItems);
childItems);
if (NS_FAILED(rv)) {
// Clean up.
// Link up any successfully-created child frames here, so that we'll
// clean them up as well.
newFrame->SetInitialChildList(kPrincipalList, childItems);
newFrame->Destroy();
return rv;
}
nsFrameList::FrameLinkEnumerator firstBlockEnumerator(childItems); nsFrameList::FrameLinkEnumerator firstBlockEnumerator(childItems);
if (!aItem.mIsAllInline) { if (!aItem.mIsAllInline) {
@@ -11173,11 +11162,9 @@ nsCSSFrameConstructor::ConstructInline(nsFrameConstructorState& aState,
// constructed). Just put all the kids into the single inline frame and // constructed). Just put all the kids into the single inline frame and
// bail. // bail.
newFrame->SetInitialChildList(kPrincipalList, childItems); newFrame->SetInitialChildList(kPrincipalList, childItems);
if (NS_SUCCEEDED(rv)) { aState.AddChild(newFrame, aFrameItems, content, styleContext, aParentFrame);
aState.AddChild(newFrame, aFrameItems, content, styleContext, aParentFrame); *aNewFrame = newFrame;
*aNewFrame = newFrame; return NS_OK;
}
return rv;
} }
// This inline frame contains several types of children. Therefore this frame // This inline frame contains several types of children. Therefore this frame

View File

@@ -1297,10 +1297,10 @@ private:
* Construct frames for the given item list and parent frame, and put the * Construct frames for the given item list and parent frame, and put the
* resulting frames in aFrameItems. * resulting frames in aFrameItems.
*/ */
nsresult ConstructFramesFromItemList(nsFrameConstructorState& aState, void ConstructFramesFromItemList(nsFrameConstructorState& aState,
FrameConstructionItemList& aItems, FrameConstructionItemList& aItems,
nsIFrame* aParentFrame, nsIFrame* aParentFrame,
nsFrameItems& aFrameItems); nsFrameItems& aFrameItems);
nsresult ConstructFramesFromItem(nsFrameConstructorState& aState, nsresult ConstructFramesFromItem(nsFrameConstructorState& aState,
FCItemIterator& aItem, FCItemIterator& aItem,
nsIFrame* aParentFrame, nsIFrame* aParentFrame,