Bug 1438527 - Use non-empty bounds for nsDisplayCompositorHitTestInfo to ensure proper layer assignment draft
authorMiko Mynttinen <mikokm@gmail.com>
Fri, 16 Feb 2018 02:01:18 +0100
changeset 756107 bf3dfc1e19eba33b58be761867f759f29eabfb1d
parent 755532 026401920e32e641eb42b068a16d7dd9e86c66a4
push id99378
push userbmo:mikokm@gmail.com
push dateFri, 16 Feb 2018 12:42:25 +0000
bugs1438527
milestone60.0a1
Bug 1438527 - Use non-empty bounds for nsDisplayCompositorHitTestInfo to ensure proper layer assignment MozReview-Commit-ID: 5CCN8t7ytP5
layout/painting/FrameLayerBuilder.cpp
layout/painting/nsDisplayList.cpp
--- 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();
 }