Bug 1230466. Make sure to update our scrollbar styles when a <body> is removed from the DOM, since we might now need to propagate from some other element. r=roc
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 08 Dec 2015 14:55:50 -0500
changeset 310060 f4eaab30e7e73b74ca3e5a82fbecf157b6084ac8
parent 310059 9474cf8b8d18de259445d3860576837f0522e224
child 310061 6196e9f9d1392798458a1dc060afa5b2be49b002
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1230466
milestone45.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 1230466. Make sure to update our scrollbar styles when a <body> is removed from the DOM, since we might now need to propagate from some other element. r=roc
layout/base/nsCSSFrameConstructor.cpp
layout/base/nsPresContext.cpp
layout/reftests/bugs/1230466.html
layout/reftests/bugs/reftest.list
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -7890,16 +7890,23 @@ nsCSSFrameConstructor::ContentRemoved(ns
   NS_PRECONDITION(mUpdateCount != 0,
                   "Should be in an update while destroying frames");
 
   *aDidReconstruct = false;
   if (aDestroyedFramesFor) {
     *aDestroyedFramesFor = aChild;
   }
 
+  if (aChild->IsHTMLElement(nsGkAtoms::body) ||
+      (!aContainer && aChild->IsElement())) {
+    // This might be the element we propagated viewport scrollbar
+    // styles from.  Recompute those.
+    mPresShell->GetPresContext()->UpdateViewportScrollbarStylesOverride();
+  }
+
   // XXXldb Do we need to re-resolve style to handle the CSS2 + combinator and
   // the :empty pseudo-class?
 
 #ifdef DEBUG
   if (gNoisyContentUpdates) {
     printf("nsCSSFrameConstructor::ContentRemoved container=%p child=%p "
            "old-next-sibling=%p\n",
            static_cast<void*>(aContainer),
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -1629,16 +1629,21 @@ GetPropagatedScrollbarStylesForViewport(
   // when printing or in print preview
   if (aPresContext->IsPaginated()) {
     return nullptr;
   }
 
   nsIDocument* document = aPresContext->Document();
   Element* docElement = document->GetRootElement();
 
+  // docElement might be null if we're doing this after removing it.
+  if (!docElement) {
+    return nullptr;
+  }
+
   // Check the style on the document root element
   nsStyleSet *styleSet = aPresContext->StyleSet();
   RefPtr<nsStyleContext> rootStyle;
   rootStyle = styleSet->ResolveStyleFor(docElement, nullptr);
   if (CheckOverflow(rootStyle->StyleDisplay(), aStyles)) {
     // tell caller we stole the overflow style from the root element
     return docElement;
   }
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/1230466.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<body>
+  <script>
+    var b = document.createElement("body");
+    b.style.overflow = "scroll";
+    var h = document.documentElement;
+    h.insertBefore(b, h.firstChild);
+    b.offsetWidth;
+    b.remove();
+  </script>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1938,8 +1938,9 @@ fuzzy(1,74) fuzzy-if(gtkWidget,6,79) == 
 != 1207326-1.html about:blank
 == 1209603-1.html 1209603-1-ref.html
 == 1209994-1.html 1209994-1-ref.html
 == 1209994-2.html 1209994-2-ref.html
 == 1209994-3.html 1209994-3-ref.html
 == 1209994-4.html 1209994-4-ref.html
 == 1222226-1.html 1222226-1-ref.html
 pref(layout.css.overflow-clip-box.enabled,true) == 1226278.html 1226278-ref.html
+== 1230466.html about:blank