overflow:scroll elements should support rubber-banding
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Aug 2014 20:08:57 +0000 (20:08 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Aug 2014 20:08:57 +0000 (20:08 +0000)
commit1ecd49c3f72ec9be01b8d0b3934056ae1ea5c530
treecd6051f7de481662dc9c3bff842841f7296323cb
parentb57ed3b007c6ce136db345b7e3a8bd74b1ef2bfc
overflow:scroll elements should support rubber-banding
https://bugs.webkit.org/show_bug.cgi?id=91655

Reviewed by Sam Weinig and Darin Adler.

Source/WebCore:

This patch enables rubber-banding in overflow regions and it keeps latching
working as currently implemented.

We cannot return early here if there is no scroll delta. There won't be a scroll
delta in most cases during event.phase() == PlatformWheelEventPhaseEnded, but that
phase is required to be processed in order for rubber-banding to work properly.
* dom/Element.cpp:
(WebCore::Element::dispatchWheelEvent):
* page/EventHandler.cpp:
(WebCore::handleWheelEventInAppropriateEnclosingBoxForSingleAxis):

Add a setting for this, which will default to true. This allows us to disable the
feature in WebKit1 for now. There is a bug about making it work.
* page/Settings.in:

allowsHorizontalStretching() and allowsVerticalStretching() now take the
PlatformWheelEvent as a parameter, so that ScrollElasticityAutomatic can use the
event to decide whether or not stretching should be allowed in this case.
ScrollElasticityAutomatic will not allow stretching if it is a brand new gesture
that would result in a rubber-band. We don't want to rubber-band in that case
because we want the event to propagate up to a parent view. Also added some helper
functions just to make that code easier to read.
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
(WebCore::newGestureIsStarting):
(WebCore::ScrollingTreeFrameScrollingNodeMac::isAlreadyPinnedInDirectionOfGesture):
(WebCore::ScrollingTreeFrameScrollingNodeMac::allowsHorizontalStretching):
(WebCore::ScrollingTreeFrameScrollingNodeMac::allowsVerticalStretching):
* platform/mac/ScrollAnimatorMac.h:
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::handleWheelEvent):
(WebCore::newGestureIsStarting):
(WebCore::ScrollAnimatorMac::isAlreadyPinnedInDirectionOfGesture):
(WebCore::ScrollAnimatorMac::allowsVerticalStretching):
(WebCore::ScrollAnimatorMac::allowsHorizontalStretching):
* platform/mac/ScrollElasticityController.h:
* platform/mac/ScrollElasticityController.mm:
(WebCore::ScrollElasticityController::handleWheelEvent):

To opt into rubber-banding, all we have to do is implement overhangAmount and set
scroll elasticity. We'll choose ScrollElasticityAutomatic which means that we'll
only rubber-band in directions that can scroll and that we won't rubber-band for
new gestures when we're already pinned to the edge.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::overhangAmount):
(WebCore::RenderLayer::setHasHorizontalScrollbar):
(WebCore::RenderLayer::setHasVerticalScrollbar):

Source/WebKit/mac:

Disable rubber-banding in overflow areas for now.
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

LayoutTests:

Re-baseline. Mostly these tests are different now that end end event is handled.
* platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-div-latched-div-expected.txt:
* platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-div-latched-div-with-handler-expected.txt:
* platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-div-latched-mainframe-with-handler-expected.txt:
* platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-iframe-latched-iframe-with-handler-expected.txt:
* platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-iframe-latched-mainframe-with-handler-expected.txt:
* platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-select-latched-mainframe-with-handler-expected.txt:
* platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-select-latched-select-with-handler-expected.txt:

This test requires a longer timeout to ensure that the rubber-band has ended.
* platform/mac/fast/scrolling/scroll-latched-nested-div.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172832 268f45cc-cd09-0410-ab3c-d52691b4dbfc
22 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-div-latched-div-expected.txt
LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-div-latched-div-with-handler-expected.txt
LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-div-latched-mainframe-with-handler-expected.txt
LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-iframe-latched-iframe-with-handler-expected.txt
LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-iframe-latched-mainframe-with-handler-expected.txt
LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-select-latched-mainframe-with-handler-expected.txt
LayoutTests/platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-select-latched-select-with-handler-expected.txt
LayoutTests/platform/mac/fast/scrolling/scroll-latched-nested-div.html
Source/WebCore/ChangeLog
Source/WebCore/dom/Element.cpp
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/Settings.in
Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h
Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm
Source/WebCore/platform/mac/ScrollAnimatorMac.h
Source/WebCore/platform/mac/ScrollAnimatorMac.mm
Source/WebCore/platform/mac/ScrollElasticityController.h
Source/WebCore/platform/mac/ScrollElasticityController.mm
Source/WebCore/rendering/RenderLayer.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebView.mm