Bug 1389143 - Refactor to extract helper method. r?jrmuizel draft
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 18 Aug 2017 13:06:30 -0400
changeset 649102 1b2533f5721d6a1a276ad17fef6b0e4df258dc93
parent 648573 a6a1f5c1d971dbee67ba6eec7ead7902351ddca2
child 649103 1ee8e595ff1f965207d8d3d112063960c343c317
push id74954
push userkgupta@mozilla.com
push dateFri, 18 Aug 2017 17:07:08 +0000
reviewersjrmuizel
bugs1389143
milestone57.0a1
Bug 1389143 - Refactor to extract helper method. r?jrmuizel MozReview-Commit-ID: 5FxrP280i5m
gfx/layers/LayersTypes.cpp
gfx/layers/LayersTypes.h
layout/painting/FrameLayerBuilder.cpp
--- a/gfx/layers/LayersTypes.cpp
+++ b/gfx/layers/LayersTypes.cpp
@@ -46,11 +46,31 @@ CSSFilter ToCSSFilter(const nsStyleFilte
     // All other filter types should be prevented by the code which converts
     // display items into layers.
     default:
       MOZ_ASSERT_UNREACHABLE("Tried to convert an unsupported filter");
       return { CSSFilterType::CONTRAST, 0 };
   }
 }
 
+EventRegions::EventRegions(const nsIntRegion& aHitRegion,
+                           const nsIntRegion& aMaybeHitRegion,
+                           const nsIntRegion& aDispatchToContentRegion,
+                           const nsIntRegion& aNoActionRegion,
+                           const nsIntRegion& aHorizontalPanRegion,
+                           const nsIntRegion& aVerticalPanRegion)
+{
+  mHitRegion = aHitRegion;
+  mNoActionRegion = aNoActionRegion;
+  mHorizontalPanRegion = aHorizontalPanRegion;
+  mVerticalPanRegion = aVerticalPanRegion;
+  // Points whose hit-region status we're not sure about need to be dispatched
+  // to the content thread. If a point is in both maybeHitRegion and hitRegion
+  // then it's not a "maybe" any more, and doesn't go into the dispatch-to-
+  // content region.
+  mDispatchToContentHitRegion.Sub(aMaybeHitRegion, mHitRegion);
+  mDispatchToContentHitRegion.OrWith(aDispatchToContentRegion);
+  mHitRegion.OrWith(aMaybeHitRegion);
+}
+
 } // namespace layers
 } // namespace mozilla
 
--- a/gfx/layers/LayersTypes.h
+++ b/gfx/layers/LayersTypes.h
@@ -105,16 +105,26 @@ struct EventRegions {
   {
   }
 
   explicit EventRegions(nsIntRegion aHitRegion)
     : mHitRegion(aHitRegion)
   {
   }
 
+  // This constructor takes the maybe-hit region and uses it to update the
+  // hit region and dispatch-to-content region. It is useful from converting
+  // from the display item representation to the layer representation.
+  EventRegions(const nsIntRegion& aHitRegion,
+               const nsIntRegion& aMaybeHitRegion,
+               const nsIntRegion& aDispatchToContentRegion,
+               const nsIntRegion& aNoActionRegion,
+               const nsIntRegion& aHorizontalPanRegion,
+               const nsIntRegion& aVerticalPanRegion);
+
   bool operator==(const EventRegions& aRegions) const
   {
     return mHitRegion == aRegions.mHitRegion &&
            mDispatchToContentHitRegion == aRegions.mDispatchToContentHitRegion &&
            mNoActionRegion == aRegions.mNoActionRegion &&
            mHorizontalPanRegion == aRegions.mHorizontalPanRegion &&
            mVerticalPanRegion == aRegions.mVerticalPanRegion;
   }
--- a/layout/painting/FrameLayerBuilder.cpp
+++ b/layout/painting/FrameLayerBuilder.cpp
@@ -3391,30 +3391,23 @@ void ContainerState::FinishPaintedLayerD
       &containingPaintedLayerData->mDispatchToContentHitRegion,
       &matrixCache,
       inactiveLayerClip);
     if (alreadyHadRegions) {
       containingPaintedLayerData->mDispatchToContentHitRegion.OrWith(
         containingPaintedLayerData->CombinedTouchActionRegion());
     }
   } else {
-    EventRegions regions;
-    regions.mHitRegion = ScaleRegionToOutsidePixels(data->mHitRegion);
-    regions.mNoActionRegion = ScaleRegionToOutsidePixels(data->mNoActionRegion);
-    regions.mHorizontalPanRegion = ScaleRegionToOutsidePixels(data->mHorizontalPanRegion);
-    regions.mVerticalPanRegion = ScaleRegionToOutsidePixels(data->mVerticalPanRegion);
-    // Points whose hit-region status we're not sure about need to be dispatched
-    // to the content thread. If a point is in both maybeHitRegion and hitRegion
-    // then it's not a "maybe" any more, and doesn't go into the dispatch-to-
-    // content region.
-    nsIntRegion maybeHitRegion = ScaleRegionToOutsidePixels(data->mMaybeHitRegion);
-    regions.mDispatchToContentHitRegion.Sub(maybeHitRegion, regions.mHitRegion);
-    regions.mDispatchToContentHitRegion.OrWith(
-        ScaleRegionToOutsidePixels(data->mDispatchToContentHitRegion));
-    regions.mHitRegion.OrWith(maybeHitRegion);
+    EventRegions regions(
+        ScaleRegionToOutsidePixels(data->mHitRegion),
+        ScaleRegionToOutsidePixels(data->mMaybeHitRegion),
+        ScaleRegionToOutsidePixels(data->mDispatchToContentHitRegion),
+        ScaleRegionToOutsidePixels(data->mNoActionRegion),
+        ScaleRegionToOutsidePixels(data->mHorizontalPanRegion),
+        ScaleRegionToOutsidePixels(data->mVerticalPanRegion));
 
     Matrix mat = layer->GetTransform().As2D();
     mat.Invert();
     regions.ApplyTranslationAndScale(mat._31, mat._32, mat._11, mat._22);
 
     layer->SetEventRegions(regions);
   }