Bug 1363423 - Prevent the maybe-hit region from growing too large (in terms of number of rectangles) in PaintedLayerData::AccumulateEventRegions(). r=jrmuizel draft
authorBotond Ballo <botond@mozilla.com>
Fri, 12 May 2017 20:28:12 -0400
changeset 577353 afd5e02e5ba0b877d968c432e426288835f9b6d7
parent 577152 8ce307a04ef9b6e184b0c3bc69d2c2ced4e5e4e1
child 628481 147d385daca6a9cf329ffa47e7e1707299e0ceb8
push id58670
push userbballo@mozilla.com
push dateSat, 13 May 2017 15:44:15 +0000
reviewersjrmuizel
bugs1363423
milestone55.0a1
Bug 1363423 - Prevent the maybe-hit region from growing too large (in terms of number of rectangles) in PaintedLayerData::AccumulateEventRegions(). r=jrmuizel MozReview-Commit-ID: E7Pco25mlBc
layout/painting/FrameLayerBuilder.cpp
--- a/layout/painting/FrameLayerBuilder.cpp
+++ b/layout/painting/FrameLayerBuilder.cpp
@@ -3592,16 +3592,20 @@ PaintedLayerData::AccumulateEventRegions
       !mVerticalPanRegion.IsEmpty();
   mNoActionRegion.OrWith(aEventRegions->NoActionRegion());
   mHorizontalPanRegion.OrWith(aEventRegions->HorizontalPanRegion());
   mVerticalPanRegion.OrWith(aEventRegions->VerticalPanRegion());
   if (alreadyHadRegions) {
     mDispatchToContentHitRegion.OrWith(CombinedTouchActionRegion());
   }
 
+  // Avoid quadratic performance as a result of the region growing to include
+  // and arbitrarily large number of rects, which can happen on some pages.
+  mMaybeHitRegion.SimplifyOutward(8);
+
   // Calculate scaled versions of the bounds of mHitRegion and mMaybeHitRegion
   // for quick access in FindPaintedLayerFor().
   mScaledHitRegionBounds = aState->ScaleToOutsidePixels(mHitRegion.GetBounds());
   mScaledMaybeHitRegionBounds = aState->ScaleToOutsidePixels(mMaybeHitRegion.GetBounds());
 }
 
 PaintedLayerData
 ContainerState::NewPaintedLayerData(nsDisplayItem* aItem,