Bug 1544060 - Use the root element's primary frame to get scroll-padding value. r=botond
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 15 Apr 2019 21:15:58 +0000
changeset 469571 9bf188c86f9c
parent 469570 1936dde5f34c
child 469572 a7c8897aea6f
push id35874
push userccoroiu@mozilla.com
push dateTue, 16 Apr 2019 04:04:58 +0000
treeherdermozilla-central@be3f40425b52 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1544060
milestone68.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 1544060 - Use the root element's primary frame to get scroll-padding value. r=botond Now the spec cleary says that we don't need to propagate body's scroll-padding value to the document viewport since https://github.com/w3c/csswg-drafts/issues/3740, so we don't need to care about GetViewportScrollStylesOverrideElement() at all. This change fixes the crash test case in this commit, but it's not sufficient. In the next patch, we will fix another crash case. Differential Revision: https://phabricator.services.mozilla.com/D27422
layout/generic/crashtests/1544060-1.html
layout/generic/crashtests/crashtests.list
layout/generic/nsGfxScrollFrame.cpp
layout/reftests/css-scroll-snap/scroll-padding-on-anchor.html
new file mode 100644
--- /dev/null
+++ b/layout/generic/crashtests/1544060-1.html
@@ -0,0 +1,3 @@
+<html>
+<body hidden style="scroll-snap-type:both proximity!important">
+</html>
--- a/layout/generic/crashtests/crashtests.list
+++ b/layout/generic/crashtests/crashtests.list
@@ -723,8 +723,9 @@ pref(layout.css.column-span.enabled,true
 pref(layout.css.column-span.enabled,true) load 1506306.html
 pref(layout.css.column-span.enabled,true) load 1507196.html
 load 1515124.html
 pref(layout.css.column-span.enabled,true) load 1517033.html
 pref(layout.css.column-span.enabled,true) load 1517297.html
 load 1520798-1.xul
 load 1520798-2.html
 load 1539656.html
+load 1544060-1.html
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -6771,21 +6771,22 @@ static nsMargin ResolveScrollPaddingStyl
                                                  eSideRight, aScrollPortSize),
                   ResolveScrollPaddingStyleValue(aScrollPaddingStyle,
                                                  eSideBottom, aScrollPortSize),
                   ResolveScrollPaddingStyleValue(aScrollPaddingStyle, eSideLeft,
                                                  aScrollPortSize));
 }
 
 nsMargin ScrollFrameHelper::GetScrollPadding() const {
-  nsIFrame* styleFrame;
+  nsIFrame* styleFrame = nullptr;
   if (mIsRoot) {
-    const Element* scrollElement =
-        mOuter->PresContext()->GetViewportScrollStylesOverrideElement();
-    styleFrame = scrollElement ? scrollElement->GetPrimaryFrame() : mOuter;
+    if (const Element* rootElement =
+            mOuter->PresContext()->Document()->GetRootElement()) {
+      styleFrame = rootElement->GetPrimaryFrame();
+    }
   } else {
     styleFrame = mOuter;
   }
   MOZ_ASSERT(styleFrame);
 
   // The spec says percentage values are relative to the scroll port size.
   // https://drafts.csswg.org/css-scroll-snap-1/#scroll-padding
   return ResolveScrollPaddingStyle(styleFrame->StylePadding()->mScrollPadding,
--- a/layout/reftests/css-scroll-snap/scroll-padding-on-anchor.html
+++ b/layout/reftests/css-scroll-snap/scroll-padding-on-anchor.html
@@ -1,17 +1,19 @@
 <!--
  This reftest is a test case that scroll-padding value is propery handled when
  navigating an anchor node, id="target" in this case, so the content scrolls
  to the target element on loading.
 -->
 <style>
-html,body {
+html {
   overflow: hidden;
   scroll-padding: 100px;
+}
+body {
   margin: 0px;
   padding: 0px;
 }
 .spacer {
   height: 2000px;
   width: 100%;
   padding: 0px;
   margin: 0px;