REGRESSION (r187593): Scroll position jumps when selecting text in an iframe
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Dec 2015 00:35:04 +0000 (00:35 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Dec 2015 00:35:04 +0000 (00:35 +0000)
commitd942bb4bbc87c778c47558778c698a95588718ae
tree7e0d1a3c5b37968e6bb3473074cea67b80433624
parent071ffe2199ac95fb119cd8a3041c69672bfebd8c
REGRESSION (r187593): Scroll position jumps when selecting text in an iframe
https://bugs.webkit.org/show_bug.cgi?id=152541
rdar://problem/23886181

Reviewed by Tim Horton.

Source/WebCore:

r154382 added code that modifies parentLayer traversal, looking for ancestor
scrollable layers. However, it confusingly added another code path in which
the ancestor layer traversal cross a frame boundary, when RenderLayer::scrollRectToVisible()
already has one. I fixed this new location to adjust the rect coordinates in r187593,
but then code that hit both crossing points double-mapped the coordinates, causing
autoscroll jumping.

Fix by reverting r154382 and r187593, going back to doing the ancestor walk in
one place. Re-fix r154382 by implementing RenderLayer::allowsCurrentScroll(),
which contains the logic for line clamp, autoscroll and ensuring that overflow:hidden
can be programmatically scrolled.

Form controls are special; they can have overflow:hidden but still be user-scrollable
during autoscroll; this is handled via the confusingly-named canBeProgramaticallyScrolled().
RenderTextControlSingleLine implements this to ensure that readonly text inputs
autoscroll (which is exercised by a test).

The frame-to-parent-frame rect mapping in RenderLayer::scrollRectToVisible() is
fixed to use the coordinate mapping functions from Widget/ScrollView, with the
addition of a new utility function contentsToContainingViewContents().

A "Scrolling" logging channel is added with a few log points.

Test: fast/events/autoscroll-in-iframe-body.html

* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::absoluteNonFastScrollableRegionForFrame):
use contentsToContainingViewContents().
* platform/Logging.h:
* platform/ScrollView.cpp:
(WebCore::ScrollView::contentsToContainingViewContents):
* platform/ScrollView.h:
* platform/graphics/IntPoint.cpp:
(WebCore::IntPoint::constrainedBetween): New helper to constrain a point between
two other points.
* platform/graphics/IntPoint.h:
(WebCore::IntPoint::expandedTo):
(WebCore::IntPoint::shrunkTo):
* rendering/RenderBox.cpp:
* rendering/RenderLayer.cpp:
(WebCore::parentLayerCrossFrame):
(WebCore::RenderLayer::enclosingScrollableLayer):
(WebCore::frameElementAndViewPermitScroll):
(WebCore::RenderLayer::allowsCurrentScroll):
(WebCore::RenderLayer::scrollRectToVisible):
* rendering/RenderLayer.h:
* rendering/RenderTextControlSingleLine.h:

LayoutTests:

New test for autoscrolling iframe contents (an existing test scrolled an overflow:scroll
inside an iframe, and didn't catch the bug).

* fast/events/autoscroll-in-iframe-body-expected.txt: Added.
* fast/events/autoscroll-in-iframe-body.html: Added.
* fast/forms/input-readonly-autoscroll.html: Fix a missing double quote.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194405 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/autoscroll-in-iframe-body-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/autoscroll-in-iframe-body.html [new file with mode: 0644]
LayoutTests/fast/forms/input-readonly-autoscroll.html
Source/WebCore/ChangeLog
Source/WebCore/page/scrolling/ScrollingCoordinator.cpp
Source/WebCore/platform/Logging.h
Source/WebCore/platform/ScrollView.cpp
Source/WebCore/platform/ScrollView.h
Source/WebCore/platform/graphics/IntPoint.cpp
Source/WebCore/platform/graphics/IntPoint.h
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h
Source/WebCore/rendering/RenderTextControlSingleLine.h