Bug 1296516: Cleanup infallible or unchecked nsCSSFrameConstructor methods. r=heycam

MozReview-Commit-ID: IoMOQyAhadv
This commit is contained in:
Emilio Cobos Álvarez 2017-03-20 02:56:43 +01:00
Родитель c8a5bc5165
Коммит 401a3ef429
5 изменённых файлов: 195 добавлений и 239 удалений

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

@ -4526,14 +4526,14 @@ PresShell::NotifyCounterStylesAreDirty()
mFrameConstructor->EndUpdate();
}
nsresult
PresShell::ReconstructFrames(void)
void
PresShell::ReconstructFrames()
{
NS_PRECONDITION(!mFrameConstructor->GetRootFrame() || mDidInitialize,
"Must not have root frame before initial reflow");
if (!mDidInitialize || mIsDestroying) {
// Nothing to do here
return NS_OK;
return;
}
nsCOMPtr<nsIPresShell> kungFuDeathGrip(this);
@ -4543,16 +4543,14 @@ PresShell::ReconstructFrames(void)
mDocument->FlushPendingNotifications(FlushType::ContentAndNotify);
if (mIsDestroying) {
return NS_OK;
return;
}
nsAutoCauseReflowNotifier crNotifier(this);
mFrameConstructor->BeginUpdate();
nsresult rv = mFrameConstructor->ReconstructDocElementHierarchy();
mFrameConstructor->ReconstructDocElementHierarchy();
VERIFY_STYLE_TREE;
mFrameConstructor->EndUpdate();
return rv;
}
void

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

@ -188,7 +188,7 @@ public:
virtual void NotifyCounterStylesAreDirty() override;
virtual nsresult ReconstructFrames(void) override;
virtual void ReconstructFrames(void) override;
virtual void Freeze() override;
virtual void Thaw() override;
virtual void FireOrClearDelayedEvents(bool aFireEvents) override;

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

@ -3215,7 +3215,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsFrameConstructorState& aState,
* But the select tag should really be fixed to use GFX scrollbars that can
* be create with BuildScrollFrame.
*/
nsresult
void
nsCSSFrameConstructor::InitializeSelectFrame(nsFrameConstructorState& aState,
nsContainerFrame* scrollFrame,
nsContainerFrame* scrolledFrame,
@ -3261,7 +3261,6 @@ nsCSSFrameConstructor::InitializeSelectFrame(nsFrameConstructorState& aState,
// Set the scrolled frame's initial child lists
scrolledFrame->SetInitialChildList(kPrincipalList, childItems);
return NS_OK;
}
nsIFrame*
@ -6264,15 +6263,15 @@ IsRootBoxFrame(nsIFrame *aFrame)
return (aFrame->GetType() == nsGkAtoms::rootFrame);
}
nsresult
void
nsCSSFrameConstructor::ReconstructDocElementHierarchy()
{
Element* rootElement = mDocument->GetRootElement();
if (!rootElement) {
/* nothing to do */
return NS_OK;
return;
}
return RecreateFramesForContent(rootElement, false, REMOVE_FOR_RECONSTRUCTION,
RecreateFramesForContent(rootElement, false, REMOVE_FOR_RECONSTRUCTION,
nullptr);
}
@ -6523,7 +6522,7 @@ GetInsertNextSibling(nsIFrame* aParentFrame, nsIFrame* aPrevSibling)
* appending flowed frames to a parent's principal child list. It handles the
* case where the parent is the trailing inline of an {ib} split.
*/
nsresult
void
nsCSSFrameConstructor::AppendFramesToParent(nsFrameConstructorState& aState,
nsContainerFrame* aParentFrame,
nsFrameItems& aFrameList,
@ -6608,13 +6607,11 @@ nsCSSFrameConstructor::AppendFramesToParent(nsFrameConstructorState& aStat
return AppendFramesToParent(aState, aParentFrame->GetParent(), ibSiblings,
aParentFrame, true);
}
return NS_OK;
return;
}
// Insert the frames after our aPrevSibling
InsertFrames(aParentFrame, kPrincipalList, aPrevSibling, aFrameList);
return NS_OK;
}
#define UNSET_DISPLAY static_cast<StyleDisplay>(255)
@ -7383,7 +7380,7 @@ nsCSSFrameConstructor::MaybeRecreateForFrameset(nsIFrame* aParentFrame,
return false;
}
nsresult
void
nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
nsIContent* aFirstNewContent,
bool aAllowLazyConstruction,
@ -7429,8 +7426,7 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
if (tag == nsGkAtoms::treechildren ||
tag == nsGkAtoms::treeitem ||
tag == nsGkAtoms::treerow)
return NS_OK;
return;
}
#endif // MOZ_XUL
@ -7443,10 +7439,10 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
//XXXsmaug This is super unefficient!
nsIContent* bindingParent = aContainer->GetBindingParent();
LAYOUT_PHASE_TEMP_EXIT();
nsresult rv = RecreateFramesForContent(bindingParent, false,
RecreateFramesForContent(bindingParent, false,
REMOVE_FOR_RECONSTRUCTION, nullptr);
LAYOUT_PHASE_TEMP_REENTER();
return rv;
return;
}
// The frame constructor uses this codepath both for bonafide newly-added
@ -7466,7 +7462,7 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
if (isNewlyAddedContentForServo) {
aContainer->AsElement()->NoteDirtyDescendantsForServo();
}
return NS_OK;
return;
}
if (aAllowLazyConstruction &&
@ -7474,7 +7470,7 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
if (isNewlyAddedContentForServo) {
aContainer->AsElement()->NoteDirtyDescendantsForServo();
}
return NS_OK;
return;
}
// We couldn't construct lazily. Make Servo eagerly traverse the subtree.
@ -7489,13 +7485,13 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
nsContainerFrame*& parentFrame = insertion.mParentFrame;
LAYOUT_PHASE_TEMP_REENTER();
if (!parentFrame) {
return NS_OK;
return;
}
LAYOUT_PHASE_TEMP_EXIT();
if (MaybeRecreateForFrameset(parentFrame, aFirstNewContent, nullptr)) {
LAYOUT_PHASE_TEMP_REENTER();
return NS_OK;
return;
}
LAYOUT_PHASE_TEMP_REENTER();
@ -7503,15 +7499,15 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
// Nothing to do here; we shouldn't be constructing kids of leaves
// Clear lazy bits so we don't try to construct again.
ClearLazyBits(aFirstNewContent, nullptr);
return NS_OK;
return;
}
if (parentFrame->IsFrameOfType(nsIFrame::eMathML)) {
LAYOUT_PHASE_TEMP_EXIT();
nsresult rv = RecreateFramesForContent(parentFrame->GetContent(), false,
RecreateFramesForContent(parentFrame->GetContent(), false,
REMOVE_FOR_RECONSTRUCTION, nullptr);
LAYOUT_PHASE_TEMP_REENTER();
return rv;
return;
}
// If the frame we are manipulating is a ib-split frame (that is, one
@ -7618,7 +7614,7 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
if (WipeContainingBlock(state, containingBlock, parentFrame, items,
true, prevSibling)) {
LAYOUT_PHASE_TEMP_REENTER();
return NS_OK;
return;
}
LAYOUT_PHASE_TEMP_REENTER();
@ -7704,8 +7700,6 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
aFirstNewContent, nullptr);
}
#endif
return NS_OK;
}
#ifdef MOZ_XUL
@ -7748,13 +7742,13 @@ bool NotifyListBoxBody(nsPresContext* aPresContext,
}
#endif // MOZ_XUL
nsresult
void
nsCSSFrameConstructor::ContentInserted(nsIContent* aContainer,
nsIContent* aChild,
nsILayoutHistoryState* aFrameState,
bool aAllowLazyConstruction)
{
return ContentRangeInserted(aContainer,
ContentRangeInserted(aContainer,
aChild,
aChild->GetNextSibling(),
aFrameState,
@ -7779,7 +7773,7 @@ nsCSSFrameConstructor::ContentInserted(nsIContent* aContainer,
// in the caption list, while skipping any nodes in the range being inserted
// (because when we treat the caption frames the other nodes have had their
// frames constructed but not yet inserted into the frame tree).
nsresult
void
nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
nsIContent* aStartChild,
nsIContent* aEndChild,
@ -7837,7 +7831,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
// The insert case in NotifyListBoxBody
// doesn't use "old next sibling".
aStartChild, nullptr, nullptr, CONTENT_INSERTED)) {
return NS_OK;
return;
}
} else {
// We don't handle a range insert to a listbox parent, issue single
@ -7846,7 +7840,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
IssueSingleInsertNofications(aContainer, aStartChild, aEndChild,
aAllowLazyConstruction);
LAYOUT_PHASE_TEMP_REENTER();
return NS_OK;
return;
}
}
#endif // MOZ_XUL
@ -7861,7 +7855,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
if (aStartChild != docElement) {
// Not the root element; just bail out
return NS_OK;
return;
}
NS_PRECONDITION(nullptr == mRootElementFrame,
@ -7898,7 +7892,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
}
#endif
return NS_OK;
return;
}
if (aContainer->HasFlag(NODE_IS_IN_SHADOW_TREE) &&
@ -7911,10 +7905,10 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
//XXXsmaug This is super unefficient!
nsIContent* bindingParent = aContainer->GetBindingParent();
LAYOUT_PHASE_TEMP_EXIT();
nsresult rv = RecreateFramesForContent(bindingParent, false,
RecreateFramesForContent(bindingParent, false,
REMOVE_FOR_RECONSTRUCTION, nullptr);
LAYOUT_PHASE_TEMP_REENTER();
return rv;
return;
}
// The frame constructor uses this codepath both for bonafide newly-added
@ -7940,7 +7934,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
if (isNewlyAddedContentForServo) {
aContainer->AsElement()->NoteDirtyDescendantsForServo();
}
return NS_OK;
return;
}
// Otherwise, we've got parent content. Find its frame.
@ -7952,7 +7946,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
if (isNewlyAddedContentForServo) {
aContainer->AsElement()->NoteDirtyDescendantsForServo();
}
return NS_OK;
return;
}
}
@ -7977,7 +7971,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
}
if (!insertion.mParentFrame) {
return NS_OK;
return;
}
bool isAppend, isRangeInsertSafe;
@ -7991,7 +7985,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
IssueSingleInsertNofications(aContainer, aStartChild, aEndChild,
aAllowLazyConstruction);
LAYOUT_PHASE_TEMP_REENTER();
return NS_OK;
return;
}
nsIContent* container = insertion.mParentFrame->GetContent();
@ -8000,7 +7994,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
LAYOUT_PHASE_TEMP_EXIT();
if (MaybeRecreateForFrameset(insertion.mParentFrame, aStartChild, aEndChild)) {
LAYOUT_PHASE_TEMP_REENTER();
return NS_OK;
return;
}
LAYOUT_PHASE_TEMP_REENTER();
@ -8017,10 +8011,10 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
// and if so, proceed. But we'd have to extend nsFieldSetFrame
// to locate this legend in the inserted frames and extract it.
LAYOUT_PHASE_TEMP_EXIT();
nsresult rv = RecreateFramesForContent(insertion.mParentFrame->GetContent(), false,
RecreateFramesForContent(insertion.mParentFrame->GetContent(), false,
REMOVE_FOR_RECONSTRUCTION, nullptr);
LAYOUT_PHASE_TEMP_REENTER();
return rv;
return;
}
// We should only get here with details when doing a single insertion because
@ -8032,26 +8026,25 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
// expensive to recreate the entire details frame, but it's the simplest way
// to handle the insertion.
LAYOUT_PHASE_TEMP_EXIT();
nsresult rv =
RecreateFramesForContent(insertion.mParentFrame->GetContent(), false,
REMOVE_FOR_RECONSTRUCTION, nullptr);
LAYOUT_PHASE_TEMP_REENTER();
return rv;
return;
}
// Don't construct kids of leaves
if (insertion.mParentFrame->IsLeaf()) {
// Clear lazy bits so we don't try to construct again.
ClearLazyBits(aStartChild, aEndChild);
return NS_OK;
return;
}
if (insertion.mParentFrame->IsFrameOfType(nsIFrame::eMathML)) {
LAYOUT_PHASE_TEMP_EXIT();
nsresult rv = RecreateFramesForContent(insertion.mParentFrame->GetContent(), false,
RecreateFramesForContent(insertion.mParentFrame->GetContent(), false,
REMOVE_FOR_RECONSTRUCTION, nullptr);
LAYOUT_PHASE_TEMP_REENTER();
return rv;
return;
}
Maybe<TreeMatchContext> matchContext;
@ -8132,7 +8125,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
IssueSingleInsertNofications(aContainer, aStartChild, aEndChild,
aAllowLazyConstruction);
LAYOUT_PHASE_TEMP_REENTER();
return NS_OK;
return;
}
container = insertion.mParentFrame->GetContent();
@ -8200,7 +8193,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
if (WipeContainingBlock(state, containingBlock, insertion.mParentFrame, items,
isAppend, prevSibling)) {
LAYOUT_PHASE_TEMP_REENTER();
return NS_OK;
return;
}
LAYOUT_PHASE_TEMP_REENTER();
@ -8371,11 +8364,9 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
aStartChild, aEndChild);
}
#endif
return NS_OK;
}
nsresult
void
nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
nsIContent* aChild,
nsIContent* aOldNextSibling,
@ -8415,7 +8406,6 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
}
#endif
nsresult rv = NS_OK;
nsIFrame* childFrame = aChild->GetPrimaryFrame();
if (!childFrame || childFrame->GetContent() != aChild) {
// XXXbz the GetContent() != aChild check is needed due to bug 135040.
@ -8442,7 +8432,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
// XXX Perhaps even only those that belong to the aChild sub-tree?
RecreateFramesForContent(ancestor, false, aFlags, aDestroyedFramesFor);
LAYOUT_PHASE_TEMP_REENTER();
return NS_OK;
return;
}
}
@ -8450,11 +8440,10 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
for (nsIContent* c = iter.GetNextChild(); c; c = iter.GetNextChild()) {
if (c->GetPrimaryFrame() || GetDisplayContentsStyleFor(c)) {
LAYOUT_PHASE_TEMP_EXIT();
rv = ContentRemoved(aChild, c, nullptr, aFlags, aDidReconstruct, aDestroyedFramesFor);
ContentRemoved(aChild, c, nullptr, aFlags, aDidReconstruct, aDestroyedFramesFor);
LAYOUT_PHASE_TEMP_REENTER();
NS_ENSURE_SUCCESS(rv, rv);
if (aFlags != REMOVE_DESTROY_FRAMES && *aDidReconstruct) {
return rv;
return;
}
}
}
@ -8468,7 +8457,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
if (aFlags == REMOVE_DESTROY_FRAMES) {
CaptureStateForFramesOf(aChild, mTempFrameTreeState);
}
return NS_OK;
return;
}
#endif // MOZ_XUL
@ -8506,10 +8495,9 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
nsIContent* bindingParent = aContainer->GetBindingParent();
*aDidReconstruct = true;
LAYOUT_PHASE_TEMP_EXIT();
nsresult rv = RecreateFramesForContent(bindingParent, false,
aFlags, aDestroyedFramesFor);
RecreateFramesForContent(bindingParent, false, aFlags, aDestroyedFramesFor);
LAYOUT_PHASE_TEMP_REENTER();
return rv;
return;
}
if (aFlags == REMOVE_DESTROY_FRAMES) {
@ -8522,14 +8510,14 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
// See whether we need to remove more than just childFrame
LAYOUT_PHASE_TEMP_EXIT();
nsIContent* container;
if (MaybeRecreateContainerForFrameRemoval(childFrame, aFlags, &rv, &container)) {
if (MaybeRecreateContainerForFrameRemoval(childFrame, aFlags, &container)) {
LAYOUT_PHASE_TEMP_REENTER();
MOZ_ASSERT(container);
*aDidReconstruct = true;
if (aDestroyedFramesFor) {
*aDestroyedFramesFor = container;
}
return rv;
return;
}
LAYOUT_PHASE_TEMP_REENTER();
@ -8542,10 +8530,10 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
// Just reframe the parent, since framesets are weird like that.
*aDidReconstruct = true;
LAYOUT_PHASE_TEMP_EXIT();
nsresult rv = RecreateFramesForContent(parentFrame->GetContent(), false,
RecreateFramesForContent(parentFrame->GetContent(), false,
aFlags, aDestroyedFramesFor);
LAYOUT_PHASE_TEMP_REENTER();
return rv;
return;
}
// If we're a child of MathML, then we should reframe the MathML content.
@ -8556,10 +8544,10 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
if (possibleMathMLAncestor->IsFrameOfType(nsIFrame::eMathML)) {
*aDidReconstruct = true;
LAYOUT_PHASE_TEMP_EXIT();
nsresult rv = RecreateFramesForContent(possibleMathMLAncestor->GetContent(),
RecreateFramesForContent(possibleMathMLAncestor->GetContent(),
false, aFlags, aDestroyedFramesFor);
LAYOUT_PHASE_TEMP_REENTER();
return rv;
return;
}
// Undo XUL wrapping if it's no longer needed.
@ -8573,10 +8561,10 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
!AnyKidsNeedBlockParent(childFrame->GetNextSibling())) {
*aDidReconstruct = true;
LAYOUT_PHASE_TEMP_EXIT();
nsresult rv = RecreateFramesForContent(grandparentFrame->GetContent(), true,
RecreateFramesForContent(grandparentFrame->GetContent(), true,
aFlags, aDestroyedFramesFor);
LAYOUT_PHASE_TEMP_REENTER();
return rv;
return;
}
#ifdef ACCESSIBILITY
@ -8620,7 +8608,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
// XXXbz the GetContent() != aChild check is needed due to bug 135040.
// Remove it once that's fixed.
ClearUndisplayedContentIn(aChild, aContainer);
return NS_OK;
return;
}
parentFrame = childFrame->GetParent();
parentType = parentFrame->GetType();
@ -8708,8 +8696,6 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
}
#endif
}
return rv;
}
/**
@ -8771,12 +8757,11 @@ nsCSSFrameConstructor::EnsureFrameForTextNode(nsGenericDOMDataNode* aContent)
return aContent->GetPrimaryFrame();
}
nsresult
void
nsCSSFrameConstructor::CharacterDataChanged(nsIContent* aContent,
CharacterDataChangeInfo* aInfo)
{
AUTO_LAYOUT_PHASE_ENTRY_POINT(mPresShell->GetPresContext(), FrameC);
nsresult rv = NS_OK;
if ((aContent->HasFlag(NS_CREATE_FRAME_IF_NON_WHITESPACE) &&
!aContent->TextIsOnlyWhitespace()) ||
@ -8788,10 +8773,10 @@ nsCSSFrameConstructor::CharacterDataChanged(nsIContent* aContent,
"Bit should never be set on generated content");
#endif
LAYOUT_PHASE_TEMP_EXIT();
nsresult rv = RecreateFramesForContent(aContent, false,
RecreateFramesForContent(aContent, false,
REMOVE_FOR_RECONSTRUCTION, nullptr);
LAYOUT_PHASE_TEMP_REENTER();
return rv;
return;
}
// Find the child frame
@ -8839,8 +8824,6 @@ nsCSSFrameConstructor::CharacterDataChanged(nsIContent* aContent,
RecoverLetterFrames(block);
}
}
return rv;
}
void
@ -9507,12 +9490,10 @@ FindPreviousNonWhitespaceSibling(nsIFrame* aFrame)
bool
nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame,
RemoveFlags aFlags,
nsresult* aResult,
nsIContent** aDestroyedFramesFor)
{
NS_PRECONDITION(aFrame, "Must have a frame");
NS_PRECONDITION(aFrame->GetParent(), "Frame shouldn't be root");
NS_PRECONDITION(aResult, "Null out param?");
NS_PRECONDITION(aFrame == aFrame->FirstContinuation(),
"aFrame not the result of GetPrimaryFrame()?");
@ -9530,7 +9511,7 @@ nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame,
}
#endif
*aResult = ReframeContainingBlock(aFrame, aFlags, aDestroyedFramesFor);
ReframeContainingBlock(aFrame, aFlags, aDestroyedFramesFor);
return true;
}
@ -9539,7 +9520,7 @@ nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame,
aFrame->GetParent()->GetType() == nsGkAtoms::fieldSetFrame) {
// When we remove the legend for a fieldset, we should reframe
// the fieldset to ensure another legend is used, if there is one
*aResult = RecreateFramesForContent(aFrame->GetParent()->GetContent(), false,
RecreateFramesForContent(aFrame->GetParent()->GetContent(), false,
aFlags, aDestroyedFramesFor);
return true;
}
@ -9553,7 +9534,7 @@ nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame,
// When removing a summary, we should reframe the parent details frame to
// ensure that another summary is used or the default summary is
// generated.
*aResult = RecreateFramesForContent(aFrame->GetParent()->GetContent(),
RecreateFramesForContent(aFrame->GetParent()->GetContent(),
false, REMOVE_FOR_RECONSTRUCTION,
aDestroyedFramesFor);
return true;
@ -9587,7 +9568,7 @@ nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame,
parent->GetChildList(nsIFrame::kCaptionList).FirstChild() == inFlowFrame)) {
// We're the first or last frame in the pseudo. Need to reframe.
// Good enough to recreate frames for |parent|'s content
*aResult = RecreateFramesForContent(parent->GetContent(), true, aFlags,
RecreateFramesForContent(parent->GetContent(), true, aFlags,
aDestroyedFramesFor);
return true;
}
@ -9617,7 +9598,7 @@ nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame,
#endif
// Good enough to recreate frames for aFrame's parent's content; even if
// aFrame's parent is a pseudo, that'll be the right content node.
*aResult = RecreateFramesForContent(parent->GetContent(), true, aFlags,
RecreateFramesForContent(parent->GetContent(), true, aFlags,
aDestroyedFramesFor);
return true;
}
@ -9634,7 +9615,7 @@ nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame,
// frames may be constructed or destroyed accordingly.
// 2. The type of the first child of a ruby frame determines
// whether a pseudo ruby base container should exist.
*aResult = RecreateFramesForContent(parent->GetContent(), true, aFlags,
RecreateFramesForContent(parent->GetContent(), true, aFlags,
aDestroyedFramesFor);
return true;
}
@ -9658,7 +9639,7 @@ nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame,
}
#endif // DEBUG
// Recreate frames for the flex container (the removed frame's parent)
*aResult = RecreateFramesForContent(parent->GetContent(), true, aFlags,
RecreateFramesForContent(parent->GetContent(), true, aFlags,
aDestroyedFramesFor);
return true;
}
@ -9677,7 +9658,7 @@ nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame,
}
#endif // DEBUG
// Recreate frames for the flex container (the removed frame's grandparent)
*aResult = RecreateFramesForContent(parent->GetParent()->GetContent(), true,
RecreateFramesForContent(parent->GetParent()->GetContent(), true,
aFlags, aDestroyedFramesFor);
return true;
}
@ -9686,7 +9667,7 @@ nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame,
if (aFrame->GetType() == nsGkAtoms::popupSetFrame) {
nsIRootBox* rootBox = nsIRootBox::GetRootBox(mPresShell);
if (rootBox && rootBox->GetPopupSetFrame() == aFrame) {
*aResult = ReconstructDocElementHierarchy();
ReconstructDocElementHierarchy();
return true;
}
}
@ -9698,7 +9679,7 @@ nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame,
!inFlowFrame->GetNextSibling() &&
((parent->GetPrevContinuation() && !parent->GetPrevInFlow()) ||
(parent->GetNextContinuation() && !parent->GetNextInFlow()))) {
*aResult = RecreateFramesForContent(parent->GetContent(), true, aFlags,
RecreateFramesForContent(parent->GetContent(), true, aFlags,
aDestroyedFramesFor);
return true;
}
@ -9735,11 +9716,11 @@ nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame,
}
#endif
*aResult = ReframeContainingBlock(parent, aFlags, aDestroyedFramesFor);
ReframeContainingBlock(parent, aFlags, aDestroyedFramesFor);
return true;
}
nsresult
void
nsCSSFrameConstructor::RecreateFramesForContent(nsIContent* aContent,
bool aAsyncInsert,
RemoveFlags aFlags,
@ -9752,7 +9733,9 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIContent* aContent,
// anyway).
// Rebuilding the frame tree can have bad effects, especially if it's the
// frame tree for chrome (see bug 157322).
NS_ENSURE_TRUE(aContent->GetComposedDoc(), NS_ERROR_FAILURE);
if (NS_WARN_IF(!aContent->GetComposedDoc())) {
return;
}
// Is the frame ib-split? If so, we need to reframe the containing
// block *here*, rather than trying to remove and re-insert the
@ -9816,15 +9799,14 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIContent* aContent,
}
}
nsresult rv = NS_OK;
nsIContent* container;
if (frame && MaybeRecreateContainerForFrameRemoval(frame, aFlags, &rv,
if (frame && MaybeRecreateContainerForFrameRemoval(frame, aFlags,
&container)) {
MOZ_ASSERT(container);
if (aDestroyedFramesFor) {
*aDestroyedFramesFor = container;
}
return rv;
return;
}
nsINode* containerNode = aContent->GetParentNode();
@ -9844,11 +9826,8 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIContent* aContent,
nullptr : aContent->GetNextSibling();
const bool reconstruct = aFlags != REMOVE_DESTROY_FRAMES;
RemoveFlags flags = reconstruct ? REMOVE_FOR_RECONSTRUCTION : aFlags;
rv = ContentRemoved(container, aContent, nextSibling, flags,
ContentRemoved(container, aContent, nextSibling, flags,
&didReconstruct, aDestroyedFramesFor);
if (NS_FAILED(rv)) {
return rv;
}
if (reconstruct && !didReconstruct) {
// Now, recreate the frames associated with this content object. If
// ContentRemoved triggered reconstruction, then we don't need to do this
@ -9858,12 +9837,10 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIContent* aContent,
RestyleManager()->PostRestyleEvent(
aContent->AsElement(), nsRestyleHint(0), nsChangeHint_ReconstructFrame);
} else {
rv = ContentInserted(container, aContent, mTempFrameTreeState, false);
ContentInserted(container, aContent, mTempFrameTreeState, false);
}
}
}
return rv;
}
void
@ -11271,7 +11248,7 @@ nsCSSFrameConstructor::AppendFirstLineFrames(
// Special routine to handle inserting a new frame into a block
// frame's child list. Takes care of placing the new frame into the
// right place when first-line style is present.
nsresult
void
nsCSSFrameConstructor::InsertFirstLineFrames(
nsFrameConstructorState& aState,
nsIContent* aContent,
@ -11280,7 +11257,6 @@ nsCSSFrameConstructor::InsertFirstLineFrames(
nsIFrame* aPrevSibling,
nsFrameItems& aFrameItems)
{
nsresult rv = NS_OK;
// XXXbz If you make this method actually do something, check to
// make sure that the caller is passing what you expect. In
// particular, which content is aContent? And audit the rest of
@ -11410,7 +11386,6 @@ nsCSSFrameConstructor::InsertFirstLineFrames(
}
#endif
return rv;
}
//----------------------------------------------------------------------
@ -11737,7 +11712,7 @@ FindFirstLetterFrame(nsIFrame* aFrame, nsIFrame::ChildListID aListID)
return nullptr;
}
nsresult
void
nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames(
nsIPresShell* aPresShell,
nsIFrame* aBlockFrame)
@ -11749,7 +11724,7 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames(
floatFrame =
::FindFirstLetterFrame(aBlockFrame, nsIFrame::kPushedFloatsList);
if (!floatFrame) {
return NS_OK;
return;
}
}
@ -11757,19 +11732,19 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames(
// destroyed when we destroy the letter frame).
nsIFrame* textFrame = floatFrame->PrincipalChildList().FirstChild();
if (!textFrame) {
return NS_OK;
return;
}
// Discover the placeholder frame for the letter frame
nsPlaceholderFrame* placeholderFrame = GetPlaceholderFrameFor(floatFrame);
if (!placeholderFrame) {
// Somethings really wrong
return NS_OK;
return;
}
nsContainerFrame* parentFrame = placeholderFrame->GetParent();
if (!parentFrame) {
// Somethings really wrong
return NS_OK;
return;
}
// Create a new text frame with the right style context that maps
@ -11778,7 +11753,7 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames(
nsStyleContext* parentSC = parentFrame->StyleContext();
nsIContent* textContent = textFrame->GetContent();
if (!textContent) {
return NS_OK;
return;
}
RefPtr<nsStyleContext> newSC = aPresShell->StyleSet()->
ResolveStyleForText(textContent, parentSC);
@ -11823,11 +11798,9 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames(
if (offsetsNeedFixing) {
prevSibling->RemoveStateBits(TEXT_OFFSETS_NEED_FIXING);
}
return NS_OK;
}
nsresult
void
nsCSSFrameConstructor::RemoveFirstLetterFrames(nsIPresShell* aPresShell,
nsContainerFrame* aFrame,
nsContainerFrame* aBlockFrame,
@ -11900,11 +11873,9 @@ nsCSSFrameConstructor::RemoveFirstLetterFrames(nsIPresShell* aPresShell,
prevSibling = kid;
kid = kid->GetNextSibling();
}
return NS_OK;
}
nsresult
void
nsCSSFrameConstructor::RemoveLetterFrames(nsIPresShell* aPresShell,
nsContainerFrame* aBlockFrame)
{
@ -11913,20 +11884,16 @@ nsCSSFrameConstructor::RemoveLetterFrames(nsIPresShell* aPresShell,
nsContainerFrame* continuation = aBlockFrame;
bool stopLooking = false;
nsresult rv;
do {
rv = RemoveFloatingFirstLetterFrames(aPresShell, continuation);
if (NS_SUCCEEDED(rv)) {
rv = RemoveFirstLetterFrames(aPresShell,
continuation, aBlockFrame, &stopLooking);
}
RemoveFloatingFirstLetterFrames(aPresShell, continuation);
RemoveFirstLetterFrames(aPresShell, continuation, aBlockFrame,
&stopLooking);
if (stopLooking) {
break;
}
continuation =
static_cast<nsContainerFrame*>(continuation->GetNextContinuation());
} while (continuation);
return rv;
}
// Fixup the letter frame situation for the given block
@ -11969,7 +11936,7 @@ nsCSSFrameConstructor::RecoverLetterFrames(nsContainerFrame* aBlockFrame)
// listbox Widget Routines
nsresult
void
nsCSSFrameConstructor::CreateListBoxContent(nsContainerFrame* aParentFrame,
nsIFrame* aPrevFrame,
nsIContent* aChild,
@ -11977,8 +11944,6 @@ nsCSSFrameConstructor::CreateListBoxContent(nsContainerFrame* aParentFrame,
bool aIsAppend)
{
#ifdef MOZ_XUL
nsresult rv = NS_OK;
// Construct a new frame
if (nullptr != aParentFrame) {
nsFrameItems frameItems;
@ -12002,7 +11967,7 @@ nsCSSFrameConstructor::CreateListBoxContent(nsContainerFrame* aParentFrame,
if (StyleDisplay::None == display->mDisplay) {
*aNewFrame = nullptr;
return NS_OK;
return;
}
BeginUpdate();
@ -12021,9 +11986,9 @@ nsCSSFrameConstructor::CreateListBoxContent(nsContainerFrame* aParentFrame,
if (newFrame) {
// Notify the parent frame
if (aIsAppend)
rv = ((nsListBoxBodyFrame*)aParentFrame)->ListBoxAppendFrames(frameItems);
((nsListBoxBodyFrame*)aParentFrame)->ListBoxAppendFrames(frameItems);
else
rv = ((nsListBoxBodyFrame*)aParentFrame)->ListBoxInsertFrames(aPrevFrame, frameItems);
((nsListBoxBodyFrame*)aParentFrame)->ListBoxInsertFrames(aPrevFrame, frameItems);
}
EndUpdate();
@ -12038,10 +12003,6 @@ nsCSSFrameConstructor::CreateListBoxContent(nsContainerFrame* aParentFrame,
}
#endif
}
return rv;
#else
return NS_ERROR_FAILURE;
#endif
}
@ -12815,7 +12776,7 @@ nsCSSFrameConstructor::WipeContainingBlock(nsFrameConstructorState& aState,
return true;
}
nsresult
void
nsCSSFrameConstructor::ReframeContainingBlock(nsIFrame* aFrame,
RemoveFlags aFlags,
nsIContent** aDestroyedFramesFor)
@ -12838,7 +12799,7 @@ nsCSSFrameConstructor::ReframeContainingBlock(nsIFrame* aFrame,
// don't ReframeContainingBlock, this will result in a crash
// if we remove a tree that's in reflow - see bug 121368 for testcase
NS_ERROR("Atemptted to nsCSSFrameConstructor::ReframeContainingBlock during a Reflow!!!");
return NS_OK;
return;
}
// Get the first "normal" ancestor of the target frame.
@ -12870,7 +12831,7 @@ nsCSSFrameConstructor::ReframeContainingBlock(nsIFrame* aFrame,
true, aFlags, nullptr);
}
nsresult
void
nsCSSFrameConstructor::GenerateChildFrames(nsContainerFrame* aFrame)
{
{
@ -12905,8 +12866,6 @@ nsCSSFrameConstructor::GenerateChildFrames(nsContainerFrame* aFrame)
// call XBL constructors after the frames are created
mPresShell->GetDocument()->BindingManager()->ProcessAttachedQueue();
return NS_OK;
}
//////////////////////////////////////////////////////////

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

@ -48,7 +48,7 @@ class FlattenedChildIterator;
} // namespace dom
} // namespace mozilla
class nsCSSFrameConstructor : public nsFrameManager
class nsCSSFrameConstructor final : public nsFrameManager
{
public:
typedef mozilla::CSSPseudoElementType CSSPseudoElementType;
@ -60,7 +60,7 @@ public:
nsCSSFrameConstructor(nsIDocument* aDocument, nsIPresShell* aPresShell);
~nsCSSFrameConstructor(void) {
NS_ASSERTION(mUpdateCount == 0, "Dying in the middle of our own update?");
MOZ_ASSERT(mUpdateCount == 0, "Dying in the middle of our own update?");
}
// get the alternate text for a content node
@ -78,7 +78,7 @@ public:
nsIFrame* ConstructRootFrame();
nsresult ReconstructDocElementHierarchy();
void ReconstructDocElementHierarchy();
// Create frames for content nodes that are marked as needing frames. This
// should be called before ProcessPendingRestyles.
@ -208,14 +208,14 @@ public:
// much easier way than nsFrameConstructorState, and thus, we're allowed to
// provide a TreeMatchContext to avoid calling InitAncestors repeatedly deep
// in the DOM.
nsresult ContentAppended(nsIContent* aContainer,
void ContentAppended(nsIContent* aContainer,
nsIContent* aFirstNewContent,
bool aAllowLazyConstruction,
TreeMatchContext* aProvidedTreeMatchContext = nullptr);
// If aAllowLazyConstruction is true then frame construction of the new child
// can be done lazily.
nsresult ContentInserted(nsIContent* aContainer,
void ContentInserted(nsIContent* aContainer,
nsIContent* aChild,
nsILayoutHistoryState* aFrameState,
bool aAllowLazyConstruction);
@ -231,7 +231,7 @@ public:
//
// See ContentAppended to see why we allow passing an already initialized
// TreeMatchContext.
nsresult ContentRangeInserted(nsIContent* aContainer,
void ContentRangeInserted(nsIContent* aContainer,
nsIContent* aStartChild,
nsIContent* aEndChild,
nsILayoutHistoryState* aFrameState,
@ -256,14 +256,14 @@ public:
* only when aFlags == REMOVE_DESTROY_FRAMES, otherwise it will only be
* captured if we reconstructed frames for an ancestor.
*/
nsresult ContentRemoved(nsIContent* aContainer,
void ContentRemoved(nsIContent* aContainer,
nsIContent* aChild,
nsIContent* aOldNextSibling,
RemoveFlags aFlags,
bool* aDidReconstruct,
nsIContent** aDestroyedFramesFor = nullptr);
nsresult CharacterDataChanged(nsIContent* aContent,
void CharacterDataChanged(nsIContent* aContent,
CharacterDataChangeInfo* aInfo);
// If aContent is a text node that has been optimized away due to being
@ -273,8 +273,8 @@ public:
// Returns the frame for aContent if there is one.
nsIFrame* EnsureFrameForTextNode(nsGenericDOMDataNode* aContent);
// generate the child frames and process bindings
nsresult GenerateChildFrames(nsContainerFrame* aFrame);
// Generate the child frames and process bindings
void GenerateChildFrames(nsContainerFrame* aFrame);
// Should be called when a frame is going to be destroyed and
// WillDestroyFrameTree hasn't been called yet.
@ -316,7 +316,7 @@ public:
*/
InsertionPoint GetInsertionPoint(nsIContent* aContainer, nsIContent* aChild);
nsresult CreateListBoxContent(nsContainerFrame* aParentFrame,
void CreateListBoxContent(nsContainerFrame* aParentFrame,
nsIFrame* aPrevFrame,
nsIContent* aChild,
nsIFrame** aResult,
@ -432,7 +432,7 @@ private:
* @param [out] aNewContent the content node we create
* @param [out] aNewFrame the new frame we create
*/
nsresult CreateAttributeContent(nsIContent* aParentContent,
void CreateAttributeContent(nsIContent* aParentContent,
nsIFrame* aParentFrame,
int32_t aAttrNamespace,
nsIAtom* aAttrName,
@ -477,7 +477,7 @@ private:
// aParentFrame. aPrevSibling must be the frame after which aFrameList is to
// be placed on aParentFrame's principal child list. It may be null if
// aFrameList is being added at the beginning of the child list.
nsresult AppendFramesToParent(nsFrameConstructorState& aState,
void AppendFramesToParent(nsFrameConstructorState& aState,
nsContainerFrame* aParentFrame,
nsFrameItems& aFrameList,
nsIFrame* aPrevSibling,
@ -1703,7 +1703,7 @@ private:
// InitializeSelectFrame puts scrollFrame in aFrameItems if aBuildCombobox is false
// aBuildCombobox indicates if we are building a combobox that has a dropdown
// popup widget or not.
nsresult
void
InitializeSelectFrame(nsFrameConstructorState& aState,
nsContainerFrame* aScrollFrame,
nsContainerFrame* aScrolledFrame,
@ -1732,7 +1732,7 @@ private:
* @param aDestroyedFramesFor if non-null, it will contain the content that
* was actually reframed - it may be different than aContent.
*/
nsresult
void
RecreateFramesForContent(nsIContent* aContent,
bool aAsyncInsert,
RemoveFlags aFlags,
@ -1750,7 +1750,6 @@ private:
// content that was reframed.
bool MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame,
RemoveFlags aFlags,
nsresult* aResult,
nsIContent** aDestroyedFramesFor);
nsIFrame* CreateContinuingOuterTableFrame(nsIPresShell* aPresShell,
@ -1875,7 +1874,7 @@ private:
bool aIsAppend,
nsIFrame* aPrevSibling);
nsresult ReframeContainingBlock(nsIFrame* aFrame,
void ReframeContainingBlock(nsIFrame* aFrame,
RemoveFlags aFlags,
nsIContent** aReframeContent);
@ -1931,17 +1930,17 @@ private:
void RecoverLetterFrames(nsContainerFrame* aBlockFrame);
//
nsresult RemoveLetterFrames(nsIPresShell* aPresShell,
void RemoveLetterFrames(nsIPresShell* aPresShell,
nsContainerFrame* aBlockFrame);
// Recursive helper for RemoveLetterFrames
nsresult RemoveFirstLetterFrames(nsIPresShell* aPresShell,
void RemoveFirstLetterFrames(nsIPresShell* aPresShell,
nsContainerFrame* aFrame,
nsContainerFrame* aBlockFrame,
bool* aStopLooking);
// Special remove method for those pesky floating first-letter frames
nsresult RemoveFloatingFirstLetterFrames(nsIPresShell* aPresShell,
void RemoveFloatingFirstLetterFrames(nsIPresShell* aPresShell,
nsIFrame* aBlockFrame);
// Capture state for the frame tree rooted at the frame associated with the
@ -1973,7 +1972,7 @@ private:
nsContainerFrame* aBlockFrame,
nsFrameItems& aFrameItems);
nsresult InsertFirstLineFrames(nsFrameConstructorState& aState,
void InsertFirstLineFrames(nsFrameConstructorState& aState,
nsIContent* aContent,
nsIFrame* aBlockFrame,
nsContainerFrame** aParentFrame,

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

@ -1022,7 +1022,7 @@ public:
/**
* Reconstruct frames for all elements in the document
*/
virtual nsresult ReconstructFrames() = 0;
virtual void ReconstructFrames() = 0;
/**
* Notify that a content node's state has changed