Changeset 194125 in webkit
- Timestamp:
- Dec 15, 2015 4:55:49 PM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r194122 r194125 1 2015-12-15 Tim Horton <timothy_horton@apple.com> 2 3 [Mac] Gesture Events should not have negative scale 4 https://bugs.webkit.org/show_bug.cgi?id=151065 5 <rdar://problem/23474123> 6 7 Reviewed by Anders Carlsson. 8 9 * page/EventHandler.cpp: 10 (WebCore::EventHandler::clear): 11 * page/EventHandler.h: 12 Make it possible to use m_gestureInitialDiameter for Mac gesture events too. 13 1 14 2015-12-15 Timothy Horton <timothy_horton@apple.com> 2 15 -
trunk/Source/WebCore/page/EventHandler.cpp
r192354 r194125 427 427 m_clickNode = nullptr; 428 428 #if ENABLE(IOS_GESTURE_EVENTS) 429 m_gestureInitialRotation = GestureUnknown; 430 #endif 431 #if ENABLE(IOS_GESTURE_EVENTS) || ENABLE(MAC_GESTURE_EVENTS) 429 432 m_gestureInitialDiameter = GestureUnknown; 430 m_gestureInitialRotation = GestureUnknown;431 #endif432 #if ENABLE(IOS_GESTURE_EVENTS) || ENABLE(MAC_GESTURE_EVENTS)433 433 m_gestureLastDiameter = GestureUnknown; 434 434 m_gestureLastRotation = GestureUnknown; -
trunk/Source/WebCore/page/EventHandler.h
r192354 r194125 513 513 514 514 #if ENABLE(IOS_GESTURE_EVENTS) 515 float m_gestureInitialRotation { GestureUnknown }; 516 #endif 517 #if ENABLE(IOS_GESTURE_EVENTS) || ENABLE(MAC_GESTURE_EVENTS) 515 518 float m_gestureInitialDiameter { GestureUnknown }; 516 float m_gestureInitialRotation { GestureUnknown };517 #endif518 #if ENABLE(IOS_GESTURE_EVENTS) || ENABLE(MAC_GESTURE_EVENTS)519 519 float m_gestureLastDiameter { GestureUnknown }; 520 520 float m_gestureLastRotation { GestureUnknown }; -
trunk/Source/WebKit2/ChangeLog
r194124 r194125 1 2015-12-15 Tim Horton <timothy_horton@apple.com> 2 3 [Mac] Gesture Events should not have negative scale 4 https://bugs.webkit.org/show_bug.cgi?id=151065 5 <rdar://problem/23474123> 6 7 Reviewed by Anders Carlsson. 8 9 * Shared/NativeWebGestureEvent.h: 10 * Shared/mac/NativeWebGestureEventMac.mm: 11 (WebKit::distanceForTouches): 12 (WebKit::NativeWebGestureEvent::NativeWebGestureEvent): 13 Compute the distance between the two oldest touches, and use that as 14 the scale (really the gesture diameter) on the event, instead of 15 passing through AppKit's magnification (which is computed differently). 16 This matches the documented behavior of the existing gesture events on iOS. 17 18 * UIProcess/API/Cocoa/WKWebView.mm: 19 (-[WKWebView touchesBeganWithEvent:]): 20 (-[WKWebView touchesMovedWithEvent:]): 21 (-[WKWebView touchesEndedWithEvent:]): 22 (-[WKWebView touchesCancelledWithEvent:]): 23 * UIProcess/API/mac/WKView.mm: 24 (-[WKView touchesBeganWithEvent:]): 25 (-[WKView touchesMovedWithEvent:]): 26 (-[WKView touchesEndedWithEvent:]): 27 (-[WKView touchesCancelledWithEvent:]): 28 Plumb touch events through to WebViewImpl. 29 30 * UIProcess/Cocoa/WebViewImpl.h: 31 * UIProcess/Cocoa/WebViewImpl.mm: 32 (WebKit::WebViewImpl::WebViewImpl): 33 (WebKit::WebViewImpl::magnifyWithEvent): 34 (WebKit::WebViewImpl::touchesOrderedByAge): 35 (WebKit::WebViewImpl::touchesBeganWithEvent): 36 (WebKit::WebViewImpl::touchesMovedWithEvent): 37 (WebKit::WebViewImpl::touchesEndedWithEvent): 38 (WebKit::WebViewImpl::touchesCancelledWithEvent): 39 (WebKit::WebViewImpl::rotateWithEvent): 40 Keep track of the most recent incoming touches, by identifier, in age order. 41 Pass them through to NativeWebGestureEvent so it can determine the gesture diameter. 42 1 43 2015-12-15 Anders Carlsson <andersca@apple.com> 2 44 -
trunk/Source/WebKit2/Shared/NativeWebGestureEvent.h
r191299 r194125 33 33 34 34 OBJC_CLASS NSEvent; 35 OBJC_CLASS NSTouch; 35 36 36 37 namespace WebKit { … … 38 39 class NativeWebGestureEvent final : public WebGestureEvent { 39 40 public: 40 explicit NativeWebGestureEvent(NSEvent *, NSView * );41 explicit NativeWebGestureEvent(NSEvent *, NSView *, Vector<NSTouch *> touches); 41 42 42 43 NSEvent *nativeEvent() const { return m_nativeEvent.get(); } -
trunk/Source/WebKit2/Shared/mac/NativeWebGestureEventMac.mm
r191299 r194125 60 60 } 61 61 62 NativeWebGestureEvent::NativeWebGestureEvent(NSEvent *event, NSView *view) 62 static CGFloat distanceForTouches(Vector<NSTouch *> touches) 63 { 64 if (touches.size() < 2) 65 return -1; 66 67 NSPoint firstTouchPosition = touches[0].normalizedPosition; 68 NSPoint secondTouchPosition = touches[1].normalizedPosition; 69 70 CGFloat dx = secondTouchPosition.x - firstTouchPosition.x; 71 CGFloat dy = secondTouchPosition.y - firstTouchPosition.y; 72 73 return sqrtf(dx * dx + dy * dy); 74 } 75 76 NativeWebGestureEvent::NativeWebGestureEvent(NSEvent *event, NSView *view, Vector<NSTouch *> touches) 63 77 : WebGestureEvent( 64 78 webEventTypeForNSEvent(event), … … 66 80 event.timestamp, 67 81 WebCore::IntPoint(pointForEvent(event, view)), 68 event.type == NSEventTypeMagnify ? event.magnification : 0,82 distanceForTouches(touches), 69 83 event.type == NSEventTypeRotate ? event.rotation : 0) 70 84 , m_nativeEvent(event) 71 85 { 86 72 87 } 73 88 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
r193489 r194125 2712 2712 } 2713 2713 2714 - (void)touchesBeganWithEvent:(NSEvent *)event 2715 { 2716 _impl->touchesBeganWithEvent(event); 2717 } 2718 2719 - (void)touchesMovedWithEvent:(NSEvent *)event 2720 { 2721 _impl->touchesMovedWithEvent(event); 2722 } 2723 2724 - (void)touchesEndedWithEvent:(NSEvent *)event 2725 { 2726 _impl->touchesEndedWithEvent(event); 2727 } 2728 2729 - (void)touchesCancelledWithEvent:(NSEvent *)event 2730 { 2731 _impl->touchesCancelledWithEvent(event); 2732 } 2733 2714 2734 - (NSTextInputContext *)_web_superInputContext 2715 2735 { -
trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm
r192834 r194125 843 843 } 844 844 845 - (void)touchesBeganWithEvent:(NSEvent *)event 846 { 847 _data->_impl->touchesBeganWithEvent(event); 848 } 849 850 - (void)touchesMovedWithEvent:(NSEvent *)event 851 { 852 _data->_impl->touchesMovedWithEvent(event); 853 } 854 855 - (void)touchesEndedWithEvent:(NSEvent *)event 856 { 857 _data->_impl->touchesEndedWithEvent(event); 858 } 859 860 - (void)touchesCancelledWithEvent:(NSEvent *)event 861 { 862 _data->_impl->touchesCancelledWithEvent(event); 863 } 864 845 865 - (instancetype)initWithFrame:(NSRect)frame processPool:(WebProcessPool&)processPool configuration:(Ref<API::PageConfiguration>&&)configuration webView:(WKWebView *)webView 846 866 { -
trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h
r192898 r194125 409 409 void smartMagnifyWithEvent(NSEvent *); 410 410 411 void touchesBeganWithEvent(NSEvent *); 412 void touchesMovedWithEvent(NSEvent *); 413 void touchesEndedWithEvent(NSEvent *); 414 void touchesCancelledWithEvent(NSEvent *); 415 411 416 void setLastMouseDownEvent(NSEvent *); 412 417 … … 492 497 bool mightBeginScrollWhileInactive(); 493 498 499 Vector<NSTouch *> touchesOrderedByAge(); 500 494 501 NSView <WebViewImplDelegate> *m_view; 495 502 std::unique_ptr<PageClient> m_pageClient; … … 603 610 RetainPtr<NSEvent> m_keyDownEventBeingResent; 604 611 Vector<WebCore::KeypressCommand>* m_collectedKeypressCommands { nullptr }; 612 613 Vector<RetainPtr<id <NSObject, NSCopying>>> m_activeTouchIdentities; 614 RetainPtr<NSArray> m_lastTouches; 605 615 }; 606 616 -
trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm
r192898 r194125 477 477 478 478 m_view.wantsLayer = YES; 479 m_view.acceptsTouchEvents = YES; 479 480 480 481 // Explicitly set the layer contents placement so AppKit will make sure that our layer has masksToBounds set to YES. … … 3117 3118 if (!m_allowsMagnification) { 3118 3119 #if ENABLE(MAC_GESTURE_EVENTS) 3119 NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, m_view );3120 NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, m_view, touchesOrderedByAge()); 3120 3121 m_page->handleGestureEvent(webEvent); 3121 3122 #endif … … 3134 3135 } 3135 3136 3136 NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, m_view );3137 NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, m_view, touchesOrderedByAge()); 3137 3138 m_page->handleGestureEvent(webEvent); 3138 3139 #else … … 3141 3142 } 3142 3143 3144 Vector<NSTouch *> WebViewImpl::touchesOrderedByAge() 3145 { 3146 Vector<NSTouch *> touches; 3147 3148 for (auto& touchIdentity : m_activeTouchIdentities) { 3149 for (NSTouch *touch in m_lastTouches.get()) { 3150 if (![touch.identity isEqual:touchIdentity.get()]) 3151 continue; 3152 touches.append(touch); 3153 break; 3154 } 3155 } 3156 3157 return touches; 3158 } 3159 3160 void WebViewImpl::touchesBeganWithEvent(NSEvent *event) 3161 { 3162 m_lastTouches = [event touchesMatchingPhase:NSTouchPhaseAny inView:m_view].allObjects; 3163 for (NSTouch *touch in [event touchesMatchingPhase:NSTouchPhaseBegan inView:m_view]) 3164 m_activeTouchIdentities.append(touch.identity); 3165 } 3166 3167 void WebViewImpl::touchesMovedWithEvent(NSEvent *event) 3168 { 3169 m_lastTouches = [event touchesMatchingPhase:NSTouchPhaseAny inView:m_view].allObjects; 3170 } 3171 3172 void WebViewImpl::touchesEndedWithEvent(NSEvent *event) 3173 { 3174 m_lastTouches = [event touchesMatchingPhase:NSTouchPhaseAny inView:m_view].allObjects; 3175 for (NSTouch *touch in [event touchesMatchingPhase:NSTouchPhaseEnded inView:m_view]) { 3176 size_t identityIndex = m_activeTouchIdentities.find(touch.identity); 3177 ASSERT(identityIndex != notFound); 3178 m_activeTouchIdentities.remove(identityIndex); 3179 } 3180 } 3181 3182 void WebViewImpl::touchesCancelledWithEvent(NSEvent *event) 3183 { 3184 m_lastTouches = [event touchesMatchingPhase:NSTouchPhaseAny inView:m_view].allObjects; 3185 for (NSTouch *touch in [event touchesMatchingPhase:NSTouchPhaseCancelled inView:m_view]) { 3186 size_t identityIndex = m_activeTouchIdentities.find(touch.identity); 3187 ASSERT(identityIndex != notFound); 3188 m_activeTouchIdentities.remove(identityIndex); 3189 } 3190 } 3191 3143 3192 void WebViewImpl::smartMagnifyWithEvent(NSEvent *event) 3144 3193 { … … 3166 3215 void WebViewImpl::rotateWithEvent(NSEvent *event) 3167 3216 { 3168 NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, m_view );3217 NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, m_view, touchesOrderedByAge()); 3169 3218 m_page->handleGestureEvent(webEvent); 3170 3219 }
Note: See TracChangeset
for help on using the changeset viewer.