Bug 1492582 - Don't create scroll frames for windows that don't need them. r=emilio
authorBrendan Dahl <bdahl@mozilla.com>
Fri, 08 Nov 2019 23:34:08 +0000
changeset 501407 d9fa29c55c42606dd014abe3816667384d19288e
parent 501406 e4d31ac43ad03c703b4282693a4e537848375bd6
child 501408 c2b41600ce78924d6a8b0cfd649fd8a7867ee6d1
push id36791
push usercsabou@mozilla.com
push dateSun, 10 Nov 2019 09:53:30 +0000
treeherdermozilla-central@72c52c0101cf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1492582
milestone72.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 1492582 - Don't create scroll frames for windows that don't need them. r=emilio When browser.xhtml switches to an <html> root element, the frame structure changed and caused performance regressions on talos for tart and tresize. browser.xhtml doesn't need scrolling, so we can disable it and keep performance on par with XUL <window>. Differential Revision: https://phabricator.services.mozilla.com/D50675
browser/base/content/browser.xhtml
dom/xul/test/mochitest.ini
dom/xul/test/test_disable_scroll_frame_plain.html
layout/base/nsCSSFrameConstructor.cpp
--- a/browser/base/content/browser.xhtml
+++ b/browser/base/content/browser.xhtml
@@ -63,16 +63,17 @@
         tabsintitlebar="true"
         titlemenuseparator="&mainWindow.titlemodifiermenuseparator;"
         windowtype="navigator:browser"
         macanimationtype="document"
         screenX="4" screenY="4"
         fullscreenbutton="true"
         sizemode="normal"
         retargetdocumentfocus="urlbar-input"
+        scrolling="false"
         persist="screenX screenY width height sizemode"
         data-l10n-sync="true">
 <head>
   <link rel="localization" href="branding/brand.ftl"/>
   <link rel="localization" href="browser/branding/sync-brand.ftl"/>
   <link rel="localization" href="browser/browser.ftl"/>
   <link rel="localization" href="browser/menubar.ftl"/>
   <link rel="localization" href="browser/protectionsPanel.ftl"/>
--- a/dom/xul/test/mochitest.ini
+++ b/dom/xul/test/mochitest.ini
@@ -1,4 +1,6 @@
 [DEFAULT]
 
 [test_bug486990.xhtml]
 skip-if = toolkit == 'android' #TIMED_OUT
+
+[test_disable_scroll_frame_plain.html]
new file mode 100644
--- /dev/null
+++ b/dom/xul/test/test_disable_scroll_frame_plain.html
@@ -0,0 +1,19 @@
+<!DOCTYPE HTML>
+<html scrolling="false">
+<head>
+  <meta charset="utf-8">
+  <title>disable scroll frame exposed</title>
+  <script src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<p id="display"></p>
+<div id="content" style="display: none"></div>
+<pre id="test"></pre>
+<div style="height: 300vh"></div>
+<script>
+  // Ensure that disabling the scroll frame isn't exposed to content.
+  ok(document.scrollingElement.scrollTopMax > 0, "Scrolling should still work.");
+</script>
+</body>
+</html>
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -2548,19 +2548,29 @@ void nsCSSFrameConstructor::SetUpDocElem
 
   bool isHTML = aDocElement->IsHTMLElement();
   bool isXUL = false;
 
   if (!isHTML) {
     isXUL = aDocElement->IsXULElement();
   }
 
-  // Never create scrollbars for XUL documents
-  bool isScrollable =
-      isPaginated ? presContext->HasPaginatedScrolling() : !isXUL;
+  // Never create scrollbars for XUL documents or top level XHTML documents that
+  // disable scrolling.
+  bool isScrollable = true;
+  if (isPaginated) {
+    isScrollable = presContext->HasPaginatedScrolling();
+  } else if (isXUL) {
+    isScrollable = false;
+  } else if (nsContentUtils::IsInChromeDocshell(aDocElement->OwnerDoc()) &&
+             aDocElement->AsElement()->AttrValueIs(
+                 kNameSpaceID_None, nsGkAtoms::scrolling, nsGkAtoms::_false,
+                 eCaseMatters)) {
+    isScrollable = false;
+  }
 
   // We no longer need to do overflow propagation here. It's taken care of
   // when we construct frames for the element whose overflow might be
   // propagated
   NS_ASSERTION(!isScrollable || !isXUL,
                "XUL documents should never be scrollable - see above");
 
   nsContainerFrame* newFrame = rootFrame;