Skip to content

Commit 292af32

Browse files
committedDec 6, 2024
Bug 1933440. Make all display item destructors default and mark all display items final that can be. r=layout-reviewers,jfkthame
This just makes things nice and consistent and lets the compiler optimize if it can. Differential Revision: https://phabricator.services.mozilla.com/D230249
1 parent 9e7791a commit 292af32

26 files changed

+115
-123
lines changed
 

‎layout/forms/nsFieldSetFrame.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ class nsDisplayFieldSetBorder final : public nsPaintedDisplayItem {
107107
: nsPaintedDisplayItem(aBuilder, aFrame) {
108108
MOZ_COUNT_CTOR(nsDisplayFieldSetBorder);
109109
}
110-
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayFieldSetBorder)
110+
111+
MOZ_COUNTED_DTOR_FINAL(nsDisplayFieldSetBorder)
111112

112113
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
113114
bool CreateWebRenderCommands(

‎layout/forms/nsHTMLButtonControlFrame.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ class nsDisplayButtonForeground final : public nsPaintedDisplayItem {
8585
: nsPaintedDisplayItem(aBuilder, aFrame) {
8686
MOZ_COUNT_CTOR(nsDisplayButtonForeground);
8787
}
88-
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayButtonForeground)
88+
89+
MOZ_COUNTED_DTOR_FINAL(nsDisplayButtonForeground)
8990

9091
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
9192
bool CreateWebRenderCommands(

‎layout/forms/nsSelectsAreaFrame.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace mozilla {
7272
* an option element to the element's own frame.
7373
* REVIEW: This is what nsSelectsAreaFrame::GetFrameForPoint used to do
7474
*/
75-
class nsDisplayOptionEventGrabber : public nsDisplayWrapList {
75+
class nsDisplayOptionEventGrabber final : public nsDisplayWrapList {
7676
public:
7777
nsDisplayOptionEventGrabber(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
7878
nsDisplayItem* aItem)
@@ -132,13 +132,14 @@ class nsOptionEventGrabberWrapper : public nsDisplayItemWrapper {
132132
}
133133
};
134134

135-
class nsDisplayListFocus : public nsPaintedDisplayItem {
135+
class nsDisplayListFocus final : public nsPaintedDisplayItem {
136136
public:
137137
nsDisplayListFocus(nsDisplayListBuilder* aBuilder, nsSelectsAreaFrame* aFrame)
138138
: nsPaintedDisplayItem(aBuilder, aFrame) {
139139
MOZ_COUNT_CTOR(nsDisplayListFocus);
140140
}
141-
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayListFocus)
141+
142+
MOZ_COUNTED_DTOR_FINAL(nsDisplayListFocus)
142143

143144
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
144145
bool* aSnap) const override {

‎layout/generic/TextOverflow.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class nsDisplayTextOverflowMarker final : public nsPaintedDisplayItem {
158158
MOZ_COUNT_CTOR(nsDisplayTextOverflowMarker);
159159
}
160160

161-
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayTextOverflowMarker)
161+
MOZ_COUNTED_DTOR_FINAL(nsDisplayTextOverflowMarker)
162162

163163
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
164164
bool* aSnap) const override {

‎layout/generic/nsCanvasFrame.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,14 @@ void nsDisplayCanvasThemedBackground::Paint(nsDisplayListBuilder* aBuilder,
386386
*
387387
* The only reason this can't use nsDisplayGeneric is overriding GetBounds.
388388
*/
389-
class nsDisplayCanvasFocus : public nsPaintedDisplayItem {
389+
class nsDisplayCanvasFocus final : public nsPaintedDisplayItem {
390390
public:
391391
nsDisplayCanvasFocus(nsDisplayListBuilder* aBuilder, nsCanvasFrame* aFrame)
392392
: nsPaintedDisplayItem(aBuilder, aFrame) {
393393
MOZ_COUNT_CTOR(nsDisplayCanvasFocus);
394394
}
395-
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayCanvasFocus)
395+
396+
MOZ_COUNTED_DTOR_FINAL(nsDisplayCanvasFocus)
396397

397398
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
398399
bool* aSnap) const override {

‎layout/generic/nsCanvasFrame.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class nsDisplayCanvasBackgroundColor final : public nsDisplaySolidColorBase {
153153
void WriteDebugInfo(std::stringstream& aStream) override;
154154
};
155155

156-
class nsDisplayCanvasBackgroundImage : public nsDisplayBackgroundImage {
156+
class nsDisplayCanvasBackgroundImage final : public nsDisplayBackgroundImage {
157157
public:
158158
explicit nsDisplayCanvasBackgroundImage(nsDisplayListBuilder* aBuilder,
159159
nsIFrame* aFrame,
@@ -172,7 +172,7 @@ class nsDisplayCanvasBackgroundImage : public nsDisplayBackgroundImage {
172172
NS_DISPLAY_DECL_NAME("CanvasBackgroundImage", TYPE_CANVAS_BACKGROUND_IMAGE)
173173
};
174174

175-
class nsDisplayCanvasThemedBackground : public nsDisplayThemedBackground {
175+
class nsDisplayCanvasThemedBackground final : public nsDisplayThemedBackground {
176176
public:
177177
nsDisplayCanvasThemedBackground(nsDisplayListBuilder* aBuilder,
178178
nsIFrame* aFrame)

‎layout/generic/nsColumnSetFrame.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ static LazyLogModule sColumnSetLog("ColumnSet");
2626
#define COLUMN_SET_LOG(msg, ...) \
2727
MOZ_LOG(sColumnSetLog, LogLevel::Debug, (msg, ##__VA_ARGS__))
2828

29-
class nsDisplayColumnRule : public nsPaintedDisplayItem {
29+
class nsDisplayColumnRule final : public nsPaintedDisplayItem {
3030
public:
3131
nsDisplayColumnRule(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
3232
: nsPaintedDisplayItem(aBuilder, aFrame) {
3333
MOZ_COUNT_CTOR(nsDisplayColumnRule);
3434
}
35-
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayColumnRule)
35+
36+
MOZ_COUNTED_DTOR_FINAL(nsDisplayColumnRule)
3637

3738
nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) const override {
3839
*aSnap = false;

‎layout/generic/nsContainerFrame.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ void nsContainerFrame::BuildDisplayListForNonBlockChildren(
384384
}
385385
}
386386

387-
class nsDisplaySelectionOverlay : public nsPaintedDisplayItem {
387+
class nsDisplaySelectionOverlay final : public nsPaintedDisplayItem {
388388
public:
389389
/**
390390
* @param aSelectionValue nsISelectionController::getDisplaySelection.
@@ -395,7 +395,8 @@ class nsDisplaySelectionOverlay : public nsPaintedDisplayItem {
395395
mSelectionValue(aSelectionValue) {
396396
MOZ_COUNT_CTOR(nsDisplaySelectionOverlay);
397397
}
398-
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplaySelectionOverlay)
398+
399+
MOZ_COUNTED_DTOR_FINAL(nsDisplaySelectionOverlay)
399400

400401
virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
401402
bool CreateWebRenderCommands(

‎layout/generic/nsFrameSetFrame.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -1317,14 +1317,15 @@ void nsHTMLFramesetBorderFrame::Reflow(nsPresContext* aPresContext,
13171317
FinishAndStoreOverflow(&aDesiredSize, aReflowInput.mStyleDisplay);
13181318
}
13191319

1320-
class nsDisplayFramesetBorder : public nsPaintedDisplayItem {
1320+
class nsDisplayFramesetBorder final : public nsPaintedDisplayItem {
13211321
public:
13221322
nsDisplayFramesetBorder(nsDisplayListBuilder* aBuilder,
13231323
nsHTMLFramesetBorderFrame* aFrame)
13241324
: nsPaintedDisplayItem(aBuilder, aFrame) {
13251325
MOZ_COUNT_CTOR(nsDisplayFramesetBorder);
13261326
}
1327-
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayFramesetBorder)
1327+
1328+
MOZ_COUNTED_DTOR_FINAL(nsDisplayFramesetBorder)
13281329

13291330
// REVIEW: see old GetFrameForPoint
13301331
// Receives events in its bounds
@@ -1496,13 +1497,14 @@ void nsHTMLFramesetBlankFrame::Reflow(nsPresContext* aPresContext,
14961497
FinishAndStoreOverflow(&aDesiredSize, aReflowInput.mStyleDisplay);
14971498
}
14981499

1499-
class nsDisplayFramesetBlank : public nsPaintedDisplayItem {
1500+
class nsDisplayFramesetBlank final : public nsPaintedDisplayItem {
15001501
public:
15011502
nsDisplayFramesetBlank(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
15021503
: nsPaintedDisplayItem(aBuilder, aFrame) {
15031504
MOZ_COUNT_CTOR(nsDisplayFramesetBlank);
15041505
}
1505-
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayFramesetBlank)
1506+
1507+
MOZ_COUNTED_DTOR_FINAL(nsDisplayFramesetBlank)
15061508

15071509
virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
15081510
NS_DISPLAY_DECL_NAME("FramesetBlank", TYPE_FRAMESET_BLANK)

‎layout/generic/nsHTMLCanvasFrame.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ class nsDisplayCanvas final : public nsPaintedDisplayItem {
5959
: nsPaintedDisplayItem(aBuilder, aFrame) {
6060
MOZ_COUNT_CTOR(nsDisplayCanvas);
6161
}
62-
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayCanvas)
62+
63+
MOZ_COUNTED_DTOR_FINAL(nsDisplayCanvas)
6364

6465
NS_DISPLAY_DECL_NAME("nsDisplayCanvas", TYPE_CANVAS)
6566

‎layout/generic/nsImageFrame.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ class nsDisplayGradient final : public nsPaintedDisplayItem {
112112
: nsPaintedDisplayItem(aBuilder, aFrame) {
113113
MOZ_COUNT_CTOR(nsDisplayGradient);
114114
}
115-
~nsDisplayGradient() final { MOZ_COUNT_DTOR(nsDisplayGradient); }
115+
116+
MOZ_COUNTED_DTOR_FINAL(nsDisplayGradient)
116117

117118
nsRect GetBounds(bool* aSnap) const {
118119
*aSnap = true;

‎layout/generic/nsImageFrame.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ class nsDisplayImage final : public nsPaintedDisplayItem {
433433
mPrevImage(aPrevImage) {
434434
MOZ_COUNT_CTOR(nsDisplayImage);
435435
}
436-
~nsDisplayImage() final { MOZ_COUNT_DTOR(nsDisplayImage); }
436+
437+
MOZ_COUNTED_DTOR_FINAL(nsDisplayImage)
437438

438439
void Paint(nsDisplayListBuilder*, gfxContext* aCtx) final;
439440

‎layout/generic/nsPageFrame.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,8 @@ class nsDisplayHeaderFooter final : public nsPaintedDisplayItem {
470470
: nsPaintedDisplayItem(aBuilder, aFrame) {
471471
MOZ_COUNT_CTOR(nsDisplayHeaderFooter);
472472
}
473-
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayHeaderFooter)
473+
474+
MOZ_COUNTED_DTOR_FINAL(nsDisplayHeaderFooter)
474475

475476
virtual void Paint(nsDisplayListBuilder* aBuilder,
476477
gfxContext* aCtx) override {

‎layout/generic/nsVideoFrame.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -539,14 +539,14 @@ void nsVideoFrame::UpdateTextTrack() {
539539

540540
namespace mozilla {
541541

542-
class nsDisplayVideo : public nsPaintedDisplayItem {
542+
class nsDisplayVideo final : public nsPaintedDisplayItem {
543543
public:
544544
nsDisplayVideo(nsDisplayListBuilder* aBuilder, nsVideoFrame* aFrame)
545545
: nsPaintedDisplayItem(aBuilder, aFrame) {
546546
MOZ_COUNT_CTOR(nsDisplayVideo);
547547
}
548548

549-
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayVideo)
549+
MOZ_COUNTED_DTOR_FINAL(nsDisplayVideo)
550550

551551
NS_DISPLAY_DECL_NAME("Video", TYPE_VIDEO)
552552

‎layout/mathml/nsMathMLChar.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -1732,7 +1732,8 @@ class nsDisplayMathMLSelectionRect final : public nsPaintedDisplayItem {
17321732
: nsPaintedDisplayItem(aBuilder, aFrame), mRect(aRect) {
17331733
MOZ_COUNT_CTOR(nsDisplayMathMLSelectionRect);
17341734
}
1735-
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayMathMLSelectionRect)
1735+
1736+
MOZ_COUNTED_DTOR_FINAL(nsDisplayMathMLSelectionRect)
17361737

17371738
virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
17381739
NS_DISPLAY_DECL_NAME("MathMLSelectionRect", TYPE_MATHML_SELECTION_RECT)
@@ -1761,7 +1762,8 @@ class nsDisplayMathMLCharForeground final : public nsPaintedDisplayItem {
17611762
mIsSelected(aIsSelected) {
17621763
MOZ_COUNT_CTOR(nsDisplayMathMLCharForeground);
17631764
}
1764-
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayMathMLCharForeground)
1765+
1766+
MOZ_COUNTED_DTOR_FINAL(nsDisplayMathMLCharForeground)
17651767

17661768
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
17671769
bool* aSnap) const override {
@@ -1804,7 +1806,8 @@ class nsDisplayMathMLCharDebug final : public nsPaintedDisplayItem {
18041806
: nsPaintedDisplayItem(aBuilder, aFrame), mRect(aRect) {
18051807
MOZ_COUNT_CTOR(nsDisplayMathMLCharDebug);
18061808
}
1807-
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayMathMLCharDebug)
1809+
1810+
MOZ_COUNTED_DTOR_FINAL(nsDisplayMathMLCharDebug)
18081811

18091812
virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
18101813
NS_DISPLAY_DECL_NAME("MathMLCharDebug", TYPE_MATHML_CHAR_DEBUG)

‎layout/mathml/nsMathMLFrame.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ class nsDisplayMathMLBar final : public nsPaintedDisplayItem {
266266
: nsPaintedDisplayItem(aBuilder, aFrame), mRect(aRect) {
267267
MOZ_COUNT_CTOR(nsDisplayMathMLBar);
268268
}
269-
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayMathMLBar)
269+
270+
MOZ_COUNTED_DTOR_FINAL(nsDisplayMathMLBar)
270271

271272
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
272273
NS_DISPLAY_DECL_NAME("MathMLBar", TYPE_MATHML_BAR)

‎layout/mathml/nsMathMLmencloseFrame.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,8 @@ class nsDisplayNotation final : public nsPaintedDisplayItem {
629629
mType(aType) {
630630
MOZ_COUNT_CTOR(nsDisplayNotation);
631631
}
632-
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayNotation)
632+
633+
MOZ_COUNTED_DTOR_FINAL(nsDisplayNotation)
633634

634635
void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
635636
NS_DISPLAY_DECL_NAME("MathMLMencloseNotation", TYPE_MATHML_MENCLOSE_NOTATION)

‎layout/painting/nsDisplayList.cpp

-26
Original file line numberDiff line numberDiff line change
@@ -2927,10 +2927,6 @@ nsDisplayBackgroundImage::nsDisplayBackgroundImage(
29272927
}
29282928
}
29292929

2930-
nsDisplayBackgroundImage::~nsDisplayBackgroundImage() {
2931-
MOZ_COUNT_DTOR(nsDisplayBackgroundImage);
2932-
}
2933-
29342930
void nsDisplayBackgroundImage::Destroy(nsDisplayListBuilder* aBuilder) {
29352931
RemoveDisplayItemFromFrame(aBuilder, mDependentFrame);
29362932
nsPaintedDisplayItem::Destroy(aBuilder);
@@ -4117,10 +4113,6 @@ nsDisplayCaret::nsDisplayCaret(nsDisplayListBuilder* aBuilder,
41174113
SetBuildingRect(mBounds);
41184114
}
41194115

4120-
#ifdef NS_BUILD_REFCNT_LOGGING
4121-
nsDisplayCaret::~nsDisplayCaret() { MOZ_COUNT_DTOR(nsDisplayCaret); }
4122-
#endif
4123-
41244116
nsRect nsDisplayCaret::GetBounds(nsDisplayListBuilder* aBuilder,
41254117
bool* aSnap) const {
41264118
*aSnap = true;
@@ -4574,8 +4566,6 @@ nsDisplayWrapList::nsDisplayWrapList(nsDisplayListBuilder* aBuilder,
45744566
SetBuildingRect(visible);
45754567
}
45764568

4577-
nsDisplayWrapList::~nsDisplayWrapList() { MOZ_COUNT_DTOR(nsDisplayWrapList); }
4578-
45794569
void nsDisplayWrapList::HitTest(nsDisplayListBuilder* aBuilder,
45804570
const nsRect& aRect, HitTestState* aState,
45814571
nsTArray<nsIFrame*>* aOutFrames) {
@@ -5334,10 +5324,6 @@ nsDisplaySubDocument::nsDisplaySubDocument(nsDisplayListBuilder* aBuilder,
53345324
}
53355325
}
53365326

5337-
nsDisplaySubDocument::~nsDisplaySubDocument() {
5338-
MOZ_COUNT_DTOR(nsDisplaySubDocument);
5339-
}
5340-
53415327
void nsDisplaySubDocument::Destroy(nsDisplayListBuilder* aBuilder) {
53425328
RemoveDisplayItemFromFrame(aBuilder, mSubDocFrame);
53435329
nsDisplayOwnLayer::Destroy(aBuilder);
@@ -5965,12 +5951,6 @@ nsDisplayAsyncZoom::nsDisplayAsyncZoom(
59655951
MOZ_COUNT_CTOR(nsDisplayAsyncZoom);
59665952
}
59675953

5968-
#ifdef NS_BUILD_REFCNT_LOGGING
5969-
nsDisplayAsyncZoom::~nsDisplayAsyncZoom() {
5970-
MOZ_COUNT_DTOR(nsDisplayAsyncZoom);
5971-
}
5972-
#endif
5973-
59745954
void nsDisplayAsyncZoom::HitTest(nsDisplayListBuilder* aBuilder,
59755955
const nsRect& aRect, HitTestState* aState,
59765956
nsTArray<nsIFrame*>* aOutFrames) {
@@ -8584,12 +8564,6 @@ nsDisplayForeignObject::nsDisplayForeignObject(nsDisplayListBuilder* aBuilder,
85848564
MOZ_COUNT_CTOR(nsDisplayForeignObject);
85858565
}
85868566

8587-
#ifdef NS_BUILD_REFCNT_LOGGING
8588-
nsDisplayForeignObject::~nsDisplayForeignObject() {
8589-
MOZ_COUNT_DTOR(nsDisplayForeignObject);
8590-
}
8591-
#endif
8592-
85938567
bool nsDisplayForeignObject::ShouldFlattenAway(nsDisplayListBuilder* aBuilder) {
85948568
return !aBuilder->GetWidgetLayerManager();
85958569
}

0 commit comments

Comments
 (0)
Failed to load comments.