Bug 1038294 part 9 - Move scroll box suppression inside the switch. r=emilio
authorMats Palmgren <mats@mozilla.com>
Wed, 14 Aug 2019 14:33:46 +0000
changeset 487937 127c7dfc011a16a64076b300ccb151634cec704f
parent 487936 6bb15997aba70ca39a931eb9dc83cfd7d84ed683
child 487938 62b047361030e2f2e963f1e5621daea812720bff
push id36433
push userbtara@mozilla.com
push dateWed, 14 Aug 2019 21:57:52 +0000
treeherdermozilla-central@7d9a2196d313 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1038294
milestone70.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 1038294 part 9 - Move scroll box suppression inside the switch. r=emilio Differential Revision: https://phabricator.services.mozilla.com/D39761
layout/base/nsCSSFrameConstructor.cpp
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -4359,39 +4359,19 @@ nsCSSFrameConstructor::FindDisplayData(c
   // and that might need to be propagated.
   // XXXbz is this the right place to do this?  If this code moves,
   // make this function static.
   bool propagatedScrollToViewport = false;
   if (aElement.IsHTMLElement(nsGkAtoms::body)) {
     if (nsPresContext* presContext = mPresShell->GetPresContext()) {
       propagatedScrollToViewport =
           presContext->UpdateViewportScrollStylesOverride() == &aElement;
-    }
-  }
-
-  NS_ASSERTION(!propagatedScrollToViewport ||
-                   !mPresShell->GetPresContext()->IsPaginated(),
-               "Shouldn't propagate scroll in paginated contexts");
-
-  // If this is for a <body> node and we've propagated the scroll-frame to the
-  // viewport, we need to make sure not to add another layer of scrollbars, so
-  // we use a different FCData struct without FCDATA_MAY_NEED_SCROLLFRAME.
-  if (propagatedScrollToViewport && aDisplay.IsScrollableOverflow()) {
-    if (aDisplay.mDisplay == StyleDisplay::Flex ||
-        aDisplay.mDisplay == StyleDisplay::WebkitBox ||
-        (StaticPrefs::layout_css_emulate_moz_box_with_flex() &&
-         aDisplay.mDisplay == StyleDisplay::MozBox)) {
-      static const FrameConstructionData sNonScrollableFlexData =
-          FCDATA_DECL(0, NS_NewFlexContainerFrame);
-      return &sNonScrollableFlexData;
-    }
-    if (aDisplay.mDisplay == StyleDisplay::Grid) {
-      static const FrameConstructionData sNonScrollableGridData =
-          FCDATA_DECL(0, NS_NewGridContainerFrame);
-      return &sNonScrollableGridData;
+      MOZ_ASSERT(!propagatedScrollToViewport ||
+                     !mPresShell->GetPresContext()->IsPaginated(),
+                 "Shouldn't propagate scroll in paginated contexts");
     }
   }
 
   switch (aDisplay.mDisplay) {
 #ifdef DEBUG
     case StyleDisplay::None:
     case StyleDisplay::Contents:
       MOZ_ASSERT_UNREACHABLE("should have been handled earlier");
@@ -4537,25 +4517,29 @@ nsCSSFrameConstructor::FindDisplayData(c
         return &data;
       }
       MOZ_FALLTHROUGH;
     }
     case StyleDisplay::Flex:
     case StyleDisplay::InlineFlex:
     case StyleDisplay::WebkitBox:
     case StyleDisplay::WebkitInlineBox: {
+      static const FrameConstructionData nonScrollableData =
+        FCDATA_DECL(0, NS_NewFlexContainerFrame);
       static const FrameConstructionData data =
         FCDATA_DECL(FCDATA_MAY_NEED_SCROLLFRAME, NS_NewFlexContainerFrame);
-      return &data;
+      return MOZ_UNLIKELY(propagatedScrollToViewport) ? &nonScrollableData : &data;
     }
     case StyleDisplay::Grid:
     case StyleDisplay::InlineGrid: {
+      static const FrameConstructionData nonScrollableData =
+        FCDATA_DECL(0, NS_NewGridContainerFrame);
       static const FrameConstructionData data =
         FCDATA_DECL(FCDATA_MAY_NEED_SCROLLFRAME, NS_NewGridContainerFrame);
-      return &data;
+      return MOZ_UNLIKELY(propagatedScrollToViewport) ? &nonScrollableData : &data;
     }
     case StyleDisplay::Ruby: {
       static const FrameConstructionData data =
         FCDATA_DECL(FCDATA_IS_LINE_PARTICIPANT, NS_NewRubyFrame);
       return &data;
     }
     case StyleDisplay::RubyBase: {
       static const FrameConstructionData data =