diff --git a/layout/generic/TextOverflow.cpp b/layout/generic/TextOverflow.cpp index a1285e490642..3ad1d627e44f 100644 --- a/layout/generic/TextOverflow.cpp +++ b/layout/generic/TextOverflow.cpp @@ -335,7 +335,7 @@ TextOverflow::TextOverflow(nsDisplayListBuilder* aBuilder, // has overflow on that side. } -/* static */ TextOverflow* +/* static */ UniquePtr TextOverflow::WillProcessLines(nsDisplayListBuilder* aBuilder, nsIFrame* aBlockFrame) { @@ -350,7 +350,7 @@ TextOverflow::WillProcessLines(nsDisplayListBuilder* aBuilder, // If the APZ is actively scrolling this, don't bother with markers. return nullptr; } - return new TextOverflow(aBuilder, aBlockFrame); + return MakeUnique(aBuilder, aBlockFrame); } void diff --git a/layout/generic/TextOverflow.h b/layout/generic/TextOverflow.h index 87f6ac3a5c34..270afd000b2c 100644 --- a/layout/generic/TextOverflow.h +++ b/layout/generic/TextOverflow.h @@ -11,6 +11,7 @@ #include "nsTHashtable.h" #include "mozilla/Attributes.h" #include "mozilla/Likely.h" +#include "mozilla/UniquePtr.h" #include "mozilla/WritingModes.h" #include @@ -32,8 +33,18 @@ class MOZ_HEAP_CLASS TextOverflow final { * Allocate an object for text-overflow processing. * @return nullptr if no processing is necessary. The caller owns the object. */ - static TextOverflow* WillProcessLines(nsDisplayListBuilder* aBuilder, - nsIFrame* aBlockFrame); + static UniquePtr + WillProcessLines(nsDisplayListBuilder* aBuilder, + nsIFrame* aBlockFrame); + + /** + * Constructor, which client code SHOULD NOT use directly. Instead, clients + * should call WillProcessLines(), which is basically the factory function + * for TextOverflow instances. + */ + TextOverflow(nsDisplayListBuilder* aBuilder, + nsIFrame* aBlockFrame); + /** * Analyze the display lists for text overflow and what kind of item is at * the content edges. Add display items for text-overflow markers as needed @@ -59,9 +70,6 @@ class MOZ_HEAP_CLASS TextOverflow final { typedef nsTHashtable> FrameHashtable; private: - TextOverflow(nsDisplayListBuilder* aBuilder, - nsIFrame* aBlockFrame); - typedef mozilla::WritingMode WritingMode; typedef mozilla::LogicalRect LogicalRect; diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index dfa66914cb85..52ce21443780 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -6756,8 +6756,8 @@ nsBlockFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, aBuilder->MarkFramesForDisplayList(this, mFloats, aDirtyRect); // Prepare for text-overflow processing. - UniquePtr textOverflow( - TextOverflow::WillProcessLines(aBuilder, this)); + UniquePtr textOverflow = + TextOverflow::WillProcessLines(aBuilder, this); // We'll collect our lines' display items here, & then append this to aLists. nsDisplayListCollection linesDisplayListCollection;