Skip to content

Commit

Permalink
Bug 1388162 - Add a Destroy function to nsDisplayItem to use instead …
Browse files Browse the repository at this point in the history
…of manually invoking the destructor, this will allow us to recycle them in the future. r=mstange

* * *
[mq]: fix

MozReview-Commit-ID: LUXZAIL73BJ
  • Loading branch information
mattwoodrow committed Aug 7, 2017
1 parent 40f5b92 commit 781ec6f
Show file tree
Hide file tree
Showing 36 changed files with 265 additions and 208 deletions.
6 changes: 2 additions & 4 deletions dom/base/nsDOMWindowUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3947,8 +3947,7 @@ nsDOMWindowUtils::GetOMTAStyle(nsIDOMElement* aElement,
if (frame && nsLayoutUtils::AreAsyncAnimationsEnabled()) {
if (aProperty.EqualsLiteral("opacity")) {
Layer* layer =
FrameLayerBuilder::GetDedicatedLayer(frame,
nsDisplayItem::TYPE_OPACITY);
FrameLayerBuilder::GetDedicatedLayer(frame, DisplayItemType::TYPE_OPACITY);
if (layer) {
float value = 0;
bool hadAnimatedOpacity = false;
Expand All @@ -3972,8 +3971,7 @@ nsDOMWindowUtils::GetOMTAStyle(nsIDOMElement* aElement,
}
} else if (aProperty.EqualsLiteral("transform")) {
Layer* layer =
FrameLayerBuilder::GetDedicatedLayer(frame,
nsDisplayItem::TYPE_TRANSFORM);
FrameLayerBuilder::GetDedicatedLayer(frame, DisplayItemType::TYPE_TRANSFORM);
if (layer) {
MaybeTransform transform;
ShadowLayerForwarder* forwarder = layer->Manager()->AsShadowForwarder();
Expand Down
6 changes: 3 additions & 3 deletions dom/html/HTMLCanvasElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ HTMLCanvasElement::InvalidateCanvasContent(const gfx::Rect* damageRect)
nsIFrame::WebRenderUserDataTable* userDataTable =
frame->GetProperty(nsIFrame::WebRenderUserDataProperty());
RefPtr<WebRenderUserData> data;
userDataTable->Get(nsDisplayItem::TYPE_CANVAS, getter_AddRefs(data));
userDataTable->Get(static_cast<uint32_t>(DisplayItemType::TYPE_CANVAS), getter_AddRefs(data));
if (data && data->AsCanvasData()) {
renderer = data->AsCanvasData()->GetCanvasRenderer();
}
Expand All @@ -1084,10 +1084,10 @@ HTMLCanvasElement::InvalidateCanvasContent(const gfx::Rect* damageRect)
nsIntSize size = GetWidthHeight();
if (size.width != 0 && size.height != 0) {
gfx::IntRect invalRect = gfx::IntRect::Truncate(*damageRect);
layer = frame->InvalidateLayer(nsDisplayItem::TYPE_CANVAS, &invalRect);
layer = frame->InvalidateLayer(DisplayItemType::TYPE_CANVAS, &invalRect);
}
} else {
layer = frame->InvalidateLayer(nsDisplayItem::TYPE_CANVAS);
layer = frame->InvalidateLayer(DisplayItemType::TYPE_CANVAS);
}

if (layer) {
Expand Down
2 changes: 1 addition & 1 deletion dom/media/VideoFrameContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ void VideoFrameContainer::InvalidateWithFlags(uint32_t aFlags)
if (invalidateFrame) {
frame->InvalidateFrame();
} else {
frame->InvalidateLayer(nsDisplayItem::TYPE_VIDEO, nullptr, nullptr,
frame->InvalidateLayer(DisplayItemType::TYPE_VIDEO, nullptr, nullptr,
asyncInvalidate ? nsIFrame::UPDATE_IS_ASYNC : 0);
}
}
Expand Down
4 changes: 2 additions & 2 deletions dom/plugins/base/nsPluginInstanceOwner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRect(NPRect *invalidRect)
double scaleFactor = 1.0;
GetContentsScaleFactor(&scaleFactor);
rect.ScaleRoundOut(scaleFactor);
mPluginFrame->InvalidateLayer(nsDisplayItem::TYPE_PLUGIN, &rect);
mPluginFrame->InvalidateLayer(DisplayItemType::TYPE_PLUGIN, &rect);
return NS_OK;
}

Expand All @@ -571,7 +571,7 @@ NS_IMETHODIMP
nsPluginInstanceOwner::RedrawPlugin()
{
if (mPluginFrame) {
mPluginFrame->InvalidateLayer(nsDisplayItem::TYPE_PLUGIN);
mPluginFrame->InvalidateLayer(DisplayItemType::TYPE_PLUGIN);
}
return NS_OK;
}
Expand Down
14 changes: 7 additions & 7 deletions gfx/layers/wr/WebRenderLayerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,15 @@ WebRenderLayerManager::CreateWebRenderCommandsFromDisplayList(nsDisplayList* aDi
nsDisplayList savedItems;
nsDisplayItem* item;
while ((item = aDisplayList->RemoveBottom()) != nullptr) {
nsDisplayItem::Type itemType = item->GetType();
DisplayItemType itemType = item->GetType();

// If the item is a event regions item, but is empty (has no regions in it)
// then we should just throw it out
if (itemType == nsDisplayItem::TYPE_LAYER_EVENT_REGIONS) {
if (itemType == DisplayItemType::TYPE_LAYER_EVENT_REGIONS) {
nsDisplayLayerEventRegions* eventRegions =
static_cast<nsDisplayLayerEventRegions*>(item);
if (eventRegions->IsEmpty()) {
item->~nsDisplayItem();
item->Destroy(aDisplayListBuilder);
continue;
}
}
Expand All @@ -220,7 +220,7 @@ WebRenderLayerManager::CreateWebRenderCommandsFromDisplayList(nsDisplayList* aDi
while ((aboveItem = aDisplayList->GetBottom()) != nullptr) {
if (aboveItem->TryMerge(item)) {
aDisplayList->RemoveBottom();
item->~nsDisplayItem();
item->Destroy(aDisplayListBuilder);
item = aboveItem;
itemType = item->GetType();
} else {
Expand All @@ -232,7 +232,7 @@ WebRenderLayerManager::CreateWebRenderCommandsFromDisplayList(nsDisplayList* aDi
= item->GetSameCoordinateSystemChildren();
if (item->ShouldFlattenAway(aDisplayListBuilder)) {
aDisplayList->AppendToBottom(itemSameCoordinateSystemChildren);
item->~nsDisplayItem();
item->Destroy(aDisplayListBuilder);
continue;
}

Expand Down Expand Up @@ -388,7 +388,7 @@ PaintItemByDrawTarget(nsDisplayItem* aItem,
RefPtr<gfxContext> context = gfxContext::CreateOrNull(aDT, aOffset.ToUnknownPoint());
MOZ_ASSERT(context);

if (aItem->GetType() == nsDisplayItem::TYPE_MASK) {
if (aItem->GetType() == DisplayItemType::TYPE_MASK) {
context->SetMatrix(gfxMatrix::Translation(-aOffset.x, -aOffset.y));
static_cast<nsDisplayMask*>(aItem)->PaintMask(aDisplayListBuilder, context);
} else {
Expand Down Expand Up @@ -464,7 +464,7 @@ WebRenderLayerManager::GenerateFallbackData(nsDisplayItem* aItem,
}
}

gfx::SurfaceFormat format = aItem->GetType() == nsDisplayItem::TYPE_MASK ?
gfx::SurfaceFormat format = aItem->GetType() == DisplayItemType::TYPE_MASK ?
gfx::SurfaceFormat::A8 : gfx::SurfaceFormat::B8G8R8A8;
if (!geometry || !invalidRegion.IsEmpty() || fallbackData->IsInvalid()) {
if (gfxPrefs::WebRenderBlobImages()) {
Expand Down
10 changes: 5 additions & 5 deletions layout/base/PresShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ struct RangePaintInfo {

~RangePaintInfo()
{
mList.DeleteAll();
mList.DeleteAll(&mBuilder);
MOZ_COUNT_DTOR(RangePaintInfo);
}
};
Expand Down Expand Up @@ -4864,7 +4864,7 @@ PresShell::ClipListToRange(nsDisplayListBuilder *aBuilder,
}
else {
// otherwise, just delete the item and don't readd it to the list
i->~nsDisplayItem();
i->Destroy(aBuilder);
}
}

Expand Down Expand Up @@ -5240,14 +5240,14 @@ AddCanvasBackgroundColor(const nsDisplayList& aList, nsIFrame* aCanvasFrame,
{
for (nsDisplayItem* i = aList.GetBottom(); i; i = i->GetAbove()) {
if (i->Frame() == aCanvasFrame &&
i->GetType() == nsDisplayItem::TYPE_CANVAS_BACKGROUND_COLOR) {
i->GetType() == DisplayItemType::TYPE_CANVAS_BACKGROUND_COLOR) {
nsDisplayCanvasBackgroundColor* bg = static_cast<nsDisplayCanvasBackgroundColor*>(i);
bg->SetExtraBackgroundColor(aColor);
return true;
}
nsDisplayList* sublist = i->GetSameCoordinateSystemChildren();
if (sublist &&
!(i->GetType() == nsDisplayItem::TYPE_BLEND_CONTAINER && !aCSSBackgroundColor) &&
!(i->GetType() == DisplayItemType::TYPE_BLEND_CONTAINER && !aCSSBackgroundColor) &&
AddCanvasBackgroundColor(*sublist, aCanvasFrame, aColor, aCSSBackgroundColor))
return true;
}
Expand Down Expand Up @@ -6131,7 +6131,7 @@ PresShell::DoUpdateApproximateFrameVisibility(bool aRemoveOnly)

ClearApproximateFrameVisibilityVisited(rootFrame->GetView(), true);

list.DeleteAll();
list.DeleteAll(&builder);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion layout/base/RestyleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,7 @@ RestyleManager::AddLayerChangesForAnimation(nsIFrame* aFrame,
// so we can skip adding any change hint here. (If we *were* to add
// nsChangeHint_UpdateTransformLayer, ApplyRenderingChangeToTree would
// complain that we're updating a transform layer without a transform).
if (layerInfo.mLayerType == nsDisplayItem::TYPE_TRANSFORM &&
if (layerInfo.mLayerType == DisplayItemType::TYPE_TRANSFORM &&
!aFrame->StyleDisplay()->HasTransformStyle()) {
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions layout/base/nsLayoutDebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@ PrintDisplayItemTo(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem,
}
}
#ifdef MOZ_DUMP_PAINTING
if (aItem->GetType() == nsDisplayItem::TYPE_MASK) {
if (aItem->GetType() == DisplayItemType::TYPE_MASK) {
nsCString str;
(static_cast<nsDisplayMask*>(aItem))->PrintEffects(str);
aStream << str.get();
}

if (aItem->GetType() == nsDisplayItem::TYPE_FILTER) {
if (aItem->GetType() == DisplayItemType::TYPE_FILTER) {
nsCString str;
(static_cast<nsDisplayFilter*>(aItem))->PrintEffects(str);
aStream << str.get();
Expand Down
4 changes: 2 additions & 2 deletions layout/base/nsLayoutUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3274,7 +3274,7 @@ nsLayoutUtils::GetFramesForArea(nsIFrame* aFrame, const nsRect& aRect,
nsDisplayItem::HitTestState hitTestState;
builder.SetHitTestShouldStopAtFirstOpaque(aFlags & ONLY_VISIBLE);
list.HitTest(&builder, aRect, &hitTestState, &aOutFrames);
list.DeleteAll();
list.DeleteAll(&builder);
return NS_OK;
}

Expand Down Expand Up @@ -3852,7 +3852,7 @@ nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext, nsIFrame* aFrame,


// Flush the list so we don't trigger the IsEmpty-on-destruction assertion
list.DeleteAll();
list.DeleteAll(&builder);
return NS_OK;
}

Expand Down
2 changes: 1 addition & 1 deletion layout/forms/nsComboboxControlFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@ nsComboboxDisplayFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,

// remove background items if parent frame is themed
if (mComboBox->IsThemed()) {
set.BorderBackground()->DeleteAll();
set.BorderBackground()->DeleteAll(aBuilder);
}

set.MoveTo(aLists);
Expand Down
2 changes: 1 addition & 1 deletion layout/forms/nsGfxCheckboxControlFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ nsGfxCheckboxControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
IsIndeterminate()
? PaintIndeterminateMark : PaintCheckMark,
"CheckedCheckbox",
nsDisplayItem::TYPE_CHECKED_CHECKBOX));
DisplayItemType::TYPE_CHECKED_CHECKBOX));
}

#endif
Expand Down
2 changes: 1 addition & 1 deletion layout/forms/nsGfxRadioControlFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ nsGfxRadioControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
aLists.Content()->AppendNewToTop(new (aBuilder)
nsDisplayGeneric(aBuilder, this, PaintCheckedRadioButton,
"CheckedRadioButton",
nsDisplayItem::TYPE_CHECKED_RADIOBUTTON));
DisplayItemType::TYPE_CHECKED_RADIOBUTTON));
}

#endif
4 changes: 2 additions & 2 deletions layout/generic/TextOverflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class nsDisplayTextOverflowMarker : public nsDisplayItem
gfxContext* aCtx) override;

virtual uint32_t GetPerFrameKey() override {
return (mIndex << nsDisplayItem::TYPE_BITS) | nsDisplayItem::GetPerFrameKey();
return (mIndex << TYPE_BITS) | nsDisplayItem::GetPerFrameKey();
}
void PaintTextToContext(gfxContext* aCtx,
nsPoint aOffsetFromRect);
Expand Down Expand Up @@ -718,7 +718,7 @@ TextOverflow::PruneDisplayListContents(nsDisplayList* aList,
while ((item = aList->RemoveBottom())) {
nsIFrame* itemFrame = item->Frame();
if (IsFrameDescendantOfAny(itemFrame, aFramesToHide, mBlock)) {
item->~nsDisplayItem();
item->Destroy(mBuilder);
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion layout/generic/nsColumnSetFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class nsDisplayColumnRule : public nsDisplayItem {
virtual void Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) override;

NS_DISPLAY_DECL_NAME("ColumnRule", nsDisplayItem::TYPE_COLUMN_RULE);
NS_DISPLAY_DECL_NAME("ColumnRule", TYPE_COLUMN_RULE);

private:
nsTArray<nsCSSBorderRenderer> mBorderRenderers;
Expand Down
38 changes: 19 additions & 19 deletions layout/generic/nsFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2248,14 +2248,14 @@ DisplayDebugBorders(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
if (nsFrame::GetShowFrameBorders() && !aFrame->GetRect().IsEmpty()) {
aLists.Outlines()->AppendNewToTop(new (aBuilder)
nsDisplayGeneric(aBuilder, aFrame, PaintDebugBorder, "DebugBorder",
nsDisplayItem::TYPE_DEBUG_BORDER));
DisplayItemType::TYPE_DEBUG_BORDER));
}
// Draw a border around the current event target
if (nsFrame::GetShowEventTargetFrameBorder() &&
aFrame->PresContext()->PresShell()->GetDrawEventTargetFrame() == aFrame) {
aLists.Outlines()->AppendNewToTop(new (aBuilder)
nsDisplayGeneric(aBuilder, aFrame, PaintEventTargetBorder, "EventTargetBorder",
nsDisplayItem::TYPE_EVENT_TARGET_BORDER));
DisplayItemType::TYPE_EVENT_TARGET_BORDER));
}
}
#endif
Expand Down Expand Up @@ -2336,9 +2336,9 @@ static bool
ItemParticipatesIn3DContext(nsIFrame* aAncestor, nsDisplayItem* aItem)
{
nsIFrame* transformFrame;
if (aItem->GetType() == nsDisplayItem::TYPE_TRANSFORM) {
if (aItem->GetType() == DisplayItemType::TYPE_TRANSFORM) {
transformFrame = aItem->Frame();
} else if (aItem->GetType() == nsDisplayItem::TYPE_PERSPECTIVE) {
} else if (aItem->GetType() == DisplayItemType::TYPE_PERSPECTIVE) {
transformFrame = static_cast<nsDisplayPerspective*>(aItem)->TransformFrame();
} else {
return false;
Expand Down Expand Up @@ -2603,11 +2603,11 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder,
}

if (aBuilder->IsBackgroundOnly()) {
set.BlockBorderBackgrounds()->DeleteAll();
set.Floats()->DeleteAll();
set.Content()->DeleteAll();
set.PositionedDescendants()->DeleteAll();
set.Outlines()->DeleteAll();
set.BlockBorderBackgrounds()->DeleteAll(aBuilder);
set.Floats()->DeleteAll(aBuilder);
set.Content()->DeleteAll(aBuilder);
set.PositionedDescendants()->DeleteAll(aBuilder);
set.Outlines()->DeleteAll(aBuilder);
}

// Sort PositionedDescendants() in CSS 'z-order' order. The list is already
Expand Down Expand Up @@ -2885,7 +2885,7 @@ WrapInWrapList(nsDisplayListBuilder* aBuilder,
// makes the perspective frame create one (so we have an atomic entry for z-index
// sorting).
nsIFrame *itemFrame = item->Frame();
if (item->GetType() == nsDisplayItem::TYPE_PERSPECTIVE) {
if (item->GetType() == DisplayItemType::TYPE_PERSPECTIVE) {
itemFrame = static_cast<nsDisplayPerspective*>(item)->TransformFrame();
}

Expand Down Expand Up @@ -6606,7 +6606,7 @@ bool
nsIFrame::TryUpdateTransformOnly(Layer** aLayerResult)
{
Layer* layer = FrameLayerBuilder::GetDedicatedLayer(
this, nsDisplayItem::TYPE_TRANSFORM);
this, DisplayItemType::TYPE_TRANSFORM);
if (!layer || !layer->HasUserData(LayerIsPrerenderedDataKey())) {
// If this layer isn't prerendered or we clip composites to our OS
// window, then we can't correctly optimize to an empty
Expand Down Expand Up @@ -6677,12 +6677,12 @@ nsIFrame::SchedulePaint(PaintType aType)
}

Layer*
nsIFrame::InvalidateLayer(uint32_t aDisplayItemKey,
nsIFrame::InvalidateLayer(DisplayItemType aDisplayItemKey,
const nsIntRect* aDamageRect,
const nsRect* aFrameDamageRect,
uint32_t aFlags /* = 0 */)
{
NS_ASSERTION(aDisplayItemKey > 0, "Need a key");
NS_ASSERTION(aDisplayItemKey > DisplayItemType::TYPE_ZERO, "Need a key");

Layer* layer = FrameLayerBuilder::GetDedicatedLayer(this, aDisplayItemKey);

Expand All @@ -6707,16 +6707,16 @@ nsIFrame::InvalidateLayer(uint32_t aDisplayItemKey,
// screen because sometimes we don't have any retainned data
// for remote type displayitem and thus Repaint event is not
// triggered. So, always invalidate here as well.
uint32_t displayItemKey = aDisplayItemKey;
if (aDisplayItemKey == nsDisplayItem::TYPE_PLUGIN ||
aDisplayItemKey == nsDisplayItem::TYPE_REMOTE) {
displayItemKey = 0;
DisplayItemType displayItemKey = aDisplayItemKey;
if (aDisplayItemKey == DisplayItemType::TYPE_PLUGIN ||
aDisplayItemKey == DisplayItemType::TYPE_REMOTE) {
displayItemKey = DisplayItemType::TYPE_ZERO;
}

if (aFrameDamageRect) {
InvalidateFrameWithRect(*aFrameDamageRect, displayItemKey);
InvalidateFrameWithRect(*aFrameDamageRect, static_cast<uint32_t>(displayItemKey));
} else {
InvalidateFrame(displayItemKey);
InvalidateFrame(static_cast<uint32_t>(displayItemKey));
}

return nullptr;
Expand Down
4 changes: 2 additions & 2 deletions layout/generic/nsGfxScrollFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2970,7 +2970,7 @@ MaxZIndexInListOfItemsContainedInFrame(nsDisplayList* aList, nsIFrame* aFrame)
nsIFrame* itemFrame = item->Frame();
// Perspective items return the scroll frame as their Frame(), so consider
// their TransformFrame() instead.
if (item->GetType() == nsDisplayItem::TYPE_PERSPECTIVE) {
if (item->GetType() == DisplayItemType::TYPE_PERSPECTIVE) {
itemFrame = static_cast<nsDisplayPerspective*>(item)->TransformFrame();
}
if (nsLayoutUtils::IsProperAncestorFrame(aFrame, itemFrame)) {
Expand Down Expand Up @@ -3227,7 +3227,7 @@ ClipItemsExceptCaret(nsDisplayList* aList,
continue;
}

if (i->GetType() != nsDisplayItem::TYPE_CARET) {
if (i->GetType() != DisplayItemType::TYPE_CARET) {
const DisplayItemClipChain* clip = i->GetClipChain();
const DisplayItemClipChain* intersection = nullptr;
if (aCache.Get(clip, &intersection)) {
Expand Down
Loading

0 comments on commit 781ec6f

Please sign in to comment.