Backed out changeset 9483bb6d8ce6 (bug 1330570) for test failures in test_selection_move_commands.html | cmd_scrollBottom - -300 should equal -300

This commit is contained in:
Carsten "Tomcat" Book 2017-05-10 12:11:11 +02:00
parent cfae756c43
commit 85e7d31eb4
5 changed files with 130 additions and 174 deletions

View File

@ -14,7 +14,6 @@
#include "nsArenaMemoryStats.h"
#include "nsPrintfCString.h"
#include "nsStyleContext.h"
#include "FrameLayerBuilder.h"
#include <inttypes.h>

View File

@ -48,7 +48,6 @@
PRES_ARENA_OBJECT_WITHOUT_ARENAREFPTR_SUPPORT(nsLineBox)
PRES_ARENA_OBJECT_WITHOUT_ARENAREFPTR_SUPPORT(nsRuleNode)
PRES_ARENA_OBJECT_WITH_ARENAREFPTR_SUPPORT(nsStyleContext)
PRES_ARENA_OBJECT_WITHOUT_ARENAREFPTR_SUPPORT(DisplayItemData)
PRES_ARENA_OBJECT_WITHOUT_ARENAREFPTR_SUPPORT(nsInheritedStyleData)
PRES_ARENA_OBJECT_WITHOUT_ARENAREFPTR_SUPPORT(nsResetStyleData)
PRES_ARENA_OBJECT_WITHOUT_ARENAREFPTR_SUPPORT(nsConditionalResetStyleData)

View File

@ -61,7 +61,7 @@ namespace mozilla {
class PaintedDisplayItemLayerUserData;
static nsTHashtable<nsPtrHashKey<DisplayItemData>>* sAliveDisplayItemDatas;
static nsTHashtable<nsPtrHashKey<FrameLayerBuilder::DisplayItemData>>* sAliveDisplayItemDatas;
/**
* The address of gPaintedDisplayItemLayerUserData is used as the user
@ -135,21 +135,20 @@ FrameLayerBuilder::~FrameLayerBuilder()
MOZ_COUNT_DTOR(FrameLayerBuilder);
}
DisplayItemData::DisplayItemData(LayerManagerData* aParent, uint32_t aKey,
Layer* aLayer, nsIFrame* aFrame)
FrameLayerBuilder::DisplayItemData::DisplayItemData(LayerManagerData* aParent, uint32_t aKey,
Layer* aLayer, nsIFrame* aFrame)
: mRefCnt(0)
, mParent(aParent)
: mParent(aParent)
, mLayer(aLayer)
, mDisplayItemKey(aKey)
, mItem(nullptr)
, mUsed(true)
, mIsInvalid(false)
{
MOZ_COUNT_CTOR(DisplayItemData);
MOZ_COUNT_CTOR(FrameLayerBuilder::DisplayItemData);
if (!sAliveDisplayItemDatas) {
sAliveDisplayItemDatas = new nsTHashtable<nsPtrHashKey<DisplayItemData>>();
sAliveDisplayItemDatas = new nsTHashtable<nsPtrHashKey<FrameLayerBuilder::DisplayItemData>>();
}
MOZ_RELEASE_ASSERT(!sAliveDisplayItemDatas->Contains(this));
sAliveDisplayItemDatas->PutEntry(this);
@ -162,7 +161,7 @@ DisplayItemData::DisplayItemData(LayerManagerData* aParent, uint32_t aKey,
}
void
DisplayItemData::AddFrame(nsIFrame* aFrame)
FrameLayerBuilder::DisplayItemData::AddFrame(nsIFrame* aFrame)
{
MOZ_RELEASE_ASSERT(mLayer);
mFrameList.AppendElement(aFrame);
@ -177,7 +176,7 @@ DisplayItemData::AddFrame(nsIFrame* aFrame)
}
void
DisplayItemData::RemoveFrame(nsIFrame* aFrame)
FrameLayerBuilder::DisplayItemData::RemoveFrame(nsIFrame* aFrame)
{
MOZ_RELEASE_ASSERT(mLayer);
bool result = mFrameList.RemoveElement(aFrame);
@ -190,7 +189,7 @@ DisplayItemData::RemoveFrame(nsIFrame* aFrame)
}
void
DisplayItemData::EndUpdate()
FrameLayerBuilder::DisplayItemData::EndUpdate()
{
MOZ_RELEASE_ASSERT(mLayer);
MOZ_ASSERT(!mItem);
@ -199,7 +198,7 @@ DisplayItemData::EndUpdate()
}
void
DisplayItemData::EndUpdate(nsAutoPtr<nsDisplayItemGeometry> aGeometry)
FrameLayerBuilder::DisplayItemData::EndUpdate(nsAutoPtr<nsDisplayItemGeometry> aGeometry)
{
MOZ_RELEASE_ASSERT(mLayer);
MOZ_ASSERT(mItem);
@ -216,9 +215,9 @@ DisplayItemData::EndUpdate(nsAutoPtr<nsDisplayItemGeometry> aGeometry)
}
void
DisplayItemData::BeginUpdate(Layer* aLayer, LayerState aState,
uint32_t aContainerLayerGeneration,
nsDisplayItem* aItem /* = nullptr */)
FrameLayerBuilder::DisplayItemData::BeginUpdate(Layer* aLayer, LayerState aState,
uint32_t aContainerLayerGeneration,
nsDisplayItem* aItem /* = nullptr */)
{
MOZ_RELEASE_ASSERT(mLayer);
MOZ_RELEASE_ASSERT(aLayer);
@ -261,9 +260,9 @@ DisplayItemData::BeginUpdate(Layer* aLayer, LayerState aState,
}
static const nsIFrame* sDestroyedFrame = nullptr;
DisplayItemData::~DisplayItemData()
FrameLayerBuilder::DisplayItemData::~DisplayItemData()
{
MOZ_COUNT_DTOR(DisplayItemData);
MOZ_COUNT_DTOR(FrameLayerBuilder::DisplayItemData);
MOZ_RELEASE_ASSERT(mLayer);
for (uint32_t i = 0; i < mFrameList.Length(); i++) {
nsIFrame* frame = mFrameList[i];
@ -271,7 +270,7 @@ DisplayItemData::~DisplayItemData()
continue;
}
nsTArray<DisplayItemData*> *array =
reinterpret_cast<nsTArray<DisplayItemData*>*>(frame->Properties().Get(FrameLayerBuilder::LayerManagerDataProperty()));
reinterpret_cast<nsTArray<DisplayItemData*>*>(frame->Properties().Get(LayerManagerDataProperty()));
array->RemoveElement(this);
}
@ -284,7 +283,7 @@ DisplayItemData::~DisplayItemData()
}
void
DisplayItemData::ClearAnimationCompositorState()
FrameLayerBuilder::DisplayItemData::ClearAnimationCompositorState()
{
if (mDisplayItemKey != nsDisplayItem::TYPE_TRANSFORM &&
mDisplayItemKey != nsDisplayItem::TYPE_OPACITY) {
@ -299,13 +298,13 @@ DisplayItemData::ClearAnimationCompositorState()
}
const nsTArray<nsIFrame*>&
DisplayItemData::GetFrameListChanges()
FrameLayerBuilder::DisplayItemData::GetFrameListChanges()
{
return mFrameListChanges;
}
DisplayItemData*
DisplayItemData::AssertDisplayItemData(DisplayItemData* aData)
FrameLayerBuilder::DisplayItemData*
FrameLayerBuilder::DisplayItemData::AssertDisplayItemData(FrameLayerBuilder::DisplayItemData* aData)
{
MOZ_RELEASE_ASSERT(aData);
MOZ_RELEASE_ASSERT(sAliveDisplayItemDatas && sAliveDisplayItemDatas->Contains(aData));
@ -395,7 +394,7 @@ public:
#ifdef DEBUG_DISPLAY_ITEM_DATA
LayerManagerData *mParent;
#endif
nsTHashtable<nsRefPtrHashKey<DisplayItemData> > mDisplayItems;
nsTHashtable<nsRefPtrHashKey<FrameLayerBuilder::DisplayItemData> > mDisplayItems;
bool mInvalidateAllLayers;
};
@ -1814,7 +1813,7 @@ FrameLayerBuilder::FlashPaint(gfxContext *aContext)
aContext->Paint();
}
DisplayItemData*
FrameLayerBuilder::DisplayItemData*
FrameLayerBuilder::GetDisplayItemData(nsIFrame* aFrame, uint32_t aKey)
{
const nsTArray<DisplayItemData*>* array =
@ -2043,7 +2042,7 @@ FrameLayerBuilder::WillEndTransaction()
data->mInvalidateAllLayers = false;
}
/* static */ DisplayItemData*
/* static */ FrameLayerBuilder::DisplayItemData*
FrameLayerBuilder::GetDisplayItemDataForManager(nsDisplayItem* aItem,
LayerManager* aManager)
{
@ -2093,7 +2092,7 @@ FrameLayerBuilder::IterateRetainedDataFor(nsIFrame* aFrame, DisplayItemDataCallb
}
}
DisplayItemData*
FrameLayerBuilder::DisplayItemData*
FrameLayerBuilder::GetOldLayerForFrame(nsIFrame* aFrame, uint32_t aDisplayItemKey)
{
// If we need to build a new layer tree, then just refuse to recycle
@ -4778,7 +4777,7 @@ FrameLayerBuilder::AddPaintedDisplayItem(PaintedLayerData* aLayerData,
}
}
DisplayItemData*
FrameLayerBuilder::DisplayItemData*
FrameLayerBuilder::StoreDataForFrame(nsDisplayItem* aItem, Layer* aLayer, LayerState aState)
{
DisplayItemData* oldData = GetDisplayItemDataForManager(aItem, mRetainingManager);
@ -4793,7 +4792,7 @@ FrameLayerBuilder::StoreDataForFrame(nsDisplayItem* aItem, Layer* aLayer, LayerS
(mRetainingManager->GetUserData(&gLayerManagerUserData));
RefPtr<DisplayItemData> data =
new (aItem->Frame()->PresContext()) DisplayItemData(lmd, aItem->GetPerFrameKey(), aLayer);
new DisplayItemData(lmd, aItem->GetPerFrameKey(), aLayer);
data->BeginUpdate(aLayer, aState, mContainerLayerGeneration, aItem);
@ -4817,7 +4816,7 @@ FrameLayerBuilder::StoreDataForFrame(nsIFrame* aFrame,
(mRetainingManager->GetUserData(&gLayerManagerUserData));
RefPtr<DisplayItemData> data =
new (aFrame->PresContext()) DisplayItemData(lmd, aDisplayItemKey, aLayer, aFrame);
new DisplayItemData(lmd, aDisplayItemKey, aLayer, aFrame);
data->BeginUpdate(aLayer, aState, mContainerLayerGeneration);

View File

@ -42,149 +42,6 @@ class LayerManagerData;
class PaintedLayerData;
class ContainerState;
/**
* Retained data storage:
*
* Each layer manager (widget, and inactive) stores a LayerManagerData object
* that keeps a hash-set of DisplayItemData items that were drawn into it.
* Each frame also keeps a list of DisplayItemData pointers that were
* created for that frame. DisplayItemData objects manage these lists automatically.
*
* During layer construction we update the data in the LayerManagerData object, marking
* items that are modified. At the end we sweep the LayerManagerData hash-set and remove
* all items that haven't been modified.
*/
/**
* Retained data for a display item.
*/
class DisplayItemData final {
public:
friend class FrameLayerBuilder;
uint32_t GetDisplayItemKey() { return mDisplayItemKey; }
layers::Layer* GetLayer() { return mLayer; }
nsDisplayItemGeometry* GetGeometry() const { return mGeometry.get(); }
void Invalidate() { mIsInvalid = true; }
void ClearAnimationCompositorState();
static DisplayItemData* AssertDisplayItemData(DisplayItemData* aData);
void* operator new(size_t sz, nsPresContext* aPresContext)
{
// Check the recycle list first.
return aPresContext->PresShell()->
AllocateByObjectID(eArenaObjectID_DisplayItemData, sz);
}
nsrefcnt AddRef() {
if (mRefCnt == UINT32_MAX) {
NS_WARNING("refcount overflow, leaking object");
return mRefCnt;
}
++mRefCnt;
NS_LOG_ADDREF(this, mRefCnt, "nsStyleContext", sizeof(nsStyleContext));
return mRefCnt;
}
nsrefcnt Release() {
if (mRefCnt == UINT32_MAX) {
NS_WARNING("refcount overflow, leaking object");
return mRefCnt;
}
--mRefCnt;
NS_LOG_RELEASE(this, mRefCnt, "nsStyleContext");
if (mRefCnt == 0) {
Destroy();
return 0;
}
return mRefCnt;
}
private:
DisplayItemData(LayerManagerData* aParent,
uint32_t aKey,
layers::Layer* aLayer,
nsIFrame* aFrame = nullptr);
/**
* Removes any references to this object from frames
* in mFrameList.
*/
~DisplayItemData();
void Destroy()
{
// Get the pres context.
RefPtr<nsPresContext> presContext = mFrameList[0]->PresContext();
// Call our destructor.
this->~DisplayItemData();
// Don't let the memory be freed, since it will be recycled
// instead. Don't call the global operator delete.
presContext->PresShell()->
FreeByObjectID(eArenaObjectID_DisplayItemData, this);
}
/**
* Associates this DisplayItemData with a frame, and adds it
* to the LayerManagerDataProperty list on the frame.
*/
void AddFrame(nsIFrame* aFrame);
void RemoveFrame(nsIFrame* aFrame);
const nsTArray<nsIFrame*>& GetFrameListChanges();
/**
* Updates the contents of this item to a new set of data, instead of allocating a new
* object.
* Set the passed in parameters, and clears the opt layer and inactive manager.
* Parent, and display item key are assumed to be the same.
*
* EndUpdate must be called before the end of the transaction to complete the update.
*/
void BeginUpdate(layers::Layer* aLayer, LayerState aState,
uint32_t aContainerLayerGeneration, nsDisplayItem* aItem = nullptr);
/**
* Completes the update of this, and removes any references to data that won't live
* longer than the transaction.
*
* Updates the geometry, frame list and clip.
* For items within a PaintedLayer, a geometry object must be specified to retain
* until the next transaction.
*
*/
void EndUpdate(nsAutoPtr<nsDisplayItemGeometry> aGeometry);
void EndUpdate();
uint32_t mRefCnt;
LayerManagerData* mParent;
RefPtr<layers::Layer> mLayer;
RefPtr<layers::Layer> mOptLayer;
RefPtr<layers::BasicLayerManager> mInactiveManager;
AutoTArray<nsIFrame*, 1> mFrameList;
nsAutoPtr<nsDisplayItemGeometry> mGeometry;
DisplayItemClip mClip;
uint32_t mDisplayItemKey;
uint32_t mContainerLayerGeneration;
LayerState mLayerState;
/**
* Temporary stoarage of the display item being referenced, only valid between
* BeginUpdate and EndUpdate.
*/
nsDisplayItem* mItem;
AutoTArray<nsIFrame*, 1> mFrameListChanges;
/**
* Used to track if data currently stored in mFramesWithLayers (from an existing
* paint) has been updated in the current paint.
*/
bool mUsed;
bool mIsInvalid;
};
class RefCountedRegion {
private:
~RefCountedRegion() {}
@ -559,6 +416,7 @@ public:
*/
static bool HasRetainedDataFor(nsIFrame* aFrame, uint32_t aDisplayItemKey);
class DisplayItemData;
typedef void (*DisplayItemDataCallback)(nsIFrame *aFrame, DisplayItemData* aItem);
static void IterateRetainedDataFor(nsIFrame* aFrame, DisplayItemDataCallback aCallback);
@ -596,6 +454,107 @@ public:
NS_DECLARE_FRAME_PROPERTY_WITH_FRAME_IN_DTOR(LayerManagerDataProperty,
nsTArray<DisplayItemData*>,
RemoveFrameFromLayerManager)
/**
* Retained data storage:
*
* Each layer manager (widget, and inactive) stores a LayerManagerData object
* that keeps a hash-set of DisplayItemData items that were drawn into it.
* Each frame also keeps a list of DisplayItemData pointers that were
* created for that frame. DisplayItemData objects manage these lists automatically.
*
* During layer construction we update the data in the LayerManagerData object, marking
* items that are modified. At the end we sweep the LayerManagerData hash-set and remove
* all items that haven't been modified.
*/
/**
* Retained data for a display item.
*/
class DisplayItemData final {
public:
friend class FrameLayerBuilder;
uint32_t GetDisplayItemKey() { return mDisplayItemKey; }
Layer* GetLayer() { return mLayer; }
nsDisplayItemGeometry* GetGeometry() const { return mGeometry.get(); }
void Invalidate() { mIsInvalid = true; }
void ClearAnimationCompositorState();
static DisplayItemData* AssertDisplayItemData(DisplayItemData* aData);
private:
DisplayItemData(LayerManagerData* aParent,
uint32_t aKey,
Layer* aLayer,
nsIFrame* aFrame = nullptr);
/**
* Removes any references to this object from frames
* in mFrameList.
*/
~DisplayItemData();
NS_INLINE_DECL_REFCOUNTING(DisplayItemData)
/**
* Associates this DisplayItemData with a frame, and adds it
* to the LayerManagerDataProperty list on the frame.
*/
void AddFrame(nsIFrame* aFrame);
void RemoveFrame(nsIFrame* aFrame);
const nsTArray<nsIFrame*>& GetFrameListChanges();
/**
* Updates the contents of this item to a new set of data, instead of allocating a new
* object.
* Set the passed in parameters, and clears the opt layer and inactive manager.
* Parent, and display item key are assumed to be the same.
*
* EndUpdate must be called before the end of the transaction to complete the update.
*/
void BeginUpdate(Layer* aLayer, LayerState aState,
uint32_t aContainerLayerGeneration, nsDisplayItem* aItem = nullptr);
/**
* Completes the update of this, and removes any references to data that won't live
* longer than the transaction.
*
* Updates the geometry, frame list and clip.
* For items within a PaintedLayer, a geometry object must be specified to retain
* until the next transaction.
*
*/
void EndUpdate(nsAutoPtr<nsDisplayItemGeometry> aGeometry);
void EndUpdate();
LayerManagerData* mParent;
RefPtr<Layer> mLayer;
RefPtr<Layer> mOptLayer;
RefPtr<BasicLayerManager> mInactiveManager;
AutoTArray<nsIFrame*, 1> mFrameList;
nsAutoPtr<nsDisplayItemGeometry> mGeometry;
DisplayItemClip mClip;
uint32_t mDisplayItemKey;
uint32_t mContainerLayerGeneration;
LayerState mLayerState;
/**
* Temporary stoarage of the display item being referenced, only valid between
* BeginUpdate and EndUpdate.
*/
nsDisplayItem* mItem;
AutoTArray<nsIFrame*, 1> mFrameListChanges;
/**
* Used to track if data currently stored in mFramesWithLayers (from an existing
* paint) has been updated in the current paint.
*/
bool mUsed;
bool mIsInvalid;
};
protected:
friend class LayerManagerData;

View File

@ -315,7 +315,7 @@ ImageLoader::GetPresContext()
}
void InvalidateImagesCallback(nsIFrame* aFrame,
DisplayItemData* aItem)
FrameLayerBuilder::DisplayItemData* aItem)
{
nsDisplayItem::Type type = nsDisplayItem::GetDisplayItemTypeFromKey(aItem->GetDisplayItemKey());
uint8_t flags = nsDisplayItem::GetDisplayItemFlagsForType(type);