Bug 1423017 - Add a telemetry for out-of-reach overflowing on root. r?mats draft
authorXidorn Quan <me@upsuper.org>
Tue, 29 May 2018 12:03:10 +1000
changeset 800757 a7e51ea461ee025ca55b57510eb1d4694c5eb409
parent 800742 fb7fc2e789c8428dbb0d516803a5578bf8aabb9e
push id111469
push userxquan@mozilla.com
push dateTue, 29 May 2018 03:40:20 +0000
reviewersmats
bugs1423017
milestone62.0a1
Bug 1423017 - Add a telemetry for out-of-reach overflowing on root. r?mats MozReview-Commit-ID: 80K9dS0gBed
dom/base/UseCounters.conf
layout/generic/nsGfxScrollFrame.cpp
--- a/dom/base/UseCounters.conf
+++ b/dom/base/UseCounters.conf
@@ -110,8 +110,11 @@ method console.groupCollapsed
 method console.groupEnd
 method console.time
 method console.timeLog
 method console.timeEnd
 method console.exception
 method console.timeStamp
 method console.profile
 method console.profileEnd
+
+// Layout
+custom HiddenViewportOverflow content overflows viewport but invisible
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -390,28 +390,30 @@ nsHTMLScrollFrame::TryLayout(ScrollReflo
     nsSize compositionSize = nsLayoutUtils::CalculateCompositionSizeForFrame(this, false);
     float resolution = presShell->GetResolution();
     compositionSize.width /= resolution;
     compositionSize.height /= resolution;
     visualScrollPortSize = nsSize(std::max(0, compositionSize.width - vScrollbarDesiredWidth),
                                   std::max(0, compositionSize.height - hScrollbarDesiredHeight));
   }
 
+  nsRect scrolledRect =
+    mHelper.GetUnsnappedScrolledRectInternal(aState->mContentsOverflowAreas.ScrollableOverflow(),
+                                             scrollPortSize);
+  nscoord oneDevPixel = aState->mBoxState.PresContext()->DevPixelsToAppUnits(1);
+
+  bool isHorizontalOverflowed =
+    scrolledRect.XMost() >= visualScrollPortSize.width + oneDevPixel ||
+    scrolledRect.x <= -oneDevPixel;
+
   if (!aForce) {
-    nsRect scrolledRect =
-      mHelper.GetUnsnappedScrolledRectInternal(aState->mContentsOverflowAreas.ScrollableOverflow(),
-                                               scrollPortSize);
-    nscoord oneDevPixel = aState->mBoxState.PresContext()->DevPixelsToAppUnits(1);
-
     // If the style is HIDDEN then we already know that aAssumeHScroll is false
     if (aState->mStyles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN) {
-      bool wantHScrollbar =
-        aState->mStyles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL ||
-        scrolledRect.XMost() >= visualScrollPortSize.width + oneDevPixel ||
-        scrolledRect.x <= -oneDevPixel;
+      bool wantHScrollbar = isHorizontalOverflowed ||
+        aState->mStyles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL;
       if (scrollPortSize.width < hScrollbarMinSize.width)
         wantHScrollbar = false;
       if (wantHScrollbar != aAssumeHScroll)
         return false;
     }
 
     // If the style is HIDDEN then we already know that aAssumeVScroll is false
     if (aState->mStyles.mVertical != NS_STYLE_OVERFLOW_HIDDEN) {
@@ -421,16 +423,26 @@ nsHTMLScrollFrame::TryLayout(ScrollReflo
         scrolledRect.y <= -oneDevPixel;
       if (scrollPortSize.height < vScrollbarMinSize.height)
         wantVScrollbar = false;
       if (wantVScrollbar != aAssumeVScroll)
         return false;
     }
   }
 
+  if (mHelper.mIsRoot && isHorizontalOverflowed &&
+      aState->mStyles.mHorizontal == NS_STYLE_OVERFLOW_HIDDEN) {
+    nsIDocument* doc = PresContext()->Document();
+    if (doc->IsTopLevelContentDocument()) {
+      // We don't need to set page use counter since we only count top
+      // level content documents.
+      doc->SetDocumentUseCounter(eUseCounter_custom_HiddenViewportOverflow);
+    }
+  }
+
   nscoord vScrollbarActualWidth = aState->mInsideBorderSize.width - scrollPortSize.width;
 
   aState->mShowHScrollbar = aAssumeHScroll;
   aState->mShowVScrollbar = aAssumeVScroll;
   nsPoint scrollPortOrigin(aState->mComputedBorder.left,
                            aState->mComputedBorder.top);
   if (!IsScrollbarOnRight()) {
     scrollPortOrigin.x += vScrollbarActualWidth;