Bug 901175. Properly handle when the frame has an empty intersection with the exposed region for events. r pending roc
authorTimothy Nikkel <tnikkel@gmail.com>
Sat, 03 Aug 2013 00:46:19 -0500
changeset 153579 66728b1aa97543410e8640ca37648849b9dec716
parent 153578 dc5bce83d80164e89844395c15ee1083b7391acb
child 153580 3ca6d03fe179f5df52e99cfd28bb467e3c9a5d3d
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs901175
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 901175. Properly handle when the frame has an empty intersection with the exposed region for events. r pending roc
layout/base/PositionedEventTargeting.cpp
--- a/layout/base/PositionedEventTargeting.cpp
+++ b/layout/base/PositionedEventTargeting.cpp
@@ -202,16 +202,17 @@ ComputeDistanceFromRect(const nsPoint& a
   nscoord dx = std::max(0, std::max(aRect.x - aPoint.x, aPoint.x - aRect.XMost()));
   nscoord dy = std::max(0, std::max(aRect.y - aPoint.y, aPoint.y - aRect.YMost()));
   return float(NS_hypot(dx, dy));
 }
 
 static float
 ComputeDistanceFromRegion(const nsPoint& aPoint, const nsRegion& aRegion)
 {
+  MOZ_ASSERT(!aRegion.IsEmpty(), "can't compute distance between point and empty region");
   nsRegionRectIterator iter(aRegion);
   const nsRect* r;
   float minDist = -1;
   while ((r = iter.Next()) != nullptr) {
     float dist = ComputeDistanceFromRect(aPoint, *r);
     if (dist < minDist || minDist < 0) {
       minDist = dist;
     }
@@ -249,16 +250,21 @@ GetClosest(nsIFrame* aRoot, const nsPoin
   for (uint32_t i = 0; i < aCandidates.Length(); ++i) {
     nsIFrame* f = aCandidates[i];
 
     bool preservesAxisAlignedRectangles = false;
     nsRect borderBox = nsLayoutUtils::TransformFrameRectToAncestor(f,
         nsRect(nsPoint(0, 0), f->GetSize()), aRoot, &preservesAxisAlignedRectangles);
     nsRegion region;
     region.And(exposedRegion, borderBox);
+
+    if (region.IsEmpty()) {
+      continue;
+    }
+
     if (preservesAxisAlignedRectangles) {
       // Subtract from the exposed region if we have a transform that won't make
       // the bounds include a bunch of area that we don't actually cover.
       SubtractFromExposedRegion(&exposedRegion, region);
     }
 
     if (!IsElementClickable(f)) {
       continue;