<!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>[191634] 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/191634">191634</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2015-10-27 13:09:29 -0700 (Tue, 27 Oct 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>WKView being inside WKWebView leads to weird API issues
https://bugs.webkit.org/show_bug.cgi?id=150174

Reviewed by Anders Carlsson.

* UIProcess/API/mac/WKView.mm:
(-[WKView scrollWheel:]):
(-[WKView swipeWithEvent:]):
(-[WKView _superSwipeWithEvent:]):
(-[WKView _superMagnifyWithEvent:]):
(-[WKView _superSmartMagnifyWithEvent:]):
(-[WKView _processDidExit]):
(-[WKView setAllowsBackForwardNavigationGestures:]):
(-[WKView allowsBackForwardNavigationGestures]):
(-[WKView setAllowsMagnification:]):
(-[WKView allowsMagnification]):
(-[WKView magnifyWithEvent:]):
(-[WKView rotateWithEvent:]):
(-[WKView _gestureEventWasNotHandledByWebCore:]):
(-[WKView smartMagnifyWithEvent:]):
(-[WKView setMagnification:centeredAtPoint:]):
(-[WKView setMagnification:]):
(-[WKView magnification]):
(-[WKView _setCustomSwipeViews:]):
(-[WKView _setCustomSwipeViewsTopContentInset:]):
(-[WKView _tryToSwipeWithEvent:ignoringPinnedState:]):
(-[WKView _setDidMoveSwipeSnapshotCallback:]):
(-[WKView _ensureGestureController]): Deleted.
(takeWindowSnapshot): Deleted.
(-[WKView _takeViewSnapshot]): Deleted.
(-[WKView _wheelEventWasNotHandledByWebCore:]): Deleted.
(-[WKView _didFirstVisuallyNonEmptyLayoutForMainFrame]): Deleted.
(-[WKView _didFinishLoadForMainFrame]): Deleted.
(-[WKView _didFailLoadForMainFrame]): Deleted.
(-[WKView _didSameDocumentNavigationForMainFrame:]): Deleted.
(-[WKView _removeNavigationGestureSnapshot]): Deleted.
* UIProcess/API/mac/WKViewInternal.h:
* UIProcess/Cocoa/WebViewImpl.h:
(WebKit::WebViewImpl::gestureController):
(WebKit::WebViewImpl::allowsBackForwardNavigationGestures):
(WebKit::WebViewImpl::allowsMagnification):
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::takeWindowSnapshot):
(WebKit::WebViewImpl::takeViewSnapshot):
(WebKit::WebViewImpl::ensureGestureController):
(WebKit::WebViewImpl::resetGestureController):
(WebKit::WebViewImpl::setAllowsBackForwardNavigationGestures):
(WebKit::WebViewImpl::setAllowsMagnification):
(WebKit::WebViewImpl::setMagnification):
(WebKit::WebViewImpl::magnification):
(WebKit::WebViewImpl::setCustomSwipeViews):
(WebKit::WebViewImpl::setCustomSwipeViewsTopContentInset):
(WebKit::WebViewImpl::tryToSwipeWithEvent):
(WebKit::WebViewImpl::setDidMoveSwipeSnapshotCallback):
(WebKit::WebViewImpl::scrollWheel):
(WebKit::WebViewImpl::swipeWithEvent):
(WebKit::WebViewImpl::magnifyWithEvent):
(WebKit::WebViewImpl::smartMagnifyWithEvent):
(WebKit::WebViewImpl::rotateWithEvent):
(WebKit::WebViewImpl::gestureEventWasNotHandledByWebCore):
(WebKit::WebViewImpl::gestureEventWasNotHandledByWebCoreFromViewOnly):
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::takeViewSnapshot):
(WebKit::PageClientImpl::wheelEventWasNotHandledByWebCore):
(WebKit::PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame):
(WebKit::PageClientImpl::didFinishLoadForMainFrame):
(WebKit::PageClientImpl::didFailLoadForMainFrame):
(WebKit::PageClientImpl::didSameDocumentNavigationForMainFrame):
(WebKit::PageClientImpl::removeNavigationGestureSnapshot):
Move swipe, zoom, rotate, and snapshotting code.

* platform/spi/cg/CoreGraphicsSPI.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformspicgCoreGraphicsSPIh">trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacWKViewmm">trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacWKViewInternalh">trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h</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>
<li><a href="#trunkSourceWebKit2UIProcessmacPageClientImplmm">trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (191633 => 191634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-10-27 20:01:08 UTC (rev 191633)
+++ trunk/Source/WebCore/ChangeLog        2015-10-27 20:09:29 UTC (rev 191634)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2015-10-27  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        WKView being inside WKWebView leads to weird API issues
+        https://bugs.webkit.org/show_bug.cgi?id=150174
+
+        Reviewed by Anders Carlsson.
+
+        * platform/spi/cg/CoreGraphicsSPI.h:
+
</ins><span class="cx"> 2015-10-27  Zhuo Li  &lt;zachli@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add WebKit API to clear data type Search Field Recent Searches.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformspicgCoreGraphicsSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h (191633 => 191634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h        2015-10-27 20:01:08 UTC (rev 191633)
+++ trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h        2015-10-27 20:09:29 UTC (rev 191634)
</span><span class="lines">@@ -182,6 +182,7 @@
</span><span class="cx"> CFArrayRef CGSHWCaptureWindowList(CGSConnectionID cid, CGSWindowIDList windowList, CGSWindowCount windowCount, CGSWindowCaptureOptions options);
</span><span class="cx"> CGError CGSSetConnectionProperty(CGSConnectionID, CGSConnectionID ownerCid, CFStringRef key, CFTypeRef value);
</span><span class="cx"> CGError CGSCopyConnectionProperty(CGSConnectionID, CGSConnectionID ownerCid, CFStringRef key, CFTypeRef *value);
</span><ins>+CGError CGSGetScreenRectForWindow(CGSConnectionID, CGSWindowID, CGRect *);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> WTF_EXTERN_C_END
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (191633 => 191634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-10-27 20:01:08 UTC (rev 191633)
+++ trunk/Source/WebKit2/ChangeLog        2015-10-27 20:09:29 UTC (rev 191634)
</span><span class="lines">@@ -1,3 +1,76 @@
</span><ins>+2015-10-27  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        WKView being inside WKWebView leads to weird API issues
+        https://bugs.webkit.org/show_bug.cgi?id=150174
+
+        Reviewed by Anders Carlsson.
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView scrollWheel:]):
+        (-[WKView swipeWithEvent:]):
+        (-[WKView _superSwipeWithEvent:]):
+        (-[WKView _superMagnifyWithEvent:]):
+        (-[WKView _superSmartMagnifyWithEvent:]):
+        (-[WKView _processDidExit]):
+        (-[WKView setAllowsBackForwardNavigationGestures:]):
+        (-[WKView allowsBackForwardNavigationGestures]):
+        (-[WKView setAllowsMagnification:]):
+        (-[WKView allowsMagnification]):
+        (-[WKView magnifyWithEvent:]):
+        (-[WKView rotateWithEvent:]):
+        (-[WKView _gestureEventWasNotHandledByWebCore:]):
+        (-[WKView smartMagnifyWithEvent:]):
+        (-[WKView setMagnification:centeredAtPoint:]):
+        (-[WKView setMagnification:]):
+        (-[WKView magnification]):
+        (-[WKView _setCustomSwipeViews:]):
+        (-[WKView _setCustomSwipeViewsTopContentInset:]):
+        (-[WKView _tryToSwipeWithEvent:ignoringPinnedState:]):
+        (-[WKView _setDidMoveSwipeSnapshotCallback:]):
+        (-[WKView _ensureGestureController]): Deleted.
+        (takeWindowSnapshot): Deleted.
+        (-[WKView _takeViewSnapshot]): Deleted.
+        (-[WKView _wheelEventWasNotHandledByWebCore:]): Deleted.
+        (-[WKView _didFirstVisuallyNonEmptyLayoutForMainFrame]): Deleted.
+        (-[WKView _didFinishLoadForMainFrame]): Deleted.
+        (-[WKView _didFailLoadForMainFrame]): Deleted.
+        (-[WKView _didSameDocumentNavigationForMainFrame:]): Deleted.
+        (-[WKView _removeNavigationGestureSnapshot]): Deleted.
+        * UIProcess/API/mac/WKViewInternal.h:
+        * UIProcess/Cocoa/WebViewImpl.h:
+        (WebKit::WebViewImpl::gestureController):
+        (WebKit::WebViewImpl::allowsBackForwardNavigationGestures):
+        (WebKit::WebViewImpl::allowsMagnification):
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::takeWindowSnapshot):
+        (WebKit::WebViewImpl::takeViewSnapshot):
+        (WebKit::WebViewImpl::ensureGestureController):
+        (WebKit::WebViewImpl::resetGestureController):
+        (WebKit::WebViewImpl::setAllowsBackForwardNavigationGestures):
+        (WebKit::WebViewImpl::setAllowsMagnification):
+        (WebKit::WebViewImpl::setMagnification):
+        (WebKit::WebViewImpl::magnification):
+        (WebKit::WebViewImpl::setCustomSwipeViews):
+        (WebKit::WebViewImpl::setCustomSwipeViewsTopContentInset):
+        (WebKit::WebViewImpl::tryToSwipeWithEvent):
+        (WebKit::WebViewImpl::setDidMoveSwipeSnapshotCallback):
+        (WebKit::WebViewImpl::scrollWheel):
+        (WebKit::WebViewImpl::swipeWithEvent):
+        (WebKit::WebViewImpl::magnifyWithEvent):
+        (WebKit::WebViewImpl::smartMagnifyWithEvent):
+        (WebKit::WebViewImpl::rotateWithEvent):
+        (WebKit::WebViewImpl::gestureEventWasNotHandledByWebCore):
+        (WebKit::WebViewImpl::gestureEventWasNotHandledByWebCoreFromViewOnly):
+        * UIProcess/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::takeViewSnapshot):
+        (WebKit::PageClientImpl::wheelEventWasNotHandledByWebCore):
+        (WebKit::PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame):
+        (WebKit::PageClientImpl::didFinishLoadForMainFrame):
+        (WebKit::PageClientImpl::didFailLoadForMainFrame):
+        (WebKit::PageClientImpl::didSameDocumentNavigationForMainFrame):
+        (WebKit::PageClientImpl::removeNavigationGestureSnapshot):
+        Move swipe, zoom, rotate, and snapshotting code.
+
</ins><span class="cx"> 2015-10-27  Zhuo Li  &lt;zachli@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add WebKit API to clear data type Search Field Recent Searches.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (191633 => 191634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2015-10-27 20:01:08 UTC (rev 191633)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2015-10-27 20:09:29 UTC (rev 191634)
</span><span class="lines">@@ -41,7 +41,6 @@
</span><span class="cx"> #import &quot;EditorState.h&quot;
</span><span class="cx"> #import &quot;LayerTreeContext.h&quot;
</span><span class="cx"> #import &quot;Logging.h&quot;
</span><del>-#import &quot;NativeWebGestureEvent.h&quot;
</del><span class="cx"> #import &quot;NativeWebKeyboardEvent.h&quot;
</span><span class="cx"> #import &quot;NativeWebMouseEvent.h&quot;
</span><span class="cx"> #import &quot;NativeWebWheelEvent.h&quot;
</span><span class="lines">@@ -54,8 +53,6 @@
</span><span class="cx"> #import &quot;TextChecker.h&quot;
</span><span class="cx"> #import &quot;TextCheckerState.h&quot;
</span><span class="cx"> #import &quot;TiledCoreAnimationDrawingAreaProxy.h&quot;
</span><del>-#import &quot;ViewGestureController.h&quot;
-#import &quot;ViewSnapshotStore.h&quot;
</del><span class="cx"> #import &quot;WKAPICast.h&quot;
</span><span class="cx"> #import &quot;WKFullScreenWindowController.h&quot;
</span><span class="cx"> #import &quot;WKLayoutMode.h&quot;
</span><span class="lines">@@ -83,6 +80,7 @@
</span><span class="cx"> #import &lt;QuartzCore/QuartzCore.h&gt;
</span><span class="cx"> #import &lt;WebCore/AXObjectCache.h&gt;
</span><span class="cx"> #import &lt;WebCore/ColorMac.h&gt;
</span><ins>+#import &lt;WebCore/CoreGraphicsSPI.h&gt;
</ins><span class="cx"> #import &lt;WebCore/DataDetectorsSPI.h&gt;
</span><span class="cx"> #import &lt;WebCore/DictionaryLookup.h&gt;
</span><span class="cx"> #import &lt;WebCore/DragController.h&gt;
</span><span class="lines">@@ -131,17 +129,6 @@
</span><span class="cx"> @end
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if defined(__has_include) &amp;&amp; __has_include(&lt;CoreGraphics/CoreGraphicsPrivate.h&gt;)
-#import &lt;CoreGraphics/CoreGraphicsPrivate.h&gt;
-#endif
-
-extern &quot;C&quot; {
-typedef uint32_t CGSConnectionID;
-typedef uint32_t CGSWindowID;
-CGSConnectionID CGSMainConnectionID(void);
-CGError CGSGetScreenRectForWindow(CGSConnectionID cid, CGSWindowID wid, CGRect *rect);
-};
-
</del><span class="cx"> using namespace WebKit;
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="lines">@@ -204,10 +191,6 @@
</span><span class="cx"> 
</span><span class="cx">     BOOL _windowOcclusionDetectionEnabled;
</span><span class="cx"> 
</span><del>-    std::unique_ptr&lt;ViewGestureController&gt; _gestureController;
-    BOOL _allowsMagnification;
-    BOOL _allowsBackForwardNavigationGestures;
-
</del><span class="cx">     CGFloat _totalHeightOfBanners;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1010,48 +993,14 @@
</span><span class="cx"> 
</span><span class="cx"> #undef NATIVE_MOUSE_EVENT_HANDLER
</span><span class="cx"> 
</span><del>-- (void)_ensureGestureController
-{
-    if (_data-&gt;_gestureController)
-        return;
-
-    _data-&gt;_gestureController = std::make_unique&lt;ViewGestureController&gt;(*_data-&gt;_page);
-}
-
</del><span class="cx"> - (void)scrollWheel:(NSEvent *)event
</span><span class="cx"> {
</span><del>-    if (_data-&gt;_impl-&gt;ignoresAllEvents())
-        return;
-
-    if (event.phase == NSEventPhaseBegan)
-        [self _dismissContentRelativeChildWindowsWithAnimation:NO];
-
-    if (_data-&gt;_allowsBackForwardNavigationGestures) {
-        [self _ensureGestureController];
-        if (_data-&gt;_gestureController-&gt;handleScrollWheelEvent(event))
-            return;
-    }
-
-    NativeWebWheelEvent webEvent = NativeWebWheelEvent(event, self);
-    _data-&gt;_page-&gt;handleWheelEvent(webEvent);
</del><ins>+    _data-&gt;_impl-&gt;scrollWheel(event);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)swipeWithEvent:(NSEvent *)event
</span><span class="cx"> {
</span><del>-    if (_data-&gt;_impl-&gt;ignoresNonWheelEvents())
-        return;
-
-    if (!_data-&gt;_allowsBackForwardNavigationGestures) {
-        [super swipeWithEvent:event];
-        return;
-    }
-
-    if (event.deltaX &gt; 0.0)
-        _data-&gt;_page-&gt;goBack();
-    else if (event.deltaX &lt; 0.0)
-        _data-&gt;_page-&gt;goForward();
-    else
-        [super swipeWithEvent:event];
</del><ins>+    _data-&gt;_impl-&gt;swipeWithEvent(event);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)mouseMoved:(NSEvent *)event
</span><span class="lines">@@ -2078,6 +2027,21 @@
</span><span class="cx">     [super quickLookWithEvent:event];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)_superSwipeWithEvent:(NSEvent *)event
+{
+    [super swipeWithEvent:event];
+}
+
+- (void)_superMagnifyWithEvent:(NSEvent *)event
+{
+    [super magnifyWithEvent:event];
+}
+
+- (void)_superSmartMagnifyWithEvent:(NSEvent *)event
+{
+    [super smartMagnifyWithEvent:event];
+}
+
</ins><span class="cx"> - (void)_superRemoveTrackingRect:(NSTrackingRectTag)tag
</span><span class="cx"> {
</span><span class="cx">     [super removeTrackingRect:tag];
</span><span class="lines">@@ -2316,7 +2280,7 @@
</span><span class="cx"> 
</span><span class="cx">     [self _updateRemoteAccessibilityRegistration:NO];
</span><span class="cx"> 
</span><del>-    _data-&gt;_gestureController = nullptr;
</del><ins>+    _data-&gt;_impl-&gt;resetGestureController();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_pageClosed
</span><span class="lines">@@ -2419,81 +2383,6 @@
</span><span class="cx">     _data-&gt;_impl-&gt;toolTipChanged(oldToolTip, newToolTip);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static RetainPtr&lt;CGImageRef&gt; takeWindowSnapshot(CGSWindowID windowID, bool captureAtNominalResolution)
-{
-    CGSWindowCaptureOptions options = kCGSCaptureIgnoreGlobalClipShape;
-    if (captureAtNominalResolution)
-        options |= kCGSWindowCaptureNominalResolution;
-    RetainPtr&lt;CFArrayRef&gt; windowSnapshotImages = adoptCF(CGSHWCaptureWindowList(CGSMainConnectionID(), &amp;windowID, 1, options));
-
-    if (windowSnapshotImages &amp;&amp; CFArrayGetCount(windowSnapshotImages.get()))
-        return (CGImageRef)CFArrayGetValueAtIndex(windowSnapshotImages.get(), 0);
-
-    // Fall back to the non-hardware capture path if we didn't get a snapshot
-    // (which usually happens if the window is fully off-screen).
-    CGWindowImageOption imageOptions = kCGWindowImageBoundsIgnoreFraming | kCGWindowImageShouldBeOpaque;
-    if (captureAtNominalResolution)
-        imageOptions |= kCGWindowImageNominalResolution;
-    return adoptCF(CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, windowID, imageOptions));
-}
-
-- (PassRefPtr&lt;ViewSnapshot&gt;)_takeViewSnapshot
-{
-    NSWindow *window = self.window;
-
-    CGSWindowID windowID = (CGSWindowID)[window windowNumber];
-    if (!windowID || ![window isVisible])
-        return nullptr;
-
-    RetainPtr&lt;CGImageRef&gt; windowSnapshotImage = takeWindowSnapshot(windowID, false);
-    if (!windowSnapshotImage)
-        return nullptr;
-
-    // Work around &lt;rdar://problem/17084993&gt;; re-request the snapshot at kCGWindowImageNominalResolution if it was captured at the wrong scale.
-    CGFloat desiredSnapshotWidth = window.frame.size.width * window.screen.backingScaleFactor;
-    if (CGImageGetWidth(windowSnapshotImage.get()) != desiredSnapshotWidth)
-        windowSnapshotImage = takeWindowSnapshot(windowID, true);
-
-    if (!windowSnapshotImage)
-        return nullptr;
-
-    [self _ensureGestureController];
-
-    NSRect windowCaptureRect;
-    FloatRect boundsForCustomSwipeViews = _data-&gt;_gestureController-&gt;windowRelativeBoundsForCustomSwipeViews();
-    if (!boundsForCustomSwipeViews.isEmpty())
-        windowCaptureRect = boundsForCustomSwipeViews;
-    else {
-        NSRect unobscuredBounds = self.bounds;
-        float topContentInset = _data-&gt;_page-&gt;topContentInset();
-        unobscuredBounds.origin.y += topContentInset;
-        unobscuredBounds.size.height -= topContentInset;
-        windowCaptureRect = [self convertRect:unobscuredBounds toView:nil];
-    }
-
-    NSRect windowCaptureScreenRect = [window convertRectToScreen:windowCaptureRect];
-    CGRect windowScreenRect;
-    CGSGetScreenRectForWindow(CGSMainConnectionID(), (CGSWindowID)[window windowNumber], &amp;windowScreenRect);
-
-    NSRect croppedImageRect = windowCaptureRect;
-    croppedImageRect.origin.y = windowScreenRect.size.height - windowCaptureScreenRect.size.height - NSMinY(windowCaptureRect);
-
-    auto croppedSnapshotImage = adoptCF(CGImageCreateWithImageInRect(windowSnapshotImage.get(), NSRectToCGRect([window convertRectToBacking:croppedImageRect])));
-
-    auto surface = IOSurface::createFromImage(croppedSnapshotImage.get());
-    if (!surface)
-        return nullptr;
-    surface-&gt;setIsVolatile(true);
-
-    return ViewSnapshot::create(WTF::move(surface));
-}
-
-- (void)_wheelEventWasNotHandledByWebCore:(NSEvent *)event
-{
-    if (_data-&gt;_gestureController)
-        _data-&gt;_gestureController-&gt;wheelEventWasNotHandledByWebCore(event);
-}
-
</del><span class="cx"> - (void)_setAccessibilityWebProcessToken:(NSData *)data
</span><span class="cx"> {
</span><span class="cx">     _data-&gt;_remoteAccessibilityChild = WKAXRemoteElementForToken(data);
</span><span class="lines">@@ -2784,12 +2673,6 @@
</span><span class="cx"> }
</span><span class="cx"> #endif // WK_API_ENABLED
</span><span class="cx"> 
</span><del>-- (void)_didFirstVisuallyNonEmptyLayoutForMainFrame
-{
-    if (_data-&gt;_gestureController)
-        _data-&gt;_gestureController-&gt;didFirstVisuallyNonEmptyLayoutForMainFrame();
-}
-
</del><span class="cx"> #if WK_API_ENABLED
</span><span class="cx"> - (_WKRemoteObjectRegistry *)_remoteObjectRegistry
</span><span class="cx"> {
</span><span class="lines">@@ -2802,30 +2685,6 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-- (void)_didFinishLoadForMainFrame
-{
-    if (_data-&gt;_gestureController)
-        _data-&gt;_gestureController-&gt;didFinishLoadForMainFrame();
-}
-
-- (void)_didFailLoadForMainFrame
-{
-    if (_data-&gt;_gestureController)
-        _data-&gt;_gestureController-&gt;didFailLoadForMainFrame();
-}
-
-- (void)_didSameDocumentNavigationForMainFrame:(SameDocumentNavigationType)type
-{
-    if (_data-&gt;_gestureController)
-        _data-&gt;_gestureController-&gt;didSameDocumentNavigationForMainFrame(type);
-}
-
-- (void)_removeNavigationGestureSnapshot
-{
-    if (_data-&gt;_gestureController)
-        _data-&gt;_gestureController-&gt;removeSwipeSnapshot();
-}
-
</del><span class="cx"> #if __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101100
</span><span class="cx"> - (void)_startWindowDrag
</span><span class="cx"> {
</span><span class="lines">@@ -3064,14 +2923,12 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)setAllowsBackForwardNavigationGestures:(BOOL)allowsBackForwardNavigationGestures
</span><span class="cx"> {
</span><del>-    _data-&gt;_allowsBackForwardNavigationGestures = allowsBackForwardNavigationGestures;
-    _data-&gt;_page-&gt;setShouldRecordNavigationSnapshots(allowsBackForwardNavigationGestures);
-    _data-&gt;_page-&gt;setShouldUseImplicitRubberBandControl(allowsBackForwardNavigationGestures);
</del><ins>+    _data-&gt;_impl-&gt;setAllowsBackForwardNavigationGestures(allowsBackForwardNavigationGestures);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (BOOL)allowsBackForwardNavigationGestures
</span><span class="cx"> {
</span><del>-    return _data-&gt;_allowsBackForwardNavigationGestures;
</del><ins>+    return _data-&gt;_impl-&gt;allowsBackForwardNavigationGestures();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (BOOL)allowsLinkPreview
</span><span class="lines">@@ -3271,145 +3128,69 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)setAllowsMagnification:(BOOL)allowsMagnification
</span><span class="cx"> {
</span><del>-    _data-&gt;_allowsMagnification = allowsMagnification;
</del><ins>+    _data-&gt;_impl-&gt;setAllowsMagnification(allowsMagnification);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (BOOL)allowsMagnification
</span><span class="cx"> {
</span><del>-    return _data-&gt;_allowsMagnification;
</del><ins>+    return _data-&gt;_impl-&gt;allowsMagnification();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)magnifyWithEvent:(NSEvent *)event
</span><span class="cx"> {
</span><del>-    if (!_data-&gt;_allowsMagnification) {
-#if ENABLE(MAC_GESTURE_EVENTS)
-        NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, self);
-        _data-&gt;_page-&gt;handleGestureEvent(webEvent);
-#endif
-        [super magnifyWithEvent:event];
-        return;
-    }
-
-    [self _dismissContentRelativeChildWindowsWithAnimation:NO];
-
-    [self _ensureGestureController];
-
-#if ENABLE(MAC_GESTURE_EVENTS)
-    if (_data-&gt;_gestureController-&gt;hasActiveMagnificationGesture()) {
-        _data-&gt;_gestureController-&gt;handleMagnificationGestureEvent(event, [self convertPoint:event.locationInWindow fromView:nil]);
-        return;
-    }
-
-    NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, self);
-    _data-&gt;_page-&gt;handleGestureEvent(webEvent);
-#else
-    _data-&gt;_gestureController-&gt;handleMagnificationGestureEvent(event, [self convertPoint:event.locationInWindow fromView:nil]);
-#endif
</del><ins>+    _data-&gt;_impl-&gt;magnifyWithEvent(event);
</ins><span class="cx"> }
</span><span class="cx"> 
</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);
-    _data-&gt;_page-&gt;handleGestureEvent(webEvent);
</del><ins>+    _data-&gt;_impl-&gt;rotateWithEvent(event);
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> - (void)_gestureEventWasNotHandledByWebCore:(NSEvent *)event
</span><span class="cx"> {
</span><del>-#if ENABLE(MAC_GESTURE_EVENTS)
-    if (_data-&gt;_gestureController)
-        _data-&gt;_gestureController-&gt;gestureEventWasNotHandledByWebCore(event, [self convertPoint:event.locationInWindow fromView:nil]);
-#endif
</del><ins>+    _data-&gt;_impl-&gt;gestureEventWasNotHandledByWebCoreFromViewOnly(event);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)smartMagnifyWithEvent:(NSEvent *)event
</span><span class="cx"> {
</span><del>-    if (!_data-&gt;_allowsMagnification) {
-        [super smartMagnifyWithEvent:event];
-        return;
-    }
-
-    [self _dismissContentRelativeChildWindowsWithAnimation:NO];
-
-    [self _ensureGestureController];
-
-    _data-&gt;_gestureController-&gt;handleSmartMagnificationGesture([self convertPoint:event.locationInWindow fromView:nil]);
</del><ins>+    _data-&gt;_impl-&gt;smartMagnifyWithEvent(event);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)setMagnification:(double)magnification centeredAtPoint:(NSPoint)point
</span><span class="cx"> {
</span><del>-    if (magnification &lt;= 0 || isnan(magnification) || isinf(magnification))
-        [NSException raise:NSInvalidArgumentException format:@&quot;Magnification should be a positive number&quot;];
-
-    [self _dismissContentRelativeChildWindowsWithAnimation:NO];
-
-    _data-&gt;_page-&gt;scalePageInViewCoordinates(magnification, roundedIntPoint(point));
</del><ins>+    _data-&gt;_impl-&gt;setMagnification(magnification, NSPointToCGPoint(point));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)setMagnification:(double)magnification
</span><span class="cx"> {
</span><del>-    if (magnification &lt;= 0 || isnan(magnification) || isinf(magnification))
-        [NSException raise:NSInvalidArgumentException format:@&quot;Magnification should be a positive number&quot;];
-
-    [self _dismissContentRelativeChildWindowsWithAnimation:NO];
-
-    FloatPoint viewCenter(NSMidX([self bounds]), NSMidY([self bounds]));
-    _data-&gt;_page-&gt;scalePageInViewCoordinates(magnification, roundedIntPoint(viewCenter));
</del><ins>+    _data-&gt;_impl-&gt;setMagnification(magnification);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (double)magnification
</span><span class="cx"> {
</span><del>-    if (_data-&gt;_gestureController)
-        return _data-&gt;_gestureController-&gt;magnification();
-
-    return _data-&gt;_page-&gt;pageScaleFactor();
</del><ins>+    return _data-&gt;_impl-&gt;magnification();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_setCustomSwipeViews:(NSArray *)customSwipeViews
</span><span class="cx"> {
</span><del>-    if (!customSwipeViews.count &amp;&amp; !_data-&gt;_gestureController)
-        return;
-
-    [self _ensureGestureController];
-
-    Vector&lt;RetainPtr&lt;NSView&gt;&gt; views;
-    for (NSView *view in customSwipeViews)
-        views.append(view);
-
-    _data-&gt;_gestureController-&gt;setCustomSwipeViews(views);
</del><ins>+    _data-&gt;_impl-&gt;setCustomSwipeViews(customSwipeViews);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_setCustomSwipeViewsTopContentInset:(float)topContentInset
</span><span class="cx"> {
</span><del>-    [self _ensureGestureController];
-    _data-&gt;_gestureController-&gt;setCustomSwipeViewsTopContentInset(topContentInset);
</del><ins>+    _data-&gt;_impl-&gt;setCustomSwipeViewsTopContentInset(topContentInset);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (BOOL)_tryToSwipeWithEvent:(NSEvent *)event ignoringPinnedState:(BOOL)ignoringPinnedState
</span><span class="cx"> {
</span><del>-    if (!_data-&gt;_allowsBackForwardNavigationGestures)
-        return NO;
-
-    [self _ensureGestureController];
-
-    BOOL wasIgnoringPinnedState = _data-&gt;_gestureController-&gt;shouldIgnorePinnedState();
-    _data-&gt;_gestureController-&gt;setShouldIgnorePinnedState(ignoringPinnedState);
-
-    BOOL handledEvent = _data-&gt;_gestureController-&gt;handleScrollWheelEvent(event);
-
-    _data-&gt;_gestureController-&gt;setShouldIgnorePinnedState(wasIgnoringPinnedState);
-
-    return handledEvent;
</del><ins>+    return _data-&gt;_impl-&gt;tryToSwipeWithEvent(event, ignoringPinnedState);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_setDidMoveSwipeSnapshotCallback:(void(^)(CGRect))callback
</span><span class="cx"> {
</span><del>-    if (!_data-&gt;_allowsBackForwardNavigationGestures)
-        return;
-
-    [self _ensureGestureController];
-    _data-&gt;_gestureController-&gt;setDidMoveSwipeSnapshotCallback(callback);
</del><ins>+    _data-&gt;_impl-&gt;setDidMoveSwipeSnapshotCallback(callback);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (id)_immediateActionAnimationControllerForHitTestResult:(WKHitTestResultRef)hitTestResult withType:(uint32_t)type userData:(WKTypeRef)userData
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h (191633 => 191634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h        2015-10-27 20:01:08 UTC (rev 191633)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h        2015-10-27 20:09:29 UTC (rev 191634)
</span><span class="lines">@@ -87,9 +87,6 @@
</span><span class="cx"> - (NSRect)_convertToDeviceSpace:(NSRect)rect;
</span><span class="cx"> - (NSRect)_convertToUserSpace:(NSRect)rect;
</span><span class="cx"> 
</span><del>-- (PassRefPtr&lt;WebKit::ViewSnapshot&gt;)_takeViewSnapshot;
-- (void)_wheelEventWasNotHandledByWebCore:(NSEvent *)event;
-
</del><span class="cx"> - (void)_setAccessibilityWebProcessToken:(NSData *)data;
</span><span class="cx"> 
</span><span class="cx"> - (void)_dragImageForView:(NSView *)view withImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag;
</span><span class="lines">@@ -106,12 +103,6 @@
</span><span class="cx"> - (void)_setSuppressVisibilityUpdates:(BOOL)suppressVisibilityUpdates;
</span><span class="cx"> - (BOOL)_suppressVisibilityUpdates;
</span><span class="cx"> 
</span><del>-- (void)_didFirstVisuallyNonEmptyLayoutForMainFrame;
-- (void)_didFinishLoadForMainFrame;
-- (void)_didFailLoadForMainFrame;
-- (void)_didSameDocumentNavigationForMainFrame:(WebKit::SameDocumentNavigationType)type;
-- (void)_removeNavigationGestureSnapshot;
-
</del><span class="cx"> #if WK_API_ENABLED
</span><span class="cx"> @property (nonatomic, setter=_setThumbnailView:) _WKThumbnailView *_thumbnailView;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h (191633 => 191634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2015-10-27 20:01:08 UTC (rev 191633)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2015-10-27 20:09:29 UTC (rev 191634)
</span><span class="lines">@@ -52,6 +52,9 @@
</span><span class="cx"> - (NSTextInputContext *)_superInputContext;
</span><span class="cx"> - (void)_superQuickLookWithEvent:(NSEvent *)event;
</span><span class="cx"> - (void)_superRemoveTrackingRect:(NSTrackingRectTag)tag;
</span><ins>+- (void)_superSwipeWithEvent:(NSEvent *)event;
+- (void)_superMagnifyWithEvent:(NSEvent *)event;
+- (void)_superSmartMagnifyWithEvent:(NSEvent *)event;
</ins><span class="cx"> 
</span><span class="cx"> // This is a hack; these things live can live on a category (e.g. WKView (Private)) but WKView itself conforms to this protocol.
</span><span class="cx"> // They're not actually optional.
</span><span class="lines">@@ -63,11 +66,13 @@
</span><span class="cx"> - (void)_completeImmediateActionAnimation;
</span><span class="cx"> - (void)_dismissContentRelativeChildWindows;
</span><span class="cx"> - (void)_dismissContentRelativeChildWindowsWithAnimation:(BOOL)animate;
</span><ins>+- (void)_gestureEventWasNotHandledByWebCore:(NSEvent *)event;
</ins><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><ins>+class ViewGestureController;
</ins><span class="cx"> class WebEditCommandProxy;
</span><span class="cx"> class WebPageProxy;
</span><span class="cx"> struct ColorSpaceData;
</span><span class="lines">@@ -250,6 +255,33 @@
</span><span class="cx">     void registerDraggedTypes();
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    RefPtr&lt;ViewSnapshot&gt; takeViewSnapshot();
+
+    ViewGestureController* gestureController() { return m_gestureController.get(); }
+    ViewGestureController&amp; ensureGestureController();
+    void resetGestureController();
+    void setAllowsBackForwardNavigationGestures(bool);
+    bool allowsBackForwardNavigationGestures() const { return m_allowsBackForwardNavigationGestures; }
+    void setAllowsMagnification(bool);
+    bool allowsMagnification() const { return m_allowsMagnification; }
+
+    void setMagnification(double, CGPoint centerPoint);
+    void setMagnification(double);
+    double magnification() const;
+    void setCustomSwipeViews(NSArray *);
+    void setCustomSwipeViewsTopContentInset(float);
+    bool tryToSwipeWithEvent(NSEvent *, bool ignoringPinnedState);
+    void setDidMoveSwipeSnapshotCallback(void(^)(CGRect));
+
+    void scrollWheel(NSEvent *);
+    void swipeWithEvent(NSEvent *);
+    void magnifyWithEvent(NSEvent *);
+    void rotateWithEvent(NSEvent *);
+    void smartMagnifyWithEvent(NSEvent *);
+
+    void gestureEventWasNotHandledByWebCore(NSEvent *);
+    void gestureEventWasNotHandledByWebCoreFromViewOnly(NSEvent *);
+
</ins><span class="cx"> private:
</span><span class="cx">     WeakPtr&lt;WebViewImpl&gt; createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
</span><span class="cx"> 
</span><span class="lines">@@ -346,6 +378,10 @@
</span><span class="cx"> #if WK_API_ENABLED
</span><span class="cx">     _WKThumbnailView *m_thumbnailView { nullptr };
</span><span class="cx"> #endif
</span><ins>+
+    std::unique_ptr&lt;ViewGestureController&gt; m_gestureController;
+    bool m_allowsBackForwardNavigationGestures { false };
+    bool m_allowsMagnification { false };
</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 (191633 => 191634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2015-10-27 20:01:08 UTC (rev 191633)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2015-10-27 20:09:29 UTC (rev 191634)
</span><span class="lines">@@ -31,11 +31,14 @@
</span><span class="cx"> #import &quot;ColorSpaceData.h&quot;
</span><span class="cx"> #import &quot;GenericCallback.h&quot;
</span><span class="cx"> #import &quot;Logging.h&quot;
</span><ins>+#import &quot;NativeWebGestureEvent.h&quot;
</ins><span class="cx"> #import &quot;NativeWebKeyboardEvent.h&quot;
</span><span class="cx"> #import &quot;NativeWebMouseEvent.h&quot;
</span><ins>+#import &quot;NativeWebWheelEvent.h&quot;
</ins><span class="cx"> #import &quot;PageClient.h&quot;
</span><span class="cx"> #import &quot;PasteboardTypes.h&quot;
</span><span class="cx"> #import &quot;StringUtilities.h&quot;
</span><ins>+#import &quot;ViewGestureController.h&quot;
</ins><span class="cx"> #import &quot;WKFullScreenWindowController.h&quot;
</span><span class="cx"> #import &quot;WKImmediateActionController.h&quot;
</span><span class="cx"> #import &quot;WKTextInputWindowController.h&quot;
</span><span class="lines">@@ -47,6 +50,7 @@
</span><span class="cx"> #import &quot;_WKThumbnailViewInternal.h&quot;
</span><span class="cx"> #import &lt;HIToolbox/CarbonEventsCore.h&gt;
</span><span class="cx"> #import &lt;WebCore/AXObjectCache.h&gt;
</span><ins>+#import &lt;WebCore/CoreGraphicsSPI.h&gt;
</ins><span class="cx"> #import &lt;WebCore/DataDetectorsSPI.h&gt;
</span><span class="cx"> #import &lt;WebCore/DictionaryLookup.h&gt;
</span><span class="cx"> #import &lt;WebCore/DragData.h&gt;
</span><span class="lines">@@ -1809,6 +1813,264 @@
</span><span class="cx"> }
</span><span class="cx"> #endif // ENABLE(DRAG_SUPPORT)
</span><span class="cx"> 
</span><ins>+static RetainPtr&lt;CGImageRef&gt; takeWindowSnapshot(CGSWindowID windowID, bool captureAtNominalResolution)
+{
+    CGSWindowCaptureOptions options = kCGSCaptureIgnoreGlobalClipShape;
+    if (captureAtNominalResolution)
+        options |= kCGSWindowCaptureNominalResolution;
+    RetainPtr&lt;CFArrayRef&gt; windowSnapshotImages = adoptCF(CGSHWCaptureWindowList(CGSMainConnectionID(), &amp;windowID, 1, options));
+
+    if (windowSnapshotImages &amp;&amp; CFArrayGetCount(windowSnapshotImages.get()))
+        return (CGImageRef)CFArrayGetValueAtIndex(windowSnapshotImages.get(), 0);
+
+    // Fall back to the non-hardware capture path if we didn't get a snapshot
+    // (which usually happens if the window is fully off-screen).
+    CGWindowImageOption imageOptions = kCGWindowImageBoundsIgnoreFraming | kCGWindowImageShouldBeOpaque;
+    if (captureAtNominalResolution)
+        imageOptions |= kCGWindowImageNominalResolution;
+    return adoptCF(CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, windowID, imageOptions));
+}
+
+RefPtr&lt;ViewSnapshot&gt; WebViewImpl::takeViewSnapshot()
+{
+    NSWindow *window = m_view.window;
+
+    CGSWindowID windowID = (CGSWindowID)window.windowNumber;
+    if (!windowID || !window.isVisible)
+        return nullptr;
+
+    RetainPtr&lt;CGImageRef&gt; windowSnapshotImage = takeWindowSnapshot(windowID, false);
+    if (!windowSnapshotImage)
+        return nullptr;
+
+    // Work around &lt;rdar://problem/17084993&gt;; re-request the snapshot at kCGWindowImageNominalResolution if it was captured at the wrong scale.
+    CGFloat desiredSnapshotWidth = window.frame.size.width * window.screen.backingScaleFactor;
+    if (CGImageGetWidth(windowSnapshotImage.get()) != desiredSnapshotWidth)
+        windowSnapshotImage = takeWindowSnapshot(windowID, true);
+
+    if (!windowSnapshotImage)
+        return nullptr;
+
+    ViewGestureController&amp; gestureController = ensureGestureController();
+
+    NSRect windowCaptureRect;
+    WebCore::FloatRect boundsForCustomSwipeViews = gestureController.windowRelativeBoundsForCustomSwipeViews();
+    if (!boundsForCustomSwipeViews.isEmpty())
+        windowCaptureRect = boundsForCustomSwipeViews;
+    else {
+        NSRect unobscuredBounds = m_view.bounds;
+        float topContentInset = m_page.topContentInset();
+        unobscuredBounds.origin.y += topContentInset;
+        unobscuredBounds.size.height -= topContentInset;
+        windowCaptureRect = [m_view convertRect:unobscuredBounds toView:nil];
+    }
+
+    NSRect windowCaptureScreenRect = [window convertRectToScreen:windowCaptureRect];
+    CGRect windowScreenRect;
+    CGSGetScreenRectForWindow(CGSMainConnectionID(), (CGSWindowID)[window windowNumber], &amp;windowScreenRect);
+
+    NSRect croppedImageRect = windowCaptureRect;
+    croppedImageRect.origin.y = windowScreenRect.size.height - windowCaptureScreenRect.size.height - NSMinY(windowCaptureRect);
+
+    auto croppedSnapshotImage = adoptCF(CGImageCreateWithImageInRect(windowSnapshotImage.get(), NSRectToCGRect([window convertRectToBacking:croppedImageRect])));
+
+    auto surface = WebCore::IOSurface::createFromImage(croppedSnapshotImage.get());
+    if (!surface)
+        return nullptr;
+    surface-&gt;setIsVolatile(true);
+
+    return ViewSnapshot::create(WTF::move(surface));
+}
+
+ViewGestureController&amp; WebViewImpl::ensureGestureController()
+{
+    if (!m_gestureController)
+        m_gestureController = std::make_unique&lt;ViewGestureController&gt;(m_page);
+    return *m_gestureController;
+}
+
+void WebViewImpl::resetGestureController()
+{
+    m_gestureController = nullptr;
+}
+
+void WebViewImpl::setAllowsBackForwardNavigationGestures(bool allowsBackForwardNavigationGestures)
+{
+    m_allowsBackForwardNavigationGestures = allowsBackForwardNavigationGestures;
+    m_page.setShouldRecordNavigationSnapshots(allowsBackForwardNavigationGestures);
+    m_page.setShouldUseImplicitRubberBandControl(allowsBackForwardNavigationGestures);
+}
+
+void WebViewImpl::setAllowsMagnification(bool allowsMagnification)
+{
+    m_allowsMagnification = allowsMagnification;
+}
+
+void WebViewImpl::setMagnification(double magnification, CGPoint centerPoint)
+{
+    if (magnification &lt;= 0 || isnan(magnification) || isinf(magnification))
+        [NSException raise:NSInvalidArgumentException format:@&quot;Magnification should be a positive number&quot;];
+
+    dismissContentRelativeChildWindowsWithAnimation(false);
+
+    m_page.scalePageInViewCoordinates(magnification, WebCore::roundedIntPoint(centerPoint));
+}
+
+void WebViewImpl::setMagnification(double magnification)
+{
+    if (magnification &lt;= 0 || isnan(magnification) || isinf(magnification))
+        [NSException raise:NSInvalidArgumentException format:@&quot;Magnification should be a positive number&quot;];
+
+    dismissContentRelativeChildWindowsWithAnimation(false);
+
+    WebCore::FloatPoint viewCenter(NSMidX([m_view bounds]), NSMidY([m_view bounds]));
+    m_page.scalePageInViewCoordinates(magnification, roundedIntPoint(viewCenter));
+}
+
+double WebViewImpl::magnification() const
+{
+    if (m_gestureController)
+        return m_gestureController-&gt;magnification();
+    return m_page.pageScaleFactor();
+}
+
+void WebViewImpl::setCustomSwipeViews(NSArray *customSwipeViews)
+{
+    if (!customSwipeViews.count &amp;&amp; !m_gestureController)
+        return;
+
+    Vector&lt;RetainPtr&lt;NSView&gt;&gt; views;
+    views.reserveInitialCapacity(customSwipeViews.count);
+    for (NSView *view in customSwipeViews)
+        views.uncheckedAppend(view);
+
+    ensureGestureController().setCustomSwipeViews(views);
+}
+
+void WebViewImpl::setCustomSwipeViewsTopContentInset(float topContentInset)
+{
+    ensureGestureController().setCustomSwipeViewsTopContentInset(topContentInset);
+}
+
+bool WebViewImpl::tryToSwipeWithEvent(NSEvent *event, bool ignoringPinnedState)
+{
+    if (!m_allowsBackForwardNavigationGestures)
+        return false;
+
+    auto&amp; gestureController = ensureGestureController();
+
+    bool wasIgnoringPinnedState = gestureController.shouldIgnorePinnedState();
+    gestureController.setShouldIgnorePinnedState(ignoringPinnedState);
+
+    bool handledEvent = gestureController.handleScrollWheelEvent(event);
+
+    gestureController.setShouldIgnorePinnedState(wasIgnoringPinnedState);
+    
+    return handledEvent;
+}
+
+void WebViewImpl::setDidMoveSwipeSnapshotCallback(void(^callback)(CGRect))
+{
+    if (!m_allowsBackForwardNavigationGestures)
+        return;
+
+    ensureGestureController().setDidMoveSwipeSnapshotCallback(callback);
+}
+
+void WebViewImpl::scrollWheel(NSEvent *event)
+{
+    if (m_ignoresAllEvents)
+        return;
+
+    if (event.phase == NSEventPhaseBegan)
+        dismissContentRelativeChildWindowsWithAnimation(false);
+
+    if (m_allowsBackForwardNavigationGestures &amp;&amp; ensureGestureController().handleScrollWheelEvent(event))
+        return;
+
+    NativeWebWheelEvent webEvent = NativeWebWheelEvent(event, m_view);
+    m_page.handleWheelEvent(webEvent);
+}
+
+void WebViewImpl::swipeWithEvent(NSEvent *event)
+{
+    if (m_ignoresNonWheelEvents)
+        return;
+
+    if (!m_allowsBackForwardNavigationGestures) {
+        [m_view _superSwipeWithEvent:event];
+        return;
+    }
+
+    if (event.deltaX &gt; 0.0)
+        m_page.goBack();
+    else if (event.deltaX &lt; 0.0)
+        m_page.goForward();
+    else
+        [m_view _superSwipeWithEvent:event];
+}
+
+void WebViewImpl::magnifyWithEvent(NSEvent *event)
+{
+    if (!m_allowsMagnification) {
+#if ENABLE(MAC_GESTURE_EVENTS)
+        NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, m_view);
+        m_page.handleGestureEvent(webEvent);
+#endif
+        [m_view _superMagnifyWithEvent:event];
+        return;
+    }
+
+    dismissContentRelativeChildWindowsWithAnimation(false);
+
+    auto&amp; gestureController = ensureGestureController();
+
+#if ENABLE(MAC_GESTURE_EVENTS)
+    if (gestureController.hasActiveMagnificationGesture()) {
+        gestureController.handleMagnificationGestureEvent(event, [m_view convertPoint:event.locationInWindow fromView:nil]);
+        return;
+    }
+
+    NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, m_view);
+    m_page.handleGestureEvent(webEvent);
+#else
+    gestureController.handleMagnificationGestureEvent(event, [m_view convertPoint:event.locationInWindow fromView:nil]);
+#endif
+}
+
+void WebViewImpl::smartMagnifyWithEvent(NSEvent *event)
+{
+    if (!m_allowsMagnification) {
+        [m_view _superSmartMagnifyWithEvent:event];
+        return;
+    }
+
+    dismissContentRelativeChildWindowsWithAnimation(false);
+
+    ensureGestureController().handleSmartMagnificationGesture([m_view convertPoint:event.locationInWindow fromView:nil]);
+}
+
+#if ENABLE(MAC_GESTURE_EVENTS)
+void WebViewImpl::rotateWithEvent(NSEvent *event)
+{
+    NativeWebGestureEvent webEvent = NativeWebGestureEvent(event, m_view);
+    m_page.handleGestureEvent(webEvent);
+}
+#endif
+
+void WebViewImpl::gestureEventWasNotHandledByWebCore(NSEvent *event)
+{
+    [m_view _gestureEventWasNotHandledByWebCore:event];
+}
+
+void WebViewImpl::gestureEventWasNotHandledByWebCoreFromViewOnly(NSEvent *event)
+{
+#if ENABLE(MAC_GESTURE_EVENTS)
+    if (m_gestureController)
+        m_gestureController-&gt;gestureEventWasNotHandledByWebCore(event, [m_view convertPoint:event.locationInWindow fromView:nil]);
+#endif
+}
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><span class="cx"> #endif // PLATFORM(MAC)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacPageClientImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (191633 => 191634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2015-10-27 20:01:08 UTC (rev 191633)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2015-10-27 20:09:29 UTC (rev 191634)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> #import &quot;NativeWebWheelEvent.h&quot;
</span><span class="cx"> #import &quot;NavigationState.h&quot;
</span><span class="cx"> #import &quot;StringUtilities.h&quot;
</span><ins>+#import &quot;ViewGestureController.h&quot;
</ins><span class="cx"> #import &quot;ViewSnapshotStore.h&quot;
</span><span class="cx"> #import &quot;WKAPICast.h&quot;
</span><span class="cx"> #import &quot;WKFullScreenWindowController.h&quot;
</span><span class="lines">@@ -514,7 +515,7 @@
</span><span class="cx"> 
</span><span class="cx"> PassRefPtr&lt;ViewSnapshot&gt; PageClientImpl::takeViewSnapshot()
</span><span class="cx"> {
</span><del>-    return [m_wkView _takeViewSnapshot];
</del><ins>+    return m_impl-&gt;takeViewSnapshot();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PageClientImpl::selectionDidChange()
</span><span class="lines">@@ -524,7 +525,8 @@
</span><span class="cx"> 
</span><span class="cx"> void PageClientImpl::wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&amp; event)
</span><span class="cx"> {
</span><del>-    [m_wkView _wheelEventWasNotHandledByWebCore:event.nativeEvent()];
</del><ins>+    if (auto gestureController = m_impl-&gt;gestureController())
+        gestureController-&gt;wheelEventWasNotHandledByWebCore(event.nativeEvent());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(MAC_GESTURE_EVENTS)
</span><span class="lines">@@ -747,27 +749,32 @@
</span><span class="cx"> 
</span><span class="cx"> void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
</span><span class="cx"> {
</span><del>-    [m_wkView _didFirstVisuallyNonEmptyLayoutForMainFrame];
</del><ins>+    if (auto gestureController = m_impl-&gt;gestureController())
+        gestureController-&gt;didFirstVisuallyNonEmptyLayoutForMainFrame();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PageClientImpl::didFinishLoadForMainFrame()
</span><span class="cx"> {
</span><del>-    [m_wkView _didFinishLoadForMainFrame];
</del><ins>+    if (auto gestureController = m_impl-&gt;gestureController())
+        gestureController-&gt;didFinishLoadForMainFrame();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PageClientImpl::didFailLoadForMainFrame()
</span><span class="cx"> {
</span><del>-    [m_wkView _didFailLoadForMainFrame];
</del><ins>+    if (auto gestureController = m_impl-&gt;gestureController())
+        gestureController-&gt;didFailLoadForMainFrame();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PageClientImpl::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType type)
</span><span class="cx"> {
</span><del>-    [m_wkView _didSameDocumentNavigationForMainFrame:type];
</del><ins>+    if (auto gestureController = m_impl-&gt;gestureController())
+        gestureController-&gt;didSameDocumentNavigationForMainFrame(type);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PageClientImpl::removeNavigationGestureSnapshot()
</span><span class="cx"> {
</span><del>-    [m_wkView _removeNavigationGestureSnapshot];
</del><ins>+    if (auto gestureController = m_impl-&gt;gestureController())
+        gestureController-&gt;removeSwipeSnapshot();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PageClientImpl::didChangeBackgroundColor()
</span></span></pre>
</div>
</div>

</body>
</html>