From c0de0d582bad7ee372bdbcb3c3da974f874d5cdc Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Thu, 28 Jan 2016 14:23:59 +1100 Subject: [PATCH] Bug 1230034 part 2 - Constify aFrame parameters of frame property functions. r=dbaron --HG-- extra : source : c77565f815bd055a551679290da8cb985d2d2bb0 --- layout/base/FrameLayerBuilder.cpp | 4 ++-- layout/base/FrameLayerBuilder.h | 2 +- layout/base/FramePropertyTable.cpp | 13 ++++++++----- layout/base/FramePropertyTable.h | 26 ++++++++++++-------------- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 9987653301e3..6bc5bd98044c 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -234,7 +234,7 @@ FrameLayerBuilder::DisplayItemData::BeginUpdate(Layer* aLayer, LayerState aState } } -static nsIFrame* sDestroyedFrame = nullptr; +static const nsIFrame* sDestroyedFrame = nullptr; FrameLayerBuilder::DisplayItemData::~DisplayItemData() { MOZ_COUNT_DTOR(FrameLayerBuilder::DisplayItemData); @@ -1709,7 +1709,7 @@ GetTranslationForPaintedLayer(PaintedLayer* aLayer) */ /* static */ void -FrameLayerBuilder::RemoveFrameFromLayerManager(nsIFrame* aFrame, +FrameLayerBuilder::RemoveFrameFromLayerManager(const nsIFrame* aFrame, void* aPropertyValue) { MOZ_RELEASE_ASSERT(!sDestroyedFrame); diff --git a/layout/base/FrameLayerBuilder.h b/layout/base/FrameLayerBuilder.h index 372fe77129e0..186d39a44533 100644 --- a/layout/base/FrameLayerBuilder.h +++ b/layout/base/FrameLayerBuilder.h @@ -514,7 +514,7 @@ protected: friend class LayerManagerData; - static void RemoveFrameFromLayerManager(nsIFrame* aFrame, void* aPropertyValue); + static void RemoveFrameFromLayerManager(const nsIFrame* aFrame, void* aPropertyValue); /** * Given a frame and a display item key that uniquely identifies a diff --git a/layout/base/FramePropertyTable.cpp b/layout/base/FramePropertyTable.cpp index 165df79358e0..1d180f770f35 100644 --- a/layout/base/FramePropertyTable.cpp +++ b/layout/base/FramePropertyTable.cpp @@ -10,7 +10,8 @@ namespace mozilla { void -FramePropertyTable::Set(nsIFrame* aFrame, const FramePropertyDescriptor* aProperty, +FramePropertyTable::Set(const nsIFrame* aFrame, + const FramePropertyDescriptor* aProperty, void* aValue) { NS_ASSERTION(aFrame, "Null frame?"); @@ -71,7 +72,7 @@ FramePropertyTable::Get(const nsIFrame* aFrame, } if (mLastFrame != aFrame) { - mLastFrame = const_cast(aFrame); + mLastFrame = aFrame; mLastEntry = mEntries.GetEntry(mLastFrame); } Entry* entry = mLastEntry; @@ -103,7 +104,8 @@ FramePropertyTable::Get(const nsIFrame* aFrame, } void* -FramePropertyTable::Remove(nsIFrame* aFrame, const FramePropertyDescriptor* aProperty, +FramePropertyTable::Remove(const nsIFrame* aFrame, + const FramePropertyDescriptor* aProperty, bool* aFoundResult) { NS_ASSERTION(aFrame, "Null frame?"); @@ -164,7 +166,8 @@ FramePropertyTable::Remove(nsIFrame* aFrame, const FramePropertyDescriptor* aPro } void -FramePropertyTable::Delete(nsIFrame* aFrame, const FramePropertyDescriptor* aProperty) +FramePropertyTable::Delete(const nsIFrame* aFrame, + const FramePropertyDescriptor* aProperty) { NS_ASSERTION(aFrame, "Null frame?"); NS_ASSERTION(aProperty, "Null property?"); @@ -193,7 +196,7 @@ FramePropertyTable::DeleteAllForEntry(Entry* aEntry) } void -FramePropertyTable::DeleteAllFor(nsIFrame* aFrame) +FramePropertyTable::DeleteAllFor(const nsIFrame* aFrame) { NS_ASSERTION(aFrame, "Null frame?"); diff --git a/layout/base/FramePropertyTable.h b/layout/base/FramePropertyTable.h index 3b4176579bc4..22912779afa2 100644 --- a/layout/base/FramePropertyTable.h +++ b/layout/base/FramePropertyTable.h @@ -18,7 +18,7 @@ namespace mozilla { struct FramePropertyDescriptor; typedef void (*FramePropertyDestructor)(void* aPropertyValue); -typedef void (*FramePropertyDestructorWithFrame)(nsIFrame* aFrame, +typedef void (*FramePropertyDestructorWithFrame)(const nsIFrame* aFrame, void* aPropertyValue); /** @@ -79,7 +79,7 @@ public: * the properties of that frame. Any existing value for the property * is destroyed. */ - void Set(nsIFrame* aFrame, const FramePropertyDescriptor* aProperty, + void Set(const nsIFrame* aFrame, const FramePropertyDescriptor* aProperty, void* aValue); /** * Get a property value for a frame. This requires one hashtable @@ -104,7 +104,7 @@ public: * disambiguate a null result, which can mean 'no such property' or * 'property value is null'. */ - void* Remove(nsIFrame* aFrame, const FramePropertyDescriptor* aProperty, + void* Remove(const nsIFrame* aFrame, const FramePropertyDescriptor* aProperty, bool* aFoundResult = nullptr); /** * Remove and destroy a property value for a frame. This requires one @@ -112,12 +112,12 @@ public: * through the properties of that frame. If the frame has no such * property, nothing happens. */ - void Delete(nsIFrame* aFrame, const FramePropertyDescriptor* aProperty); + void Delete(const nsIFrame* aFrame, const FramePropertyDescriptor* aProperty); /** * Remove and destroy all property values for a frame. This requires one * hashtable lookup (using the frame as the key). */ - void DeleteAllFor(nsIFrame* aFrame); + void DeleteAllFor(const nsIFrame* aFrame); /** * Remove and destroy all property values for all frames. */ @@ -142,7 +142,7 @@ protected: return reinterpret_cast*>(&mValue); } - void DestroyValueFor(nsIFrame* aFrame) { + void DestroyValueFor(const nsIFrame* aFrame) { if (mProperty->mDestructor) { mProperty->mDestructor(mValue); } else if (mProperty->mDestructorWithFrame) { @@ -189,12 +189,12 @@ protected: * Our hashtable entry. The key is an nsIFrame*, the value is a * PropertyValue representing one or more property/value pairs. */ - class Entry : public nsPtrHashKey + class Entry : public nsPtrHashKey { public: - explicit Entry(KeyTypePointer aKey) : nsPtrHashKey(aKey) {} + explicit Entry(KeyTypePointer aKey) : nsPtrHashKey(aKey) {} Entry(const Entry &toCopy) : - nsPtrHashKey(toCopy), mProp(toCopy.mProp) {} + nsPtrHashKey(toCopy), mProp(toCopy.mProp) {} size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) { return mProp.SizeOfExcludingThis(aMallocSizeOf); @@ -206,7 +206,7 @@ protected: static void DeleteAllForEntry(Entry* aEntry); nsTHashtable mEntries; - nsIFrame* mLastFrame; + const nsIFrame* mLastFrame; Entry* mLastEntry; }; @@ -215,10 +215,8 @@ protected: */ class FrameProperties { public: - FrameProperties(FramePropertyTable* aTable, nsIFrame* aFrame) - : mTable(aTable), mFrame(aFrame) {} FrameProperties(FramePropertyTable* aTable, const nsIFrame* aFrame) - : mTable(aTable), mFrame(const_cast(aFrame)) {} + : mTable(aTable), mFrame(aFrame) {} void Set(const FramePropertyDescriptor* aProperty, void* aValue) const { @@ -241,7 +239,7 @@ public: private: FramePropertyTable* mTable; - nsIFrame* mFrame; + const nsIFrame* mFrame; }; } // namespace mozilla