Bug 68959 - Extend DOM WheelEvent to differentiate between physical and logical scroll directions
Summary: Extend DOM WheelEvent to differentiate between physical and logical scroll di...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.7
: P2 Normal
Assignee: Jon Lee
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2011-09-27 16:43 PDT by Jon Lee
Modified: 2011-10-04 14:19 PDT (History)
4 users (show)

See Also:


Attachments
Patch (21.98 KB, patch)
2011-09-28 14:01 PDT, Jon Lee
no flags Details | Formatted Diff | Diff
Patch (21.99 KB, patch)
2011-09-28 14:17 PDT, Jon Lee
no flags Details | Formatted Diff | Diff
Patch (22.00 KB, patch)
2011-09-28 14:39 PDT, Jon Lee
no flags Details | Formatted Diff | Diff
Patch (22.22 KB, patch)
2011-09-28 16:02 PDT, Jon Lee
no flags Details | Formatted Diff | Diff
Patch (28.13 KB, patch)
2011-10-03 12:54 PDT, Jon Lee
sam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jon Lee 2011-09-27 16:43:57 PDT
With Lion, users may choose to reverse the scrolling direction. Exposing a boolean indicating whether the user is scrolling naturally would help web authors determine a scroll event's direction.

<rdar://problem/10036688>
Comment 1 Jon Lee 2011-09-28 14:01:22 PDT
Created attachment 109072 [details]
Patch
Comment 2 Mark Rowe (bdash) 2011-09-28 14:11:08 PDT
Comment on attachment 109072 [details]
Patch

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

> Source/WebKit2/Shared/mac/WebEventFactory.mm:1103
> +#if BUILDING_ON_LION
> +    bool directionInvertedFromDevice        = [event isDirectionInvertedFromDevice];
> +#else
> +    bool directionInvertedFromDevice        = false;
> +#endif

This is not correct.
Comment 3 Jon Lee 2011-09-28 14:17:03 PDT
Created attachment 109078 [details]
Patch
Comment 4 Jon Lee 2011-09-28 14:17:51 PDT
Fixed the #if OS check.
Comment 5 Jon Lee 2011-09-28 14:29:20 PDT
The #if should be #if !defined(...)-- sending another patch.
Comment 6 Jon Lee 2011-09-28 14:39:52 PDT
Created attachment 109079 [details]
Patch
Comment 7 Sam Weinig 2011-09-28 15:20:40 PDT
Comment on attachment 109079 [details]
Patch

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

I think we probably want to prefix the IDL attribute with webkit as well.

> Source/WebCore/platform/mac/WheelEventMac.mm:104
> +    , m_directionInvertedFromDevice([event isDirectionInvertedFromDevice])

I think this probably needs to be conditional on Lion or later.
Comment 8 Jon Lee 2011-09-28 15:29:29 PDT
(In reply to comment #7)
> (From update of attachment 109079 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=109079&action=review
> 
> I think we probably want to prefix the IDL attribute with webkit as well.

OK.

> 
> > Source/WebCore/platform/mac/WheelEventMac.mm:104
> > +    , m_directionInvertedFromDevice([event isDirectionInvertedFromDevice])
> 
> I think this probably needs to be conditional on Lion or later.

Whoops, you are right. Will add.
Comment 9 Jon Lee 2011-09-28 16:02:56 PDT
Created attachment 109083 [details]
Patch
Comment 10 Jon Lee 2011-09-28 16:07:36 PDT
Updated with Sam's corrections.
Comment 11 Darin Adler 2011-10-03 09:58:09 PDT
Comment on attachment 109083 [details]
Patch

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

OK as-is, but seems to be too conditional in the wrong way, so maybe we could tighten it up.

> Source/WebCore/dom/WheelEvent.h:95
> +#if PLATFORM(MAC)
> +        WheelEvent(const FloatPoint& wheelTicks, const FloatPoint& rawDelta,
> +            Granularity, PassRefPtr<AbstractView>,
> +            const IntPoint& screenLocation, const IntPoint& pageLocation,
> +            bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool directionInvertedFromDevice);
> +#endif

Perhaps we could set the directionInvertedFromDevice flag with an explicit set call after construction. That would eliminate the need to repeat the entire constructor and improve the ifdefs.

> Source/WebCore/dom/WheelEvent.idl:45
> +#if defined(WTF_PLATFORM_MAC) && WTF_PLATFORM_MAC
> +        readonly attribute boolean webkitDirectionInvertedFromDevice;
> +#endif /* PLATFORM(WTF_PLATFORM_MAC) */

It’s ugly to use the WTF prefixed macros directly in IDL files.

Ideally this would be a HAVE-type define instead of a direct platform one, like HAVE(INVERTED_WHEEL) or something like that. The platform macros themselves are slated for demolition.

Why wouldn’t we want this attribute to exist and be false on all platforms?
Comment 12 Sam Weinig 2011-10-03 10:23:24 PDT
> 
> Why wouldn’t we want this attribute to exist and be false on all platforms?

I think the answer to that is we probably do want it on all platforms.

-Sam
Comment 13 Jon Lee 2011-10-03 10:42:09 PDT
I'll make the adjustments and send out another patch.
Comment 14 Jon Lee 2011-10-03 12:54:18 PDT
Created attachment 109510 [details]
Patch
Comment 15 Sam Weinig 2011-10-04 10:22:25 PDT
Comment on attachment 109510 [details]
Patch

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

> Source/WebKit2/ChangeLog:41
> +2011-09-28  Jon Lee  <jonlee@apple.com>
> +
> +        Extend DOM WheelEvent to differentiate between physical and logical scroll directions
> +        https://bugs.webkit.org/show_bug.cgi?id=68959
> +        <rdar://problem/10036688>
> +
> +        Reviewed by NOBODY (OOPS!).
> +
> +        * Shared/WebEvent.h:
> +        (WebKit::WebWheelEvent::directionInvertedFromDevice):
> +        * Shared/WebEventConversion.cpp:
> +        (WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
> +        * Shared/WebWheelEvent.cpp:
> +        (WebKit::WebWheelEvent::WebWheelEvent):
> +        (WebKit::WebWheelEvent::encode):
> +        (WebKit::WebWheelEvent::decode):
> +        * Shared/mac/WebEventFactory.mm:
> +        (WebKit::WebEventFactory::createWebWheelEvent): get the flag from the NSEvent.
> +        * UIProcess/WebPageProxy.cpp:
> +        (WebKit::coalesce):

Double changelog!
Comment 16 Jon Lee 2011-10-04 10:38:07 PDT
(In reply to comment #15)
> Double changelog!

Fixed, and thanks!
Comment 17 Jon Lee 2011-10-04 11:07:34 PDT
Committed r96613: <http://trac.webkit.org/changeset/96613>
Comment 18 Ryosuke Niwa 2011-10-04 12:16:49 PDT
This patch broke Leopard build. Fix attempted in http://trac.webkit.org/changeset/96629.
Comment 19 Gavin Peters 2011-10-04 14:11:43 PDT
This bug also appears to have broken the gtk build.
http://build.webkit.org/builders/GTK%20Linux%2032-bit%20Release/builds/17973/steps/compile-webkit/logs/stdio
Comment 20 Gavin Peters 2011-10-04 14:15:41 PDT
n/m, false alarm on the gtk folks.
Comment 21 Ryosuke Niwa 2011-10-04 14:19:24 PDT
(In reply to comment #19)
> This bug also appears to have broken the gtk build.
> http://build.webkit.org/builders/GTK%20Linux%2032-bit%20Release/builds/17973/steps/compile-webkit/logs/stdio

This is due to https://bugs.webkit.org/show_bug.cgi?id=69357.