Bug 146693 - Rubber banding is broken when using a Mighty Mouse
Summary: Rubber banding is broken when using a Mighty Mouse
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-07-07 13:59 PDT by Wenson Hsieh
Modified: 2015-07-09 16:03 PDT (History)
11 users (show)

See Also:


Attachments
Patch (5.86 KB, patch)
2015-07-07 15:08 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Patch (5.86 KB, patch)
2015-07-07 15:14 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Patch (9.15 KB, patch)
2015-07-09 11:32 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Patch (5.58 KB, patch)
2015-07-09 13:18 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews100 for mac-mavericks (769.76 KB, application/zip)
2015-07-09 13:53 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews104 for mac-mavericks-wk2 (895.04 KB, application/zip)
2015-07-09 13:54 PDT, Build Bot
no flags Details
Patch (6.30 KB, patch)
2015-07-09 14:18 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wenson Hsieh 2015-07-07 13:59:37 PDT
Scrolling against the edge of a container with a mighty mouse causes the offset to move out of the container.
Comment 1 Wenson Hsieh 2015-07-07 14:01:50 PDT
<rdar://problem/20824782>
Comment 2 Wenson Hsieh 2015-07-07 15:08:50 PDT
Created attachment 256323 [details]
Patch
Comment 3 Wenson Hsieh 2015-07-07 15:14:59 PDT
Created attachment 256325 [details]
Patch
Comment 4 Brent Fulgham 2015-07-08 10:16:55 PDT
Comment on attachment 256325 [details]
Patch

This looks good to me, but I think Beth should double-check in case I'm missing something.
Comment 5 Beth Dakin 2015-07-08 10:42:44 PDT
Comment on attachment 256325 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=256325&action=review

> Source/WebCore/ChangeLog:1
> +2015-07-07  Wenson Hsieh  <whsieh@berkeley.edu>

You should be using your apple email address here.

> Source/WebCore/platform/mac/ScrollAnimatorMac.mm:1110
> +static bool isStatelessWheelEvent(const PlatformWheelEvent& wheelEvent)

I'm concerned about this phrase "stateless." This does not seem like a good/descriptive-enough name for this to me.

> Source/WebCore/platform/mac/ScrollAnimatorMac.mm:1112
> +    return wheelEvent.phase() == PlatformWheelEventPhaseNone && wheelEvent.momentumPhase() == PlatformWheelEventPhaseNone;

Why is it okay to definitely return early here? Are you certain there is nothing more to do? Has the event already had a chance to be propagated to the DOM? Do we ever get events with this phase configuration for a non-Mighty-mouse? 

This bug, I believe, it unique to overflow scrolling. In other words, it does not happen to the main document. How do we get it right for the main document?
Comment 6 Wenson Hsieh 2015-07-08 22:44:50 PDT
Ok -- I've traced the bug to what I believe is the source. Both mainframe and overflow scrolling go through ScrollController::handleWheelEvent. This, in turn, invokes the scroll client (m_client)'s immediateScrollBy method. This is where things start to diverge.

Mainframe scrolling uses ScrollingTreeFrameScrollingNodeMac::immediateScrollBy, which calls a few methods which end up clamping the destination scroll offset to a min and max. When scrolling against the edge of the mainframe a Mighty Mouse, this clamping operation doesn't cause us to go over the edge of the container, so mainframe Mighty Mouse scrolling behaves as expected.

For overflow scrolling, ScrollAnimatorMac::immediateScrollBy does something similar: before performing the scroll, it consults adjustScrollPositionIfNecessary for the scroll offsets it should land on. However, this *only* clamps the scroll offsets to the min/max if !m_scrollableArea.constrainsScrollingToContentEdge(). This is not the case initially, as the constructor for RenderLayer does not constrain scrolling to the content edge by default! I was able to "fix" this issue by turning this edge constraint on by default, but it's not clear whether this will have unintended consequences for other scrolling behaviors.

It was also reported in the original bug that scrolling was no longer broken once you scrolled within the container for a bit (i.e. if you scrolled down away from the edge and then scrolled back up against the edge, the problem would not occur). I found out that this is due to the current implementation of ScrollAnimatorMac::immediateScrollByWithoutContentEdgeConstraints for overflow scrolling, which calls m_scrollableArea.setConstrainsScrollingToContentEdge(true) regardless of whether or not the ScrollableArea previously constrained scrolling to content edges. I'm not sure whether this is intended behavior.

TL;DR The bug seems to be caused by the value of constrainsScrollingToContentEdge() in ScrollAnimatorMac::adjustScrollPositionIfNecessary.
Comment 7 Wenson Hsieh 2015-07-09 11:32:31 PDT
Created attachment 256494 [details]
Patch
Comment 8 Wenson Hsieh 2015-07-09 13:18:24 PDT
Created attachment 256503 [details]
Patch
Comment 9 Beth Dakin 2015-07-09 13:19:21 PDT
Comment on attachment 256503 [details]
Patch

Looks good!
Comment 10 Build Bot 2015-07-09 13:52:59 PDT
Comment on attachment 256503 [details]
Patch

Attachment 256503 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/5744092755525632

New failing tests:
fast/html/marquee-scroll.html
fast/block/float/marquee-shrink-to-avoid-floats.html
fast/html/marquee-scrollamount.html
fast/inline-block/003.html
Comment 11 Build Bot 2015-07-09 13:53:02 PDT
Created attachment 256510 [details]
Archive of layout-test-results from ews100 for mac-mavericks

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews100  Port: mac-mavericks  Platform: Mac OS X 10.9.5
Comment 12 Build Bot 2015-07-09 13:54:16 PDT
Comment on attachment 256503 [details]
Patch

Attachment 256503 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/5514735059468288

New failing tests:
fast/html/marquee-scroll.html
fast/block/float/marquee-shrink-to-avoid-floats.html
fast/html/marquee-scrollamount.html
fast/inline-block/003.html
Comment 13 Build Bot 2015-07-09 13:54:19 PDT
Created attachment 256511 [details]
Archive of layout-test-results from ews104 for mac-mavericks-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews104  Port: mac-mavericks-wk2  Platform: Mac OS X 10.9.5
Comment 14 Wenson Hsieh 2015-07-09 14:18:23 PDT
Created attachment 256519 [details]
Patch
Comment 15 WebKit Commit Bot 2015-07-09 16:03:47 PDT
Comment on attachment 256519 [details]
Patch

Clearing flags on attachment: 256519

Committed r186644: <http://trac.webkit.org/changeset/186644>
Comment 16 WebKit Commit Bot 2015-07-09 16:03:53 PDT
All reviewed patches have been landed.  Closing bug.