Make momentum scroll event latching work in WebKit2 on Mac.
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Apr 2011 19:57:53 +0000 (19:57 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Apr 2011 19:57:53 +0000 (19:57 +0000)
<rdar://problem/8751861>

Reviewed by Darin Adler.

Source/WebCore:

* WebCore.exp.in: Remove _wkIsLatchingWheelEvent, add _wkGetNSEventMomentumPhase.
* page/EventHandler.cpp:
(WebCore::EventHandler::handleWheelEvent): Set m_useLatchedWheelEventNode based on the
event's momentumPhase.
* page/mac/EventHandlerMac.mm:
(WebCore::EventHandler::wheelEvent): Remove the setting of m_useLatchedWheelEventNode.
It is now done in EventHandler::handleWheelEvent.
* platform/mac/WebCoreSystemInterface.h: Remove wkIsLatchingWheelEvent, add wkGetNSEventMomentumPhase.
* platform/mac/WebCoreSystemInterface.mm: Ditto.
* platform/mac/WheelEventMac.mm:
(WebCore::momentumPhaseForEvent): Return a phase on older Mac system by using wkGetNSEventMomentumPhase.

Source/WebKit/mac:

* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface): Remove IsLatchingWheelEvent, add GetNSEventMomentumPhase.
* WebView/WebDynamicScrollBarsView.mm:
(-[WebDynamicScrollBarsView scrollWheel:]): Use WKGetNSEventMomentumPhase to set isLatchingEvent.

Source/WebKit2:

* Shared/mac/WebEventFactory.mm:
(WebKit::momentumPhaseForEvent): Return a phase on older Mac system by using WKGetNSEventMomentumPhase.
* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface): Remove IsLatchingWheelEvent, add GetNSEventMomentumPhase.

WebKitLibraries:

* WebKitSystemInterface.h:
* libWebKitSystemInterfaceLeopard.a: Updated to remove WKIsLatchingWheelEvent and add WKGetNSEventMomentumPhase.
* libWebKitSystemInterfaceSnowLeopard.a: Ditto.

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

17 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/mac/EventHandlerMac.mm
Source/WebCore/platform/mac/WebCoreSystemInterface.h
Source/WebCore/platform/mac/WebCoreSystemInterface.mm
Source/WebCore/platform/mac/WheelEventMac.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm
Source/WebKit/mac/WebView/WebDynamicScrollBarsView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/mac/WebEventFactory.mm
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitSystemInterface.h
WebKitLibraries/libWebKitSystemInterfaceLeopard.a
WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a

index ec431a3185e3e20c383face24d1119a7c0818886..486aa435f35cdd12e6b0d68a7239fa6fe55a64a8 100644 (file)
@@ -1,3 +1,23 @@
+2011-04-01  Timothy Hatcher  <timothy@apple.com>
+
+        Make momentum scroll event latching work in WebKit2 on Mac.
+
+        <rdar://problem/8751861>
+
+        Reviewed by Darin Adler.
+
+        * WebCore.exp.in: Remove _wkIsLatchingWheelEvent, add _wkGetNSEventMomentumPhase.
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleWheelEvent): Set m_useLatchedWheelEventNode based on the
+        event's momentumPhase.
+        * page/mac/EventHandlerMac.mm:
+        (WebCore::EventHandler::wheelEvent): Remove the setting of m_useLatchedWheelEventNode.
+        It is now done in EventHandler::handleWheelEvent.
+        * platform/mac/WebCoreSystemInterface.h: Remove wkIsLatchingWheelEvent, add wkGetNSEventMomentumPhase.
+        * platform/mac/WebCoreSystemInterface.mm: Ditto.
+        * platform/mac/WheelEventMac.mm:
+        (WebCore::momentumPhaseForEvent): Return a phase on older Mac system by using wkGetNSEventMomentumPhase.
+
 2011-04-01  Steve Block  <steveblock@google.com>
 
         Reviewed by Jeremy Orlow.
index 1b2a9c2b10090265e983ed2c16e3ea4406fd97c6..93402de3aae5fbf8fb2f878d3c18b4d0c3eaf50f 100644 (file)
@@ -1343,7 +1343,6 @@ _wkGetWheelEventDeltas
 _wkHTTPCookiesForURL
 _wkHitTestMediaUIPart
 _wkInitializeMaximumHTTPConnectionCountPerHost
-_wkIsLatchingWheelEvent
 _wkMeasureMediaUIPart
 _wkMediaControllerThemeAvailable
 _wkPopupMenu
@@ -1425,6 +1424,8 @@ _wkSetScrollbarPainterTrackAlpha
 _wkVerticalScrollbarPainterForController
 _wkWillEndLiveResize
 _wkWillStartLiveResize
+#else
+_wkGetNSEventMomentumPhase
 #endif
 
 _wkUnregisterUniqueIdForElement
index b1f69d5465abeb37afbbc7fa4bb59c6865a90c66..1046c04a4f4d642f6763af22cf69dd538f6f7496 100644 (file)
@@ -2041,6 +2041,10 @@ bool EventHandler::handleWheelEvent(PlatformWheelEvent& e)
     HitTestResult result(vPoint);
     doc->renderView()->layer()->hitTest(request, result);
 
+#if PLATFORM(MAC)
+    m_useLatchedWheelEventNode = e.momentumPhase() == PlatformWheelEventPhaseBegan || e.momentumPhase() == PlatformWheelEventPhaseChanged;
+#endif
+
     if (m_useLatchedWheelEventNode) {
         if (!m_latchedWheelEventNode) {
             m_latchedWheelEventNode = result.innerNode();
index 5e9691718e31f4c932f1968ff7af1abe641bcefe..380884b18dc07b23589580464d891419fdfd97f6 100644 (file)
@@ -113,8 +113,6 @@ bool EventHandler::wheelEvent(NSEvent *event)
 
     CurrentEventScope scope(event);
 
-    m_useLatchedWheelEventNode = wkIsLatchingWheelEvent(event);
-    
     PlatformWheelEvent wheelEvent(event, page->chrome()->platformPageClient());
     handleWheelEvent(wheelEvent);
 
index 308a551c6eebc259dd2960de2c6e55338ccc1bc6..ea23ae5e0021d9249cc81c66680132db72eb1579 100644 (file)
@@ -159,7 +159,6 @@ extern void (*wkSetHTTPPipeliningPriority)(NSMutableURLRequest *, int priority);
 extern void (*wkSetCONNECTProxyForStream)(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort);
 extern void (*wkSetCONNECTProxyAuthorizationForStream)(CFReadStreamRef, CFStringRef proxyAuthorizationString);
 extern CFHTTPMessageRef (*wkCopyCONNECTProxyResponse)(CFReadStreamRef, CFURLRef responseURL);
-extern BOOL (*wkIsLatchingWheelEvent)(NSEvent *);
 
 #ifndef BUILDING_ON_TIGER
 extern void (*wkGetGlyphsForCharacters)(CGFontRef, const UniChar[], CGGlyph[], size_t);
@@ -187,6 +186,15 @@ extern BOOL (*wkUseSharedMediaUI)();
 extern void* wkGetHyphenationLocationBeforeIndex;
 #else
 extern CFIndex (*wkGetHyphenationLocationBeforeIndex)(CFStringRef string, CFIndex index);
+
+typedef enum {
+    wkEventPhaseNone = 0,
+    wkEventPhaseBegan = 1,
+    wkEventPhaseChanged = 2,
+    wkEventPhaseEnded = 3,
+} wkEventPhase;
+
+extern int (*wkGetNSEventMomentumPhase)(NSEvent *);
 #endif
 
 extern CTLineRef (*wkCreateCTLineWithUniCharProvider)(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*);
index ab059bdba224029dbcbc9c36988646a878a2c1b0..e6fc47e395af73570e4eef40f35570568b492791 100644 (file)
@@ -95,7 +95,6 @@ void (*wkSetHTTPPipeliningPriority)(NSMutableURLRequest *, int priority);
 void (*wkSetCONNECTProxyForStream)(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort);
 void (*wkSetCONNECTProxyAuthorizationForStream)(CFReadStreamRef, CFStringRef proxyAuthorizationString);
 CFHTTPMessageRef (*wkCopyCONNECTProxyResponse)(CFReadStreamRef, CFURLRef responseURL);
-BOOL (*wkIsLatchingWheelEvent)(NSEvent *);
 
 #ifndef BUILDING_ON_TIGER
 void (*wkGetGlyphsForCharacters)(CGFontRef, const UniChar[], CGGlyph[], size_t);
@@ -120,6 +119,7 @@ BOOL (*wkSupportsMultipartXMixedReplace)(NSMutableURLRequest *);
 void* wkGetHyphenationLocationBeforeIndex;
 #else
 CFIndex (*wkGetHyphenationLocationBeforeIndex)(CFStringRef string, CFIndex index);
+int (*wkGetNSEventMomentumPhase)(NSEvent *);
 #endif
 
 CTLineRef (*wkCreateCTLineWithUniCharProvider)(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*);
index 4e9a8b72395007f1a3bd38923a6b96dc366deba6..2494e69abad2615cb6d84b424ea34664964664e7 100644 (file)
@@ -35,8 +35,9 @@ namespace WebCore {
 
 static PlatformWheelEventPhase momentumPhaseForEvent(NSEvent *event)
 {
+    uint32_t phase = PlatformWheelEventPhaseNone;
+
 #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
-    uint32_t phase = PlatformWheelEventPhaseNone; 
     if ([event momentumPhase] & NSEventPhaseBegan)
         phase |= PlatformWheelEventPhaseBegan;
     if ([event momentumPhase] & NSEventPhaseStationary)
@@ -47,11 +48,24 @@ static PlatformWheelEventPhase momentumPhaseForEvent(NSEvent *event)
         phase |= PlatformWheelEventPhaseEnded;
     if ([event momentumPhase] & NSEventPhaseCancelled)
         phase |= PlatformWheelEventPhaseCancelled;
-    return static_cast<PlatformWheelEventPhase>(phase);
 #else
-    UNUSED_PARAM(event);
-    return PlatformWheelEventPhaseNone;
+    switch (wkGetNSEventMomentumPhase(event)) {
+    case wkEventPhaseNone:
+        phase = PlatformWheelEventPhaseNone;
+        break;
+    case wkEventPhaseBegan:
+        phase = PlatformWheelEventPhaseBegan;
+        break;
+    case wkEventPhaseChanged:
+        phase = PlatformWheelEventPhaseChanged;
+        break;
+    case wkEventPhaseEnded:
+        phase = PlatformWheelEventPhaseEnded;
+        break;
+    }
 #endif
+
+    return static_cast<PlatformWheelEventPhase>(phase);
 }
 
 static PlatformWheelEventPhase phaseForEvent(NSEvent *event)
index d54506b5fcec21b198d3ce5950ce751edfaa86a4..675b581e6c1ff7b487a7ab61fb585ae6867fb397 100644 (file)
@@ -1,3 +1,16 @@
+2011-04-01  Timothy Hatcher  <timothy@apple.com>
+
+        Make momentum scroll event latching work in WebKit2 on Mac.
+
+        <rdar://problem/8751861>
+
+        Reviewed by Darin Adler.
+
+        * WebCoreSupport/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface): Remove IsLatchingWheelEvent, add GetNSEventMomentumPhase.
+        * WebView/WebDynamicScrollBarsView.mm:
+        (-[WebDynamicScrollBarsView scrollWheel:]): Use WKGetNSEventMomentumPhase to set isLatchingEvent.
+
 2011-03-31  Darin Adler  <darin@apple.com>
 
         Reviewed by Anders Carlsson.
index 1b212a73adbde7c7f65a2d189379ef54c24e68fb..77ca3e76bc31d423ae09354b72bf1987bd6ddec2 100644 (file)
@@ -68,7 +68,6 @@ void InitWebCoreSystemInterface(void)
     INIT(GetWheelEventDeltas);
     INIT(HitTestMediaUIPart);
     INIT(InitializeMaximumHTTPConnectionCountPerHost);
-    INIT(IsLatchingWheelEvent);
     INIT(MeasureMediaUIPart);
     INIT(MediaControllerThemeAvailable);
     INIT(PopupMenu);
@@ -119,9 +118,11 @@ void InitWebCoreSystemInterface(void)
 
 #if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
     INIT(GetHyphenationLocationBeforeIndex);
+    INIT(GetNSEventMomentumPhase);
 #endif
 
     INIT(CreateCTLineWithUniCharProvider);
+
 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
     INIT(IOSurfaceContextCreate);
     INIT(IOSurfaceContextCreateImage);
index 9f0dd8dd431a336a73e44fae2dd9fd7bd17e4437..62479187704db99b84c8ead7828faad6bc2f144b 100644 (file)
@@ -515,7 +515,8 @@ static const unsigned cMaxUpdateScrollbarsPass = 2;
     BOOL isContinuous;
     WKGetWheelEventDeltas(event, &deltaX, &deltaY, &isContinuous);
 
-    BOOL isLatchingEvent = WKIsLatchingWheelEvent(event);
+    int momentumPhase = WKGetNSEventMomentumPhase(event);
+    BOOL isLatchingEvent = momentumPhase == WKEventPhaseBegan || momentumPhase == WKEventPhaseChanged;
 
     if (fabsf(deltaY) > fabsf(deltaX)) {
         if (![self allowsVerticalScrolling]) {
index f19c77ae53a50a3acf212df09569fe34340996f4..5c4657ad67d74e779c5ef18e21ef2f1730b39139 100644 (file)
@@ -1,3 +1,16 @@
+2011-04-01  Timothy Hatcher  <timothy@apple.com>
+
+        Make momentum scroll event latching work in WebKit2 on Mac.
+
+        <rdar://problem/8751861>
+
+        Reviewed by Darin Adler.
+
+        * Shared/mac/WebEventFactory.mm:
+        (WebKit::momentumPhaseForEvent): Return a phase on older Mac system by using WKGetNSEventMomentumPhase.
+        * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface): Remove IsLatchingWheelEvent, add GetNSEventMomentumPhase.
+
 2011-04-01  Alexey Proskuryakov  <ap@apple.com>
 
         Reviewed by Anders Carlsson.
index 67ab1bab50e24e1776dd0473a1ed920a5558c6c0..dfc2d6cb65c42ae49d516f1512514e5a1598c0bc 100644 (file)
@@ -207,8 +207,9 @@ static WebWheelEvent::Phase phaseForEvent(NSEvent *event)
 
 static WebWheelEvent::Phase momentumPhaseForEvent(NSEvent *event)
 {
-#if !defined(BUILDING_ON_SNOW_LEOPARD)
     uint32_t phase = WebWheelEvent::PhaseNone; 
+
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
     if ([event momentumPhase] & NSEventPhaseBegan)
         phase |= WebWheelEvent::PhaseBegan;
     if ([event momentumPhase] & NSEventPhaseStationary)
@@ -219,10 +220,24 @@ static WebWheelEvent::Phase momentumPhaseForEvent(NSEvent *event)
         phase |= WebWheelEvent::PhaseEnded;
     if ([event momentumPhase] & NSEventPhaseCancelled)
         phase |= WebWheelEvent::PhaseCancelled;
-    return static_cast<WebWheelEvent::Phase>(phase);
 #else
-    return WebWheelEvent::PhaseNone;
+    switch (WKGetNSEventMomentumPhase(event)) {
+    case WKEventPhaseNone:
+        phase = WebWheelEvent::PhaseNone;
+        break;
+    case WKEventPhaseBegan:
+        phase = WebWheelEvent::PhaseBegan;
+        break;
+    case WKEventPhaseChanged:
+        phase = WebWheelEvent::PhaseChanged;
+        break;
+    case WKEventPhaseEnded:
+        phase = WebWheelEvent::PhaseEnded;
+        break;
+    }
 #endif
+
+    return static_cast<WebWheelEvent::Phase>(phase);
 }
 
 #if ENABLE(GESTURE_EVENTS)
index 06faa2f1ca0d745bdac8a7ff6652c06a39126ea9..5fd67027324f13ca72aa43fe965bb0b8414c3dba 100644 (file)
@@ -65,7 +65,6 @@ void InitWebCoreSystemInterface(void)
         INIT(GetWheelEventDeltas);
         INIT(HitTestMediaUIPart);
         INIT(InitializeMaximumHTTPConnectionCountPerHost);
-        INIT(IsLatchingWheelEvent);
         INIT(MeasureMediaUIPart);
         INIT(MediaControllerThemeAvailable);
         INIT(PopupMenu);
@@ -138,6 +137,7 @@ void InitWebCoreSystemInterface(void)
         INIT(ScrollbarPainterUsesOverlayScrollers);
 #else
         INIT(GetHyphenationLocationBeforeIndex);
+        INIT(GetNSEventMomentumPhase);
 #endif
         
         INIT(GetAXTextMarkerTypeID);
index c917b97028e026906d32091351dbea5357571278..c1a8ee085d75b8b239a1916b0ab83b8e06772bdf 100644 (file)
@@ -1,3 +1,15 @@
+2011-04-01  Timothy Hatcher  <timothy@apple.com>
+
+        Make momentum scroll event latching work in WebKit2 on Mac.
+
+        <rdar://problem/8751861>
+
+        Reviewed by Darin Adler.
+
+        * WebKitSystemInterface.h:
+        * libWebKitSystemInterfaceLeopard.a: Updated to remove WKIsLatchingWheelEvent and add WKGetNSEventMomentumPhase.
+        * libWebKitSystemInterfaceSnowLeopard.a: Ditto.
+
 2011-03-30  Steve Falkenburg  <sfalken@apple.com>
 
         Reviewed by Adam Roben.
index 3f3c049d4a7274332d157e5bbbccc6ac5c87ecb5..6f9c243518225087472dc4ff27b92941500b13f9 100644 (file)
@@ -358,7 +358,16 @@ void WKSetCONNECTProxyForStream(CFReadStreamRef, CFStringRef proxyHost, CFNumber
 void WKSetCONNECTProxyAuthorizationForStream(CFReadStreamRef, CFStringRef proxyAuthorizationString);
 CFHTTPMessageRef WKCopyCONNECTProxyResponse(CFReadStreamRef, CFURLRef responseURL);
 
-BOOL WKIsLatchingWheelEvent(NSEvent *);
+#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
+typedef enum {
+    WKEventPhaseNone = 0,
+    WKEventPhaseBegan = 1,
+    WKEventPhaseChanged = 2,
+    WKEventPhaseEnded = 3,
+} WKEventPhase;
+
+int WKGetNSEventMomentumPhase(NSEvent *);
+#endif
 
 #ifndef BUILDING_ON_TIGER
 void WKWindowSetAlpha(NSWindow *window, float alphaValue);
@@ -448,6 +457,10 @@ void WKContentAreaDidHide(WKScrollbarPainterControllerRef);
 
 bool WKScrollbarPainterUsesOverlayScrollers(void);
 
+NSRange WKExtractWordDefinitionTokenRangeFromContextualString(NSString *contextString, NSRange range, NSDictionary **options);
+void WKShowWordDefinitionWindow(NSAttributedString *term, NSPoint screenPoint, NSDictionary *options);
+void WKHideWordDefinitionWindow(void);
+
 #endif
 
 #ifdef __cplusplus
index 886d78a84cdbc8108f56a9580dd30ed12be9d81f..a854587ed502e323a35775b4143d252ebd9abc3b 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceLeopard.a differ
index d55a6944416fd3cb2f7131cc6c43a45eff05505f..895cd884728ca93ff240a172e00b4ad3f4b5efdd 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a differ