<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[194176] branches/safari-601-branch/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/194176">194176</a></dd>
<dt>Author</dt> <dd>bshafiei@apple.com</dd>
<dt>Date</dt> <dd>2015-12-16 15:03:28 -0800 (Wed, 16 Dec 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/194125">r194125</a>. rdar://problem/23791292</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari601branchSourceWebCoreChangeLog">branches/safari-601-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari601branchSourceWebCorepageEventHandlercpp">branches/safari-601-branch/Source/WebCore/page/EventHandler.cpp</a></li>
<li><a href="#branchessafari601branchSourceWebCorepageEventHandlerh">branches/safari-601-branch/Source/WebCore/page/EventHandler.h</a></li>
<li><a href="#branchessafari601branchSourceWebKit2ChangeLog">branches/safari-601-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari601branchSourceWebKit2SharedNativeWebGestureEventh">branches/safari-601-branch/Source/WebKit2/Shared/NativeWebGestureEvent.h</a></li>
<li><a href="#branchessafari601branchSourceWebKit2SharedmacNativeWebGestureEventMacmm">branches/safari-601-branch/Source/WebKit2/Shared/mac/NativeWebGestureEventMac.mm</a></li>
<li><a href="#branchessafari601branchSourceWebKit2UIProcessAPICocoaWKWebViewmm">branches/safari-601-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#branchessafari601branchSourceWebKit2UIProcessAPImacWKViewmm">branches/safari-601-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari601branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/ChangeLog (194175 => 194176)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,5 +1,22 @@
</span><span class="cx"> 2015-12-16 Babak Shafiei <bshafiei@apple.com>
</span><span class="cx">
</span><ins>+ Merge r194125.
+
+ 2015-12-15 Tim Horton <timothy_horton@apple.com>
+
+ [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 <bshafiei@apple.com>
+
</ins><span class="cx"> Merge r191299.
</span><span class="cx">
</span><span class="cx"> 2015-10-19 Tim Horton <timothy_horton@apple.com>
</span></span></pre></div>
<a id="branchessafari601branchSourceWebCorepageEventHandlercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/page/EventHandler.cpp (194175 => 194176)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -426,10 +426,10 @@
</span><span class="cx"> m_clickCount = 0;
</span><span class="cx"> m_clickNode = nullptr;
</span><span class="cx"> #if ENABLE(IOS_GESTURE_EVENTS)
</span><del>- m_gestureInitialDiameter = GestureUnknown;
</del><span class="cx"> m_gestureInitialRotation = GestureUnknown;
</span><span class="cx"> #endif
</span><span class="cx"> #if ENABLE(IOS_GESTURE_EVENTS) || ENABLE(MAC_GESTURE_EVENTS)
</span><ins>+ m_gestureInitialDiameter = GestureUnknown;
</ins><span class="cx"> m_gestureLastDiameter = GestureUnknown;
</span><span class="cx"> m_gestureLastRotation = GestureUnknown;
</span><span class="cx"> m_gestureTargets.clear();
</span></span></pre></div>
<a id="branchessafari601branchSourceWebCorepageEventHandlerh"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/page/EventHandler.h (194175 => 194176)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -522,10 +522,10 @@
</span><span class="cx"> RefPtr<Node> m_clickNode;
</span><span class="cx">
</span><span class="cx"> #if ENABLE(IOS_GESTURE_EVENTS)
</span><del>- float m_gestureInitialDiameter { GestureUnknown };
</del><span class="cx"> float m_gestureInitialRotation { GestureUnknown };
</span><span class="cx"> #endif
</span><span class="cx"> #if ENABLE(IOS_GESTURE_EVENTS) || ENABLE(MAC_GESTURE_EVENTS)
</span><ins>+ float m_gestureInitialDiameter { GestureUnknown };
</ins><span class="cx"> float m_gestureLastDiameter { GestureUnknown };
</span><span class="cx"> float m_gestureLastRotation { GestureUnknown };
</span><span class="cx"> EventTargetSet m_gestureTargets;
</span></span></pre></div>
<a id="branchessafari601branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebKit2/ChangeLog (194175 => 194176)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,5 +1,51 @@
</span><span class="cx"> 2015-12-16 Babak Shafiei <bshafiei@apple.com>
</span><span class="cx">
</span><ins>+ Merge r194125.
+
+ 2015-12-15 Tim Horton <timothy_horton@apple.com>
+
+ [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 <bshafiei@apple.com>
+
</ins><span class="cx"> Merge r191299.
</span><span class="cx">
</span><span class="cx"> 2015-10-19 Tim Horton <timothy_horton@apple.com>
</span></span></pre></div>
<a id="branchessafari601branchSourceWebKit2SharedNativeWebGestureEventh"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebKit2/Shared/NativeWebGestureEvent.h (194175 => 194176)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -32,12 +32,13 @@
</span><span class="cx"> #include "WebGestureEvent.h"
</span><span class="cx">
</span><span class="cx"> OBJC_CLASS NSEvent;
</span><ins>+OBJC_CLASS NSTouch;
</ins><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><span class="cx"> class NativeWebGestureEvent final : public WebGestureEvent {
</span><span class="cx"> public:
</span><del>- explicit NativeWebGestureEvent(NSEvent *, NSView *);
</del><ins>+ explicit NativeWebGestureEvent(NSEvent *, NSView *, Vector<NSTouch *> touches);
</ins><span class="cx">
</span><span class="cx"> NSEvent *nativeEvent() const { return m_nativeEvent.get(); }
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari601branchSourceWebKit2SharedmacNativeWebGestureEventMacmm"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebKit2/Shared/mac/NativeWebGestureEventMac.mm (194175 => 194176)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -59,16 +59,31 @@
</span><span class="cx"> return location;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-NativeWebGestureEvent::NativeWebGestureEvent(NSEvent *event, NSView *view)
</del><ins>+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)
</ins><span class="cx"> : WebGestureEvent(
</span><span class="cx"> webEventTypeForNSEvent(event),
</span><span class="cx"> static_cast<Modifiers>(0),
</span><span class="cx"> event.timestamp,
</span><span class="cx"> WebCore::IntPoint(pointForEvent(event, view)),
</span><del>- event.type == NSEventTypeMagnify ? event.magnification : 0,
</del><ins>+ distanceForTouches(touches),
</ins><span class="cx"> event.type == NSEventTypeRotate ? event.rotation : 0)
</span><span class="cx"> , m_nativeEvent(event)
</span><span class="cx"> {
</span><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="branchessafari601branchSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (194175 => 194176)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1911,6 +1911,7 @@
</span><span class="cx"> {
</span><span class="cx"> return [_wkView performDragOperation:sender];
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> #endif // PLATFORM(MAC)
</span><span class="cx">
</span><span class="cx"> #if ENABLE(VIDEO)
</span></span></pre></div>
<a id="branchessafari601branchSourceWebKit2UIProcessAPImacWKViewmm"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm (194175 => 194176)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -288,6 +288,9 @@
</span><span class="cx"> #if WK_API_ENABLED
</span><span class="cx"> _WKThumbnailView *_thumbnailView;
</span><span class="cx"> #endif
</span><ins>+
+ Vector<RetainPtr<id <NSObject, NSCopying>>> _activeTouchIdentities;
+ RetainPtr<NSArray> _lastTouches;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> @end
</span><span class="lines">@@ -3257,6 +3260,54 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (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);
+ }
+}
+
</ins><span class="cx"> - (void)_setTextIndicator:(TextIndicator&)textIndicator
</span><span class="cx"> {
</span><span class="cx"> [self _setTextIndicator:textIndicator withLifetime:TextIndicatorLifetime::Permanent];
</span><span class="lines">@@ -3793,6 +3844,7 @@
</span><span class="cx"> [self _registerDraggedTypes];
</span><span class="cx">
</span><span class="cx"> self.wantsLayer = YES;
</span><ins>+ self.acceptsTouchEvents = YES;
</ins><span class="cx">
</span><span class="cx"> // Explicitly set the layer contents placement so AppKit will make sure that our layer has masksToBounds set to YES.
</span><span class="cx"> self.layerContentsPlacement = NSViewLayerContentsPlacementTopLeft;
</span><span class="lines">@@ -4546,7 +4598,7 @@
</span><span class="cx"> {
</span><span class="cx"> if (!_data->_allowsMagnification) {
</span><span class="cx"> #if ENABLE(MAC_GESTURE_EVENTS)
</span><del>- NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, self);
</del><ins>+ NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, self, [self _touchesOrderedByAge]);
</ins><span class="cx"> _data->_page->handleGestureEvent(webEvent);
</span><span class="cx"> #endif
</span><span class="cx"> [super magnifyWithEvent:event];
</span><span class="lines">@@ -4563,7 +4615,7 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, self);
</del><ins>+ NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, self, [self _touchesOrderedByAge]);
</ins><span class="cx"> _data->_page->handleGestureEvent(webEvent);
</span><span class="cx"> #else
</span><span class="cx"> _data->_gestureController->handleMagnificationGestureEvent(event, [self convertPoint:event.locationInWindow fromView:nil]);
</span><span class="lines">@@ -4573,7 +4625,7 @@
</span><span class="cx"> #if ENABLE(MAC_GESTURE_EVENTS)
</span><span class="cx"> - (void)rotateWithEvent:(NSEvent *)event
</span><span class="cx"> {
</span><del>- NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, self);
</del><ins>+ NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, self, [self _touchesOrderedByAge]);
</ins><span class="cx"> _data->_page->handleGestureEvent(webEvent);
</span><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>
</body>
</html>