Changeset 96613 in webkit


Ignore:
Timestamp:
Oct 4, 2011 11:06:44 AM (13 years ago)
Author:
jonlee@apple.com
Message:

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 Sam Weinig.

Source/JavaScriptCore:

  • wtf/Platform.h: Added HAVE_INVERTED_WHEEL_EVENTS for Lion and later.

Source/WebCore:

Test: fast/events/wheelevent-direction-inverted-from-device.html

  • dom/WheelEvent.cpp:

(WebCore::WheelEvent::WheelEvent):
(WebCore::WheelEvent::initWheelEvent):
(WebCore::WheelEventDispatchMediator::WheelEventDispatchMediator):

  • dom/WheelEvent.h:

(WebCore::WheelEvent::create):
(WebCore::WheelEvent::webkitDirectionInvertedFromDevice):

  • dom/WheelEvent.idl: Added the webkitDirectionInvertedFromDevice idl attribute.
  • platform/PlatformWheelEvent.h:

(WebCore::PlatformWheelEvent::PlatformWheelEvent):
(WebCore::PlatformWheelEvent::webkitDirectionInvertedFromDevice):

  • platform/efl/PlatformWheelEventEfl.cpp:

(WebCore::PlatformWheelEvent::PlatformWheelEvent): default to false.

  • platform/gtk/PlatformWheelEventGtk.cpp:

(WebCore::PlatformWheelEvent::PlatformWheelEvent): default to false.

  • platform/mac/WheelEventMac.mm:

(WebCore::PlatformWheelEvent::PlatformWheelEvent): if building on Lion or later, use
[NSEvent isDirectionInvertedFromDevice].

  • platform/qt/WheelEventQt.cpp:

(WebCore::PlatformWheelEvent::PlatformWheelEvent): default to false.

  • platform/win/WheelEventWin.cpp:

(WebCore::PlatformWheelEvent::PlatformWheelEvent): default to false.

  • platform/wx/MouseWheelEventWx.cpp:

(WebCore::PlatformWheelEvent::PlatformWheelEvent): default to false.

Source/WebKit2:

  • 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):

LayoutTests:

  • fast/events/wheelevent-direction-inverted-from-device-expected.txt: Added.
  • fast/events/wheelevent-direction-inverted-from-device.html: Added.
  • platform/mac-wk2/Skipped: WKTR does not support mouse scroll events yet.
Location:
trunk
Files:
2 added
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    • Property svn:executable deleted
    r96610 r96613  
     12011-10-03  Jon Lee  <jonlee@apple.com>
     2
     3        Extend DOM WheelEvent to differentiate between physical and logical scroll directions
     4        https://bugs.webkit.org/show_bug.cgi?id=68959
     5        <rdar://problem/10036688>
     6
     7        Reviewed by Sam Weinig.
     8
     9        * fast/events/wheelevent-direction-inverted-from-device-expected.txt: Added.
     10        * fast/events/wheelevent-direction-inverted-from-device.html: Added.
     11        * platform/mac-wk2/Skipped: WKTR does not support mouse scroll events yet.
     12
    1132011-10-03 Ken Buchanan <kenrb@chromium.org>
    214
  • trunk/LayoutTests/platform/mac-wk2/Skipped

    r96439 r96613  
    158158fast/events/wheelevent-in-horizontal-scrollbar-in-rtl.html
    159159fast/events/wheelevent-in-vertical-scrollbar-in-rtl.html
     160fast/events/wheelevent-direction-inverted-from-device.html
    160161fast/files/apply-blob-url-to-xhr.html
    161162fast/files/file-reader-abort.html
  • trunk/Source/JavaScriptCore/ChangeLog

    r96598 r96613  
     12011-10-03  Jon Lee  <jonlee@apple.com>
     2
     3        Extend DOM WheelEvent to differentiate between physical and logical scroll directions
     4        https://bugs.webkit.org/show_bug.cgi?id=68959
     5        <rdar://problem/10036688>
     6
     7        Reviewed by Sam Weinig.
     8
     9        * wtf/Platform.h: Added HAVE_INVERTED_WHEEL_EVENTS for Lion and later.
     10
    1112011-10-04  Csaba Osztrogonác  <ossy@webkit.org>
    212
  • trunk/Source/JavaScriptCore/wtf/Platform.h

    r96545 r96613  
    11051105#endif
    11061106
     1107#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD)
     1108#define HAVE_INVERTED_WHEEL_EVENTS 1
     1109#endif
     1110
    11071111#endif /* WTF_Platform_h */
  • trunk/Source/WebCore/ChangeLog

    • Property svn:executable deleted
    r96612 r96613  
     12011-10-03  Jon Lee  <jonlee@apple.com>
     2
     3        Extend DOM WheelEvent to differentiate between physical and logical scroll directions
     4        https://bugs.webkit.org/show_bug.cgi?id=68959
     5        <rdar://problem/10036688>
     6
     7        Reviewed by Sam Weinig.
     8
     9        Test: fast/events/wheelevent-direction-inverted-from-device.html
     10
     11        * dom/WheelEvent.cpp:
     12        (WebCore::WheelEvent::WheelEvent):
     13        (WebCore::WheelEvent::initWheelEvent):
     14        (WebCore::WheelEventDispatchMediator::WheelEventDispatchMediator):
     15        * dom/WheelEvent.h:
     16        (WebCore::WheelEvent::create):
     17        (WebCore::WheelEvent::webkitDirectionInvertedFromDevice):
     18        * dom/WheelEvent.idl: Added the webkitDirectionInvertedFromDevice idl attribute.
     19        * platform/PlatformWheelEvent.h:
     20        (WebCore::PlatformWheelEvent::PlatformWheelEvent):
     21        (WebCore::PlatformWheelEvent::webkitDirectionInvertedFromDevice):
     22        * platform/efl/PlatformWheelEventEfl.cpp:
     23        (WebCore::PlatformWheelEvent::PlatformWheelEvent): default to false.
     24        * platform/gtk/PlatformWheelEventGtk.cpp:
     25        (WebCore::PlatformWheelEvent::PlatformWheelEvent): default to false.
     26        * platform/mac/WheelEventMac.mm:
     27        (WebCore::PlatformWheelEvent::PlatformWheelEvent): if building on Lion or later, use
     28        [NSEvent isDirectionInvertedFromDevice].
     29        * platform/qt/WheelEventQt.cpp:
     30        (WebCore::PlatformWheelEvent::PlatformWheelEvent): default to false.
     31        * platform/win/WheelEventWin.cpp:
     32        (WebCore::PlatformWheelEvent::PlatformWheelEvent): default to false.
     33        * platform/wx/MouseWheelEventWx.cpp:
     34        (WebCore::PlatformWheelEvent::PlatformWheelEvent): default to false.
     35
    1362011-10-04  Rémi Duraffort  <remi.duraffort@st.com>
    237
  • trunk/Source/WebCore/dom/WheelEvent.cpp

    r92266 r96613  
    4040                       Granularity granularity, PassRefPtr<AbstractView> view,
    4141                       const IntPoint& screenLocation, const IntPoint& pageLocation,
    42                        bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
     42                       bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
     43                       bool directionInvertedFromDevice)
    4344    : MouseRelatedEvent(eventNames().mousewheelEvent,
    4445                        true, true, view, 0, screenLocation, pageLocation,
     
    4748    , m_rawDelta(roundedIntPoint(rawDelta))
    4849    , m_granularity(granularity)
     50    , m_directionInvertedFromDevice(directionInvertedFromDevice)
    4951{
    5052}
     
    7072    m_rawDelta = IntPoint(rawDeltaX, rawDeltaY);
    7173    m_granularity = Pixel;
    72    
     74    m_directionInvertedFromDevice = false;
     75
    7376    initCoordinates(IntPoint(pageX, pageY));
    7477}
     
    102105        return;
    103106
    104     setEvent(WheelEvent::create(FloatPoint(event.wheelTicksX(), event.wheelTicksY()), FloatPoint(event.deltaX(), event.deltaY()), granularity(event),
    105         view, IntPoint(event.globalX(), event.globalY()), IntPoint(event.x(), event.y()), event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey()));
    106 
     107    setEvent(WheelEvent::create(FloatPoint(event.wheelTicksX(), event.wheelTicksY()), FloatPoint(event.deltaX(), event.deltaY()),
     108                                granularity(event), view, IntPoint(event.globalX(), event.globalY()), IntPoint(event.x(), event.y()),
     109                                event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), event.webkitDirectionInvertedFromDevice()));
    107110}
    108111
  • trunk/Source/WebCore/dom/WheelEvent.h

    r93385 r96613  
    4545            const FloatPoint& rawDelta, Granularity granularity, PassRefPtr<AbstractView> view,
    4646            const IntPoint& screenLocation, const IntPoint& pageLocation,
    47             bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
     47            bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool directionInvertedFromDevice)
    4848        {
    4949            return adoptRef(new WheelEvent(wheelTicks, rawDelta, granularity, view,
    50                 screenLocation, pageLocation, ctrlKey, altKey, shiftKey, metaKey));
     50                screenLocation, pageLocation, ctrlKey, altKey, shiftKey, metaKey, directionInvertedFromDevice));
    5151        }
    5252
     
    6666        Granularity granularity() const { return m_granularity; }
    6767
     68        bool webkitDirectionInvertedFromDevice() const { return m_directionInvertedFromDevice; }
    6869        // Needed for Objective-C legacy support
    6970        bool isHorizontal() const { return m_wheelDelta.x(); }
     
    7475                   Granularity granularity, PassRefPtr<AbstractView>,
    7576                   const IntPoint& screenLocation, const IntPoint& pageLocation,
    76                    bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);
     77                   bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool directionInvertedFromDevice);
    7778
    7879        virtual bool isWheelEvent() const;
     
    8182        IntPoint m_rawDelta;
    8283        Granularity m_granularity;
     84        bool m_directionInvertedFromDevice;
    8385    };
    8486
  • trunk/Source/WebCore/dom/WheelEvent.idl

    r91617 r96613  
    4040        readonly attribute long    x;
    4141        readonly attribute long    y;
     42        readonly attribute boolean webkitDirectionInvertedFromDevice;
    4243
    4344#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
  • trunk/Source/WebCore/platform/PlatformWheelEvent.h

    r92699 r96613  
    9898            , m_altKey(false)
    9999            , m_metaKey(false)
     100            , m_directionInvertedFromDevice(false)
    100101#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
    101102            , m_hasPreciseScrollingDeltas(false)
     
    120121            , m_altKey(altKey)
    121122            , m_metaKey(metaKey)
     123            , m_directionInvertedFromDevice(false)
    122124#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
    123125            , m_hasPreciseScrollingDeltas(false)
     
    150152        int globalX() const { return m_globalPosition.x(); } // Screen coordinates.
    151153        int globalY() const { return m_globalPosition.y(); }
     154
     155        bool webkitDirectionInvertedFromDevice() const { return m_directionInvertedFromDevice; }
    152156
    153157        void accept() { m_isAccepted = true; }
     
    216220        bool m_altKey;
    217221        bool m_metaKey;
     222        bool m_directionInvertedFromDevice;
    218223#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
    219224        bool m_hasPreciseScrollingDeltas;
  • trunk/Source/WebCore/platform/efl/PlatformWheelEventEfl.cpp

    r95901 r96613  
    5252    , m_altKey(evas_key_modifier_is_set(ev->modifiers, "Alt"))
    5353    , m_metaKey(evas_key_modifier_is_set(ev->modifiers, "Meta"))
     54    , m_directionInvertedFromDevice(false)
    5455{
    5556    // A negative z value means (in EFL) that we are scrolling down, so we need
  • trunk/Source/WebCore/platform/gtk/PlatformWheelEventGtk.cpp

    r83429 r96613  
    6868    m_altKey = event->state & GDK_MOD1_MASK;
    6969    m_metaKey = event->state & GDK_META_MASK;
     70    m_directionInvertedFromDevice = false;
    7071
    7172    // FIXME: retrieve the user setting for the number of lines to scroll on each wheel event
  • trunk/Source/WebCore/platform/mac/WheelEventMac.mm

    r82709 r96613  
    116116        m_hasPreciseScrollingDeltas = false;
    117117    }
     118
     119#if HAVE(INVERTED_WHEEL_EVENTS)
     120    m_directionInvertedFromDevice = [event isDirectionInvertedFromDevice];
     121#else
     122    m_directionInvertedFromDevice = false;
     123#endif
    118124}
    119125
  • trunk/Source/WebCore/platform/qt/WheelEventQt.cpp

    r75467 r96613  
    6868    , m_altKey(e->modifiers() & Qt::AltModifier)
    6969    , m_metaKey(e->modifiers() & Qt::MetaModifier)
     70    , m_directionInvertedFromDevice(false)
    7071#endif
    7172{
     
    8788    , m_altKey(e->modifiers() & Qt::AltModifier)
    8889    , m_metaKey(e->modifiers() & Qt::MetaModifier)
     90    , m_directionInvertedFromDevice(false)
    8991#endif
    9092{
  • trunk/Source/WebCore/platform/win/WheelEventWin.cpp

    r45304 r96613  
    7272    , m_altKey(false)
    7373    , m_metaKey(false)
     74    , m_directionInvertedFromDevice(false)
    7475{
    7576    m_deltaX = delta.width();
     
    9697    , m_altKey(GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT)
    9798    , m_metaKey(m_altKey) // FIXME: We'll have to test other browsers
     99    , m_directionInvertedFromDevice(false)
    98100{
    99101    // How many pixels should we scroll per line?  Gecko uses the height of the
  • trunk/Source/WebCore/platform/wx/MouseWheelEventWx.cpp

    r54345 r96613  
    4646    , m_wheelTicksY(m_deltaY)
    4747    , m_isAccepted(false)
     48    , m_directionInvertedFromDevice(false)
    4849{
    4950    // FIXME: retrieve the user setting for the number of lines to scroll on each wheel event
  • trunk/Source/WebKit2/ChangeLog

    r96611 r96613  
     12011-10-03  Jon Lee  <jonlee@apple.com>
     2
     3        Extend DOM WheelEvent to differentiate between physical and logical scroll directions
     4        https://bugs.webkit.org/show_bug.cgi?id=68959
     5        <rdar://problem/10036688>
     6
     7        Reviewed by Sam Weinig.
     8
     9        * Shared/WebEvent.h:
     10        (WebKit::WebWheelEvent::directionInvertedFromDevice):
     11        * Shared/WebEventConversion.cpp:
     12        (WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
     13        * Shared/WebWheelEvent.cpp:
     14        (WebKit::WebWheelEvent::WebWheelEvent):
     15        (WebKit::WebWheelEvent::encode):
     16        (WebKit::WebWheelEvent::decode):
     17        * Shared/mac/WebEventFactory.mm:
     18        (WebKit::WebEventFactory::createWebWheelEvent): get the flag from the NSEvent.
     19        * UIProcess/WebPageProxy.cpp:
     20        (WebKit::coalesce):
     21
    1222011-10-04  Nayan Kumar K  <nayankk@motorola.com>
    223
  • trunk/Source/WebKit2/Shared/WebEvent.h

    r95901 r96613  
    180180    WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Granularity, Modifiers, double timestamp);
    181181#if PLATFORM(MAC)
    182     WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Granularity, Phase phase, Phase momentumPhase,bool hasPreciseScrollingDeltas, Modifiers, double timestamp);
     182    WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Granularity, Phase, Phase momentumPhase, bool hasPreciseScrollingDeltas, Modifiers, double timestamp, bool directionInvertedFromDevice);
    183183#endif
    184184
     
    188188    const WebCore::FloatSize wheelTicks() const { return m_wheelTicks; }
    189189    Granularity granularity() const { return static_cast<Granularity>(m_granularity); }
     190    bool directionInvertedFromDevice() const { return m_directionInvertedFromDevice; }
    190191#if PLATFORM(MAC)
    191192    Phase phase() const { return static_cast<Phase>(m_phase); }
     
    205206    WebCore::FloatSize m_wheelTicks;
    206207    uint32_t m_granularity; // Granularity
     208    bool m_directionInvertedFromDevice;
    207209#if PLATFORM(MAC)
    208210    uint32_t m_phase; // Phase
  • trunk/Source/WebKit2/Shared/WebEventConversion.cpp

    r95901 r96613  
    111111        m_altKey = webEvent.altKey();
    112112        m_metaKey = webEvent.metaKey();
     113        m_directionInvertedFromDevice = webEvent.directionInvertedFromDevice();
    113114#if PLATFORM(MAC)
    114115        m_phase = static_cast<WebCore::PlatformWheelEventPhase>(webEvent.phase());
  • trunk/Source/WebKit2/Shared/WebWheelEvent.cpp

    r95901 r96613  
    4141    , m_wheelTicks(wheelTicks)
    4242    , m_granularity(granularity)
     43    , m_directionInvertedFromDevice(false)
    4344#if PLATFORM(MAC)
    4445    , m_phase(PhaseNone)
     
    5051
    5152#if PLATFORM(MAC)
    52 WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& delta, const FloatSize& wheelTicks, Granularity granularity, Phase phase, Phase momentumPhase, bool hasPreciseScrollingDeltas, Modifiers modifiers, double timestamp)
     53WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& delta, const FloatSize& wheelTicks, Granularity granularity, Phase phase, Phase momentumPhase, bool hasPreciseScrollingDeltas, Modifiers modifiers, double timestamp, bool directionInvertedFromDevice)
    5354    : WebEvent(type, modifiers, timestamp)
    5455    , m_position(position)
     
    5758    , m_wheelTicks(wheelTicks)
    5859    , m_granularity(granularity)
     60    , m_directionInvertedFromDevice(directionInvertedFromDevice)
    5961    , m_phase(phase)
    6062    , m_momentumPhase(momentumPhase)
     
    7476    encoder->encode(m_wheelTicks);
    7577    encoder->encode(m_granularity);
     78    encoder->encode(m_directionInvertedFromDevice);
    7679#if PLATFORM(MAC)
    7780    encoder->encode(m_phase);
     
    9598    if (!decoder->decode(t.m_granularity))
    9699        return false;
     100    if (!decoder->decode(t.m_directionInvertedFromDevice))
     101        return false;
    97102#if PLATFORM(MAC)
    98103    if (!decoder->decode(t.m_phase))
  • trunk/Source/WebKit2/Shared/mac/WebEventFactory.mm

    r95901 r96613  
    10971097    WebEvent::Modifiers modifiers           = modifiersForEvent(event);
    10981098    double timestamp                        = [event timestamp];
    1099    
    1100     return WebWheelEvent(WebEvent::Wheel, IntPoint(position), IntPoint(globalPosition), FloatSize(deltaX, deltaY), FloatSize(wheelTicksX, wheelTicksY), granularity, phase, momentumPhase, hasPreciseScrollingDeltas, modifiers, timestamp);
     1099#if HAVE(INVERTED_WHEEL_EVENTS)
     1100    bool directionInvertedFromDevice        = [event isDirectionInvertedFromDevice];
     1101#else
     1102    bool directionInvertedFromDevice        = false;
     1103#endif
     1104    return WebWheelEvent(WebEvent::Wheel, IntPoint(position), IntPoint(globalPosition), FloatSize(deltaX, deltaY), FloatSize(wheelTicksX, wheelTicksY), granularity, phase, momentumPhase, hasPreciseScrollingDeltas, modifiers, timestamp, directionInvertedFromDevice);
    11011105}
    11021106
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r96439 r96613  
    26712671
    26722672#if PLATFORM(MAC)
    2673     return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.phase(), b.momentumPhase(), b.hasPreciseScrollingDeltas(), b.modifiers(), b.timestamp());
     2673    return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.phase(), b.momentumPhase(), b.hasPreciseScrollingDeltas(), b.modifiers(), b.timestamp(), b.directionInvertedFromDevice());
    26742674#else
    26752675    return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.modifiers(), b.timestamp());
Note: See TracChangeset for help on using the changeset viewer.