Bug 1549812 - ScrollFrameRectIntoView should handle the frame going away. r=mats
☠☠ backed out by c81a6ac1b894 ☠ ☠
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 14 May 2019 16:03:18 +0000
changeset 474339 ac4a070f110542b267763a0544a6e13912170d8c
parent 474328 c94c54aff4669f52cebc76ddad34a76f4fafd03b
child 474340 cbc5c04bd3e4fb6cbfa04dc02f3f1e3cfd6c05a1
push id113149
push userrgurzau@mozilla.com
push dateFri, 17 May 2019 21:50:06 +0000
treeherdermozilla-inbound@6e4c58629a7c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs1549812
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 1549812 - ScrollFrameRectIntoView should handle the frame going away. r=mats ScrollToShowRect already considers that possibility, so not doing it on the caller is a bug. Ideally scroll observers shouldn't be able to run script, more to that in a second. Differential Revision: https://phabricator.services.mozilla.com/D31088
layout/base/PresShell.cpp
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -3578,18 +3578,24 @@ bool PresShell::ScrollFrameRectIntoView(
 
       targetRect -= sf->GetScrolledFrame()->GetPosition();
       if (!(aScrollFlags & ScrollFlags::IgnoreMarginAndPadding)) {
         nsMargin scrollPadding = sf->GetScrollPadding();
         targetRect.Inflate(scrollPadding);
         targetRect = targetRect.Intersect(sf->GetScrolledRect());
       }
 
-      ScrollToShowRect(this, sf, targetRect, aVertical, aHorizontal,
-                       aScrollFlags);
+      {
+        AutoWeakFrame wf(container);
+        ScrollToShowRect(this, sf, targetRect, aVertical, aHorizontal,
+                         aScrollFlags);
+        if (!wf.IsAlive()) {
+          return didScroll;
+        }
+      }
 
       nsPoint newPosition = sf->LastScrollDestination();
       // If the scroll position increased, that means our content moved up,
       // so our rect's offset should decrease
       rect += oldPosition - newPosition;
 
       if (oldPosition != newPosition) {
         didScroll = true;