summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--layout/base/FrameLayerBuilder.cpp82
1 files changed, 21 insertions, 61 deletions
diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp
index 3a244b96d9..d38b17adc4 100644
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -162,7 +162,6 @@ void
FrameLayerBuilder::DisplayItemData::AddFrame(nsIFrame* aFrame)
{
MOZ_RELEASE_ASSERT(mLayer);
-
mFrameList.AppendElement(aFrame);
nsTArray<DisplayItemData*>* array =
@@ -329,7 +328,8 @@ public:
void Dump(const char *aPrefix = "") {
printf_stderr("%sLayerManagerData %p\n", aPrefix, this);
- for (auto& data : mDisplayItems) {
+ for (auto iter = mDisplayItems.Iter(); !iter.Done(); iter.Next()) {
+ FrameLayerBuilder::DisplayItemData* data = iter.Get()->GetKey();
nsAutoCString prefix;
prefix += aPrefix;
@@ -388,7 +388,7 @@ public:
#ifdef DEBUG_DISPLAY_ITEM_DATA
LayerManagerData *mParent;
#endif
- std::vector<RefPtr<FrameLayerBuilder::DisplayItemData> > mDisplayItems;
+ nsTHashtable<nsRefPtrHashKey<FrameLayerBuilder::DisplayItemData> > mDisplayItems;
bool mInvalidateAllLayers;
};
@@ -1971,15 +1971,7 @@ FrameLayerBuilder::RemoveFrameFromLayerManager(const nsIFrame* aFrame,
}
}
- auto it = std::find(data->mParent->mDisplayItems.begin(),
- data->mParent->mDisplayItems.end(),
- data);
- // Don't attempt to remove the frame from the display items vector
- // if it is not in the container. It might've been removed already.
- if (it != data->mParent->mDisplayItems.end()) {
- std::iter_swap(it, data->mParent->mDisplayItems.end() - 1);
- data->mParent->mDisplayItems.pop_back();
- }
+ data->mParent->mDisplayItems.RemoveEntry(data);
}
arrayCopy.Clear();
@@ -2032,40 +2024,27 @@ FrameLayerBuilder::WillEndTransaction()
NS_ASSERTION(data, "Must have data!");
// Update all the frames that used to have layers.
- auto iter = data->mDisplayItems.begin();
- while (iter != data->mDisplayItems.end()) {
- DisplayItemData* did = iter->get();
- if (!did->mUsed) {
+ for (auto iter = data->mDisplayItems.Iter(); !iter.Done(); iter.Next()) {
+ DisplayItemData* data = iter.Get()->GetKey();
+ if (!data->mUsed) {
// This item was visible, but isn't anymore.
- PaintedLayer* t = did->mLayer->AsPaintedLayer();
- if (t && did->mGeometry) {
+ PaintedLayer* t = data->mLayer->AsPaintedLayer();
+ if (t && data->mGeometry) {
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
- printf_stderr("Invalidating unused display item (%i) belonging to frame %p from layer %p\n", did->mDisplayItemKey, did->mFrameList[0], t);
+ printf_stderr("Invalidating unused display item (%i) belonging to frame %p from layer %p\n", data->mDisplayItemKey, data->mFrameList[0], t);
}
#endif
InvalidatePostTransformRegion(t,
- did->mGeometry->ComputeInvalidationRegion(),
- did->mClip,
+ data->mGeometry->ComputeInvalidationRegion(),
+ data->mClip,
GetLastPaintOffset(t));
}
- did->ClearAnimationCompositorState();
-
- // Remove this item. Swapping it with the last element first is
- // quicker than erasing from the middle.
- if (iter != data->mDisplayItems.end() - 1) {
- std::iter_swap(iter, data->mDisplayItems.end() - 1);
- data->mDisplayItems.pop_back();
- } else {
- data->mDisplayItems.pop_back();
- break;
- }
-
- // Don't increment iter because we still need to process the item which was moved.
+ data->ClearAnimationCompositorState();
+ iter.Remove();
} else {
- ComputeGeometryChangeForItem(did);
- iter++;
+ ComputeGeometryChangeForItem(data);
}
}
@@ -4821,12 +4800,7 @@ FrameLayerBuilder::StoreDataForFrame(nsDisplayItem* aItem, Layer* aLayer, LayerS
data->BeginUpdate(aLayer, aState, mContainerLayerGeneration, aItem);
- // Make sure we don't add duplicate display items for the same frame.
- if (std::find(lmd->mDisplayItems.begin(),
- lmd->mDisplayItems.end(),
- data) == lmd->mDisplayItems.end()) {
- lmd->mDisplayItems.push_back(data);
- }
+ lmd->mDisplayItems.PutEntry(data);
return data;
}
@@ -4850,12 +4824,7 @@ FrameLayerBuilder::StoreDataForFrame(nsIFrame* aFrame,
data->BeginUpdate(aLayer, aState, mContainerLayerGeneration);
- // Make sure we don't add duplicate display items for the same frame.
- if (std::find(lmd->mDisplayItems.begin(),
- lmd->mDisplayItems.end(),
- data) == lmd->mDisplayItems.end()) {
- lmd->mDisplayItems.push_back(data);
- }
+ lmd->mDisplayItems.PutEntry(data);
}
FrameLayerBuilder::ClippedDisplayItem::ClippedDisplayItem(nsDisplayItem* aItem,
@@ -5589,19 +5558,10 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder,
flattenToSingleLayer = true;
// Restore DisplayItemData
- auto iter = data->mDisplayItems.begin();
- while (iter != data->mDisplayItems.end()) {
- DisplayItemData* did = iter->get();
- if (did->mUsed && did->mContainerLayerGeneration >= mContainerLayerGeneration) {
- if (iter != data->mDisplayItems.end() - 1) {
- std::iter_swap(iter, data->mDisplayItems.end() - 1);
- data->mDisplayItems.pop_back();
- } else {
- data->mDisplayItems.pop_back();
- break;
- }
- } else {
- iter++;
+ for (auto iter = data->mDisplayItems.Iter(); !iter.Done(); iter.Next()) {
+ DisplayItemData* data = iter.Get()->GetKey();
+ if (data->mUsed && data->mContainerLayerGeneration >= mContainerLayerGeneration) {
+ iter.Remove();
}
}