Bug 1128356 - Add template functions for common frame property destructors. r=dbaron

This commit is contained in:
Seth Fowler 2015-02-04 15:22:27 -08:00
parent 1430792c6b
commit a271bba567
19 changed files with 71 additions and 186 deletions

View File

@ -107,13 +107,8 @@ LayerActivity::~LayerActivity()
}
}
static void DestroyLayerActivity(void* aPropertyValue)
{
delete static_cast<LayerActivity*>(aPropertyValue);
}
// Frames with this property have NS_FRAME_HAS_LAYER_ACTIVITY_PROPERTY set
NS_DECLARE_FRAME_PROPERTY(LayerActivityProperty, DestroyLayerActivity)
NS_DECLARE_FRAME_PROPERTY(LayerActivityProperty, DeleteValue<LayerActivity>)
void
LayerActivityTracker::NotifyExpired(LayerActivity* aObject)

View File

@ -714,13 +714,10 @@ public:
DisplayItemClip mContainingBlockClip;
nsRect mDirtyRect;
};
static void DestroyOutOfFlowDisplayData(void* aPropertyValue)
{
delete static_cast<OutOfFlowDisplayData*>(aPropertyValue);
}
NS_DECLARE_FRAME_PROPERTY(OutOfFlowDisplayDataProperty, DestroyOutOfFlowDisplayData)
NS_DECLARE_FRAME_PROPERTY(Preserve3DDirtyRectProperty, nsIFrame::DestroyRect)
NS_DECLARE_FRAME_PROPERTY(OutOfFlowDisplayDataProperty,
DeleteValue<OutOfFlowDisplayData>)
NS_DECLARE_FRAME_PROPERTY(Preserve3DDirtyRectProperty, DeleteValue<nsRect>)
nsPresContext* CurrentPresContext() {
return CurrentPresShellState()->mPresShell->GetPresContext();

View File

@ -32,7 +32,7 @@ class nsTextControlFrame MOZ_FINAL : public nsContainerFrame,
public:
NS_DECL_FRAMEARENA_HELPERS
NS_DECLARE_FRAME_PROPERTY(ContentScrollPos, DestroyPoint)
NS_DECLARE_FRAME_PROPERTY(ContentScrollPos, DeleteValue<nsPoint>)
explicit nsTextControlFrame(nsStyleContext* aContext);
virtual ~nsTextControlFrame();

View File

@ -17,13 +17,8 @@
namespace mozilla {
void DestroyStickyScrollContainer(void* aPropertyValue)
{
delete static_cast<StickyScrollContainer*>(aPropertyValue);
}
NS_DECLARE_FRAME_PROPERTY(StickyScrollContainerProperty,
DestroyStickyScrollContainer)
DeleteValue<StickyScrollContainer>)
StickyScrollContainer::StickyScrollContainer(nsIScrollableFrame* aScrollFrame)
: mScrollFrame(aScrollFrame)

View File

@ -86,9 +86,10 @@ public:
virtual void ScrollPositionWillChange(nscoord aX, nscoord aY) MOZ_OVERRIDE;
virtual void ScrollPositionDidChange(nscoord aX, nscoord aY) MOZ_OVERRIDE;
~StickyScrollContainer();
private:
explicit StickyScrollContainer(nsIScrollableFrame* aScrollFrame);
~StickyScrollContainer();
/**
* Compute two rectangles that determine sticky positioning: |aStick|, based
@ -99,8 +100,6 @@ private:
void ComputeStickyLimits(nsIFrame* aFrame, nsRect* aStick,
nsRect* aContain) const;
friend void DestroyStickyScrollContainer(void* aPropertyValue);
nsIScrollableFrame* const mScrollFrame;
nsTArray<nsIFrame*> mFrames;
nsPoint mScrollPosition;

View File

@ -307,7 +307,7 @@ nsFloatManager::CalculateRegionFor(WritingMode aWM,
return region;
}
NS_DECLARE_FRAME_PROPERTY(FloatRegionProperty, nsIFrame::DestroyMargin)
NS_DECLARE_FRAME_PROPERTY(FloatRegionProperty, DeleteValue<nsMargin>)
LogicalRect
nsFloatManager::GetRegionFor(WritingMode aWM, nsIFrame* aFloat,

View File

@ -16,13 +16,8 @@
using namespace mozilla;
using namespace mozilla::layout;
static void
DestroyFontInflationData(void *aPropertyValue)
{
delete static_cast<nsFontInflationData*>(aPropertyValue);
}
NS_DECLARE_FRAME_PROPERTY(FontInflationDataProperty, DestroyFontInflationData)
NS_DECLARE_FRAME_PROPERTY(FontInflationDataProperty,
DeleteValue<nsFontInflationData>)
/* static */ nsFontInflationData*
nsFontInflationData::FindFontInflationDataFor(const nsIFrame *aFrame)

View File

@ -152,13 +152,7 @@ static void RefreshContentFrames(nsPresContext* aPresContext, nsIContent * aStar
#include "prenv.h"
static void
DestroyBoxMetrics(void* aPropertyValue)
{
delete static_cast<nsBoxLayoutMetrics*>(aPropertyValue);
}
NS_DECLARE_FRAME_PROPERTY(BoxMetricsProperty, DestroyBoxMetrics)
NS_DECLARE_FRAME_PROPERTY(BoxMetricsProperty, DeleteValue<nsBoxLayoutMetrics>)
static void
InitBoxMetrics(nsIFrame* aFrame, bool aClear)
@ -250,13 +244,8 @@ nsFrame::GetLogModuleInfo()
#endif
static void
DestroyAbsoluteContainingBlock(void* aPropertyValue)
{
delete static_cast<nsAbsoluteContainingBlock*>(aPropertyValue);
}
NS_DECLARE_FRAME_PROPERTY(AbsoluteContainingBlockProperty, DestroyAbsoluteContainingBlock)
NS_DECLARE_FRAME_PROPERTY(AbsoluteContainingBlockProperty,
DeleteValue<nsAbsoluteContainingBlock>)
bool
nsIFrame::HasAbsolutelyPositionedChildren() const {
@ -7122,8 +7111,7 @@ nsFrame::AccessibleType()
}
#endif
NS_DECLARE_FRAME_PROPERTY(OverflowAreasProperty,
nsIFrame::DestroyOverflowAreas)
NS_DECLARE_FRAME_PROPERTY(OverflowAreasProperty, DeleteValue<nsOverflowAreas>)
bool
nsIFrame::ClearOverflowRects()
@ -8772,24 +8760,6 @@ nsIFrame::IsSelected() const
IsFrameSelected() : false;
}
void
nsIFrame::DestroySurface(void* aPropertyValue)
{
static_cast<gfxASurface*>(aPropertyValue)->Release();
}
void
nsIFrame::DestroyDT(void* aPropertyValue)
{
static_cast<mozilla::gfx::DrawTarget*>(aPropertyValue)->Release();
}
void
nsIFrame::DestroyRegion(void* aPropertyValue)
{
delete static_cast<nsRegion*>(aPropertyValue);
}
/*static*/ void
nsIFrame::DestroyContentArray(void* aPropertyValue)
{

View File

@ -64,12 +64,6 @@ NS_NewGridContainerFrame(nsIPresShell* aPresShell,
// nsGridContainerFrame Method Implementations
// ===========================================
/* static */ void
nsGridContainerFrame::DestroyImplicitNamedAreas(void* aPropertyValue)
{
delete static_cast<ImplicitNamedAreas*>(aPropertyValue);
}
void
nsGridContainerFrame::AddImplicitNamedAreas(
const nsTArray<nsTArray<nsString>>& aLineNameLists)

View File

@ -49,14 +49,14 @@ protected:
* grid-template-columns / grid-template-rows are stored in this frame
* property when needed, as a ImplicitNamedAreas* value.
*/
NS_DECLARE_FRAME_PROPERTY(ImplicitNamedAreasProperty, DestroyImplicitNamedAreas)
NS_DECLARE_FRAME_PROPERTY(ImplicitNamedAreasProperty,
DeleteValue<ImplicitNamedAreas>)
void InitImplicitNamedAreas(const nsStylePosition* aStyle);
void AddImplicitNamedAreas(const nsTArray<nsTArray<nsString>>& aLineNameLists);
typedef nsTHashtable<nsStringHashKey> ImplicitNamedAreas;
ImplicitNamedAreas* GetImplicitNamedAreas() const {
return static_cast<ImplicitNamedAreas*>(Properties().Get(ImplicitNamedAreasProperty()));
}
static void DestroyImplicitNamedAreas(void* aPropertyValue);
#ifdef DEBUG
void SanityCheckAnonymousGridItems() const;

View File

@ -367,6 +367,20 @@ struct IntrinsicSize {
};
}
/// Generic destructor for frame properties. Calls delete.
template<typename T>
static void DeleteValue(void* aPropertyValue)
{
delete static_cast<T*>(aPropertyValue);
}
/// Generic destructor for frame properties. Calls Release().
template<typename T>
static void ReleaseValue(void* aPropertyValue)
{
static_cast<T*>(aPropertyValue)->Release();
}
//----------------------------------------------------------------------
/**
@ -783,30 +797,6 @@ public:
nsPoint GetPositionIgnoringScrolling();
static void DestroyRegion(void* aPropertyValue);
static void DestroyMargin(void* aPropertyValue)
{
delete static_cast<nsMargin*>(aPropertyValue);
}
static void DestroyRect(void* aPropertyValue)
{
delete static_cast<nsRect*>(aPropertyValue);
}
static void DestroyPoint(void* aPropertyValue)
{
delete static_cast<nsPoint*>(aPropertyValue);
}
static void DestroyOverflowAreas(void* aPropertyValue)
{
delete static_cast<nsOverflowAreas*>(aPropertyValue);
}
static void DestroySurface(void* aPropertyValue);
static void DestroyDT(void* aPropertyValue);
static void DestroyContentArray(void* aPropertyValue);
#ifdef _MSC_VER
@ -832,18 +822,19 @@ public:
NS_DECLARE_FRAME_PROPERTY(IBSplitSibling, nullptr)
NS_DECLARE_FRAME_PROPERTY(IBSplitPrevSibling, nullptr)
NS_DECLARE_FRAME_PROPERTY(NormalPositionProperty, DestroyPoint)
NS_DECLARE_FRAME_PROPERTY(ComputedOffsetProperty, DestroyMargin)
NS_DECLARE_FRAME_PROPERTY(NormalPositionProperty, DeleteValue<nsPoint>)
NS_DECLARE_FRAME_PROPERTY(ComputedOffsetProperty, DeleteValue<nsMargin>)
NS_DECLARE_FRAME_PROPERTY(OutlineInnerRectProperty, DestroyRect)
NS_DECLARE_FRAME_PROPERTY(PreEffectsBBoxProperty, DestroyRect)
NS_DECLARE_FRAME_PROPERTY(OutlineInnerRectProperty, DeleteValue<nsRect>)
NS_DECLARE_FRAME_PROPERTY(PreEffectsBBoxProperty, DeleteValue<nsRect>)
NS_DECLARE_FRAME_PROPERTY(PreTransformOverflowAreasProperty,
DestroyOverflowAreas)
DeleteValue<nsOverflowAreas>)
// The initial overflow area passed to FinishAndStoreOverflow. This is only set
// on frames that Preserve3D() or HasPerspective() or IsTransformed(), and
// when at least one of the overflow areas differs from the frame bound rect.
NS_DECLARE_FRAME_PROPERTY(InitialOverflowProperty, DestroyOverflowAreas)
NS_DECLARE_FRAME_PROPERTY(InitialOverflowProperty,
DeleteValue<nsOverflowAreas>)
#ifdef DEBUG
// InitialOverflowPropertyDebug is added to the frame to indicate that either
@ -852,18 +843,19 @@ public:
NS_DECLARE_FRAME_PROPERTY(DebugInitialOverflowPropertyApplied, nullptr)
#endif
NS_DECLARE_FRAME_PROPERTY(UsedMarginProperty, DestroyMargin)
NS_DECLARE_FRAME_PROPERTY(UsedPaddingProperty, DestroyMargin)
NS_DECLARE_FRAME_PROPERTY(UsedBorderProperty, DestroyMargin)
NS_DECLARE_FRAME_PROPERTY(UsedMarginProperty, DeleteValue<nsMargin>)
NS_DECLARE_FRAME_PROPERTY(UsedPaddingProperty, DeleteValue<nsMargin>)
NS_DECLARE_FRAME_PROPERTY(UsedBorderProperty, DeleteValue<nsMargin>)
NS_DECLARE_FRAME_PROPERTY(ScrollLayerCount, nullptr)
NS_DECLARE_FRAME_PROPERTY(LineBaselineOffset, nullptr)
NS_DECLARE_FRAME_PROPERTY(CachedBackgroundImage, DestroySurface)
NS_DECLARE_FRAME_PROPERTY(CachedBackgroundImageDT, DestroyDT)
NS_DECLARE_FRAME_PROPERTY(CachedBackgroundImage, ReleaseValue<gfxASurface>)
NS_DECLARE_FRAME_PROPERTY(CachedBackgroundImageDT,
ReleaseValue<mozilla::gfx::DrawTarget>)
NS_DECLARE_FRAME_PROPERTY(InvalidationRect, DestroyRect)
NS_DECLARE_FRAME_PROPERTY(InvalidationRect, DeleteValue<nsRect>)
NS_DECLARE_FRAME_PROPERTY(RefusedAsyncAnimation, nullptr)

View File

@ -181,12 +181,7 @@ TabWidthStore::ApplySpacing(gfxTextRun::PropertyProvider::Spacing *aSpacing,
}
}
static void DestroyTabWidth(void* aPropertyValue)
{
delete static_cast<TabWidthStore*>(aPropertyValue);
}
NS_DECLARE_FRAME_PROPERTY(TabWidthProperty, DestroyTabWidth)
NS_DECLARE_FRAME_PROPERTY(TabWidthProperty, DeleteValue<TabWidthStore>)
NS_DECLARE_FRAME_PROPERTY(OffsetToFrameProperty, nullptr)
@ -204,18 +199,14 @@ private:
nsTextFrame* mFrame;
};
static void DestroyGlyphObserverList(void* aPropertyValue)
{
delete static_cast<nsTArray<nsAutoPtr<GlyphObserver> >*>(aPropertyValue);
}
/**
* This property is set on text frames with TEXT_IN_TEXTRUN_USER_DATA set that
* have potentially-animated glyphs.
* The only reason this list is in a property is to automatically destroy the
* list when the frame is deleted, unregistering the observers.
*/
NS_DECLARE_FRAME_PROPERTY(TextFrameGlyphObservers, DestroyGlyphObserverList);
NS_DECLARE_FRAME_PROPERTY(TextFrameGlyphObservers,
DeleteValue<nsTArray<nsAutoPtr<GlyphObserver>>>);
static const nsFrameState TEXT_REFLOW_FLAGS =
TEXT_FIRST_LETTER |

View File

@ -129,13 +129,8 @@ IsForeignChild(const nsIFrame* aFrame)
aFrame->GetType() == nsGkAtoms::blockFrame;
}
static void
DestroyHTMLReflowMetrics(void *aPropertyValue)
{
delete static_cast<nsHTMLReflowMetrics*>(aPropertyValue);
}
NS_DECLARE_FRAME_PROPERTY(HTMLReflowMetricsProperty, DestroyHTMLReflowMetrics)
NS_DECLARE_FRAME_PROPERTY(HTMLReflowMetricsProperty,
DeleteValue<nsHTMLReflowMetrics>)
/* static */ void
nsMathMLContainerFrame::SaveReflowAndBoundingMetricsFor(nsIFrame* aFrame,

View File

@ -130,16 +130,10 @@ static nsresult ReportParseError(nsIFrame* aFrame, const char16_t* aAttribute,
// stored in the property table. Row/Cell frames query the property table
// to see what values apply to them.
static void
DestroyStylePropertyList(void* aPropertyValue)
{
delete static_cast<nsTArray<int8_t>*>(aPropertyValue);
}
NS_DECLARE_FRAME_PROPERTY(RowAlignProperty, DestroyStylePropertyList)
NS_DECLARE_FRAME_PROPERTY(RowLinesProperty, DestroyStylePropertyList)
NS_DECLARE_FRAME_PROPERTY(ColumnAlignProperty, DestroyStylePropertyList)
NS_DECLARE_FRAME_PROPERTY(ColumnLinesProperty, DestroyStylePropertyList)
NS_DECLARE_FRAME_PROPERTY(RowAlignProperty, DeleteValue<nsTArray<int8_t>>)
NS_DECLARE_FRAME_PROPERTY(RowLinesProperty, DeleteValue<nsTArray<int8_t>>)
NS_DECLARE_FRAME_PROPERTY(ColumnAlignProperty, DeleteValue<nsTArray<int8_t>>)
NS_DECLARE_FRAME_PROPERTY(ColumnLinesProperty, DeleteValue<nsTArray<int8_t>>)
static const FramePropertyDescriptor*
AttributeToProperty(nsIAtom* aAttribute)

View File

@ -1286,12 +1286,8 @@ struct TextNodeCorrespondence
uint32_t mUndisplayedCharacters;
};
static void DestroyTextNodeCorrespondence(void* aPropertyValue)
{
delete static_cast<TextNodeCorrespondence*>(aPropertyValue);
}
NS_DECLARE_FRAME_PROPERTY(TextNodeCorrespondenceProperty, DestroyTextNodeCorrespondence)
NS_DECLARE_FRAME_PROPERTY(TextNodeCorrespondenceProperty,
DeleteValue<TextNodeCorrespondence>)
/**
* Returns the number of undisplayed characters before the specified

View File

@ -390,11 +390,6 @@ public:
typedef nsInterfaceHashtable<nsURIHashKey, nsIMutationObserver>
URIObserverHashtable;
static void DestroySupports(void* aPropertyValue)
{
(static_cast<nsISupports*>(aPropertyValue))->Release();
}
static void DestroyFilterProperty(void* aPropertyValue)
{
auto* prop = static_cast<nsSVGFilterProperty*>(aPropertyValue);
@ -407,21 +402,17 @@ public:
prop->Release();
}
static void DestroyHashtable(void* aPropertyValue)
{
delete static_cast<URIObserverHashtable*> (aPropertyValue);
}
NS_DECLARE_FRAME_PROPERTY(FilterProperty, DestroyFilterProperty)
NS_DECLARE_FRAME_PROPERTY(MaskProperty, DestroySupports)
NS_DECLARE_FRAME_PROPERTY(ClipPathProperty, DestroySupports)
NS_DECLARE_FRAME_PROPERTY(MarkerBeginProperty, DestroySupports)
NS_DECLARE_FRAME_PROPERTY(MarkerMiddleProperty, DestroySupports)
NS_DECLARE_FRAME_PROPERTY(MarkerEndProperty, DestroySupports)
NS_DECLARE_FRAME_PROPERTY(FillProperty, DestroySupports)
NS_DECLARE_FRAME_PROPERTY(StrokeProperty, DestroySupports)
NS_DECLARE_FRAME_PROPERTY(HrefProperty, DestroySupports)
NS_DECLARE_FRAME_PROPERTY(BackgroundImageProperty, DestroyHashtable)
NS_DECLARE_FRAME_PROPERTY(MaskProperty, ReleaseValue<nsISupports>)
NS_DECLARE_FRAME_PROPERTY(ClipPathProperty, ReleaseValue<nsISupports>)
NS_DECLARE_FRAME_PROPERTY(MarkerBeginProperty, ReleaseValue<nsISupports>)
NS_DECLARE_FRAME_PROPERTY(MarkerMiddleProperty, ReleaseValue<nsISupports>)
NS_DECLARE_FRAME_PROPERTY(MarkerEndProperty, ReleaseValue<nsISupports>)
NS_DECLARE_FRAME_PROPERTY(FillProperty, ReleaseValue<nsISupports>)
NS_DECLARE_FRAME_PROPERTY(StrokeProperty, ReleaseValue<nsISupports>)
NS_DECLARE_FRAME_PROPERTY(HrefProperty, ReleaseValue<nsISupports>)
NS_DECLARE_FRAME_PROPERTY(BackgroundImageProperty,
DeleteValue<URIObserverHashtable>)
/**
* Get the paint server for a aTargetFrame.

View File

@ -260,13 +260,6 @@ nsTableFrame::PageBreakAfter(nsIFrame* aSourceFrame,
typedef nsTArray<nsIFrame*> FrameTArray;
/* static */ void
nsTableFrame::DestroyPositionedTablePartArray(void* aPropertyValue)
{
auto positionedObjs = static_cast<FrameTArray*>(aPropertyValue);
delete positionedObjs;
}
/* static */ void
nsTableFrame::RegisterPositionedTablePart(nsIFrame* aFrame)
{
@ -2549,14 +2542,7 @@ nsTableFrame::GetUsedMargin() const
return nsMargin(0, 0, 0, 0);
}
// Destructor function for BCPropertyData properties
static void
DestroyBCProperty(void* aPropertyValue)
{
delete static_cast<BCPropertyData*>(aPropertyValue);
}
NS_DECLARE_FRAME_PROPERTY(TableBCProperty, DestroyBCProperty)
NS_DECLARE_FRAME_PROPERTY(TableBCProperty, DeleteValue<BCPropertyData>)
BCPropertyData*
nsTableFrame::GetBCProperty(bool aCreateIfNecessary) const

View File

@ -109,8 +109,8 @@ class nsTableFrame : public nsContainerFrame
public:
NS_DECL_FRAMEARENA_HELPERS
static void DestroyPositionedTablePartArray(void* aPropertyValue);
NS_DECLARE_FRAME_PROPERTY(PositionedTablePartArray, DestroyPositionedTablePartArray)
NS_DECLARE_FRAME_PROPERTY(PositionedTablePartArray,
DeleteValue<nsTArray<nsIFrame*>>)
/** nsTableOuterFrame has intimate knowledge of the inner table frame */
friend class nsTableOuterFrame;

View File

@ -1832,13 +1832,8 @@ nsTableRowGroupFrame::GetNextSiblingOnLine(nsIFrame*& aFrame,
//end nsLineIterator methods
static void
DestroyFrameCursorData(void* aPropertyValue)
{
delete static_cast<nsTableRowGroupFrame::FrameCursorData*>(aPropertyValue);
}
NS_DECLARE_FRAME_PROPERTY(RowCursorProperty, DestroyFrameCursorData)
NS_DECLARE_FRAME_PROPERTY(RowCursorProperty,
DeleteValue<nsTableRowGroupFrame::FrameCursorData>)
void
nsTableRowGroupFrame::ClearRowCursor()