<!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>[194125] trunk/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/194125">194125</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2015-12-15 16:55:49 -0800 (Tue, 15 Dec 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Mac] Gesture Events should not have negative scale
https://bugs.webkit.org/show_bug.cgi?id=151065
&lt;rdar://problem/23474123&gt;

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.

* page/EventHandler.cpp:
(WebCore::EventHandler::clear):
* page/EventHandler.h:
Make it possible to use m_gestureInitialDiameter for Mac gesture events too.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorepageEventHandlercpp">trunk/Source/WebCore/page/EventHandler.cpp</a></li>
<li><a href="#trunkSourceWebCorepageEventHandlerh">trunk/Source/WebCore/page/EventHandler.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedNativeWebGestureEventh">trunk/Source/WebKit2/Shared/NativeWebGestureEvent.h</a></li>
<li><a href="#trunkSourceWebKit2SharedmacNativeWebGestureEventMacmm">trunk/Source/WebKit2/Shared/mac/NativeWebGestureEventMac.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacWKViewmm">trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebViewImplh">trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebViewImplmm">trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (194124 => 194125)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-12-16 00:52:55 UTC (rev 194124)
+++ trunk/Source/WebCore/ChangeLog        2015-12-16 00:55:49 UTC (rev 194125)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2015-12-15  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        [Mac] Gesture Events should not have negative scale
+        https://bugs.webkit.org/show_bug.cgi?id=151065
+        &lt;rdar://problem/23474123&gt;
+
+        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.
+
</ins><span class="cx"> 2015-12-15  Timothy Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Try to fix the CMake build
</span></span></pre></div>
<a id="trunkSourceWebCorepageEventHandlercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/EventHandler.cpp (194124 => 194125)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/EventHandler.cpp        2015-12-16 00:52:55 UTC (rev 194124)
+++ trunk/Source/WebCore/page/EventHandler.cpp        2015-12-16 00:55:49 UTC (rev 194125)
</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="trunkSourceWebCorepageEventHandlerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/EventHandler.h (194124 => 194125)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/EventHandler.h        2015-12-16 00:52:55 UTC (rev 194124)
+++ trunk/Source/WebCore/page/EventHandler.h        2015-12-16 00:55:49 UTC (rev 194125)
</span><span class="lines">@@ -512,10 +512,10 @@
</span><span class="cx">     RefPtr&lt;Node&gt; 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="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (194124 => 194125)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-12-16 00:52:55 UTC (rev 194124)
+++ trunk/Source/WebKit2/ChangeLog        2015-12-16 00:55:49 UTC (rev 194125)
</span><span class="lines">@@ -1,3 +1,45 @@
</span><ins>+2015-12-15  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        [Mac] Gesture Events should not have negative scale
+        https://bugs.webkit.org/show_bug.cgi?id=151065
+        &lt;rdar://problem/23474123&gt;
+
+        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.
+
</ins><span class="cx"> 2015-12-15  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Call DatabaseManager directly from WKBundle.cpp
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedNativeWebGestureEventh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/NativeWebGestureEvent.h (194124 => 194125)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/NativeWebGestureEvent.h        2015-12-16 00:52:55 UTC (rev 194124)
+++ trunk/Source/WebKit2/Shared/NativeWebGestureEvent.h        2015-12-16 00:55:49 UTC (rev 194125)
</span><span class="lines">@@ -32,12 +32,13 @@
</span><span class="cx"> #include &quot;WebGestureEvent.h&quot;
</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&lt;NSTouch *&gt; 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="trunkSourceWebKit2SharedmacNativeWebGestureEventMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/NativeWebGestureEventMac.mm (194124 => 194125)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/NativeWebGestureEventMac.mm        2015-12-16 00:52:55 UTC (rev 194124)
+++ trunk/Source/WebKit2/Shared/mac/NativeWebGestureEventMac.mm        2015-12-16 00:55:49 UTC (rev 194125)
</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&lt;NSTouch *&gt; touches)
+{
+    if (touches.size() &lt; 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&lt;NSTouch *&gt; touches)
</ins><span class="cx">     : WebGestureEvent(
</span><span class="cx">         webEventTypeForNSEvent(event),
</span><span class="cx">         static_cast&lt;Modifiers&gt;(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="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (194124 => 194125)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2015-12-16 00:52:55 UTC (rev 194124)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2015-12-16 00:55:49 UTC (rev 194125)
</span><span class="lines">@@ -2711,6 +2711,26 @@
</span><span class="cx">     [[self _ensureTextFinderClient] selectFindMatch:findMatch completionHandler:completionHandler];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)touchesBeganWithEvent:(NSEvent *)event
+{
+    _impl-&gt;touchesBeganWithEvent(event);
+}
+
+- (void)touchesMovedWithEvent:(NSEvent *)event
+{
+    _impl-&gt;touchesMovedWithEvent(event);
+}
+
+- (void)touchesEndedWithEvent:(NSEvent *)event
+{
+    _impl-&gt;touchesEndedWithEvent(event);
+}
+
+- (void)touchesCancelledWithEvent:(NSEvent *)event
+{
+    _impl-&gt;touchesCancelledWithEvent(event);
+}
+
</ins><span class="cx"> - (NSTextInputContext *)_web_superInputContext
</span><span class="cx"> {
</span><span class="cx">     return [super inputContext];
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (194124 => 194125)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2015-12-16 00:52:55 UTC (rev 194124)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2015-12-16 00:55:49 UTC (rev 194125)
</span><span class="lines">@@ -842,6 +842,26 @@
</span><span class="cx">     return _data-&gt;_impl-&gt;namesOfPromisedFilesDroppedAtDestination(dropDestination);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)touchesBeganWithEvent:(NSEvent *)event
+{
+    _data-&gt;_impl-&gt;touchesBeganWithEvent(event);
+}
+
+- (void)touchesMovedWithEvent:(NSEvent *)event
+{
+    _data-&gt;_impl-&gt;touchesMovedWithEvent(event);
+}
+
+- (void)touchesEndedWithEvent:(NSEvent *)event
+{
+    _data-&gt;_impl-&gt;touchesEndedWithEvent(event);
+}
+
+- (void)touchesCancelledWithEvent:(NSEvent *)event
+{
+    _data-&gt;_impl-&gt;touchesCancelledWithEvent(event);
+}
+
</ins><span class="cx"> - (instancetype)initWithFrame:(NSRect)frame processPool:(WebProcessPool&amp;)processPool configuration:(Ref&lt;API::PageConfiguration&gt;&amp;&amp;)configuration webView:(WKWebView *)webView
</span><span class="cx"> {
</span><span class="cx">     self = [super initWithFrame:frame];
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h (194124 => 194125)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2015-12-16 00:52:55 UTC (rev 194124)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2015-12-16 00:55:49 UTC (rev 194125)
</span><span class="lines">@@ -408,6 +408,11 @@
</span><span class="cx">     void rotateWithEvent(NSEvent *);
</span><span class="cx">     void smartMagnifyWithEvent(NSEvent *);
</span><span class="cx"> 
</span><ins>+    void touchesBeganWithEvent(NSEvent *);
+    void touchesMovedWithEvent(NSEvent *);
+    void touchesEndedWithEvent(NSEvent *);
+    void touchesCancelledWithEvent(NSEvent *);
+
</ins><span class="cx">     void setLastMouseDownEvent(NSEvent *);
</span><span class="cx"> 
</span><span class="cx">     void gestureEventWasNotHandledByWebCore(NSEvent *);
</span><span class="lines">@@ -491,6 +496,8 @@
</span><span class="cx">     bool mightBeginDragWhileInactive();
</span><span class="cx">     bool mightBeginScrollWhileInactive();
</span><span class="cx"> 
</span><ins>+    Vector&lt;NSTouch *&gt; touchesOrderedByAge();
+
</ins><span class="cx">     NSView &lt;WebViewImplDelegate&gt; *m_view;
</span><span class="cx">     std::unique_ptr&lt;PageClient&gt; m_pageClient;
</span><span class="cx">     Ref&lt;WebPageProxy&gt; m_page;
</span><span class="lines">@@ -602,6 +609,9 @@
</span><span class="cx">     // that has been already sent to WebCore.
</span><span class="cx">     RetainPtr&lt;NSEvent&gt; m_keyDownEventBeingResent;
</span><span class="cx">     Vector&lt;WebCore::KeypressCommand&gt;* m_collectedKeypressCommands { nullptr };
</span><ins>+
+    Vector&lt;RetainPtr&lt;id &lt;NSObject, NSCopying&gt;&gt;&gt; m_activeTouchIdentities;
+    RetainPtr&lt;NSArray&gt; m_lastTouches;
</ins><span class="cx"> };
</span><span class="cx">     
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm (194124 => 194125)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2015-12-16 00:52:55 UTC (rev 194124)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2015-12-16 00:55:49 UTC (rev 194125)
</span><span class="lines">@@ -476,6 +476,7 @@
</span><span class="cx">     registerDraggedTypes();
</span><span class="cx"> 
</span><span class="cx">     m_view.wantsLayer = YES;
</span><ins>+    m_view.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">     m_view.layerContentsPlacement = NSViewLayerContentsPlacementTopLeft;
</span><span class="lines">@@ -3116,7 +3117,7 @@
</span><span class="cx"> {
</span><span class="cx">     if (!m_allowsMagnification) {
</span><span class="cx"> #if ENABLE(MAC_GESTURE_EVENTS)
</span><del>-        NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, m_view);
</del><ins>+        NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, m_view, touchesOrderedByAge());
</ins><span class="cx">         m_page-&gt;handleGestureEvent(webEvent);
</span><span class="cx"> #endif
</span><span class="cx">         [m_view _web_superMagnifyWithEvent:event];
</span><span class="lines">@@ -3133,13 +3134,61 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, m_view);
</del><ins>+    NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, m_view, touchesOrderedByAge());
</ins><span class="cx">     m_page-&gt;handleGestureEvent(webEvent);
</span><span class="cx"> #else
</span><span class="cx">     gestureController.handleMagnificationGestureEvent(event, [m_view convertPoint:event.locationInWindow fromView:nil]);
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Vector&lt;NSTouch *&gt; WebViewImpl::touchesOrderedByAge()
+{
+    Vector&lt;NSTouch *&gt; touches;
+
+    for (auto&amp; touchIdentity : m_activeTouchIdentities) {
+        for (NSTouch *touch in m_lastTouches.get()) {
+            if (![touch.identity isEqual:touchIdentity.get()])
+                continue;
+            touches.append(touch);
+            break;
+        }
+    }
+
+    return touches;
+}
+
+void WebViewImpl::touchesBeganWithEvent(NSEvent *event)
+{
+    m_lastTouches = [event touchesMatchingPhase:NSTouchPhaseAny inView:m_view].allObjects;
+    for (NSTouch *touch in [event touchesMatchingPhase:NSTouchPhaseBegan inView:m_view])
+        m_activeTouchIdentities.append(touch.identity);
+}
+
+void WebViewImpl::touchesMovedWithEvent(NSEvent *event)
+{
+    m_lastTouches = [event touchesMatchingPhase:NSTouchPhaseAny inView:m_view].allObjects;
+}
+
+void WebViewImpl::touchesEndedWithEvent(NSEvent *event)
+{
+    m_lastTouches = [event touchesMatchingPhase:NSTouchPhaseAny inView:m_view].allObjects;
+    for (NSTouch *touch in [event touchesMatchingPhase:NSTouchPhaseEnded inView:m_view]) {
+        size_t identityIndex = m_activeTouchIdentities.find(touch.identity);
+        ASSERT(identityIndex != notFound);
+        m_activeTouchIdentities.remove(identityIndex);
+    }
+}
+
+void WebViewImpl::touchesCancelledWithEvent(NSEvent *event)
+{
+    m_lastTouches = [event touchesMatchingPhase:NSTouchPhaseAny inView:m_view].allObjects;
+    for (NSTouch *touch in [event touchesMatchingPhase:NSTouchPhaseCancelled inView:m_view]) {
+        size_t identityIndex = m_activeTouchIdentities.find(touch.identity);
+        ASSERT(identityIndex != notFound);
+        m_activeTouchIdentities.remove(identityIndex);
+    }
+}
+
</ins><span class="cx"> void WebViewImpl::smartMagnifyWithEvent(NSEvent *event)
</span><span class="cx"> {
</span><span class="cx">     if (!m_allowsMagnification) {
</span><span class="lines">@@ -3165,7 +3214,7 @@
</span><span class="cx"> #if ENABLE(MAC_GESTURE_EVENTS)
</span><span class="cx"> void WebViewImpl::rotateWithEvent(NSEvent *event)
</span><span class="cx"> {
</span><del>-    NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, m_view);
</del><ins>+    NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, m_view, touchesOrderedByAge());
</ins><span class="cx">     m_page-&gt;handleGestureEvent(webEvent);
</span><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>

</body>
</html>