Bug 1798373 Part 4 - Remove nsFrameList::SetFrames() that takes nsFrameList. r=emilio

SetFrame() is equivalent to `operator=`, so external callers can use `operator=`
instead. For the two callers wanting to set `nsFrameList` to `AbsoluteFrameList`
in `nsCSSFrameConstructor`, removing SetFrame() disallows it. However, we can
easily change the declaration from `nsFrameList` to a `AbsoluteFrameList` to
resolve the problem.

Differential Revision: https://phabricator.services.mozilla.com/D160840
This commit is contained in:
Ting-Yu Lin 2022-11-01 21:15:53 +00:00
Родитель 2d28e97d61
Коммит fc3719b5aa
8 изменённых файлов: 14 добавлений и 19 удалений

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

@ -996,7 +996,7 @@ void nsFrameConstructorState::ReparentAbsoluteItems(
MOZ_ASSERT(aNewParent->HasAnyStateBits(NS_FRAME_HAS_MULTI_COLUMN_ANCESTOR),
"Restrict the usage under column hierarchy.");
nsFrameList newAbsoluteItems;
AbsoluteFrameList newAbsoluteItems(aNewParent);
nsIFrame* current = mAbsoluteList.FirstChild();
while (current) {
@ -1020,7 +1020,7 @@ void nsFrameConstructorState::ReparentAbsoluteItems(
// It doesn't matter whether aNewParent has position style or not. Caller
// won't call us if we can't have absolute children.
PushAbsoluteContainingBlock(aNewParent, aNewParent, absoluteSaveState);
mAbsoluteList.SetFrames(newAbsoluteItems);
mAbsoluteList = std::move(newAbsoluteItems);
}
}
@ -1032,7 +1032,7 @@ void nsFrameConstructorState::ReparentFloats(nsContainerFrame* aNewParent) {
"Why calling this method if aNewParent is not a float containing block?");
// Gather floats that should reparent under aNewParent.
nsFrameList floats;
AbsoluteFrameList floats(aNewParent);
nsIFrame* current = mFloatedList.FirstChild();
while (current) {
nsIFrame* placeholder = current->GetPlaceholderFrame();
@ -1049,7 +1049,7 @@ void nsFrameConstructorState::ReparentFloats(nsContainerFrame* aNewParent) {
// ~nsFrameConstructorSaveState() when destructing floatSaveState.
nsFrameConstructorSaveState floatSaveState;
PushFloatContainingBlock(aNewParent, floatSaveState);
mFloatedList.SetFrames(floats);
mFloatedList = std::move(floats);
}
}

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

@ -54,7 +54,7 @@ void nsAbsoluteContainingBlock::SetInitialChildList(nsIFrame* aDelegatingFrame,
MOZ_ASSERT(f->GetParent() == aDelegatingFrame, "Unexpected parent");
}
#endif
mAbsoluteFrames.SetFrames(aChildList);
mAbsoluteFrames = std::move(aChildList);
}
void nsAbsoluteContainingBlock::AppendFrames(nsIFrame* aDelegatingFrame,

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

@ -7482,7 +7482,7 @@ void nsBlockFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
void nsBlockFrame::SetInitialChildList(ChildListID aListID,
nsFrameList& aChildList) {
if (kFloatList == aListID) {
mFloats.SetFrames(aChildList);
mFloats = std::move(aChildList);
} else if (kPrincipalList == aListID) {
#ifdef DEBUG
// The only times a block that is an anonymous box is allowed to have a

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

@ -85,7 +85,7 @@ void nsContainerFrame::SetInitialChildList(ChildListID aListID,
if (aListID == kPrincipalList) {
MOZ_ASSERT(mFrames.IsEmpty(),
"unexpected second call to SetInitialChildList");
mFrames.SetFrames(aChildList);
mFrames = std::move(aChildList);
} else if (aListID == kBackdropList) {
MOZ_ASSERT(StyleDisplay()->mTopLayer != StyleTopLayer::None,
"Only top layer frames should have backdrop");

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

@ -78,7 +78,7 @@ void nsFirstLetterFrame::SetInitialChildList(ChildListID aListID,
nsLayoutUtils::MarkDescendantsDirty(f); // Drops cached textruns
}
mFrames.SetFrames(aChildList);
mFrames = std::move(aChildList);
}
nsresult nsFirstLetterFrame::GetChildFrameContainingOffset(

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

@ -115,7 +115,10 @@ class nsFrameList {
}
nsFrameList& operator=(nsFrameList&& aOther) {
if (this != &aOther) {
SetFrames(aOther);
MOZ_ASSERT(IsEmpty(), "Assigning to a non-empty list will lose frames!");
mFirstChild = aOther.FirstChild();
mLastChild = aOther.LastChild();
aOther.Clear();
}
return *this;
}
@ -147,14 +150,6 @@ class nsFrameList {
void Clear() { mFirstChild = mLastChild = nullptr; }
void SetFrames(nsFrameList& aFrameList) {
MOZ_ASSERT(!mFirstChild, "Losing frames");
mFirstChild = aFrameList.FirstChild();
mLastChild = aFrameList.LastChild();
aFrameList.Clear();
}
/**
* Append aFrameList to this list. If aParent is not null,
* reparents the newly added frames. Clears out aFrameList and

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

@ -308,7 +308,7 @@ void nsInlineFrame::Reflow(nsPresContext* aPresContext, ReflowOutput& aMetrics,
// wait to do this until we actually reflow the frame. If the overflow
// list contains thousands of frames this is a big performance issue
// (see bug #5588)
mFrames.SetFrames(*prevOverflowFrames);
mFrames = std::move(*prevOverflowFrames);
lazilySetParentPointer = true;
} else {
// Insert the new frames at the beginning of the child list

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

@ -94,7 +94,7 @@ void nsTableWrapperFrame::SetInitialChildList(ChildListID aListID,
// the frame constructor already checked for table-caption display type
MOZ_ASSERT(mCaptionFrames.IsEmpty(),
"already have child frames in CaptionList");
mCaptionFrames.SetFrames(aChildList);
mCaptionFrames = std::move(aChildList);
} else {
MOZ_ASSERT(kPrincipalList != aListID ||
(aChildList.FirstChild() &&