Bug 1714584 - Part 2: Remove nsDisplayList::RemoveBottom() r=mstange

Differential Revision: https://phabricator.services.mozilla.com/D138153
This commit is contained in:
Miko Mynttinen 2022-02-22 00:44:25 +00:00
Родитель 28474c7ad2
Коммит 0bd7fc8c56
7 изменённых файлов: 30 добавлений и 58 удалений

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

@ -4692,12 +4692,10 @@ nsRect PresShell::ClipListToRange(nsDisplayListBuilder* aBuilder,
// part of the selection. Then, append the wrapper to the top of the list.
// Otherwise, just delete the item and don't append it.
nsRect surfaceRect;
nsDisplayList tmpList;
nsDisplayItem* i;
while ((i = aList->RemoveBottom())) {
for (nsDisplayItem* i : aList->TakeItems()) {
if (i->GetType() == DisplayItemType::TYPE_CONTAINER) {
tmpList.AppendToTop(i);
aList->AppendToTop(i);
surfaceRect.UnionRect(
surfaceRect, ClipListToRange(aBuilder, i->GetChildren(), aRange));
continue;
@ -4778,7 +4776,7 @@ nsRect PresShell::ClipListToRange(nsDisplayListBuilder* aBuilder,
// list, insert that as well
nsDisplayList* sublist = i->GetSameCoordinateSystemChildren();
if (itemToInsert || sublist) {
tmpList.AppendToTop(itemToInsert ? itemToInsert : i);
aList->AppendToTop(itemToInsert ? itemToInsert : i);
// if the item is a list, iterate over it as well
if (sublist)
surfaceRect.UnionRect(surfaceRect,
@ -4789,9 +4787,6 @@ nsRect PresShell::ClipListToRange(nsDisplayListBuilder* aBuilder,
}
}
// now add all the items back onto the original list again
aList->AppendToTop(&tmpList);
return surfaceRect;
}

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

@ -766,9 +766,7 @@ void TextOverflow::ProcessLine(const nsDisplayListSet& aLists, nsLineBox* aLine,
void TextOverflow::PruneDisplayListContents(
nsDisplayList* aList, const FrameHashtable& aFramesToHide,
const LogicalRect& aInsideMarkersArea) {
nsDisplayList saved;
nsDisplayItem* item;
while ((item = aList->RemoveBottom())) {
for (nsDisplayItem* item : aList->TakeItems()) {
nsIFrame* itemFrame = item->Frame();
if (IsFrameDescendantOfAny(itemFrame, aFramesToHide, mBlock)) {
item->Destroy(mBuilder);
@ -804,9 +802,8 @@ void TextOverflow::PruneDisplayListContents(
}
}
saved.AppendToTop(item);
aList->AppendToTop(item);
}
aList->AppendToTop(&saved);
}
/* static */

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

@ -3702,7 +3702,8 @@ void nsIFrame::BuildDisplayListForStackingContext(
nsDisplayItem* separator = nullptr;
while (nsDisplayItem* item = resultList.RemoveBottom()) {
// TODO: This can be simplified: |participants| is just |resultList|.
for (nsDisplayItem* item : resultList.TakeItems()) {
if (ItemParticipatesIn3DContext(this, item) &&
!item->GetClip().HasClip()) {
// The frame of this item participates the same 3D context.
@ -3883,7 +3884,8 @@ void nsIFrame::BuildDisplayListForStackingContext(
container = MakeDisplayItem<nsDisplayContainer>(
aBuilder, this, containerItemASR, &resultList);
} else {
container = resultList.RemoveBottom();
MOZ_ASSERT(resultList.Length() == 1);
resultList.Clear();
}
// Mark the outermost display item as reusable. These display items and
@ -3923,7 +3925,8 @@ static nsDisplayItem* WrapInWrapList(nsDisplayListBuilder* aBuilder,
// invalidation) or we're doing a full build and don't need a wrap list, then
// we can skip adding one.
if (aBuiltContainerItem || (!aBuilder->IsPartialUpdate() && !needsWrapList)) {
aList->RemoveBottom();
MOZ_ASSERT(aList->Length() == 1);
aList->Clear();
return item;
}
@ -3940,7 +3943,8 @@ static nsDisplayItem* WrapInWrapList(nsDisplayListBuilder* aBuilder,
if (needsWrapList) {
DiscardOldItems(aFrame);
} else {
aList->RemoveBottom();
MOZ_ASSERT(aList->Length() == 1);
aList->Clear();
return item;
}
}

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

@ -267,10 +267,7 @@ static void BuildPreviousPageOverflow(nsDisplayListBuilder* aBuilder,
static void PruneDisplayListForExtraPage(nsDisplayListBuilder* aBuilder,
nsPageFrame* aPage,
nsDisplayList* aList) {
nsDisplayList newList;
while (true) {
nsDisplayItem* i = aList->RemoveBottom();
for (nsDisplayItem* i : aList->TakeItems()) {
if (!i) break;
nsDisplayList* subList = i->GetSameCoordinateSystemChildren();
if (subList) {
@ -285,9 +282,8 @@ static void PruneDisplayListForExtraPage(nsDisplayListBuilder* aBuilder,
continue;
}
}
newList.AppendToTop(i);
aList->AppendToTop(i);
}
aList->AppendToTop(&newList);
}
static void BuildDisplayListForExtraPage(nsDisplayListBuilder* aBuilder,

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

@ -306,9 +306,7 @@ ScreenIntSize nsSubDocumentFrame::GetSubdocumentSize() {
static void WrapBackgroundColorInOwnLayer(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame,
nsDisplayList* aList) {
nsDisplayList tempItems;
nsDisplayItem* item;
while ((item = aList->RemoveBottom()) != nullptr) {
for (nsDisplayItem* item : aList->TakeItems()) {
if (item->GetType() == DisplayItemType::TYPE_BACKGROUND_COLOR) {
nsDisplayList tmpList(aBuilder);
tmpList.AppendToTop(item);
@ -317,11 +315,8 @@ static void WrapBackgroundColorInOwnLayer(nsDisplayListBuilder* aBuilder,
&tmpList, aBuilder->CurrentActiveScrolledRoot(),
nsDisplayOwnLayerFlags::None, ScrollbarData{}, true, false);
}
if (item) {
tempItems.AppendToTop(item);
}
aList->AppendToTop(item);
}
aList->AppendToTop(&tempItems);
}
void nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,

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

@ -203,10 +203,8 @@ bool RetainedDisplayListBuilder::PreProcessDisplayList(
aList->mDAG.Length() ==
(initializeOldItems ? aList->Length() : aList->mOldItems.Length()));
nsDisplayList out;
size_t i = 0;
while (nsDisplayItem* item = aList->RemoveBottom()) {
for (nsDisplayItem* item : aList->TakeItems()) {
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
item->SetMergedPreProcessed(false, true);
#endif
@ -343,16 +341,13 @@ bool RetainedDisplayListBuilder::PreProcessDisplayList(
if (item->GetType() == DisplayItemType::TYPE_SUBDOCUMENT) {
IncrementSubDocPresShellPaintCount(item);
}
out.AppendToTop(item);
aList->AppendToTop(item);
}
i++;
}
MOZ_RELEASE_ASSERT(aList->mOldItems.Length() == aList->mDAG.Length());
if (aKeepLinked) {
aList->AppendToTop(&out);
}
return true;
}
@ -856,7 +851,7 @@ bool RetainedDisplayListBuilder::MergeDisplayLists(
MergeState merge(this, *aOldList, aOuterItem);
Maybe<MergedListIndex> previousItemIndex;
while (nsDisplayItem* item = aNewList->RemoveBottom()) {
for (nsDisplayItem* item : aNewList->TakeItems()) {
Metrics()->mNewItems++;
previousItemIndex = merge.ProcessItemFromNewList(item, previousItemIndex);
}
@ -1561,9 +1556,7 @@ bool IsReuseableStackingContextItem(nsDisplayItem* aItem) {
void CollectStackingContextItems(nsDisplayListBuilder* aBuilder,
nsDisplayList* aList, nsIFrame* aOuterFrame,
int aDepth = 0, bool aParentReused = false) {
nsDisplayList out;
for (nsDisplayItem* item : *aList) {
for (nsDisplayItem* item : aList->TakeItems()) {
if (DL_LOG_TEST(LogLevel::Debug)) {
DL_LOGD(
"%*s Preprocessing item %p (%s) (frame: %p) "
@ -1600,7 +1593,7 @@ void CollectStackingContextItems(nsDisplayListBuilder* aBuilder,
if (aParentReused) {
// Keep the contents of the current container item linked.
RDLUtils::AssertDisplayItemUnmodified(item);
out.AppendToTop(item);
aList->AppendToTop(item);
} else if (isStackingContextItem) {
// |item| is a stacking context item that can be reused.
ReuseStackingContextItem(aBuilder, item);
@ -1615,9 +1608,6 @@ void CollectStackingContextItems(nsDisplayListBuilder* aBuilder,
IncrementPresShellPaintCount(aBuilder, item);
}
}
aList->Clear();
aList->AppendToTop(&out);
}
} // namespace RDL

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

@ -2326,8 +2326,7 @@ void nsDisplayList::PaintRoot(nsDisplayListBuilder* aBuilder, gfxContext* aCtx,
}
void nsDisplayList::DeleteAll(nsDisplayListBuilder* aBuilder) {
nsDisplayItem* item;
while ((item = RemoveBottom()) != nullptr) {
for (auto* item : TakeItems()) {
item->Destroy(aBuilder);
}
}
@ -4674,17 +4673,14 @@ static nsresult WrapDisplayList(nsDisplayListBuilder* aBuilder,
static nsresult WrapEachDisplayItem(nsDisplayListBuilder* aBuilder,
nsDisplayList* aList,
nsDisplayItemWrapper* aWrapper) {
nsDisplayList newList;
nsDisplayItem* item;
while ((item = aList->RemoveBottom())) {
for (nsDisplayItem* item : aList->TakeItems()) {
item = aWrapper->WrapItem(aBuilder, item);
if (!item) {
return NS_ERROR_OUT_OF_MEMORY;
}
newList.AppendToTop(item);
aList->AppendToTop(item);
}
// aList was emptied
aList->AppendToTop(&newList);
return NS_OK;
}
@ -8543,15 +8539,14 @@ void nsDisplayListCollection::SerializeWithCorrectZOrder(
// 1,2: backgrounds and borders
aOutResultList->AppendToTop(BorderBackground());
// 3: negative z-index children.
for (;;) {
nsDisplayItem* item = PositionedDescendants()->GetBottom();
if (item && item->ZIndex() < 0) {
PositionedDescendants()->RemoveBottom();
for (auto* item : PositionedDescendants()->TakeItems()) {
if (item->ZIndex() < 0) {
aOutResultList->AppendToTop(item);
continue;
} else {
PositionedDescendants()->AppendToTop(item);
}
break;
}
// 4: block backgrounds
aOutResultList->AppendToTop(BlockBorderBackgrounds());
// 5: floats