diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index 0294e285ea02..9f95332609d8 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -5219,8 +5219,8 @@ PresShell::AddPrintPreviewBackgroundItem(nsDisplayListBuilder& aBuilder, nsIFrame* aFrame, const nsRect& aBounds) { - aList.AppendToBottom(new (&aBuilder) - nsDisplaySolidColor(&aBuilder, aFrame, aBounds, NS_RGB(115, 115, 115))); + aList.AppendToBottom( + MakeDisplayItem(&aBuilder, aFrame, aBounds, NS_RGB(115, 115, 115))); } static bool @@ -5310,7 +5310,7 @@ PresShell::AddCanvasBackgroundColorItem(nsDisplayListBuilder& aBuilder, if (!addedScrollingBackgroundColor || forceUnscrolledItem) { aList.AppendToBottom( - new (&aBuilder) nsDisplaySolidColor(&aBuilder, aFrame, aBounds, bgcolor)); + MakeDisplayItem(&aBuilder, aFrame, aBounds, bgcolor)); } } diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index c4a549386dbe..d5a440158650 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -3021,7 +3021,7 @@ nsLayoutUtils::GetLayerTransformForFrame(nsIFrame* aFrame, builder.BeginFrame(); nsDisplayList list; nsDisplayTransform* item = - new (&builder) nsDisplayTransform(&builder, aFrame, &list, nsRect()); + MakeDisplayItem(&builder, aFrame, &list, nsRect()); *aTransform = item->GetTransform(); item->Destroy(&builder); diff --git a/layout/forms/nsButtonFrameRenderer.cpp b/layout/forms/nsButtonFrameRenderer.cpp index 3148be618d86..7bc01f43073e 100644 --- a/layout/forms/nsButtonFrameRenderer.cpp +++ b/layout/forms/nsButtonFrameRenderer.cpp @@ -477,8 +477,8 @@ nsButtonFrameRenderer::DisplayButton(nsDisplayListBuilder* aBuilder, nsDisplayList* aForeground) { if (mFrame->StyleEffects()->mBoxShadow) { - aBackground->AppendToTop(new (aBuilder) - nsDisplayButtonBoxShadowOuter(aBuilder, this)); + aBackground->AppendToTop( + MakeDisplayItem(aBuilder, this)); } nsRect buttonRect = mFrame->GetRectRelativeToSelf(); @@ -486,14 +486,14 @@ nsButtonFrameRenderer::DisplayButton(nsDisplayListBuilder* aBuilder, nsDisplayBackgroundImage::AppendBackgroundItemsToTop( aBuilder, mFrame, buttonRect, aBackground); - aBackground->AppendToTop(new (aBuilder) - nsDisplayButtonBorder(aBuilder, this)); + aBackground->AppendToTop( + MakeDisplayItem(aBuilder, this)); // Only display focus rings if we actually have them. Since at most one // button would normally display a focus ring, most buttons won't have them. if (mInnerFocusStyle && mInnerFocusStyle->StyleBorder()->HasBorder()) { - aForeground->AppendToTop(new (aBuilder) - nsDisplayButtonForeground(aBuilder, this)); + aForeground->AppendToTop( + MakeDisplayItem(aBuilder, this)); } return NS_OK; } diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index ec19c8f4aaa6..4a7cc525f129 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -1599,7 +1599,7 @@ nsComboboxControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, !presContext->GetTheme()->ThemeDrawsFocusForWidget(disp->mAppearance)) && mDisplayFrame && IsVisibleForPainting(aBuilder)) { aLists.Content()->AppendToTop( - new (aBuilder) nsDisplayComboboxFocus(aBuilder, this)); + MakeDisplayItem(aBuilder, this)); } } } diff --git a/layout/forms/nsFieldSetFrame.cpp b/layout/forms/nsFieldSetFrame.cpp index cc14b6fecd8a..207e078aa7ee 100644 --- a/layout/forms/nsFieldSetFrame.cpp +++ b/layout/forms/nsFieldSetFrame.cpp @@ -196,8 +196,8 @@ nsFieldSetFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, if (!(GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER) && IsVisibleForPainting(aBuilder)) { if (StyleEffects()->mBoxShadow) { - aLists.BorderBackground()->AppendToTop(new (aBuilder) - nsDisplayBoxShadowOuter(aBuilder, this)); + aLists.BorderBackground()->AppendToTop( + MakeDisplayItem(aBuilder, this)); } nsDisplayBackgroundImage::AppendBackgroundItemsToTop( @@ -205,8 +205,8 @@ nsFieldSetFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, aLists.BorderBackground(), /* aAllowWillPaintBorderOptimization = */ false); - aLists.BorderBackground()->AppendToTop(new (aBuilder) - nsDisplayFieldSetBorder(aBuilder, this)); + aLists.BorderBackground()->AppendToTop( + MakeDisplayItem(aBuilder, this)); DisplayOutlineUnconditional(aBuilder, aLists); diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 81e2dd9b7515..b1570961181d 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -185,7 +185,7 @@ nsListControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, // this frame as the root of a stacking context we need make sure to draw // some opaque color over the whole widget. (Bug 511323) aLists.BorderBackground()->AppendToBottom( - new (aBuilder) nsDisplaySolidColor(aBuilder, + MakeDisplayItem(aBuilder, this, nsRect(aBuilder->ToReferenceFrame(this), GetSize()), mLastDropdownBackstopColor)); } diff --git a/layout/forms/nsRangeFrame.cpp b/layout/forms/nsRangeFrame.cpp index f444f32ff5f1..79abf71105df 100644 --- a/layout/forms/nsRangeFrame.cpp +++ b/layout/forms/nsRangeFrame.cpp @@ -305,7 +305,7 @@ nsRangeFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, } aLists.Content()->AppendToTop( - new (aBuilder) nsDisplayRangeFocusRing(aBuilder, this)); + MakeDisplayItem(aBuilder, this)); } void diff --git a/layout/forms/nsSelectsAreaFrame.cpp b/layout/forms/nsSelectsAreaFrame.cpp index ab46c5713df3..cdc12130dea9 100644 --- a/layout/forms/nsSelectsAreaFrame.cpp +++ b/layout/forms/nsSelectsAreaFrame.cpp @@ -75,11 +75,11 @@ public: nsOptionEventGrabberWrapper() {} virtual nsDisplayItem* WrapList(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList) override { - return new (aBuilder) nsDisplayOptionEventGrabber(aBuilder, aFrame, aList); + return MakeDisplayItem(aBuilder, aFrame, aList); } virtual nsDisplayItem* WrapItem(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem) override { - return new (aBuilder) nsDisplayOptionEventGrabber(aBuilder, aItem->Frame(), aItem); + return MakeDisplayItem(aBuilder, aItem->Frame(), aItem); } }; @@ -154,8 +154,8 @@ nsSelectsAreaFrame::BuildDisplayListInternal(nsDisplayListBuilder* aBuilder, // we can't just associate the display item with the list frame, // because then the list's scrollframe won't clip it (the scrollframe // only clips contained descendants). - aLists.Outlines()->AppendToTop(new (aBuilder) - nsDisplayListFocus(aBuilder, this)); + aLists.Outlines()->AppendToTop( + MakeDisplayItem(aBuilder, this)); } } diff --git a/layout/generic/TextOverflow.cpp b/layout/generic/TextOverflow.cpp index 6aeb4dabf4fa..f5730421564c 100644 --- a/layout/generic/TextOverflow.cpp +++ b/layout/generic/TextOverflow.cpp @@ -861,9 +861,10 @@ TextOverflow::CreateMarkers(const nsLineBox* aLine, markerLogicalRect.GetPhysicalRect(mBlockWM, mBlockSize) + offset; ClipMarker(aContentArea.GetPhysicalRect(mBlockWM, mBlockSize) + offset, markerRect, clipState); - nsDisplayItem* marker = new (mBuilder) - nsDisplayTextOverflowMarker(mBuilder, mBlock, markerRect, - aLine->GetLogicalAscent(), mIStart.mStyle, aLineNumber, 0); + nsDisplayItem* marker = + MakeDisplayItem(mBuilder, mBlock, markerRect, + aLine->GetLogicalAscent(), mIStart.mStyle, + aLineNumber, 0); mMarkerList.AppendToTop(marker); } @@ -878,9 +879,10 @@ TextOverflow::CreateMarkers(const nsLineBox* aLine, markerLogicalRect.GetPhysicalRect(mBlockWM, mBlockSize) + offset; ClipMarker(aContentArea.GetPhysicalRect(mBlockWM, mBlockSize) + offset, markerRect, clipState); - nsDisplayItem* marker = new (mBuilder) - nsDisplayTextOverflowMarker(mBuilder, mBlock, markerRect, - aLine->GetLogicalAscent(), mIEnd.mStyle, aLineNumber, 1); + nsDisplayItem* marker = + MakeDisplayItem(mBuilder, mBlock, markerRect, + aLine->GetLogicalAscent(), mIEnd.mStyle, + aLineNumber, 1); mMarkerList.AppendToTop(marker); } } diff --git a/layout/generic/ViewportFrame.cpp b/layout/generic/ViewportFrame.cpp index 48e46f25b97b..8a539d3818c0 100644 --- a/layout/generic/ViewportFrame.cpp +++ b/layout/generic/ViewportFrame.cpp @@ -72,7 +72,7 @@ ViewportFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, // Wrap the whole top layer in a single item with maximum z-index, // and append it at the very end, so that it stays at the topmost. nsDisplayWrapList* wrapList = - new (aBuilder) nsDisplayWrapList(aBuilder, this, &topLayerList); + MakeDisplayItem(aBuilder, this, &topLayerList); wrapList->SetOverrideZIndex( std::numeric_limitsZIndex())>::max()); aLists.PositionedDescendants()->AppendToTop(wrapList); diff --git a/layout/generic/nsBulletFrame.cpp b/layout/generic/nsBulletFrame.cpp index 13265b9690aa..d37cc71696b7 100644 --- a/layout/generic/nsBulletFrame.cpp +++ b/layout/generic/nsBulletFrame.cpp @@ -789,7 +789,7 @@ nsBulletFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, DO_GLOBAL_REFLOW_COUNT_DSP("nsBulletFrame"); aLists.Content()->AppendToTop( - new (aBuilder) nsDisplayBullet(aBuilder, this)); + MakeDisplayItem(aBuilder, this)); } Maybe diff --git a/layout/generic/nsCanvasFrame.cpp b/layout/generic/nsCanvasFrame.cpp index 6b398cc3695a..ec23f4894dcd 100644 --- a/layout/generic/nsCanvasFrame.cpp +++ b/layout/generic/nsCanvasFrame.cpp @@ -470,11 +470,11 @@ nsCanvasFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, } } aLists.BorderBackground()->AppendToTop( - new (aBuilder) nsDisplayCanvasBackgroundColor(aBuilder, this)); + MakeDisplayItem(aBuilder, this)); if (isThemed) { aLists.BorderBackground()->AppendToTop( - new (aBuilder) nsDisplayCanvasThemedBackground(aBuilder, this)); + MakeDisplayItem(aBuilder, this)); return; } @@ -528,14 +528,14 @@ nsCanvasFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, { DisplayListClipState::AutoSaveRestore bgImageClip(aBuilder); bgImageClip.Clear(); - bgItem = new (aBuilder) nsDisplayCanvasBackgroundImage(bgData); + bgItem = MakeDisplayItem(aBuilder, bgData); bgItem->SetDependentFrame(aBuilder, dependentFrame); } thisItemList.AppendToTop( nsDisplayFixedPosition::CreateForFixedBackground(aBuilder, this, bgItem, i)); } else { - nsDisplayCanvasBackgroundImage* bgItem = new (aBuilder) nsDisplayCanvasBackgroundImage(bgData); + nsDisplayCanvasBackgroundImage* bgItem = MakeDisplayItem(aBuilder, bgData); bgItem->SetDependentFrame(aBuilder, dependentFrame); thisItemList.AppendToTop(bgItem); } @@ -543,9 +543,9 @@ nsCanvasFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, if (layers.mLayers[i].mBlendMode != NS_STYLE_BLEND_NORMAL) { DisplayListClipState::AutoSaveRestore blendClip(aBuilder); thisItemList.AppendToTop( - new (aBuilder) nsDisplayBlendMode(aBuilder, this, &thisItemList, - layers.mLayers[i].mBlendMode, - thisItemASR, i + 1)); + MakeDisplayItem(aBuilder, this, &thisItemList, + layers.mLayers[i].mBlendMode, + thisItemASR, i + 1)); } aLists.BorderBackground()->AppendToTop(&thisItemList); } @@ -591,8 +591,8 @@ nsCanvasFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, if (!StyleVisibility()->IsVisible()) return; - aLists.Outlines()->AppendToTop(new (aBuilder) - nsDisplayCanvasFocus(aBuilder, this)); + aLists.Outlines()->AppendToTop( + MakeDisplayItem(aBuilder, this)); } void diff --git a/layout/generic/nsCanvasFrame.h b/layout/generic/nsCanvasFrame.h index f59e2897f314..c1a39ddf438f 100644 --- a/layout/generic/nsCanvasFrame.h +++ b/layout/generic/nsCanvasFrame.h @@ -190,8 +190,8 @@ public: class nsDisplayCanvasBackgroundImage : public nsDisplayBackgroundImage { public: - explicit nsDisplayCanvasBackgroundImage(const InitData& aInitData) - : nsDisplayBackgroundImage(aInitData) + explicit nsDisplayCanvasBackgroundImage(nsDisplayListBuilder* aBuilder, const InitData& aInitData) + : nsDisplayBackgroundImage(aBuilder, aInitData) { } diff --git a/layout/generic/nsColumnSetFrame.cpp b/layout/generic/nsColumnSetFrame.cpp index b3a5af0b1262..40748e06d6d5 100644 --- a/layout/generic/nsColumnSetFrame.cpp +++ b/layout/generic/nsColumnSetFrame.cpp @@ -1280,7 +1280,7 @@ nsColumnSetFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, if (IsVisibleForPainting(aBuilder)) { aLists.BorderBackground()-> - AppendToTop(new (aBuilder) nsDisplayColumnRule(aBuilder, this)); + AppendToTop(MakeDisplayItem(aBuilder, this)); } // Our children won't have backgrounds so it doesn't matter where we put them. diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index c4909cfb3d4b..8b027ccbb906 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -2318,8 +2318,8 @@ nsFrame::DisplaySelectionOverlay(nsDisplayListBuilder* aBuilder, return; } - aList->AppendToTop(new (aBuilder) - nsDisplaySelectionOverlay(aBuilder, this, selectionValue)); + aList->AppendToTop( + MakeDisplayItem(aBuilder, this, selectionValue)); } void @@ -2331,7 +2331,7 @@ nsFrame::DisplayOutlineUnconditional(nsDisplayListBuilder* aBuilder, } aLists.Outlines()->AppendToTop( - new (aBuilder) nsDisplayOutline(aBuilder, this)); + MakeDisplayItem(aBuilder, this)); } void @@ -2351,7 +2351,7 @@ nsIFrame::DisplayCaret(nsDisplayListBuilder* aBuilder, if (!IsVisibleForPainting(aBuilder)) return; - aList->AppendToTop(new (aBuilder) nsDisplayCaret(aBuilder, this)); + aList->AppendToTop(MakeDisplayItem(aBuilder, this)); } nscolor @@ -2390,23 +2390,23 @@ nsFrame::DisplayBorderBackgroundOutline(nsDisplayListBuilder* aBuilder, nsCSSShadowArray* shadows = StyleEffects()->mBoxShadow; if (shadows && shadows->HasShadowWithInset(false)) { - aLists.BorderBackground()->AppendToTop(new (aBuilder) - nsDisplayBoxShadowOuter(aBuilder, this)); + aLists.BorderBackground()->AppendToTop( + MakeDisplayItem(aBuilder, this)); } bool bgIsThemed = DisplayBackgroundUnconditional(aBuilder, aLists, aForceBackground); if (shadows && shadows->HasShadowWithInset(true)) { - aLists.BorderBackground()->AppendToTop(new (aBuilder) - nsDisplayBoxShadowInner(aBuilder, this)); + aLists.BorderBackground()->AppendToTop( + MakeDisplayItem(aBuilder, this)); } // If there's a themed background, we should not create a border item. // It won't be rendered. if (!bgIsThemed && StyleBorder()->HasBorder()) { - aLists.BorderBackground()->AppendToTop(new (aBuilder) - nsDisplayBorder(aBuilder, this)); + aLists.BorderBackground()->AppendToTop( + MakeDisplayItem(aBuilder, this)); } DisplayOutlineUnconditional(aBuilder, aLists); @@ -2541,16 +2541,16 @@ DisplayDebugBorders(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, // Draw a border around the child // REVIEW: From nsContainerFrame::PaintChild if (nsFrame::GetShowFrameBorders() && !aFrame->GetRect().IsEmpty()) { - aLists.Outlines()->AppendToTop(new (aBuilder) - nsDisplayGeneric(aBuilder, aFrame, PaintDebugBorder, "DebugBorder", - DisplayItemType::TYPE_DEBUG_BORDER)); + aLists.Outlines()->AppendToTop( + MakeDisplayItem(aBuilder, aFrame, PaintDebugBorder, "DebugBorder", + DisplayItemType::TYPE_DEBUG_BORDER)); } // Draw a border around the current event target if (nsFrame::GetShowEventTargetFrameBorder() && aFrame->PresShell()->GetDrawEventTargetFrame() == aFrame) { - aLists.Outlines()->AppendToTop(new (aBuilder) - nsDisplayGeneric(aBuilder, aFrame, PaintEventTargetBorder, "EventTargetBorder", - DisplayItemType::TYPE_EVENT_TARGET_BORDER)); + aLists.Outlines()->AppendToTop( + MakeDisplayItem(aBuilder, aFrame, PaintEventTargetBorder, "EventTargetBorder", + DisplayItemType::TYPE_EVENT_TARGET_BORDER)); } } #endif @@ -2654,7 +2654,7 @@ WrapSeparatorTransform(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, int aIndex) { if (!aSource->IsEmpty()) { nsDisplayTransform *sepIdItem = - new (aBuilder) nsDisplayTransform(aBuilder, aFrame, aSource, + MakeDisplayItem(aBuilder, aFrame, aSource, aBuilder->GetVisibleRect(), Matrix4x4(), aIndex); sepIdItem->SetNoExtendContext(); aTarget->AppendToTop(sepIdItem); @@ -3031,7 +3031,7 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder, nsDisplayLayerEventRegions* eventRegions = nullptr; if (aBuilder->IsBuildingLayerEventRegions()) { - eventRegions = new (aBuilder) nsDisplayLayerEventRegions(aBuilder, this); + eventRegions = MakeDisplayItem(aBuilder, this); eventRegions->AddFrame(aBuilder, this); aBuilder->SetLayerEventRegions(eventRegions); } @@ -3072,7 +3072,7 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder, if (eventRegions) { eventRegions->Destroy(aBuilder); - eventRegions = new (aBuilder) nsDisplayLayerEventRegions(aBuilder, this); + eventRegions = MakeDisplayItem(aBuilder, this); eventRegions->AddFrame(aBuilder, this); aBuilder->SetLayerEventRegions(eventRegions); } @@ -3116,7 +3116,7 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder, if (hasOverrideDirtyRect && gfxPrefs::LayoutDisplayListShowArea()) { nsDisplaySolidColor* color = - new (aBuilder) nsDisplaySolidColor(aBuilder, this, + MakeDisplayItem(aBuilder, this, dirtyRect + aBuilder->GetCurrentFrameOffsetToReferenceFrame(), NS_RGBA(255, 0, 0, 64), false); color->SetOverrideZIndex(INT32_MAX); @@ -3219,7 +3219,7 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder, /* List now emptied, so add the new list to the top. */ resultList.AppendToTop( - new (aBuilder) nsDisplayFilter(aBuilder, this, &resultList, + MakeDisplayItem(aBuilder, this, &resultList, handleOpacity)); } @@ -3239,7 +3239,7 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder, : containerItemASR; /* List now emptied, so add the new list to the top. */ resultList.AppendToTop( - new (aBuilder) nsDisplayMask(aBuilder, this, &resultList, !useOpacity, + MakeDisplayItem(aBuilder, this, &resultList, !useOpacity, maskASR)); } @@ -3261,7 +3261,7 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder, // all descendant content, but some should not be clipped. DisplayListClipState::AutoSaveRestore opacityClipState(aBuilder); resultList.AppendToTop( - new (aBuilder) nsDisplayOpacity(aBuilder, this, &resultList, + MakeDisplayItem(aBuilder, this, &resultList, containerItemASR, opacityItemForEventsAndPluginsOnly)); if (aCreatedContainerItem) { @@ -3327,7 +3327,7 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder, GetOffsetToCrossDoc(outerReferenceFrame)); nsDisplayTransform *transformItem = - new (aBuilder) nsDisplayTransform(aBuilder, this, + MakeDisplayItem(aBuilder, this, &resultList, visibleRect, 0, allowAsyncAnimation); resultList.AppendToTop(transformItem); @@ -3337,7 +3337,7 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder, clipState.Restore(); } resultList.AppendToTop( - new (aBuilder) nsDisplayPerspective( + MakeDisplayItem( aBuilder, this, GetContainingBlock(0, disp)->GetContent()->GetPrimaryFrame(), &resultList)); @@ -3351,7 +3351,7 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder, if (clipCapturedBy == ContainerItemType::eOwnLayerForTransformWithRoundedClip) { clipState.Restore(); resultList.AppendToTop( - new (aBuilder) nsDisplayOwnLayer(aBuilder, this, &resultList, + MakeDisplayItem(aBuilder, this, &resultList, aBuilder->CurrentActiveScrolledRoot(), nsDisplayOwnLayerFlags::eNone, mozilla::layers::FrameMetrics::NULL_SCROLL_ID, @@ -3374,7 +3374,7 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder, const ActiveScrolledRoot* fixedASR = ActiveScrolledRoot::PickAncestor(containerItemASR, aBuilder->CurrentActiveScrolledRoot()); resultList.AppendToTop( - new (aBuilder) nsDisplayFixedPosition(aBuilder, this, &resultList, fixedASR)); + MakeDisplayItem(aBuilder, this, &resultList, fixedASR)); if (aCreatedContainerItem) { *aCreatedContainerItem = true; } @@ -3390,7 +3390,7 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder, const ActiveScrolledRoot* stickyASR = ActiveScrolledRoot::PickAncestor(containerItemASR, aBuilder->CurrentActiveScrolledRoot()); resultList.AppendToTop( - new (aBuilder) nsDisplayStickyPosition(aBuilder, this, &resultList, stickyASR)); + MakeDisplayItem(aBuilder, this, &resultList, stickyASR)); if (aCreatedContainerItem) { *aCreatedContainerItem = true; } @@ -3404,7 +3404,7 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder, if (useBlendMode) { DisplayListClipState::AutoSaveRestore blendModeClipState(aBuilder); resultList.AppendToTop( - new (aBuilder) nsDisplayBlendMode(aBuilder, this, &resultList, + MakeDisplayItem(aBuilder, this, &resultList, effects->mMixBlendMode, containerItemASR)); if (aCreatedContainerItem) { @@ -3436,7 +3436,7 @@ WrapInWrapList(nsDisplayListBuilder* aBuilder, // Clear clip rect for the construction of the items below. Since we're // clipping all their contents, they themselves don't need to be clipped. - return new (aBuilder) nsDisplayWrapList(aBuilder, aFrame, aList, aContainerASR, true); + return MakeDisplayItem(aBuilder, aFrame, aList, aContainerASR, true); } /** @@ -3777,7 +3777,7 @@ nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder, // make sure we accumulate event regions for its layer. if (buildingForChild.IsAnimatedGeometryRoot() || isPositioned) { nsDisplayLayerEventRegions* eventRegions = - new (aBuilder) nsDisplayLayerEventRegions(aBuilder, child); + MakeDisplayItem(aBuilder, child); eventRegions->AddFrame(aBuilder, child); aBuilder->SetLayerEventRegions(eventRegions); @@ -10966,8 +10966,8 @@ nsIFrame::CreateOwnLayerIfNeeded(nsDisplayListBuilder* aBuilder, if (GetContent() && GetContent()->IsXULElement() && GetContent()->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::layer)) { - aList->AppendToTop(new (aBuilder) - nsDisplayOwnLayer(aBuilder, this, aList, aBuilder->CurrentActiveScrolledRoot())); + aList->AppendToTop( + MakeDisplayItem(aBuilder, this, aList, aBuilder->CurrentActiveScrolledRoot())); if (aCreatedContainerItem) { *aCreatedContainerItem = true; } diff --git a/layout/generic/nsFrameSetFrame.cpp b/layout/generic/nsFrameSetFrame.cpp index b0d5e2ca29c8..dcbac06ce90a 100644 --- a/layout/generic/nsFrameSetFrame.cpp +++ b/layout/generic/nsFrameSetFrame.cpp @@ -680,7 +680,7 @@ nsHTMLFramesetFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, if (mDragger && aBuilder->IsForEventDelivery()) { aLists.Content()->AppendToTop( - new (aBuilder) nsDisplayEventReceiver(aBuilder, this)); + MakeDisplayItem(aBuilder, this)); } } @@ -1425,7 +1425,7 @@ nsHTMLFramesetBorderFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) { aLists.Content()->AppendToTop( - new (aBuilder) nsDisplayFramesetBorder(aBuilder, this)); + MakeDisplayItem(aBuilder, this)); } void nsHTMLFramesetBorderFrame::PaintBorder(DrawTarget* aDrawTarget, @@ -1636,5 +1636,5 @@ nsHTMLFramesetBlankFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) { aLists.Content()->AppendToTop( - new (aBuilder) nsDisplayFramesetBlank(aBuilder, this)); + MakeDisplayItem(aBuilder, this)); } diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 373d4a00598e..7b4884df33ee 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -3072,9 +3072,9 @@ AppendToTop(nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists, flags |= nsDisplayOwnLayerFlags::eScrollbarContainer; } - newItem = new (aBuilder) nsDisplayOwnLayer(aBuilder, aSourceFrame, aSource, asr, flags, scrollTarget); + newItem = MakeDisplayItem(aBuilder, aSourceFrame, aSource, asr, flags, scrollTarget); } else { - newItem = new (aBuilder) nsDisplayWrapList(aBuilder, aSourceFrame, aSource, asr); + newItem = MakeDisplayItem(aBuilder, aSourceFrame, aSource, asr); } if (aFlags & APPEND_POSITIONED) { @@ -3618,9 +3618,9 @@ ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder, if (dirtyRectHasBeenOverriden && gfxPrefs::LayoutDisplayListShowArea()) { nsDisplaySolidColor* color = - new (aBuilder) nsDisplaySolidColor(aBuilder, mOuter, - dirtyRect + aBuilder->GetCurrentFrameOffsetToReferenceFrame(), - NS_RGBA(0, 0, 255, 64), false); + MakeDisplayItem(aBuilder, mOuter, + dirtyRect + aBuilder->GetCurrentFrameOffsetToReferenceFrame(), + NS_RGBA(0, 0, 255, 64), false); color->SetOverrideZIndex(INT32_MAX); scrolledContent.PositionedDescendants()->AppendToTop(color); } @@ -3695,13 +3695,13 @@ ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder, info |= CompositorHitTestInfo::eRequiresTargetConfirmation; } nsDisplayCompositorHitTestInfo* hitInfo = - new (aBuilder) nsDisplayCompositorHitTestInfo(aBuilder, mScrolledFrame, info, 1, + MakeDisplayItem(aBuilder, mScrolledFrame, info, 1, Some(mScrollPort + aBuilder->ToReferenceFrame(mOuter))); AppendInternalItemToTop(scrolledContent, hitInfo, zIndex); } if (aBuilder->IsBuildingLayerEventRegions()) { nsDisplayLayerEventRegions* inactiveRegionItem = - new (aBuilder) nsDisplayLayerEventRegions(aBuilder, mScrolledFrame, 1); + MakeDisplayItem(aBuilder, mScrolledFrame, 1); inactiveRegionItem->AddInactiveScrollPort(mScrolledFrame, mScrollPort + aBuilder->ToReferenceFrame(mOuter)); AppendInternalItemToTop(scrolledContent, inactiveRegionItem, zIndex); } @@ -3709,7 +3709,7 @@ ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder, if (aBuilder->ShouldBuildScrollInfoItemsForHoisting()) { aBuilder->AppendNewScrollInfoItemForHoisting( - new (aBuilder) nsDisplayScrollInfoLayer(aBuilder, mScrolledFrame, + MakeDisplayItem(aBuilder, mScrolledFrame, mOuter)); } } diff --git a/layout/generic/nsHTMLCanvasFrame.cpp b/layout/generic/nsHTMLCanvasFrame.cpp index 7a17f02782d6..b61acf20117a 100644 --- a/layout/generic/nsHTMLCanvasFrame.cpp +++ b/layout/generic/nsHTMLCanvasFrame.cpp @@ -482,7 +482,7 @@ nsHTMLCanvasFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, clip(aBuilder, this, clipFlags); aLists.Content()->AppendToTop( - new (aBuilder) nsDisplayCanvas(aBuilder, this)); + MakeDisplayItem(aBuilder, this)); DisplaySelectionOverlay(aBuilder, aLists.Content(), nsISelectionDisplay::DISPLAY_IMAGES); diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index b03798446dcc..fc80b9f7e032 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -1849,8 +1849,8 @@ nsImageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, if (!imageOK || !mImage || !SizeIsAvailable(currentRequest)) { // No image yet, or image load failed. Draw the alt-text and an icon // indicating the status - aLists.Content()->AppendToTop(new (aBuilder) - nsDisplayAltFeedback(aBuilder, this)); + aLists.Content()->AppendToTop( + MakeDisplayItem(aBuilder, this)); // This image is visible (we are being asked to paint it) but it's not // decoded yet. And we are not going to ask the image to draw, so this @@ -1867,8 +1867,8 @@ nsImageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, } } } else { - aLists.Content()->AppendToTop(new (aBuilder) - nsDisplayImage(aBuilder, this, mImage, mPrevImage)); + aLists.Content()->AppendToTop( + MakeDisplayItem(aBuilder, this, mImage, mPrevImage)); // If we were previously displaying an icon, we're not anymore if (mDisplayingIcon) { @@ -1878,9 +1878,9 @@ nsImageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, #ifdef DEBUG if (GetShowFrameBorders() && GetImageMap()) { - aLists.Outlines()->AppendToTop(new (aBuilder) - nsDisplayGeneric(aBuilder, this, PaintDebugImageMap, "DebugImageMap", - DisplayItemType::TYPE_DEBUG_IMAGE_MAP)); + aLists.Outlines()->AppendToTop( + MakeDisplayItem(aBuilder, this, PaintDebugImageMap, "DebugImageMap", + DisplayItemType::TYPE_DEBUG_IMAGE_MAP)); } #endif } diff --git a/layout/generic/nsPageFrame.cpp b/layout/generic/nsPageFrame.cpp index c43be63902be..3b0f7661ace6 100644 --- a/layout/generic/nsPageFrame.cpp +++ b/layout/generic/nsPageFrame.cpp @@ -586,14 +586,14 @@ nsPageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, *aBuilder, content, child, backgroundRect, NS_RGBA(0,0,0,0)); } - content.AppendToTop(new (aBuilder) nsDisplayTransform(aBuilder, child, + content.AppendToTop(MakeDisplayItem(aBuilder, child, &content, content.GetVisibleRect(), ::ComputePageTransform)); set.Content()->AppendToTop(&content); if (PresContext()->IsRootPaginatedDocument()) { - set.Content()->AppendToTop(new (aBuilder) - nsDisplayHeaderFooter(aBuilder, this)); + set.Content()->AppendToTop( + MakeDisplayItem(aBuilder, this)); } set.MoveTo(aLists); diff --git a/layout/generic/nsPlaceholderFrame.cpp b/layout/generic/nsPlaceholderFrame.cpp index 6c9053ec0ba0..73ce1b965caf 100644 --- a/layout/generic/nsPlaceholderFrame.cpp +++ b/layout/generic/nsPlaceholderFrame.cpp @@ -273,9 +273,9 @@ nsPlaceholderFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, #ifdef DEBUG if (GetShowFrameBorders()) { aLists.Outlines()->AppendToTop( - new (aBuilder) nsDisplayGeneric(aBuilder, this, PaintDebugPlaceholder, - "DebugPlaceholder", - DisplayItemType::TYPE_DEBUG_PLACEHOLDER)); + MakeDisplayItem(aBuilder, this, PaintDebugPlaceholder, + "DebugPlaceholder", + DisplayItemType::TYPE_DEBUG_PLACEHOLDER)); } #endif } diff --git a/layout/generic/nsPluginFrame.cpp b/layout/generic/nsPluginFrame.cpp index 226b33471c3a..efb771a93b3d 100644 --- a/layout/generic/nsPluginFrame.cpp +++ b/layout/generic/nsPluginFrame.cpp @@ -1187,9 +1187,9 @@ nsPluginFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, // determine if we are printing if (type == nsPresContext::eContext_Print) { - aLists.Content()->AppendToTop(new (aBuilder) - nsDisplayGeneric(aBuilder, this, PaintPrintPlugin, "PrintPlugin", - DisplayItemType::TYPE_PRINT_PLUGIN)); + aLists.Content()->AppendToTop( + MakeDisplayItem(aBuilder, this, PaintPrintPlugin, "PrintPlugin", + DisplayItemType::TYPE_PRINT_PLUGIN)); } else { LayerState state = GetLayerState(aBuilder, nullptr); if (state == LAYER_INACTIVE && @@ -1199,12 +1199,12 @@ nsPluginFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, if (aBuilder->IsPaintingToWindow() && state == LAYER_ACTIVE && IsTransparentMode()) { - aLists.Content()->AppendToTop(new (aBuilder) - nsDisplayPluginReadback(aBuilder, this)); + aLists.Content()->AppendToTop( + MakeDisplayItem(aBuilder, this)); } - aLists.Content()->AppendToTop(new (aBuilder) - nsDisplayPlugin(aBuilder, this)); + aLists.Content()->AppendToTop( + MakeDisplayItem(aBuilder, this)); } } diff --git a/layout/generic/nsSimplePageSequenceFrame.cpp b/layout/generic/nsSimplePageSequenceFrame.cpp index 84a549926e2a..81e9c898a902 100644 --- a/layout/generic/nsSimplePageSequenceFrame.cpp +++ b/layout/generic/nsSimplePageSequenceFrame.cpp @@ -747,9 +747,9 @@ nsSimplePageSequenceFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, } } - content.AppendToTop(new (aBuilder) - nsDisplayTransform(aBuilder, this, &content, content.GetVisibleRect(), - ::ComputePageSequenceTransform)); + content.AppendToTop( + MakeDisplayItem(aBuilder, this, &content, content.GetVisibleRect(), + ::ComputePageSequenceTransform)); aLists.Content()->AppendToTop(&content); } diff --git a/layout/generic/nsSubDocumentFrame.cpp b/layout/generic/nsSubDocumentFrame.cpp index 390a27575019..424f9215372b 100644 --- a/layout/generic/nsSubDocumentFrame.cpp +++ b/layout/generic/nsSubDocumentFrame.cpp @@ -318,7 +318,7 @@ WrapBackgroundColorInOwnLayer(nsDisplayListBuilder* aBuilder, if (item->GetType() == DisplayItemType::TYPE_BACKGROUND_COLOR) { nsDisplayList tmpList; tmpList.AppendToTop(item); - item = new (aBuilder) nsDisplayOwnLayer(aBuilder, aFrame, &tmpList, aBuilder->CurrentActiveScrolledRoot()); + item = MakeDisplayItem(aBuilder, aFrame, &tmpList, aBuilder->CurrentActiveScrolledRoot()); } tempItems.AppendToTop(item); } @@ -558,7 +558,7 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, zoomFlags |= nsDisplayOwnLayerFlags::eGenerateScrollableLayer; } nsDisplayZoom* zoomItem = - new (aBuilder) nsDisplayZoom(aBuilder, subdocRootFrame, &childItems, + MakeDisplayItem(aBuilder, subdocRootFrame, &childItems, subdocAPD, parentAPD, zoomFlags); childItems.AppendToTop(zoomItem); needsOwnLayer = false; @@ -570,14 +570,14 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, } if (constructResolutionItem) { nsDisplayResolution* resolutionItem = - new (aBuilder) nsDisplayResolution(aBuilder, subdocRootFrame, &childItems, - flags); + MakeDisplayItem(aBuilder, subdocRootFrame, &childItems, + flags); childItems.AppendToTop(resolutionItem); needsOwnLayer = false; } // We always want top level content documents to be in their own layer. - nsDisplaySubDocument* layerItem = new (aBuilder) nsDisplaySubDocument( + nsDisplaySubDocument* layerItem = MakeDisplayItem( aBuilder, subdocRootFrame ? subdocRootFrame : this, this, &childItems, flags); childItems.AppendToTop(layerItem); diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 6efb16885938..6885ad6c9ffa 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -5237,7 +5237,7 @@ nsTextFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, } aLists.Content()->AppendToTop( - new (aBuilder) nsDisplayText(aBuilder, this, isSelected)); + MakeDisplayItem(aBuilder, this, isSelected)); } static nsIFrame* diff --git a/layout/generic/nsVideoFrame.cpp b/layout/generic/nsVideoFrame.cpp index 5f925b4a1313..645202a2ee81 100644 --- a/layout/generic/nsVideoFrame.cpp +++ b/layout/generic/nsVideoFrame.cpp @@ -570,7 +570,7 @@ nsVideoFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, if (HasVideoElement() && !shouldDisplayPoster) { aLists.Content()->AppendToTop( - new (aBuilder) nsDisplayVideo(aBuilder, this)); + MakeDisplayItem(aBuilder, this)); } // Add child frames to display list. We expect various children, diff --git a/layout/ipc/RenderFrameParent.cpp b/layout/ipc/RenderFrameParent.cpp index 53ca2ed8ec13..9312ecbb0ed8 100644 --- a/layout/ipc/RenderFrameParent.cpp +++ b/layout/ipc/RenderFrameParent.cpp @@ -294,7 +294,7 @@ RenderFrameParent::BuildDisplayList(nsDisplayListBuilder* aBuilder, clipState.ClipContentDescendants(bounds); aLists.Content()->AppendToTop( - new (aBuilder) nsDisplayRemote(aBuilder, aFrame, this)); + MakeDisplayItem(aBuilder, aFrame, this)); } void diff --git a/layout/mathml/nsMathMLChar.cpp b/layout/mathml/nsMathMLChar.cpp index b5d871635818..f70b407aafa0 100644 --- a/layout/mathml/nsMathMLChar.cpp +++ b/layout/mathml/nsMathMLChar.cpp @@ -1988,8 +1988,8 @@ nsMathMLChar::Display(nsDisplayListBuilder* aBuilder, // purposes. Normally, users will set the background on the container frame. // paint the selection background -- beware MathML frames overlap a lot if (aSelectedRect && !aSelectedRect->IsEmpty()) { - aLists.BorderBackground()->AppendToTop(new (aBuilder) - nsDisplayMathMLSelectionRect(aBuilder, aForFrame, *aSelectedRect)); + aLists.BorderBackground()->AppendToTop( + MakeDisplayItem(aBuilder, aForFrame, *aSelectedRect)); } else if (mRect.width && mRect.height) { if (styleContext != parentContext && @@ -2004,15 +2004,15 @@ nsMathMLChar::Display(nsDisplayListBuilder* aBuilder, #if defined(DEBUG) && defined(SHOW_BOUNDING_BOX) // for visual debug - aLists.BorderBackground()->AppendToTop(new (aBuilder) - nsDisplayMathMLCharDebug(aBuilder, aForFrame, mRect)); + aLists.BorderBackground()->AppendToTop( + MakeDisplayItem(aBuilder, aForFrame, mRect)); #endif } - aLists.Content()->AppendToTop(new (aBuilder) - nsDisplayMathMLCharForeground(aBuilder, aForFrame, this, - aIndex, - aSelectedRect && - !aSelectedRect->IsEmpty())); + aLists.Content()->AppendToTop( + MakeDisplayItem(aBuilder, aForFrame, this, + aIndex, + aSelectedRect && + !aSelectedRect->IsEmpty())); } void diff --git a/layout/mathml/nsMathMLContainerFrame.cpp b/layout/mathml/nsMathMLContainerFrame.cpp index 81744423e699..bdccac6d33ce 100644 --- a/layout/mathml/nsMathMLContainerFrame.cpp +++ b/layout/mathml/nsMathMLContainerFrame.cpp @@ -625,7 +625,7 @@ nsMathMLContainerFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, return; aLists.Content()->AppendToTop( - new (aBuilder) nsDisplayMathMLError(aBuilder, this)); + MakeDisplayItem(aBuilder, this)); return; } diff --git a/layout/mathml/nsMathMLFrame.cpp b/layout/mathml/nsMathMLFrame.cpp index da2b26ca6520..4f15132a1783 100644 --- a/layout/mathml/nsMathMLFrame.cpp +++ b/layout/mathml/nsMathMLFrame.cpp @@ -318,8 +318,8 @@ nsMathMLFrame::DisplayBoundingMetrics(nsDisplayListBuilder* aBuilder, nscoord w = aMetrics.rightBearing - aMetrics.leftBearing; nscoord h = aMetrics.ascent + aMetrics.descent; - aLists.Content()->AppendToTop(new (aBuilder) - nsDisplayMathMLBoundingMetrics(aBuilder, aFrame, nsRect(x,y,w,h))); + aLists.Content()->AppendToTop( + MakeDisplayItem(aBuilder, aFrame, nsRect(x,y,w,h))); } #endif @@ -370,8 +370,8 @@ nsMathMLFrame::DisplayBar(nsDisplayListBuilder* aBuilder, if (!aFrame->StyleVisibility()->IsVisible() || aRect.IsEmpty()) return; - aLists.Content()->AppendToTop(new (aBuilder) - nsDisplayMathMLBar(aBuilder, aFrame, aRect, aIndex)); + aLists.Content()->AppendToTop( + MakeDisplayItem(aBuilder, aFrame, aRect, aIndex)); } void diff --git a/layout/mathml/nsMathMLmencloseFrame.cpp b/layout/mathml/nsMathMLmencloseFrame.cpp index f541108be8e4..52818bf99ba6 100644 --- a/layout/mathml/nsMathMLmencloseFrame.cpp +++ b/layout/mathml/nsMathMLmencloseFrame.cpp @@ -873,6 +873,6 @@ nsMathMLmencloseFrame::DisplayNotation(nsDisplayListBuilder* aBuilder, aThickness <= 0) return; - aLists.Content()->AppendToTop(new (aBuilder) - nsDisplayNotation(aBuilder, aFrame, aRect, aThickness, aType)); + aLists.Content()->AppendToTop( + MakeDisplayItem(aBuilder, aFrame, aRect, aThickness, aType)); } diff --git a/layout/mathml/nsMathMLmfracFrame.cpp b/layout/mathml/nsMathMLmfracFrame.cpp index 04a213755c00..a169f4ae6b2f 100644 --- a/layout/mathml/nsMathMLmfracFrame.cpp +++ b/layout/mathml/nsMathMLmfracFrame.cpp @@ -656,7 +656,7 @@ nsMathMLmfracFrame::DisplaySlash(nsDisplayListBuilder* aBuilder, if (!aFrame->StyleVisibility()->IsVisible() || aRect.IsEmpty()) return; - aLists.Content()->AppendToTop(new (aBuilder) - nsDisplayMathMLSlash(aBuilder, aFrame, aRect, aThickness, - StyleVisibility()->mDirection)); + aLists.Content()->AppendToTop( + MakeDisplayItem(aBuilder, aFrame, aRect, aThickness, + StyleVisibility()->mDirection)); } diff --git a/layout/mathml/nsMathMLmtableFrame.cpp b/layout/mathml/nsMathMLmtableFrame.cpp index 6665408779d8..f2802b387017 100644 --- a/layout/mathml/nsMathMLmtableFrame.cpp +++ b/layout/mathml/nsMathMLmtableFrame.cpp @@ -1232,8 +1232,7 @@ nsMathMLmtdFrame::ProcessBorders(nsTableFrame* aFrame, nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) { - aLists.BorderBackground()->AppendToTop(new (aBuilder) - nsDisplaymtdBorder(aBuilder, this)); + aLists.BorderBackground()->AppendToTop(MakeDisplayItem(aBuilder, this)); return NS_OK; } diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index dc64b8253919..bc861a9504a1 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -2257,7 +2257,7 @@ nsDisplayListBuilder::BuildCompositorHitTestInfoIfNeeded(nsIFrame* aFrame, } nsDisplayCompositorHitTestInfo* item = - new (this) nsDisplayCompositorHitTestInfo(this, aFrame, info); + MakeDisplayItem(this, aFrame, info); SetCompositorHitTestInfo(item); aList->AppendToTop(item); @@ -3531,9 +3531,10 @@ nsDisplayBackgroundImage::GetInitData(nsDisplayListBuilder* aBuilder, }; } -nsDisplayBackgroundImage::nsDisplayBackgroundImage(const InitData& aInitData, +nsDisplayBackgroundImage::nsDisplayBackgroundImage(nsDisplayListBuilder* aBuilder, + const InitData& aInitData, nsIFrame* aFrameForBounds) - : nsDisplayImageContainer(aInitData.builder, aInitData.frame) + : nsDisplayImageContainer(aBuilder, aInitData.frame) , mBackgroundStyle(aInitData.backgroundStyle) , mImage(aInitData.image) , mDependentFrame(nullptr) @@ -3643,7 +3644,7 @@ SpecialCutoutRegionCase(nsDisplayListBuilder* aBuilder, region.Sub(aBackgroundRect, *static_cast(cutoutRegion)); region.MoveBy(aBuilder->ToReferenceFrame(aFrame)); aList->AppendToTop( - new (aBuilder) nsDisplaySolidColorRegion(aBuilder, aFrame, region, aColor)); + MakeDisplayItem(aBuilder, aFrame, region, aColor)); return true; } @@ -3748,12 +3749,12 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil nsDisplayBackgroundColor *bgItem; if (aSecondaryReferenceFrame) { bgItem = - new (aBuilder) nsDisplayTableBackgroundColor(aBuilder, aSecondaryReferenceFrame, bgColorRect, bg, + MakeDisplayItem(aBuilder, aSecondaryReferenceFrame, bgColorRect, bg, drawBackgroundColor ? color : NS_RGBA(0, 0, 0, 0), aFrame); } else { bgItem = - new (aBuilder) nsDisplayBackgroundColor(aBuilder, aFrame, bgColorRect, bg, + MakeDisplayItem(aBuilder, aFrame, bgColorRect, bg, drawBackgroundColor ? color : NS_RGBA(0, 0, 0, 0)); } bgItem->SetDependentFrame(aBuilder, dependentFrame); @@ -3765,11 +3766,11 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil if (theme->NeedToClearBackgroundBehindWidget(aFrame, aFrame->StyleDisplay()->mAppearance) && aBuilder->IsInChromeDocumentOrPopup() && !aBuilder->IsInTransform()) { bgItemList.AppendToTop( - new (aBuilder) nsDisplayClearBackground(aBuilder, aFrame)); + MakeDisplayItem(aBuilder, aFrame)); } if (aSecondaryReferenceFrame) { nsDisplayTableThemedBackground* bgItem = - new (aBuilder) nsDisplayTableThemedBackground(aBuilder, + MakeDisplayItem(aBuilder, aSecondaryReferenceFrame, bgRect, aFrame); @@ -3777,7 +3778,7 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil bgItemList.AppendToTop(bgItem); } else { nsDisplayThemedBackground* bgItem = - new (aBuilder) nsDisplayThemedBackground(aBuilder, aFrame, bgRect); + MakeDisplayItem(aBuilder, aFrame, bgRect); bgItem->Init(aBuilder); bgItemList.AppendToTop(bgItem); } @@ -3851,9 +3852,9 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil nsDisplayBackgroundImage::InitData tableData = bgData; nsIFrame* styleFrame = tableData.frame; tableData.frame = aSecondaryReferenceFrame; - bgItem = new (aBuilder) nsDisplayTableBackgroundImage(tableData, styleFrame); + bgItem = MakeDisplayItem(aBuilder, tableData, styleFrame); } else { - bgItem = new (aBuilder) nsDisplayBackgroundImage(bgData); + bgItem = MakeDisplayItem(aBuilder, bgData); } } bgItem->SetDependentFrame(aBuilder, dependentFrame); @@ -3876,9 +3877,9 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil nsIFrame* styleFrame = tableData.frame; tableData.frame = aSecondaryReferenceFrame; - bgItem = new (aBuilder) nsDisplayTableBackgroundImage(tableData, styleFrame); + bgItem = MakeDisplayItem(aBuilder, tableData, styleFrame); } else { - bgItem = new (aBuilder) nsDisplayBackgroundImage(bgData); + bgItem = MakeDisplayItem(aBuilder, bgData); } bgItem->SetDependentFrame(aBuilder, dependentFrame); thisItemList.AppendToTop(bgItem); @@ -3891,12 +3892,12 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil // item with respect to asr. if (aSecondaryReferenceFrame) { thisItemList.AppendToTop( - new (aBuilder) nsDisplayTableBlendMode(aBuilder, aSecondaryReferenceFrame, &thisItemList, + MakeDisplayItem(aBuilder, aSecondaryReferenceFrame, &thisItemList, bg->mImage.mLayers[i].mBlendMode, asr, i + 1, aFrame)); } else { thisItemList.AppendToTop( - new (aBuilder) nsDisplayBlendMode(aBuilder, aFrame, &thisItemList, + MakeDisplayItem(aBuilder, aFrame, &thisItemList, bg->mImage.mLayers[i].mBlendMode, asr, i + 1)); } @@ -4399,9 +4400,10 @@ nsDisplayBackgroundImage::GetBoundsInternal(nsDisplayListBuilder* aBuilder, aBuilder->GetBackgroundPaintFlags()); } -nsDisplayTableBackgroundImage::nsDisplayTableBackgroundImage(const InitData& aData, +nsDisplayTableBackgroundImage::nsDisplayTableBackgroundImage(nsDisplayListBuilder* aBuilder, + const InitData& aData, nsIFrame* aCellFrame) - : nsDisplayBackgroundImage(aData, aCellFrame) + : nsDisplayBackgroundImage(aBuilder, aData, aCellFrame) , mStyleFrame(aCellFrame) , mTableType(GetTableTypeFromFrame(mStyleFrame)) { @@ -6268,7 +6270,7 @@ nsDisplayWrapList::MergeDisplayListFromItem(nsDisplayListBuilder* aBuilder, // Create a new nsDisplayWrapList using a copy-constructor. This is done // to preserve the information about bounds. - nsDisplayWrapList* wrapper = new (aBuilder) nsDisplayWrapList(aBuilder, *wrappedItem); + nsDisplayWrapList* wrapper = MakeDisplayItem(aBuilder, *wrappedItem); // Set the display list pointer of the new wrapper item to the display list // of the wrapped item. @@ -6920,7 +6922,7 @@ nsDisplayBlendContainer::CreateForMixBlendMode(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList, const ActiveScrolledRoot* aActiveScrolledRoot) { - return new (aBuilder) nsDisplayBlendContainer(aBuilder, aFrame, aList, aActiveScrolledRoot, false); + return MakeDisplayItem(aBuilder, aFrame, aList, aActiveScrolledRoot, false); } /* static */ nsDisplayBlendContainer* @@ -6928,7 +6930,7 @@ nsDisplayBlendContainer::CreateForBackgroundBlendMode(nsDisplayListBuilder* aBui nsIFrame* aFrame, nsDisplayList* aList, const ActiveScrolledRoot* aActiveScrolledRoot) { - return new (aBuilder) nsDisplayBlendContainer(aBuilder, aFrame, aList, aActiveScrolledRoot, true); + return MakeDisplayItem(aBuilder, aFrame, aList, aActiveScrolledRoot, true); } nsDisplayBlendContainer::nsDisplayBlendContainer(nsDisplayListBuilder* aBuilder, @@ -6995,7 +6997,7 @@ nsDisplayTableBlendContainer::CreateForBackgroundBlendMode(nsDisplayListBuilder* const ActiveScrolledRoot* aActiveScrolledRoot, nsIFrame* aAncestorFrame) { - return new (aBuilder) nsDisplayTableBlendContainer(aBuilder, aFrame, aList, aActiveScrolledRoot, true, aAncestorFrame); + return MakeDisplayItem(aBuilder, aFrame, aList, aActiveScrolledRoot, true, aAncestorFrame); } nsDisplayOwnLayer::nsDisplayOwnLayer(nsDisplayListBuilder* aBuilder, @@ -7374,7 +7376,7 @@ nsDisplayFixedPosition::CreateForFixedBackground(nsDisplayListBuilder* aBuilder, nsDisplayList temp; temp.AppendToTop(aImage); - return new (aBuilder) nsDisplayFixedPosition(aBuilder, aFrame, &temp, aIndex + 1); + return MakeDisplayItem(aBuilder, aFrame, &temp, aIndex + 1); } @@ -7487,7 +7489,7 @@ nsDisplayTableFixedPosition::CreateForFixedBackground(nsDisplayListBuilder* aBui nsDisplayList temp; temp.AppendToTop(aImage); - return new (aBuilder) nsDisplayTableFixedPosition(aBuilder, aFrame, &temp, aIndex + 1, aAncestorFrame); + return MakeDisplayItem(aBuilder, aFrame, &temp, aIndex + 1, aAncestorFrame); } nsDisplayStickyPosition::nsDisplayStickyPosition(nsDisplayListBuilder* aBuilder, diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h index c629ae0f3cb1..fc0227edde61 100644 --- a/layout/painting/nsDisplayList.h +++ b/layout/painting/nsDisplayList.h @@ -130,10 +130,14 @@ typedef mozilla::EnumSet BlendModeSet; #define NS_DISPLAY_DECL_NAME(n, e) \ virtual const char* Name() const override { return n; } \ virtual DisplayItemType GetType() const override { return DisplayItemType::e; } \ +private: \ void* operator new(size_t aSize, \ nsDisplayListBuilder* aBuilder) { \ return aBuilder->Allocate(aSize, DisplayItemType::e); \ - } + } \ + template \ + friend T* ::MakeDisplayItem(nsDisplayListBuilder* aBuilder, Args&&... aArgs); \ +public: /** @@ -2025,6 +2029,13 @@ protected: class nsDisplayWrapList; +template +MOZ_ALWAYS_INLINE T* +MakeDisplayItem(nsDisplayListBuilder* aBuilder, Args&&... aArgs) +{ + return new (aBuilder) T(aBuilder, mozilla::Forward(aArgs)...); +} + /** * This is the unit of rendering and event testing. Each instance of this * class represents an entity that can be drawn on the screen, e.g., a @@ -3386,10 +3397,6 @@ public: } virtual const char* Name() const override { return mName; } virtual DisplayItemType GetType() const override { return mType; } - void* operator new(size_t aSize, - nsDisplayListBuilder* aBuilder) { - return aBuilder->Allocate(aSize, DisplayItemType::TYPE_GENERIC); - } // This override is needed because GetType() for nsDisplayGeneric subclasses // does not match TYPE_GENERIC that was used to allocate the object. @@ -3400,6 +3407,13 @@ public: } protected: + void* operator new(size_t aSize, + nsDisplayListBuilder* aBuilder) { + return aBuilder->Allocate(aSize, DisplayItemType::TYPE_GENERIC); + } + template + friend T* MakeDisplayItem(nsDisplayListBuilder* aBuilder, Args&&... aArgs); + PaintCallback mPaint; OldPaintCallback mOldPaint; // XXX: should be removed eventually const char* mName; @@ -3453,7 +3467,7 @@ protected: if (!aBuilder->IsBackgroundOnly() && !aBuilder->IsForEventDelivery() && \ PresShell()->IsPaintingFrameCounts()) { \ aLists.Outlines()->AppendToTop( \ - new (aBuilder) nsDisplayReflowCount(aBuilder, this, _name)); \ + MakeDisplayItem(aBuilder, this, _name)); \ } \ PR_END_MACRO @@ -3462,7 +3476,7 @@ protected: if (!aBuilder->IsBackgroundOnly() && !aBuilder->IsForEventDelivery() && \ PresShell()->IsPaintingFrameCounts()) { \ aLists.Outlines()->AppendToTop( \ - new (aBuilder) nsDisplayReflowCount(aBuilder, this, _name, _color)); \ + MakeDisplayItem(aBuilder, this, _name, _color)); \ } \ PR_END_MACRO @@ -3834,7 +3848,8 @@ public: const nsRect& aBackgroundRect, const nsStyleBackground* aBackgroundStyle); - explicit nsDisplayBackgroundImage(const InitData& aInitData, + explicit nsDisplayBackgroundImage(nsDisplayListBuilder* aBuilder, + const InitData& aInitData, nsIFrame* aFrameForBounds = nullptr); virtual ~nsDisplayBackgroundImage(); @@ -4028,7 +4043,7 @@ TableType GetTableTypeFromFrame(nsIFrame* aFrame); */ class nsDisplayTableBackgroundImage : public nsDisplayBackgroundImage { public: - nsDisplayTableBackgroundImage(const InitData& aInitData, nsIFrame* aCellFrame); + nsDisplayTableBackgroundImage(nsDisplayListBuilder* aBuilder, const InitData& aInitData, nsIFrame* aCellFrame); virtual uint32_t GetPerFrameKey() const override { return (mLayer << (TYPE_BITS + static_cast(TableTypeBits::COUNT))) | @@ -5104,7 +5119,7 @@ public: virtual nsDisplayWrapList* Clone(nsDisplayListBuilder* aBuilder) const override { MOZ_COUNT_CTOR(nsDisplayOpacity); - return new (aBuilder) nsDisplayOpacity(aBuilder, *this); + return MakeDisplayItem(aBuilder, *this); } virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder, @@ -5184,7 +5199,7 @@ public: virtual nsDisplayWrapList* Clone(nsDisplayListBuilder* aBuilder) const override { MOZ_COUNT_CTOR(nsDisplayBlendMode); - return new (aBuilder) nsDisplayBlendMode(aBuilder, *this); + return MakeDisplayItem(aBuilder, *this); } nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder, @@ -5248,7 +5263,7 @@ public: virtual nsDisplayWrapList* Clone(nsDisplayListBuilder* aBuilder) const override { - return new (aBuilder) nsDisplayTableBlendMode(aBuilder, *this); + return MakeDisplayItem(aBuilder, *this); } virtual nsIFrame* FrameForInvalidation() const override { return mAncestorFrame; } @@ -5285,7 +5300,7 @@ public: virtual nsDisplayWrapList* Clone(nsDisplayListBuilder* aBuilder) const override { MOZ_COUNT_CTOR(nsDisplayBlendContainer); - return new (aBuilder) nsDisplayBlendContainer(aBuilder, *this); + return MakeDisplayItem(aBuilder, *this); } virtual already_AddRefed BuildLayer(nsDisplayListBuilder* aBuilder, @@ -5344,7 +5359,7 @@ public: virtual nsDisplayWrapList* Clone(nsDisplayListBuilder* aBuilder) const override { - return new (aBuilder) nsDisplayTableBlendContainer(aBuilder, *this); + return MakeDisplayItem(aBuilder, *this); } virtual nsIFrame* FrameForInvalidation() const override { return mAncestorFrame; } @@ -5582,7 +5597,7 @@ public: virtual nsDisplayWrapList* Clone(nsDisplayListBuilder* aBuilder) const override { MOZ_COUNT_CTOR(nsDisplayStickyPosition); - return new (aBuilder) nsDisplayStickyPosition(aBuilder, *this); + return MakeDisplayItem(aBuilder, *this); } virtual already_AddRefed BuildLayer(nsDisplayListBuilder* aBuilder, @@ -5636,7 +5651,7 @@ public: virtual nsDisplayWrapList* Clone(nsDisplayListBuilder* aBuilder) const override { - return new (aBuilder) nsDisplayFixedPosition(aBuilder, *this); + return MakeDisplayItem(aBuilder, *this); } virtual already_AddRefed BuildLayer(nsDisplayListBuilder* aBuilder, @@ -5694,7 +5709,7 @@ public: virtual nsDisplayWrapList* Clone(nsDisplayListBuilder* aBuilder) const override { - return new (aBuilder) nsDisplayTableFixedPosition(aBuilder, *this); + return MakeDisplayItem(aBuilder, *this); } virtual nsIFrame* FrameForInvalidation() const override { return mAncestorFrame; } @@ -5899,7 +5914,7 @@ public: virtual nsDisplayWrapList* Clone(nsDisplayListBuilder* aBuilder) const override { MOZ_COUNT_CTOR(nsDisplayMask); - return new (aBuilder) nsDisplayMask(aBuilder, *this); + return MakeDisplayItem(aBuilder, *this); } NS_DISPLAY_DECL_NAME("Mask", TYPE_MASK) @@ -5988,7 +6003,7 @@ public: virtual nsDisplayWrapList* Clone(nsDisplayListBuilder* aBuilder) const override { MOZ_COUNT_CTOR(nsDisplayFilter); - return new (aBuilder) nsDisplayFilter(aBuilder, *this); + return MakeDisplayItem(aBuilder, *this); } NS_DISPLAY_DECL_NAME("Filter", TYPE_FILTER) diff --git a/layout/svg/SVGGeometryFrame.cpp b/layout/svg/SVGGeometryFrame.cpp index 56ead13c2b29..25451e7110a3 100644 --- a/layout/svg/SVGGeometryFrame.cpp +++ b/layout/svg/SVGGeometryFrame.cpp @@ -260,7 +260,7 @@ SVGGeometryFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, } DisplayOutline(aBuilder, aLists); aLists.Content()->AppendToTop( - new (aBuilder) nsDisplaySVGGeometry(aBuilder, this)); + MakeDisplayItem(aBuilder, this)); } //---------------------------------------------------------------------- diff --git a/layout/svg/SVGTextFrame.cpp b/layout/svg/SVGTextFrame.cpp index f9c8f49a67ba..f2c1193c90e8 100644 --- a/layout/svg/SVGTextFrame.cpp +++ b/layout/svg/SVGTextFrame.cpp @@ -3204,7 +3204,7 @@ SVGTextFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, } DisplayOutline(aBuilder, aLists); aLists.Content()->AppendToTop( - new (aBuilder) nsDisplaySVGText(aBuilder, this)); + MakeDisplayItem(aBuilder, this)); } nsresult diff --git a/layout/svg/nsSVGOuterSVGFrame.cpp b/layout/svg/nsSVGOuterSVGFrame.cpp index 15603b22f8a6..d21a73a611d9 100644 --- a/layout/svg/nsSVGOuterSVGFrame.cpp +++ b/layout/svg/nsSVGOuterSVGFrame.cpp @@ -786,10 +786,10 @@ nsSVGOuterSVGFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, nsDisplayListSet set(&newList, &newList, &newList, &newList, &newList, &newList); BuildDisplayListForNonBlockChildren(aBuilder, set); - aLists.Content()->AppendToTop(new (aBuilder) nsDisplaySVGWrapper(aBuilder, this, &newList)); + aLists.Content()->AppendToTop(MakeDisplayItem(aBuilder, this, &newList)); } else if (IsVisibleForPainting(aBuilder) || !aBuilder->IsForPainting()) { aLists.Content()->AppendToTop( - new (aBuilder) nsDisplayOuterSVG(aBuilder, this)); + MakeDisplayItem(aBuilder, this)); } } diff --git a/layout/tables/nsTableCellFrame.cpp b/layout/tables/nsTableCellFrame.cpp index c7b50162e8da..1e488d550c40 100644 --- a/layout/tables/nsTableCellFrame.cpp +++ b/layout/tables/nsTableCellFrame.cpp @@ -391,8 +391,7 @@ nsTableCellFrame::ProcessBorders(nsTableFrame* aFrame, if (!GetContentEmpty() || StyleTableBorder()->mEmptyCells == NS_STYLE_TABLE_EMPTY_CELLS_SHOW) { - aLists.BorderBackground()->AppendToTop(new (aBuilder) - nsDisplayBorder(aBuilder, this)); + aLists.BorderBackground()->AppendToTop(MakeDisplayItem(aBuilder, this)); } return NS_OK; @@ -496,7 +495,7 @@ nsTableCellFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, bool hasBoxShadow = !!StyleEffects()->mBoxShadow; if (hasBoxShadow) { aLists.BorderBackground()->AppendToTop( - new (aBuilder) nsDisplayBoxShadowOuter(aBuilder, this)); + MakeDisplayItem(aBuilder, this)); } // display background if we need to. @@ -512,7 +511,7 @@ nsTableCellFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, // display inset box-shadows if we need to. if (hasBoxShadow) { aLists.BorderBackground()->AppendToTop( - new (aBuilder) nsDisplayBoxShadowInner(aBuilder, this)); + MakeDisplayItem(aBuilder, this)); } // display borders if we need to @@ -520,8 +519,8 @@ nsTableCellFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, // and display the selection border if we need to if (IsSelected()) { - aLists.BorderBackground()->AppendToTop(new (aBuilder) - nsDisplayTableCellSelection(aBuilder, this)); + aLists.BorderBackground()->AppendToTop( + MakeDisplayItem(aBuilder, this)); } } diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 0d536ce3590e..2f4544ed5e6c 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -1533,7 +1533,7 @@ nsTableFrame::DisplayGenericTablePart(nsDisplayListBuilder* aBuilder, // Paint the outset box-shadows for the table frames if (aFrame->StyleEffects()->mBoxShadow) { aLists.BorderBackground()->AppendToTop( - new (aBuilder) nsDisplayBoxShadowOuter(aBuilder, aFrame)); + MakeDisplayItem(aBuilder, aFrame)); } } @@ -1601,7 +1601,7 @@ nsTableFrame::DisplayGenericTablePart(nsDisplayListBuilder* aBuilder, // Paint the inset box-shadows for the table frames if (aFrame->StyleEffects()->mBoxShadow) { aLists.BorderBackground()->AppendToTop( - new (aBuilder) nsDisplayBoxShadowInner(aBuilder, aFrame)); + MakeDisplayItem(aBuilder, aFrame)); } } @@ -1616,13 +1616,13 @@ nsTableFrame::DisplayGenericTablePart(nsDisplayListBuilder* aBuilder, if (table->IsBorderCollapse()) { if (table->HasBCBorders()) { aLists.BorderBackground()->AppendToTop( - new (aBuilder) nsDisplayTableBorderCollapse(aBuilder, table)); + MakeDisplayItem(aBuilder, table)); } } else { const nsStyleBorder* borderStyle = aFrame->StyleBorder(); if (borderStyle->HasBorder()) { aLists.BorderBackground()->AppendToTop( - new (aBuilder) nsDisplayBorder(aBuilder, table)); + MakeDisplayItem(aBuilder, table)); } } } diff --git a/layout/xul/nsBoxFrame.cpp b/layout/xul/nsBoxFrame.cpp index fbd0b8f82fed..e22854ffa92f 100644 --- a/layout/xul/nsBoxFrame.cpp +++ b/layout/xul/nsBoxFrame.cpp @@ -1348,11 +1348,11 @@ nsBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, #ifdef DEBUG_LAYOUT if (mState & NS_STATE_CURRENTLY_IN_DEBUG) { - destination.BorderBackground()->AppendToTop(new (aBuilder) - nsDisplayGeneric(aBuilder, this, PaintXULDebugBackground, + destination.BorderBackground()->AppendToTop( + MakeDisplayItem(aBuilder, this, PaintXULDebugBackground, "XULDebugBackground")); - destination.Outlines()->AppendToTop(new (aBuilder) - nsDisplayXULDebug(aBuilder, this)); + destination.Outlines()->AppendToTop( + MakeDisplayItem(aBuilder, this)); } #endif @@ -1384,11 +1384,11 @@ nsBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, DisplayListClipState::AutoSaveRestore ownLayerClipState(aBuilder); // Wrap the list to make it its own layer - aLists.Content()->AppendToTop(new (aBuilder) - nsDisplayOwnLayer(aBuilder, this, &masterList, ownLayerASR, - nsDisplayOwnLayerFlags::eNone, - mozilla::layers::FrameMetrics::NULL_SCROLL_ID, - mozilla::layers::ScrollThumbData{}, true, true)); + aLists.Content()->AppendToTop( + MakeDisplayItem(aBuilder, this, &masterList, ownLayerASR, + nsDisplayOwnLayerFlags::eNone, + mozilla::layers::FrameMetrics::NULL_SCROLL_ID, + mozilla::layers::ScrollThumbData{}, true, true)); } } @@ -2086,14 +2086,13 @@ public: virtual nsDisplayItem* WrapList(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList) override { - return new (aBuilder) - nsDisplayXULEventRedirector(aBuilder, aFrame, aList, mTargetFrame); + return MakeDisplayItem(aBuilder, aFrame, aList, + mTargetFrame); } virtual nsDisplayItem* WrapItem(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem) override { - return new (aBuilder) - nsDisplayXULEventRedirector(aBuilder, aItem->Frame(), aItem, - mTargetFrame); + return MakeDisplayItem(aBuilder, aItem->Frame(), aItem, + mTargetFrame); } private: nsIFrame* mTargetFrame; diff --git a/layout/xul/nsGroupBoxFrame.cpp b/layout/xul/nsGroupBoxFrame.cpp index c58fd9b18b65..120855b923af 100644 --- a/layout/xul/nsGroupBoxFrame.cpp +++ b/layout/xul/nsGroupBoxFrame.cpp @@ -153,8 +153,8 @@ nsGroupBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, nsDisplayBackgroundImage::AppendBackgroundItemsToTop( aBuilder, this, GetBackgroundRectRelativeToSelf(), aLists.BorderBackground()); - aLists.BorderBackground()->AppendToTop(new (aBuilder) - nsDisplayXULGroupBorder(aBuilder, this)); + aLists.BorderBackground()->AppendToTop( + MakeDisplayItem(aBuilder, this)); DisplayOutline(aBuilder, aLists); } diff --git a/layout/xul/nsImageBoxFrame.cpp b/layout/xul/nsImageBoxFrame.cpp index 01a4268b2c4a..e1c04c6662be 100644 --- a/layout/xul/nsImageBoxFrame.cpp +++ b/layout/xul/nsImageBoxFrame.cpp @@ -342,7 +342,7 @@ nsImageBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, nsDisplayList list; list.AppendToTop( - new (aBuilder) nsDisplayXULImage(aBuilder, this)); + MakeDisplayItem(aBuilder, this)); CreateOwnLayerIfNeeded(aBuilder, &list); diff --git a/layout/xul/nsLeafBoxFrame.cpp b/layout/xul/nsLeafBoxFrame.cpp index 1aa5db58805b..a8b11e4160c3 100644 --- a/layout/xul/nsLeafBoxFrame.cpp +++ b/layout/xul/nsLeafBoxFrame.cpp @@ -112,8 +112,8 @@ nsLeafBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, if (!aBuilder->IsForEventDelivery() || !IsVisibleForPainting(aBuilder)) return; - aLists.Content()->AppendToTop(new (aBuilder) - nsDisplayEventReceiver(aBuilder, this)); + aLists.Content()->AppendToTop( + MakeDisplayItem(aBuilder, this)); } /* virtual */ nscoord diff --git a/layout/xul/nsSliderFrame.cpp b/layout/xul/nsSliderFrame.cpp index ebe279255436..c363a5e42e69 100644 --- a/layout/xul/nsSliderFrame.cpp +++ b/layout/xul/nsSliderFrame.cpp @@ -326,8 +326,8 @@ nsSliderFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, if (aBuilder->IsForEventDelivery() && isDraggingThumb()) { // This is EVIL, we shouldn't be messing with event delivery just to get // thumb mouse drag events to arrive at the slider! - aLists.Outlines()->AppendToTop(new (aBuilder) - nsDisplayEventReceiver(aBuilder, this)); + aLists.Outlines()->AppendToTop( + MakeDisplayItem(aBuilder, this)); return; } @@ -458,16 +458,16 @@ nsSliderFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder, // Wrap the list to make it its own layer. const ActiveScrolledRoot* ownLayerASR = contASRTracker.GetContainerASR(); - aLists.Content()->AppendToTop(new (aBuilder) - nsDisplayOwnLayer(aBuilder, this, &masterList, ownLayerASR, - flags, scrollTargetId, - ScrollThumbData{scrollDirection, - GetThumbRatio(), - thumbStart, - thumbLength, - isAsyncDraggable, - sliderTrackStart, - sliderTrackLength})); + aLists.Content()->AppendToTop( + MakeDisplayItem(aBuilder, this, &masterList, ownLayerASR, + flags, scrollTargetId, + ScrollThumbData{scrollDirection, + GetThumbRatio(), + thumbStart, + thumbLength, + isAsyncDraggable, + sliderTrackStart, + sliderTrackLength})); return; } diff --git a/layout/xul/nsSplitterFrame.cpp b/layout/xul/nsSplitterFrame.cpp index cddcb7f53834..276b990f8b41 100644 --- a/layout/xul/nsSplitterFrame.cpp +++ b/layout/xul/nsSplitterFrame.cpp @@ -384,8 +384,8 @@ nsSplitterFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, if (mInner->mDragging && aBuilder->IsForEventDelivery()) { // XXX It's probably better not to check visibility here, right? - aLists.Outlines()->AppendToTop(new (aBuilder) - nsDisplayEventReceiver(aBuilder, this)); + aLists.Outlines()->AppendToTop( + MakeDisplayItem(aBuilder, this)); return; } } diff --git a/layout/xul/nsTextBoxFrame.cpp b/layout/xul/nsTextBoxFrame.cpp index 8fa78bb54ce8..e3ac37eacdbc 100644 --- a/layout/xul/nsTextBoxFrame.cpp +++ b/layout/xul/nsTextBoxFrame.cpp @@ -373,8 +373,8 @@ nsTextBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, nsLeafBoxFrame::BuildDisplayList(aBuilder, aLists); - aLists.Content()->AppendToTop(new (aBuilder) - nsDisplayXULTextBox(aBuilder, this)); + aLists.Content()->AppendToTop( + MakeDisplayItem(aBuilder, this)); } void diff --git a/layout/xul/tree/nsTreeBodyFrame.cpp b/layout/xul/tree/nsTreeBodyFrame.cpp index 37d76cc23178..9caf362db142 100644 --- a/layout/xul/tree/nsTreeBodyFrame.cpp +++ b/layout/xul/tree/nsTreeBodyFrame.cpp @@ -2845,7 +2845,7 @@ nsTreeBodyFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, if (!mView || !GetContent ()->GetComposedDoc()->GetWindow()) return; - nsDisplayItem* item = new (aBuilder) nsDisplayTreeBody(aBuilder, this); + nsDisplayItem* item = MakeDisplayItem(aBuilder, this); aLists.Content()->AppendToTop(item); #ifdef XP_MACOSX diff --git a/layout/xul/tree/nsTreeColFrame.cpp b/layout/xul/tree/nsTreeColFrame.cpp index d0c8087add33..cc51cfda4292 100644 --- a/layout/xul/tree/nsTreeColFrame.cpp +++ b/layout/xul/tree/nsTreeColFrame.cpp @@ -126,8 +126,8 @@ nsTreeColFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder, WrapListsInRedirector(aBuilder, set, aLists); - aLists.Content()->AppendToTop(new (aBuilder) - nsDisplayXULTreeColSplitterTarget(aBuilder, this)); + aLists.Content()->AppendToTop( + MakeDisplayItem(aBuilder, this)); } nsresult