Add phase in addition to momentumPhase to platform wheel events
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Feb 2011 23:59:55 +0000 (23:59 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Feb 2011 23:59:55 +0000 (23:59 +0000)
Part of <rdar://problem/8945362>

Reviewed by Anders Carlsson.

Rename existing phase to momentumPhase.

../WebCore:

* platform/PlatformWheelEvent.h:
(WebCore::PlatformWheelEvent::PlatformWheelEvent):
(WebCore::PlatformWheelEvent::momentumPhase):
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::handleWheelEvent):
(WebCore::ScrollAnimatorMac::smoothScrollWithEvent):
* platform/mac/WheelEventMac.mm:
(WebCore::momentumPhaseForEvent):
(WebCore::phaseForEvent):
(WebCore::PlatformWheelEvent::PlatformWheelEvent):

../WebKit2:

* Shared/WebEvent.h:
(WebKit::WebWheelEvent::momentumPhase):
* Shared/WebEventConversion.cpp:
(WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
* Shared/WebWheelEvent.cpp:
(WebKit::WebWheelEvent::WebWheelEvent):
(WebKit::WebWheelEvent::encode):
(WebKit::WebWheelEvent::decode):
* Shared/mac/WebEventFactory.mm:
(WebKit::phaseForEvent):
(WebKit::momentumPhaseForEvent):
(WebKit::WebEventFactory::createWebWheelEvent):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@79141 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/PlatformWheelEvent.h
Source/WebCore/platform/mac/ScrollAnimatorMac.mm
Source/WebCore/platform/mac/WheelEventMac.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebEvent.h
Source/WebKit2/Shared/WebEventConversion.cpp
Source/WebKit2/Shared/WebWheelEvent.cpp
Source/WebKit2/Shared/mac/WebEventFactory.mm

index 2795d555bb33af4a7b6c472107bf9345d6d61507..ae5bc3d3fbe5e832399fe072bed58b4895bd8074 100644 (file)
@@ -1,3 +1,23 @@
+2011-02-19  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Anders Carlsson.
+
+        Add phase in addition to momentumPhase to platform wheel events
+        Part of <rdar://problem/8945362>
+
+        Rename existing phase to momentumPhase.
+
+        * platform/PlatformWheelEvent.h:
+        (WebCore::PlatformWheelEvent::PlatformWheelEvent):
+        (WebCore::PlatformWheelEvent::momentumPhase):
+        * platform/mac/ScrollAnimatorMac.mm:
+        (WebCore::ScrollAnimatorMac::handleWheelEvent):
+        (WebCore::ScrollAnimatorMac::smoothScrollWithEvent):
+        * platform/mac/WheelEventMac.mm:
+        (WebCore::momentumPhaseForEvent):
+        (WebCore::phaseForEvent):
+        (WebCore::PlatformWheelEvent::PlatformWheelEvent):
+
 2011-02-19  Gavin Barraclough  <barraclough@apple.com>
 
         Qt build fix.
index 2698e6e4795b399549dd7b9109d509f79255d2cd..37655533bd48e31f551ced2d33044a9be887e00c 100644 (file)
@@ -100,6 +100,7 @@ namespace WebCore {
 #if PLATFORM(MAC)
             , m_hasPreciseScrollingDeltas(false)
             , m_phase(PlatformWheelEventPhaseNone)
+            , m_momentumPhase(PlatformWheelEventPhaseNone)
             , m_timestamp(0)
 #endif
         {
@@ -153,6 +154,7 @@ namespace WebCore {
 #endif
 
         PlatformWheelEventPhase phase() const { return m_phase; }
+        PlatformWheelEventPhase momentumPhase() const { return m_momentumPhase; }
         bool hasPreciseScrollingDeltas() const { return m_hasPreciseScrollingDeltas; }
         double timestamp() const { return m_timestamp; }
 #endif
@@ -192,6 +194,7 @@ namespace WebCore {
 #if PLATFORM(MAC)
         bool m_hasPreciseScrollingDeltas;
         PlatformWheelEventPhase m_phase;
+        PlatformWheelEventPhase m_momentumPhase;
         double m_timestamp;
 #endif
     };
index f273c0ffc27b39da987a016de66ef5f197183b69..67c0904b78b6147c867eaa43e7cb3bac36270cc0 100644 (file)
@@ -727,9 +727,9 @@ void ScrollAnimatorMac::handleWheelEvent(PlatformWheelEvent& wheelEvent)
 
     wheelEvent.accept();
 
-    bool isMometumScrollEvent = (wheelEvent.phase() != PlatformWheelEventPhaseNone);
+    bool isMometumScrollEvent = (wheelEvent.momentumPhase() != PlatformWheelEventPhaseNone);
     if (m_ignoreMomentumScrolls && (isMometumScrollEvent || m_snapRubberBandTimer.isActive())) {
-        if (wheelEvent.phase() == PlatformWheelEventPhaseEnded)
+        if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseEnded)
             m_ignoreMomentumScrolls = false;
         return;
     }
@@ -820,7 +820,7 @@ void ScrollAnimatorMac::smoothScrollWithEvent(PlatformWheelEvent& wheelEvent)
     isHorizontallyStretched = stretchAmount.width();
     isVerticallyStretched = stretchAmount.height();
 
-    PlatformWheelEventPhase phase = wheelEvent.phase();
+    PlatformWheelEventPhase phase = wheelEvent.momentumPhase();
 
     // If we are starting momentum scrolling then do some setup.
     if (!m_momentumScrollInProgress && (phase == PlatformWheelEventPhaseBegan || phase == PlatformWheelEventPhaseChanged))
index 74265d1f7df49297928d9321dd2035adc4f2149b..4e9a8b72395007f1a3bd38923a6b96dc366deba6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2006, 2010 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004, 2006, 2010, 2011 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -33,7 +33,7 @@
 
 namespace WebCore {
 
-static PlatformWheelEventPhase phaseForEvent(NSEvent *event)
+static PlatformWheelEventPhase momentumPhaseForEvent(NSEvent *event)
 {
 #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
     uint32_t phase = PlatformWheelEventPhaseNone; 
@@ -54,6 +54,27 @@ static PlatformWheelEventPhase phaseForEvent(NSEvent *event)
 #endif
 }
 
+static PlatformWheelEventPhase phaseForEvent(NSEvent *event)
+{
+#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+    uint32_t phase = PlatformWheelEventPhaseNone; 
+    if ([event phase] & NSEventPhaseBegan)
+        phase |= PlatformWheelEventPhaseBegan;
+    if ([event phase] & NSEventPhaseStationary)
+        phase |= PlatformWheelEventPhaseStationary;
+    if ([event phase] & NSEventPhaseChanged)
+        phase |= PlatformWheelEventPhaseChanged;
+    if ([event phase] & NSEventPhaseEnded)
+        phase |= PlatformWheelEventPhaseEnded;
+    if ([event phase] & NSEventPhaseCancelled)
+        phase |= PlatformWheelEventPhaseCancelled;
+    return static_cast<PlatformWheelEventPhase>(phase);
+#else
+    UNUSED_PARAM(event);
+    return PlatformWheelEventPhaseNone;
+#endif
+}
+
 PlatformWheelEvent::PlatformWheelEvent(NSEvent* event, NSView *windowView)
     : m_position(pointForEvent(event, windowView))
     , m_globalPosition(globalPointForEvent(event))
@@ -64,10 +85,10 @@ PlatformWheelEvent::PlatformWheelEvent(NSEvent* event, NSView *windowView)
     , m_altKey([event modifierFlags] & NSAlternateKeyMask)
     , m_metaKey([event modifierFlags] & NSCommandKeyMask)
     , m_phase(phaseForEvent(event))
+    , m_momentumPhase(momentumPhaseForEvent(event))
     , m_timestamp([event timestamp])
 {
     BOOL continuous;
-
     wkGetWheelEventDeltas(event, &m_deltaX, &m_deltaY, &continuous);
     if (continuous) {
         m_wheelTicksX = m_deltaX / static_cast<float>(Scrollbar::pixelsPerLineStep());
index 411846fbd90a22351b9312e136b904c1616a6f49..4e67aaf9b1fef7bce775bf60e52d39b2309c4d50 100644 (file)
@@ -1,3 +1,25 @@
+2011-02-19  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Anders Carlsson.
+
+        Add phase in addition to momentumPhase to platform wheel events
+        Part of <rdar://problem/8945362>
+
+        Rename existing phase to momentumPhase.
+
+        * Shared/WebEvent.h:
+        (WebKit::WebWheelEvent::momentumPhase):
+        * Shared/WebEventConversion.cpp:
+        (WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
+        * Shared/WebWheelEvent.cpp:
+        (WebKit::WebWheelEvent::WebWheelEvent):
+        (WebKit::WebWheelEvent::encode):
+        (WebKit::WebWheelEvent::decode):
+        * Shared/mac/WebEventFactory.mm:
+        (WebKit::phaseForEvent):
+        (WebKit::momentumPhaseForEvent):
+        (WebKit::WebEventFactory::createWebWheelEvent):
+
 2011-02-19  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Dan Bernstein.
index 361aa462d4fa4d3d24416410c0cd061417d0338e..6d2e60b9c6227873a686fc07b94f2b9d3b9dd3c4 100644 (file)
@@ -173,7 +173,7 @@ public:
 
     WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Granularity, Modifiers, double timestamp);
 #if PLATFORM(MAC)
-    WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Granularity, Phasebool hasPreciseScrollingDeltas, Modifiers, double timestamp);
+    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);
 #endif
 
     const WebCore::IntPoint position() const { return m_position; }
@@ -183,6 +183,7 @@ public:
     Granularity granularity() const { return static_cast<Granularity>(m_granularity); }
 #if PLATFORM(MAC)
     Phase phase() const { return static_cast<Phase>(m_phase); }
+    Phase momentumPhase() const { return static_cast<Phase>(m_momentumPhase); }
     bool hasPreciseScrollingDeltas() const { return m_hasPreciseScrollingDeltas; }
 #endif
 
@@ -199,6 +200,7 @@ private:
     uint32_t m_granularity; // Granularity
 #if PLATFORM(MAC)
     uint32_t m_phase; // Phase
+    uint32_t m_momentumPhase; // Phase
     bool m_hasPreciseScrollingDeltas;
 #endif
 };
index 62147d05b73dc8eae6c8d853619f3dcb6fffeb87..9c2fad17ff59b63e687b5dcdf003540680bc4688 100644 (file)
@@ -112,6 +112,7 @@ public:
         m_metaKey = webEvent.metaKey();
 #if PLATFORM(MAC)
         m_phase = static_cast<WebCore::PlatformWheelEventPhase>(webEvent.phase());
+        m_momentumPhase = static_cast<WebCore::PlatformWheelEventPhase>(webEvent.momentumPhase());
         m_hasPreciseScrollingDeltas = webEvent.hasPreciseScrollingDeltas();
         m_timestamp = webEvent.timestamp();
 #endif
index 26f2337b2b43a4bd38289f5f4d628dba7268798a..5940bcc9bd76645b2d4f4525349c07cd9648c75e 100644 (file)
@@ -49,7 +49,7 @@ WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint
 }
 
 #if PLATFORM(MAC)
-WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& delta, const FloatSize& wheelTicks, Granularity granularity, Phase phase, bool hasPreciseScrollingDeltas, Modifiers modifiers, double timestamp)
+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)
     : WebEvent(type, modifiers, timestamp)
     , m_position(position)
     , m_globalPosition(globalPosition)
@@ -57,6 +57,7 @@ WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint
     , m_wheelTicks(wheelTicks)
     , m_granularity(granularity)
     , m_phase(phase)
+    , m_momentumPhase(momentumPhase)
     , m_hasPreciseScrollingDeltas(hasPreciseScrollingDeltas)
 {
     ASSERT(isWheelEventType(type));
@@ -74,6 +75,7 @@ void WebWheelEvent::encode(CoreIPC::ArgumentEncoder* encoder) const
     encoder->encode(m_granularity);
 #if PLATFORM(MAC)
     encoder->encode(m_phase);
+    encoder->encode(m_momentumPhase);
     encoder->encode(m_hasPreciseScrollingDeltas);
 #endif
 }
@@ -95,6 +97,8 @@ bool WebWheelEvent::decode(CoreIPC::ArgumentDecoder* decoder, WebWheelEvent& t)
 #if PLATFORM(MAC)
     if (!decoder->decode(t.m_phase))
         return false;
+    if (!decoder->decode(t.m_momentumPhase))
+        return false;
     if (!decoder->decode(t.m_hasPreciseScrollingDeltas))
         return false;
 #endif
index e31c62e4ab7a3b7eb29e1222fb2d5db4798d3d42..8f02f6b44fc8b9031d57de4bc05000f2e79f835f 100644 (file)
@@ -172,6 +172,26 @@ static NSPoint pointForEvent(NSEvent *event, NSView *windowView)
 
 static WebWheelEvent::Phase phaseForEvent(NSEvent *event)
 {
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+    uint32_t phase = WebWheelEvent::PhaseNone; 
+    if ([event phase] & NSEventPhaseBegan)
+        phase |= WebWheelEvent::PhaseBegan;
+    if ([event phase] & NSEventPhaseStationary)
+        phase |= WebWheelEvent::PhaseStationary;
+    if ([event phase] & NSEventPhaseChanged)
+        phase |= WebWheelEvent::PhaseChanged;
+    if ([event phase] & NSEventPhaseEnded)
+        phase |= WebWheelEvent::PhaseEnded;
+    if ([event phase] & NSEventPhaseCancelled)
+        phase |= WebWheelEvent::PhaseCancelled;
+    return static_cast<WebWheelEvent::Phase>(phase);
+#else
+    return WebWheelEvent::PhaseNone;
+#endif
+}
+
+static WebWheelEvent::Phase momentumPhaseForEvent(NSEvent *event)
+{
 #if !defined(BUILDING_ON_SNOW_LEOPARD)
     uint32_t phase = WebWheelEvent::PhaseNone; 
     if ([event momentumPhase] & NSEventPhaseBegan)
@@ -1036,11 +1056,12 @@ WebWheelEvent WebEventFactory::createWebWheelEvent(NSEvent *event, NSView *windo
     }
 
     WebWheelEvent::Phase phase              = phaseForEvent(event);
+    WebWheelEvent::Phase momentumPhase      = momentumPhaseForEvent(event);
     bool hasPreciseScrollingDeltas          = continuous;
     WebEvent::Modifiers modifiers           = modifiersForEvent(event);
     double timestamp                        = [event timestamp];
     
-    return WebWheelEvent(WebEvent::Wheel, IntPoint(position), IntPoint(globalPosition), FloatSize(deltaX, deltaY), FloatSize(wheelTicksX, wheelTicksY), granularity, phase, hasPreciseScrollingDeltas, modifiers, timestamp);
+    return WebWheelEvent(WebEvent::Wheel, IntPoint(position), IntPoint(globalPosition), FloatSize(deltaX, deltaY), FloatSize(wheelTicksX, wheelTicksY), granularity, phase, momentumPhase, hasPreciseScrollingDeltas, modifiers, timestamp);
 }
 
 WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(NSEvent *event, NSView *)