Bug 1230034 part 10 - Convert remaining frame properties to by typed and remove the unsafe declaring macro. r=dbaron

This commit is contained in:
Xidorn Quan 2016-01-28 14:23:59 +11:00
parent 1b58047970
commit 793aa45e62
10 changed files with 32 additions and 48 deletions

View File

@ -63,7 +63,7 @@ protected:
* static member) FramePropertyDescriptor and pass its address as
* aProperty in the FramePropertyTable methods.
*/
template<typename T=void>
template<typename T>
struct FramePropertyDescriptor : public FramePropertyDescriptorUntyped
{
typedef void Destructor(T* aPropertyValue);

View File

@ -152,10 +152,6 @@ public:
NS_DECL_QUERYFRAME
// Temp reference to scriptrunner
// We could make these auto-Revoking via the "delete" entry for safety
NS_DECLARE_FRAME_PROPERTY(TextControlInitializer, nullptr)
protected:
/**
* Launch the reflow on the child frames - see nsTextControlFrame::Reflow()
@ -202,6 +198,11 @@ protected:
friend class EditorInitializer;
friend class nsTextEditorState; // needs access to UpdateValueDisplay
// Temp reference to scriptrunner
// We could make these auto-Revoking via the "delete" entry for safety
NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(TextControlInitializer,
EditorInitializer)
class EditorInitializer : public nsRunnable {
public:
explicit EditorInitializer(nsTextControlFrame* aFrame) :

View File

@ -288,7 +288,7 @@ NS_DECLARE_FRAME_PROPERTY_WITH_DTOR_NEVER_CALLED(OverflowLinesProperty,
NS_DECLARE_FRAME_PROPERTY_FRAMELIST(OverflowOutOfFlowsProperty)
NS_DECLARE_FRAME_PROPERTY_FRAMELIST(PushedFloatProperty)
NS_DECLARE_FRAME_PROPERTY_FRAMELIST(OutsideBulletProperty)
NS_DECLARE_FRAME_PROPERTY(InsideBulletProperty, nullptr)
NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(InsideBulletProperty, nsBulletFrame)
NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(BlockEndEdgeOfChildrenProperty, nscoord)
//----------------------------------------------------------------------
@ -4951,8 +4951,7 @@ nsBlockFrame::GetInsideBullet() const
return nullptr;
}
NS_ASSERTION(!HasOutsideBullet(), "invalid bullet state");
nsBulletFrame* frame =
static_cast<nsBulletFrame*>(Properties().Get(InsideBulletProperty()));
nsBulletFrame* frame = Properties().Get(InsideBulletProperty());
NS_ASSERTION(frame && frame->GetType() == nsGkAtoms::bulletFrame,
"bogus inside bullet frame");
return frame;
@ -6655,8 +6654,7 @@ nsLineBox* nsBlockFrame::GetFirstLineContaining(nscoord y)
FrameProperties props = Properties();
nsLineBox* property = static_cast<nsLineBox*>
(props.Get(LineCursorProperty()));
nsLineBox* property = props.Get(LineCursorProperty());
line_iterator cursor = mLines.begin(property);
nsRect cursorArea = cursor->GetVisualOverflowArea();

View File

@ -372,10 +372,10 @@ protected:
}
#endif
NS_DECLARE_FRAME_PROPERTY(LineCursorProperty, nullptr)
NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(LineCursorProperty, nsLineBox)
nsLineBox* GetLineCursor() {
return (GetStateBits() & NS_BLOCK_HAS_LINE_CURSOR) ?
static_cast<nsLineBox*>(Properties().Get(LineCursorProperty())) : nullptr;
Properties().Get(LineCursorProperty()) : nullptr;
}
nsLineBox* NewLineBox(nsIFrame* aFrame, bool aIsBlock) {

View File

@ -4800,7 +4800,7 @@ nsIFrame* nsIFrame::GetTailContinuation()
return frame;
}
NS_DECLARE_FRAME_PROPERTY(ViewProperty, nullptr)
NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(ViewProperty, nsView)
// Associated view object
nsView*
@ -4811,9 +4811,9 @@ nsIFrame::GetView() const
return nullptr;
// Check for a property on the frame
void* value = Properties().Get(ViewProperty());
nsView* value = Properties().Get(ViewProperty());
NS_ASSERTION(value, "frame state bit was set but frame has no view");
return static_cast<nsView*>(value);
return value;
}
/* virtual */ nsView*

View File

@ -847,13 +847,6 @@ public:
typedef nsAutoTArray<nsIContent*, 2> ContentArray;
static void DestroyContentArray(ContentArray* aArray);
#define NS_DECLARE_FRAME_PROPERTY(prop, dtor) \
static const mozilla::FramePropertyDescriptor<>* prop() { \
static const auto descriptor = \
mozilla::FramePropertyDescriptor<>::NewWithDestructor<dtor>(); \
return &descriptor; \
}
#define NS_DECLARE_FRAME_PROPERTY_WITH_DTOR(prop, type, dtor) \
static const mozilla::FramePropertyDescriptor<type>* prop() { \
static MOZ_CONSTEXPR auto descriptor = \
@ -893,8 +886,8 @@ public:
#define NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(prop, type) \
NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(prop, mozilla::SmallValueHolder<type>)
NS_DECLARE_FRAME_PROPERTY(IBSplitSibling, nullptr)
NS_DECLARE_FRAME_PROPERTY(IBSplitPrevSibling, nullptr)
NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(IBSplitSibling, nsIFrame)
NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(IBSplitPrevSibling, nsIFrame)
NS_DECLARE_FRAME_PROPERTY_DELETABLE(NormalPositionProperty, nsPoint)
NS_DECLARE_FRAME_PROPERTY_DELETABLE(ComputedOffsetProperty, nsMargin)
@ -3111,8 +3104,7 @@ private:
void MarkAbsoluteFramesForDisplayList(nsDisplayListBuilder* aBuilder, const nsRect& aDirtyRect);
static void DestroyPaintedPresShellList(void* propertyValue) {
nsTArray<nsWeakPtr>* list = static_cast<nsTArray<nsWeakPtr>*>(propertyValue);
static void DestroyPaintedPresShellList(nsTArray<nsWeakPtr>* list) {
list->Clear();
delete list;
}
@ -3120,7 +3112,9 @@ private:
// Stores weak references to all the PresShells that were painted during
// the last paint event so that we can increment their paint count during
// empty transactions
NS_DECLARE_FRAME_PROPERTY(PaintedPresShellsProperty, DestroyPaintedPresShellList)
NS_DECLARE_FRAME_PROPERTY_WITH_DTOR(PaintedPresShellsProperty,
nsTArray<nsWeakPtr>,
DestroyPaintedPresShellList)
nsTArray<nsWeakPtr>* PaintedPresShellList() {
nsTArray<nsWeakPtr>* list = static_cast<nsTArray<nsWeakPtr>*>(

View File

@ -186,10 +186,10 @@ TabWidthStore::ApplySpacing(gfxTextRun::PropertyProvider::Spacing *aSpacing,
NS_DECLARE_FRAME_PROPERTY_DELETABLE(TabWidthProperty, TabWidthStore)
NS_DECLARE_FRAME_PROPERTY(OffsetToFrameProperty, nullptr)
NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(OffsetToFrameProperty, nsTextFrame)
// text runs are destroyed by the text run cache
NS_DECLARE_FRAME_PROPERTY(UninflatedTextRunProperty, nullptr)
NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(UninflatedTextRunProperty, gfxTextRun)
NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(FontSizeInflationProperty, float)
@ -4483,8 +4483,7 @@ nsTextFrame::InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemK
gfxTextRun*
nsTextFrame::GetUninflatedTextRun()
{
return static_cast<gfxTextRun*>(
Properties().Get(UninflatedTextRunProperty()));
return Properties().Get(UninflatedTextRunProperty());
}
void
@ -7194,8 +7193,7 @@ nsTextFrame::GetChildFrameContainingOffset(int32_t aContentOffset,
int32_t offset = mContentOffset;
// Try to look up the offset to frame property
nsTextFrame* cachedFrame = static_cast<nsTextFrame*>
(Properties().Get(OffsetToFrameProperty()));
nsTextFrame* cachedFrame = Properties().Get(OffsetToFrameProperty());
if (cachedFrame) {
f = cachedFrame;

View File

@ -475,15 +475,14 @@ GetOrCreateFilterProperty(nsIFrame *aFrame)
return nullptr;
FrameProperties props = aFrame->Properties();
nsSVGFilterProperty *prop =
static_cast<nsSVGFilterProperty*>(props.Get(nsSVGEffects::FilterProperty()));
nsSVGFilterProperty *prop = props.Get(nsSVGEffects::FilterProperty());
if (prop)
return prop;
prop = new nsSVGFilterProperty(style->mFilters, aFrame);
if (!prop)
return nullptr;
NS_ADDREF(prop);
props.Set(nsSVGEffects::FilterProperty(), static_cast<nsISupports*>(prop));
props.Set(nsSVGEffects::FilterProperty(), prop);
return prop;
}

View File

@ -395,19 +395,18 @@ public:
using URIObserverHashtablePropertyDescriptor =
const mozilla::FramePropertyDescriptor<URIObserverHashtable>*;
static void DestroyFilterProperty(void* aPropertyValue)
static void DestroyFilterProperty(nsSVGFilterProperty* aProp)
{
auto* prop = static_cast<nsSVGFilterProperty*>(aPropertyValue);
// nsSVGFilterProperty is cycle-collected, so dropping the last reference
// doesn't necessarily destroy it. We need to tell it that the frame
// has now become invalid.
prop->DetachFromFrame();
aProp->DetachFromFrame();
prop->Release();
aProp->Release();
}
NS_DECLARE_FRAME_PROPERTY(FilterProperty, DestroyFilterProperty)
NS_DECLARE_FRAME_PROPERTY_WITH_DTOR(FilterProperty, nsSVGFilterProperty,
DestroyFilterProperty)
NS_DECLARE_FRAME_PROPERTY_RELEASABLE(MaskProperty, nsISupports)
NS_DECLARE_FRAME_PROPERTY_RELEASABLE(ClipPathProperty, nsISupports)
NS_DECLARE_FRAME_PROPERTY_RELEASABLE(MarkerBeginProperty, nsISupports)

View File

@ -185,12 +185,7 @@ public:
static void Init();
static void DestroyObjectBoundingBoxProperty(void* aPropertyValue) {
delete static_cast<gfxRect*>(aPropertyValue);
}
NS_DECLARE_FRAME_PROPERTY(ObjectBoundingBoxProperty,
DestroyObjectBoundingBoxProperty);
NS_DECLARE_FRAME_PROPERTY_DELETABLE(ObjectBoundingBoxProperty, gfxRect)
/**
* Gets the nearest nsSVGInnerSVGFrame or nsSVGOuterSVGFrame frame. aFrame