Bug 145642 - Latching algorithm in findEnclosingOverflowScroll is broken
Summary: Latching algorithm in findEnclosingOverflowScroll is broken
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Brent Fulgham
URL:
Keywords: InRadar
Depends on: 145655
Blocks: 145649
  Show dependency treegraph
 
Reported: 2015-06-04 09:35 PDT by Brent Fulgham
Modified: 2015-06-04 18:36 PDT (History)
8 users (show)

See Also:


Attachments
Patch (5.37 KB, patch)
2015-06-04 11:23 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (4.62 KB, patch)
2015-06-04 11:36 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (5.75 KB, patch)
2015-06-04 17:59 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (5.83 KB, patch)
2015-06-04 18:21 PDT, Brent Fulgham
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Fulgham 2015-06-04 09:35:44 PDT
I discovered this problem while debugging Bug 145637.

The logic in findEnclosingOverflowScroll uses the RenderBox "canBeScrolledAndHasScrollableArea" to identify the nearest enclosing element that can be scrolled. However, this method considers horizontal and vertical scrolling as equally relevant. This is a problem when we want to perform a vertical scroll, but the element underneath the mouse pointer can only be scrolled in a horizontal direction.

When we have this scenario, the latching logic chooses the horizontally scrollable region and attempts to latch to it. When it discovers that it cannot be scrolled in the user's gesture direction, it gives up and passes control to the next enclosing latching context. When we are working on a single page, this means the document body, and things generally work as the user expects. But when we have nested iframes, this causes us to pop up to the enclosing iframe, which looks wrong to the user.

The test case I added in Bug 145637 highlights this problem if you modify the <img> style to remove the "max-width:100%" in 'inner_content.html'.

I think the right fix here is to modify 'findEnclosingOverflowScroll' so that it takes the gesture's dominant direction into account.
Comment 1 Radar WebKit Bug Importer 2015-06-04 09:36:10 PDT
<rdar://problem/21242308>
Comment 2 Brent Fulgham 2015-06-04 11:23:07 PDT
Created attachment 254281 [details]
Patch
Comment 3 Simon Fraser (smfr) 2015-06-04 11:30:11 PDT
Comment on attachment 254281 [details]
Patch

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

> Source/WebCore/page/mac/EventHandlerMac.mm:795
> +            if ((verticalScroll && box->hasScrollableOverflowY()) || (!verticalScroll && box->hasScrollableOverflowX()))
> +                return candidate;

I'm not sure I like the idea of adding "predominantly vertical" logic here. The event could have non-zero X delta, and box->hasScrollableOverflowX() could be true, but we would not return that box as a candidate.
Comment 4 Brent Fulgham 2015-06-04 11:31:43 PDT
(In reply to comment #3)
> Comment on attachment 254281 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=254281&action=review
> 
> > Source/WebCore/page/mac/EventHandlerMac.mm:795
> > +            if ((verticalScroll && box->hasScrollableOverflowY()) || (!verticalScroll && box->hasScrollableOverflowX()))
> > +                return candidate;
> 
> I'm not sure I like the idea of adding "predominantly vertical" logic here.
> The event could have non-zero X delta, and box->hasScrollableOverflowX()
> could be true, but we would not return that box as a candidate.

Ah! Good point.

Maybe something like "deltaX && box->hasScrollableOverflowX() || deltaY && box->hasScrollableOverflowY()"
Comment 5 Brent Fulgham 2015-06-04 11:36:35 PDT
Created attachment 254282 [details]
Patch
Comment 6 Brent Fulgham 2015-06-04 11:56:07 PDT
Committed r185208: <http://trac.webkit.org/changeset/185208>
Comment 7 Alexey Proskuryakov 2015-06-04 14:02:32 PDT
This broke platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-iframe-latched-select.html
Comment 8 Said Abou-Hallawa 2015-06-04 14:08:22 PDT
@@ -8,7 +8,7 @@
 
 TEST COMPLETE
 PASS Page did not receive wheel events.
-PASS IFrame did not receive wheel events.
+FAIL IFrame consumed wheel events.
 PASS Select consumed wheel events.
 PASS successfullyParsed is true

Rolling out.
Comment 9 WebKit Commit Bot 2015-06-04 14:09:02 PDT
Re-opened since this is blocked by bug 145655
Comment 10 Alexey Proskuryakov 2015-06-04 16:15:50 PDT
Rolling out r185211 too (which just added tests that now fail).
Comment 11 Brent Fulgham 2015-06-04 17:54:35 PDT
(In reply to comment #7)
> This broke
> platform/mac-wk2/tiled-drawing/scrolling/fast-scroll-iframe-latched-select.
> html

Ah! Indeed it does. The <select> case doesn't work the same way because it doesn't treat its scrollable area as overflow. So the "scrollsOverflowY()" returns false for <select>, even though it does satisfy "canBeScrolledAndHasScrollableArea".
Comment 12 Brent Fulgham 2015-06-04 17:59:43 PDT
Created attachment 254323 [details]
Patch
Comment 13 Brent Fulgham 2015-06-04 18:21:42 PDT
Created attachment 254325 [details]
Patch
Comment 14 Simon Fraser (smfr) 2015-06-04 18:25:20 PDT
Comment on attachment 254325 [details]
Patch

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

> Source/WebCore/page/mac/EventHandlerMac.mm:782
> +static ContainerNode* findEnclosingOverflowScrollForDominantDirection(ContainerNode* node, float deltaX, float deltaY)

This isn't really "dominant direction" any more.
Comment 15 Brent Fulgham 2015-06-04 18:36:04 PDT
Committed r185234: <http://trac.webkit.org/changeset/185234>