Diff
Modified: branches/safari-601-branch/Source/WebCore/ChangeLog (194175 => 194176)
--- branches/safari-601-branch/Source/WebCore/ChangeLog 2015-12-16 22:39:13 UTC (rev 194175)
+++ branches/safari-601-branch/Source/WebCore/ChangeLog 2015-12-16 23:03:28 UTC (rev 194176)
@@ -1,5 +1,22 @@
2015-12-16 Babak Shafiei <[email protected]>
+ Merge r194125.
+
+ 2015-12-15 Tim Horton <[email protected]>
+
+ [Mac] Gesture Events should not have negative scale
+ https://bugs.webkit.org/show_bug.cgi?id=151065
+ <rdar://problem/23474123>
+
+ Reviewed by Anders Carlsson.
+
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::clear):
+ * page/EventHandler.h:
+ Make it possible to use m_gestureInitialDiameter for Mac gesture events too.
+
+2015-12-16 Babak Shafiei <[email protected]>
+
Merge r191299.
2015-10-19 Tim Horton <[email protected]>
Modified: branches/safari-601-branch/Source/WebCore/page/EventHandler.cpp (194175 => 194176)
--- branches/safari-601-branch/Source/WebCore/page/EventHandler.cpp 2015-12-16 22:39:13 UTC (rev 194175)
+++ branches/safari-601-branch/Source/WebCore/page/EventHandler.cpp 2015-12-16 23:03:28 UTC (rev 194176)
@@ -426,10 +426,10 @@
m_clickCount = 0;
m_clickNode = nullptr;
#if ENABLE(IOS_GESTURE_EVENTS)
- m_gestureInitialDiameter = GestureUnknown;
m_gestureInitialRotation = GestureUnknown;
#endif
#if ENABLE(IOS_GESTURE_EVENTS) || ENABLE(MAC_GESTURE_EVENTS)
+ m_gestureInitialDiameter = GestureUnknown;
m_gestureLastDiameter = GestureUnknown;
m_gestureLastRotation = GestureUnknown;
m_gestureTargets.clear();
Modified: branches/safari-601-branch/Source/WebCore/page/EventHandler.h (194175 => 194176)
--- branches/safari-601-branch/Source/WebCore/page/EventHandler.h 2015-12-16 22:39:13 UTC (rev 194175)
+++ branches/safari-601-branch/Source/WebCore/page/EventHandler.h 2015-12-16 23:03:28 UTC (rev 194176)
@@ -522,10 +522,10 @@
RefPtr<Node> m_clickNode;
#if ENABLE(IOS_GESTURE_EVENTS)
- float m_gestureInitialDiameter { GestureUnknown };
float m_gestureInitialRotation { GestureUnknown };
#endif
#if ENABLE(IOS_GESTURE_EVENTS) || ENABLE(MAC_GESTURE_EVENTS)
+ float m_gestureInitialDiameter { GestureUnknown };
float m_gestureLastDiameter { GestureUnknown };
float m_gestureLastRotation { GestureUnknown };
EventTargetSet m_gestureTargets;
Modified: branches/safari-601-branch/Source/WebKit2/ChangeLog (194175 => 194176)
--- branches/safari-601-branch/Source/WebKit2/ChangeLog 2015-12-16 22:39:13 UTC (rev 194175)
+++ branches/safari-601-branch/Source/WebKit2/ChangeLog 2015-12-16 23:03:28 UTC (rev 194176)
@@ -1,5 +1,51 @@
2015-12-16 Babak Shafiei <[email protected]>
+ Merge r194125.
+
+ 2015-12-15 Tim Horton <[email protected]>
+
+ [Mac] Gesture Events should not have negative scale
+ https://bugs.webkit.org/show_bug.cgi?id=151065
+ <rdar://problem/23474123>
+
+ Reviewed by Anders Carlsson.
+
+ * Shared/NativeWebGestureEvent.h:
+ * Shared/mac/NativeWebGestureEventMac.mm:
+ (WebKit::distanceForTouches):
+ (WebKit::NativeWebGestureEvent::NativeWebGestureEvent):
+ Compute the distance between the two oldest touches, and use that as
+ the scale (really the gesture diameter) on the event, instead of
+ passing through AppKit's magnification (which is computed differently).
+ This matches the documented behavior of the existing gesture events on iOS.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView touchesBeganWithEvent:]):
+ (-[WKWebView touchesMovedWithEvent:]):
+ (-[WKWebView touchesEndedWithEvent:]):
+ (-[WKWebView touchesCancelledWithEvent:]):
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView touchesBeganWithEvent:]):
+ (-[WKView touchesMovedWithEvent:]):
+ (-[WKView touchesEndedWithEvent:]):
+ (-[WKView touchesCancelledWithEvent:]):
+ Plumb touch events through to WebViewImpl.
+
+ * UIProcess/Cocoa/WebViewImpl.h:
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (WebKit::WebViewImpl::WebViewImpl):
+ (WebKit::WebViewImpl::magnifyWithEvent):
+ (WebKit::WebViewImpl::touchesOrderedByAge):
+ (WebKit::WebViewImpl::touchesBeganWithEvent):
+ (WebKit::WebViewImpl::touchesMovedWithEvent):
+ (WebKit::WebViewImpl::touchesEndedWithEvent):
+ (WebKit::WebViewImpl::touchesCancelledWithEvent):
+ (WebKit::WebViewImpl::rotateWithEvent):
+ Keep track of the most recent incoming touches, by identifier, in age order.
+ Pass them through to NativeWebGestureEvent so it can determine the gesture diameter.
+
+2015-12-16 Babak Shafiei <[email protected]>
+
Merge r191299.
2015-10-19 Tim Horton <[email protected]>
Modified: branches/safari-601-branch/Source/WebKit2/Shared/NativeWebGestureEvent.h (194175 => 194176)
--- branches/safari-601-branch/Source/WebKit2/Shared/NativeWebGestureEvent.h 2015-12-16 22:39:13 UTC (rev 194175)
+++ branches/safari-601-branch/Source/WebKit2/Shared/NativeWebGestureEvent.h 2015-12-16 23:03:28 UTC (rev 194176)
@@ -32,12 +32,13 @@
#include "WebGestureEvent.h"
OBJC_CLASS NSEvent;
+OBJC_CLASS NSTouch;
namespace WebKit {
class NativeWebGestureEvent final : public WebGestureEvent {
public:
- explicit NativeWebGestureEvent(NSEvent *, NSView *);
+ explicit NativeWebGestureEvent(NSEvent *, NSView *, Vector<NSTouch *> touches);
NSEvent *nativeEvent() const { return m_nativeEvent.get(); }
Modified: branches/safari-601-branch/Source/WebKit2/Shared/mac/NativeWebGestureEventMac.mm (194175 => 194176)
--- branches/safari-601-branch/Source/WebKit2/Shared/mac/NativeWebGestureEventMac.mm 2015-12-16 22:39:13 UTC (rev 194175)
+++ branches/safari-601-branch/Source/WebKit2/Shared/mac/NativeWebGestureEventMac.mm 2015-12-16 23:03:28 UTC (rev 194176)
@@ -59,16 +59,31 @@
return location;
}
-NativeWebGestureEvent::NativeWebGestureEvent(NSEvent *event, NSView *view)
+static CGFloat distanceForTouches(Vector<NSTouch *> touches)
+{
+ if (touches.size() < 2)
+ return -1;
+
+ NSPoint firstTouchPosition = touches[0].normalizedPosition;
+ NSPoint secondTouchPosition = touches[1].normalizedPosition;
+
+ CGFloat dx = secondTouchPosition.x - firstTouchPosition.x;
+ CGFloat dy = secondTouchPosition.y - firstTouchPosition.y;
+
+ return sqrtf(dx * dx + dy * dy);
+}
+
+NativeWebGestureEvent::NativeWebGestureEvent(NSEvent *event, NSView *view, Vector<NSTouch *> touches)
: WebGestureEvent(
webEventTypeForNSEvent(event),
static_cast<Modifiers>(0),
event.timestamp,
WebCore::IntPoint(pointForEvent(event, view)),
- event.type == NSEventTypeMagnify ? event.magnification : 0,
+ distanceForTouches(touches),
event.type == NSEventTypeRotate ? event.rotation : 0)
, m_nativeEvent(event)
{
+
}
} // namespace WebKit
Modified: branches/safari-601-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (194175 => 194176)
--- branches/safari-601-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2015-12-16 22:39:13 UTC (rev 194175)
+++ branches/safari-601-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2015-12-16 23:03:28 UTC (rev 194176)
@@ -1911,6 +1911,7 @@
{
return [_wkView performDragOperation:sender];
}
+
#endif // PLATFORM(MAC)
#if ENABLE(VIDEO)
Modified: branches/safari-601-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm (194175 => 194176)
--- branches/safari-601-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm 2015-12-16 22:39:13 UTC (rev 194175)
+++ branches/safari-601-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm 2015-12-16 23:03:28 UTC (rev 194176)
@@ -288,6 +288,9 @@
#if WK_API_ENABLED
_WKThumbnailView *_thumbnailView;
#endif
+
+ Vector<RetainPtr<id <NSObject, NSCopying>>> _activeTouchIdentities;
+ RetainPtr<NSArray> _lastTouches;
}
@end
@@ -3257,6 +3260,54 @@
}
}
+- (Vector<NSTouch *>)_touchesOrderedByAge
+{
+ Vector<NSTouch *> touches;
+
+ for (auto& touchIdentity : _data->_activeTouchIdentities) {
+ for (NSTouch *touch in _data->_lastTouches.get()) {
+ if (![touch.identity isEqual:touchIdentity.get()])
+ continue;
+ touches.append(touch);
+ break;
+ }
+ }
+
+ return touches;
+}
+
+- (void)touchesBeganWithEvent:(NSEvent *)event
+{
+ _data->_lastTouches = [event touchesMatchingPhase:NSTouchPhaseAny inView:self].allObjects;
+ for (NSTouch *touch in [event touchesMatchingPhase:NSTouchPhaseBegan inView:self])
+ _data->_activeTouchIdentities.append(touch.identity);
+}
+
+- (void)touchesMovedWithEvent:(NSEvent *)event
+{
+ _data->_lastTouches = [event touchesMatchingPhase:NSTouchPhaseAny inView:self].allObjects;
+}
+
+- (void)touchesEndedWithEvent:(NSEvent *)event
+{
+ _data->_lastTouches = [event touchesMatchingPhase:NSTouchPhaseAny inView:self].allObjects;
+ for (NSTouch *touch in [event touchesMatchingPhase:NSTouchPhaseEnded inView:self]) {
+ size_t identityIndex = _data->_activeTouchIdentities.find(touch.identity);
+ ASSERT(identityIndex != notFound);
+ _data->_activeTouchIdentities.remove(identityIndex);
+ }
+}
+
+- (void)touchesCancelledWithEvent:(NSEvent *)event
+{
+ _data->_lastTouches = [event touchesMatchingPhase:NSTouchPhaseAny inView:self].allObjects;
+ for (NSTouch *touch in [event touchesMatchingPhase:NSTouchPhaseCancelled inView:self]) {
+ size_t identityIndex = _data->_activeTouchIdentities.find(touch.identity);
+ ASSERT(identityIndex != notFound);
+ _data->_activeTouchIdentities.remove(identityIndex);
+ }
+}
+
- (void)_setTextIndicator:(TextIndicator&)textIndicator
{
[self _setTextIndicator:textIndicator withLifetime:TextIndicatorLifetime::Permanent];
@@ -3793,6 +3844,7 @@
[self _registerDraggedTypes];
self.wantsLayer = YES;
+ self.acceptsTouchEvents = YES;
// Explicitly set the layer contents placement so AppKit will make sure that our layer has masksToBounds set to YES.
self.layerContentsPlacement = NSViewLayerContentsPlacementTopLeft;
@@ -4546,7 +4598,7 @@
{
if (!_data->_allowsMagnification) {
#if ENABLE(MAC_GESTURE_EVENTS)
- NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, self);
+ NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, self, [self _touchesOrderedByAge]);
_data->_page->handleGestureEvent(webEvent);
#endif
[super magnifyWithEvent:event];
@@ -4563,7 +4615,7 @@
return;
}
- NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, self);
+ NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, self, [self _touchesOrderedByAge]);
_data->_page->handleGestureEvent(webEvent);
#else
_data->_gestureController->handleMagnificationGestureEvent(event, [self convertPoint:event.locationInWindow fromView:nil]);
@@ -4573,7 +4625,7 @@
#if ENABLE(MAC_GESTURE_EVENTS)
- (void)rotateWithEvent:(NSEvent *)event
{
- NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, self);
+ NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, self, [self _touchesOrderedByAge]);
_data->_page->handleGestureEvent(webEvent);
}
#endif