Bug 1389143 - Refactor to extract helper method. r?jrmuizel
MozReview-Commit-ID: 5FxrP280i5m
--- 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);
}