Bug 1404181 - Part 13: Expose DisplayItemData better from FrameLayerBuilder so we can query the geometry (for sync decode invalidations). r?mstange
MozReview-Commit-ID: 43oxBMdRRTK
--- a/layout/base/nsLayoutDebugger.cpp
+++ b/layout/base/nsLayoutDebugger.cpp
@@ -146,18 +146,18 @@ PrintDisplayItemTo(nsDisplayListBuilder*
if (aDumpHtml && aItem->Painted()) {
nsCString string(aItem->Name());
string.Append('-');
string.AppendInt((uint64_t)aItem);
aStream << nsPrintfCString("<a href=\"javascript:ViewImage('%s')\">", string.BeginReading());
}
#endif
- aStream << nsPrintfCString("%s p=0x%p f=0x%p(%s) %sbounds(%d,%d,%d,%d) layerBounds(%d,%d,%d,%d) visible(%d,%d,%d,%d) componentAlpha(%d,%d,%d,%d) clip(%s) asr(%s) clipChain(%s)%s ref=0x%p agr=0x%p",
- aItem->Name(), aItem, (void*)f, NS_ConvertUTF16toUTF8(contentData).get(),
+ aStream << nsPrintfCString("%s p=0x%p f=0x%p(%s) key=%d %sbounds(%d,%d,%d,%d) layerBounds(%d,%d,%d,%d) visible(%d,%d,%d,%d) componentAlpha(%d,%d,%d,%d) clip(%s) asr(%s) clipChain(%s)%s ref=0x%p agr=0x%p",
+ aItem->Name(), aItem, (void*)f, NS_ConvertUTF16toUTF8(contentData).get(), aItem->GetPerFrameKey(),
(aItem->ZIndex() ? nsPrintfCString("z=%d ", aItem->ZIndex()).get() : ""),
rect.x, rect.y, rect.width, rect.height,
layerRect.x, layerRect.y, layerRect.width, layerRect.height,
vis.x, vis.y, vis.width, vis.height,
component.x, component.y, component.width, component.height,
clip.ToString().get(),
ActiveScrolledRoot::ToString(aItem->GetActiveScrolledRoot()).get(),
DisplayItemClipChain::ToString(aItem->GetClipChain()).get(),
@@ -185,23 +185,22 @@ PrintDisplayItemTo(nsDisplayListBuilder*
// Display item specific debug info
aItem->WriteDebugInfo(aStream);
#ifdef MOZ_DUMP_PAINTING
if (aDumpHtml && aItem->Painted()) {
aStream << "</a>";
}
#endif
- uint32_t key = aItem->GetPerFrameKey();
- Layer* layer = mozilla::FrameLayerBuilder::GetDebugOldLayerFor(f, key);
- if (layer) {
+ DisplayItemData* data = mozilla::FrameLayerBuilder::GetOldDataFor(aItem);
+ if (data && data->GetLayer()) {
if (aDumpHtml) {
- aStream << nsPrintfCString(" <a href=\"#%p\">layer=%p</a>", layer, layer);
+ aStream << nsPrintfCString(" <a href=\"#%p\">layer=%p</a>", data->GetLayer(), data->GetLayer());
} else {
- aStream << nsPrintfCString(" layer=0x%p", layer);
+ aStream << nsPrintfCString(" layer=0x%p", data->GetLayer());
}
}
#ifdef MOZ_DUMP_PAINTING
if (aItem->GetType() == DisplayItemType::TYPE_MASK) {
nsCString str;
(static_cast<nsDisplayMask*>(aItem))->PrintEffects(str);
aStream << str.get();
}
--- a/layout/painting/FrameLayerBuilder.cpp
+++ b/layout/painting/FrameLayerBuilder.cpp
@@ -2127,26 +2127,26 @@ FrameLayerBuilder::ClearCachedGeometry(n
nsIFrame* frame = aItem->Frame();
DisplayItemData* oldData = GetOldLayerForFrame(frame, key);
if (oldData) {
oldData->mGeometry = nullptr;
}
}
-/* static */ Layer*
-FrameLayerBuilder::GetDebugOldLayerFor(nsIFrame* aFrame, uint32_t aDisplayItemKey)
+/* static */ DisplayItemData*
+FrameLayerBuilder::GetOldDataFor(nsDisplayItem* aItem)
{
- const SmallPointerArray<DisplayItemData>& array = aFrame->DisplayItemData();
+ const SmallPointerArray<DisplayItemData>& array = aItem->Frame()->DisplayItemData();
for (uint32_t i = 0; i < array.Length(); i++) {
DisplayItemData *data = DisplayItemData::AssertDisplayItemData(array.ElementAt(i));
- if (data->mDisplayItemKey == aDisplayItemKey) {
- return data->mLayer;
+ if (data->mDisplayItemKey == aItem->GetPerFrameKey()) {
+ return data;
}
}
return nullptr;
}
// Reset state that should not persist when a layer is recycled.
static void
ResetLayerStateForRecycling(Layer* aLayer) {
--- a/layout/painting/FrameLayerBuilder.h
+++ b/layout/painting/FrameLayerBuilder.h
@@ -59,17 +59,17 @@ class ContainerState;
/**
* Retained data for a display item.
*/
class DisplayItemData final {
public:
friend class FrameLayerBuilder;
uint32_t GetDisplayItemKey() { return mDisplayItemKey; }
- layers::Layer* GetLayer() { return mLayer; }
+ layers::Layer* GetLayer() const { 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)
{
@@ -499,17 +499,17 @@ public:
* frame.
*/
Layer* GetOldLayerFor(nsDisplayItem* aItem,
nsDisplayItemGeometry** aOldGeometry = nullptr,
DisplayItemClip** aOldClip = nullptr);
void ClearCachedGeometry(nsDisplayItem* aItem);
- static Layer* GetDebugOldLayerFor(nsIFrame* aFrame, uint32_t aDisplayItemKey);
+ static DisplayItemData* GetOldDataFor(nsDisplayItem* aItem);
/**
* Return the layer that all display items of aFrame were assigned to in the
* last paint, or nullptr if there was no single layer assigned to all of the
* frame's display items (i.e. zero, or more than one).
* This function is for testing purposes and not performance sensitive.
*/
template<class T>