Bug 1438527 - Use non-empty bounds for nsDisplayCompositorHitTestInfo to ensure proper layer assignment
MozReview-Commit-ID: 5CCN8t7ytP5
--- a/layout/painting/FrameLayerBuilder.cpp
+++ b/layout/painting/FrameLayerBuilder.cpp
@@ -4162,38 +4162,44 @@ ContainerState::ProcessDisplayItems(nsDi
bool snap;
nsRect itemContent = item->GetBounds(mBuilder, &snap);
if (itemType == DisplayItemType::TYPE_LAYER_EVENT_REGIONS) {
nsDisplayLayerEventRegions* eventRegions =
static_cast<nsDisplayLayerEventRegions*>(item);
itemContent = eventRegions->GetHitRegionBounds(mBuilder, &snap);
}
+
+ if (itemType == DisplayItemType::TYPE_COMPOSITOR_HITTEST_INFO) {
+ nsDisplayCompositorHitTestInfo* eventRegions =
+ static_cast<nsDisplayCompositorHitTestInfo*>(item);
+ itemContent = eventRegions->Area();
+ }
+
nsIntRect itemDrawRect = ScaleToOutsidePixels(itemContent, snap);
bool prerenderedTransform = itemType == DisplayItemType::TYPE_TRANSFORM &&
static_cast<nsDisplayTransform*>(item)->MayBeAnimated(mBuilder);
ParentLayerIntRect clipRect;
const DisplayItemClip& itemClip = item->GetClip();
if (itemClip.HasClip()) {
itemContent.IntersectRect(itemContent, itemClip.GetClipRect());
clipRect = ViewAs<ParentLayerPixel>(ScaleToNearestPixels(itemClip.GetClipRect()));
if (!prerenderedTransform && !IsScrollThumbLayer(item)) {
itemDrawRect.IntersectRect(itemDrawRect, clipRect.ToUnknownRect());
}
clipRect.MoveBy(ViewAs<ParentLayerPixel>(mParameters.mOffset));
}
#ifdef DEBUG
nsRect bounds = itemContent;
- bool dummy;
- if (itemType == DisplayItemType::TYPE_LAYER_EVENT_REGIONS) {
- bounds = item->GetBounds(mBuilder, &dummy);
- if (itemClip.HasClip()) {
- bounds.IntersectRect(bounds, itemClip.GetClipRect());
- }
+
+ if (itemType == DisplayItemType::TYPE_LAYER_EVENT_REGIONS ||
+ itemType == DisplayItemType::TYPE_COMPOSITOR_HITTEST_INFO) {
+ bounds.SetEmpty();
}
+
if (!bounds.IsEmpty()) {
if (itemASR != mContainerASR) {
if (Maybe<nsRect> clip = item->GetClipWithRespectToASR(mBuilder, mContainerASR)) {
bounds = clip.ref();
}
}
}
((nsRect&)mAccumulatedChildBounds).UnionRect(mAccumulatedChildBounds, bounds);
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -5133,16 +5133,17 @@ nsDisplayCompositorHitTestInfo::CreateWe
return true;
}
void
nsDisplayCompositorHitTestInfo::WriteDebugInfo(std::stringstream& aStream)
{
aStream << nsPrintfCString(" (hitTestInfo 0x%x)", (int)mHitTestInfo).get();
+ AppendToString(aStream, mArea, " hitTestArea");
}
uint32_t
nsDisplayCompositorHitTestInfo::GetPerFrameKey() const
{
return (mIndex << TYPE_BITS) | nsDisplayItem::GetPerFrameKey();
}