Bug 1331718 - Part 3: Store pointers to DisplayItemData directly on nsIFrame. r=mattwoodrow r=dbaron

This patch aims to speed up the lookup and storage of DisplayItemData objects, by removing a level of indirection and preventing the previously required hashtable lookup in order to access these. Instead it stores an array of pointers on each frame that allows direct access to the DisplayItemData object by dereferencing the frame. Since most frames get either 1 or 2 DisplayItemData objects attached to them a specialized class is used that is of minimal size (2 * sizeof(void)) and that performs well for sizes 1 or 2.

MozReview-Commit-ID: HONKAmpk5H8
This commit is contained in:
Bas Schouten
2017-05-10 05:07:38 +02:00
parent a9963e5997
commit fce9449853
4 changed files with 82 additions and 120 deletions

View File

@@ -2078,6 +2078,12 @@ PresShell::SetIgnoreFrameDestruction(bool aIgnore)
void
PresShell::NotifyDestroyingFrame(nsIFrame* aFrame)
{
// We must remove these from FrameLayerBuilder::DisplayItemData::mFrameList here,
// otherwise the DisplayItemData destructor will use the destroyed frame when it
// tries to remove it from the (array) value of this property.
FrameLayerBuilder::RemoveFrameFromLayerManager(aFrame, aFrame->DisplayItemData());
aFrame->DisplayItemData().Clear();
if (!mIgnoreFrameDestruction) {
mDocument->StyleImageLoader()->DropRequestsForFrame(aFrame);
@@ -2115,13 +2121,6 @@ PresShell::NotifyDestroyingFrame(nsIFrame* aFrame)
}
mFramesToDirty.RemoveEntry(aFrame);
} else {
// We must delete this property in situ so that its destructor removes the
// frame from FrameLayerBuilder::DisplayItemData::mFrameList -- otherwise
// the DisplayItemData destructor will use the destroyed frame when it
// tries to remove it from the (array) value of this property.
mPresContext->PropertyTable()->
Delete(aFrame, FrameLayerBuilder::LayerManagerDataProperty());
}
}