Bug 1416067 - Avoid doing a bunch of useless event-regions work for frames with empty border boxes. r?mstange draft
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 09 Nov 2017 19:40:44 -0500
changeset 696023 6781c119176c9b6cdd7283a7a799304c32e4dd6a
parent 695799 41a66272bd113526fa1e533268ebd5bbf39f7532
child 739767 fb3119dd7b7f0e79ccc142bf86589b78b21d3474
push id88615
push userkgupta@mozilla.com
push dateFri, 10 Nov 2017 04:10:48 +0000
reviewersmstange
bugs1416067
milestone58.0a1
Bug 1416067 - Avoid doing a bunch of useless event-regions work for frames with empty border boxes. r?mstange MozReview-Commit-ID: 8gsIJojhQ6t
layout/painting/nsDisplayList.cpp
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -4834,21 +4834,16 @@ nsDisplayLayerEventRegions::AddFrame(nsD
   }
   bool simpleRegions = aFrame->HasAnyStateBits(NS_FRAME_SIMPLE_EVENT_REGIONS);
   if (!simpleRegions) {
     if (!aFrame->StyleVisibility()->IsVisible()) {
       return;
     }
   }
 
-  if (aFrame != mFrame &&
-      aBuilder->IsRetainingDisplayList()) {
-    aFrame->AddDisplayItem(this);
-  }
-
 
   // XXX handle other pointerEvents values for SVG
 
   // XXX Do something clever here for the common case where the border box
   // is obviously entirely inside mHitRegion.
   nsRect borderBox;
 
   nsIScrollableFrame* scrollFrame = nsLayoutUtils::GetScrollableFrameFor(aFrame);
@@ -4857,16 +4852,25 @@ nsDisplayLayerEventRegions::AddFrame(nsD
     // area corresponding to the overflow rect as well. Otherwise the parts of
     // the overflow that are not occupied by descendants get skipped and the
     // APZ code sends touch events to the content underneath instead.
     // See https://bugzilla.mozilla.org/show_bug.cgi?id=1127773#c15.
     borderBox = aFrame->GetScrollableOverflowRect();
   } else {
     borderBox = nsRect(nsPoint(0, 0), aFrame->GetSize());
   }
+  if (borderBox.IsEmpty()) {
+    return;
+  }
+
+  if (aFrame != mFrame &&
+      aBuilder->IsRetainingDisplayList()) {
+    aFrame->AddDisplayItem(this);
+  }
+
   borderBox += aBuilder->ToReferenceFrame(aFrame);
 
   bool borderBoxHasRoundedCorners = false;
   if (!simpleRegions) {
     if (nsLayoutUtils::HasNonZeroCorner(aFrame->StyleBorder()->mBorderRadius)) {
       borderBoxHasRoundedCorners = true;
     } else {
       aFrame->AddStateBits(NS_FRAME_SIMPLE_EVENT_REGIONS);