<!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>[163666] trunk/Source/WebKit2</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/163666">163666</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2014-02-07 16:58:08 -0800 (Fri, 07 Feb 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>WebKit2 View Gestures (Swipe): Support for iOS
https://bugs.webkit.org/show_bug.cgi?id=128363
&lt;rdar://problem/15194194&gt;

Reviewed by Anders Carlsson.

* Shared/mac/RemoteLayerTreeTransaction.h:
(WebKit::RemoteLayerTreeTransaction::renderTreeSize):
(WebKit::RemoteLayerTreeTransaction::setRenderTreeSize):
* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::encode):
(WebKit::RemoteLayerTreeTransaction::decode):
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::flushLayers):
Send the render tree size along with remote layer tree commits,
so that we can act upon it (to hide snapshots) in the UI process
in sync with layer commits.

* UIProcess/API/Cocoa/WKViewPrivate.h:
We want allowsBackForwardNavigationGestures for both platforms.

* UIProcess/API/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::takeViewSnapshot):
* UIProcess/API/ios/WKContentView.h:
* UIProcess/API/ios/WKContentView.mm:
(-[WKContentView _takeViewSnapshot]):
* UIProcess/API/ios/WKContentViewInternal.h:
Plumb snapshotting through to WKViewIOS.

* UIProcess/API/ios/WKViewIOS.mm:
(-[WKView setAllowsBackForwardNavigationGestures:]):
(-[WKView allowsBackForwardNavigationGestures]):
Create/destroy the gesture controller when we turn on/off back-forward swipe.
Tell WebPageProxy to save snapshots if swipe is enabled.

(-[WKView contentView:didCommitLayerTree:]):
Forward the current transaction's render tree size to ViewGestureController.

(-[WKView takeViewSnapshotForContentView:]):
Snapshot the view. This is not the best SPI to use, we should consider
using one of those which returns an IOSurface and plumbing it through
to ViewSnapshotStore, but all of our PageClient abstraction makes that annoying.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::recordNavigationSnapshot):
Record snapshots on iOS as well.

* UIProcess/ios/ViewGestureControllerIOS.mm: Added.
(-[WKSwipeInteractiveTransitionDelegate initWithViewGestureController:WebKit::swipingView:]):
(-[WKSwipeInteractiveTransitionDelegate WebKit::ViewGestureController::directionForTransition:]):
(-[WKSwipeInteractiveTransitionDelegate startInteractiveTransition:]):
(-[WKSwipeInteractiveTransitionDelegate shouldBeginInteractiveTransition:]):
(-[WKSwipeInteractiveTransitionDelegate interactiveTransition:gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
(-[WKSwipeInteractiveTransitionDelegate interactiveTransition:gestureRecognizer:shouldReceiveTouch:]):
(-[WKSwipeInteractiveTransitionDelegate gestureRecognizerForInteractiveTransition:WithTarget:action:]):
(WebKit::ViewGestureController::ViewGestureController):
(WebKit::ViewGestureController::~ViewGestureController):
(WebKit::ViewGestureController::installSwipeHandler):
(WebKit::ViewGestureController::beginSwipeGesture):
(WebKit::ViewGestureController::canSwipeInDirection):
(WebKit::ViewGestureController::endSwipeGesture):
(WebKit::ViewGestureController::setRenderTreeSize):
(WebKit::ViewGestureController::swipeSnapshotWatchdogTimerFired):
(WebKit::ViewGestureController::removeSwipeSnapshot):

* UIProcess/mac/ViewGestureController.h:
Add iOS-specific methods, and don't include all of the Mac-specific code.
We can move towards sharing more logic in the future.

* UIProcess/mac/ViewGestureController.messages.in:
* UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::ViewGestureController):
* UIProcess/mac/ViewSnapshotStore.h:
* UIProcess/mac/ViewSnapshotStore.mm:
(WebKit::ViewSnapshotStore::recordSnapshot):
(WebKit::ViewSnapshotStore::snapshotAndRenderTreeSize):
Make ViewSnapshotStore build/work without IOSurface.

* WebKit2.xcodeproj/project.pbxproj:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedmacRemoteLayerTreeTransactionh">trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h</a></li>
<li><a href="#trunkSourceWebKit2SharedmacRemoteLayerTreeTransactionmm">trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKViewh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKView.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKViewPrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIiosPageClientImplIOSmm">trunk/Source/WebKit2/UIProcess/API/ios/PageClientImplIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIiosWKContentViewh">trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIiosWKContentViewmm">trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIiosWKContentViewInternalh">trunk/Source/WebKit2/UIProcess/API/ios/WKContentViewInternal.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIiosWKViewIOSmm">trunk/Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewGestureControllerh">trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewGestureControllermessagesin">trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewGestureControllerMacmm">trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewSnapshotStoreh">trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewSnapshotStoremm">trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacRemoteLayerTreeDrawingAreamm">trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessiosViewGestureControllerIOSmm">trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (163665 => 163666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-02-08 00:55:15 UTC (rev 163665)
+++ trunk/Source/WebKit2/ChangeLog        2014-02-08 00:58:08 UTC (rev 163666)
</span><span class="lines">@@ -1,3 +1,85 @@
</span><ins>+2014-02-07  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        WebKit2 View Gestures (Swipe): Support for iOS
+        https://bugs.webkit.org/show_bug.cgi?id=128363
+        &lt;rdar://problem/15194194&gt;
+
+        Reviewed by Anders Carlsson.
+
+        * Shared/mac/RemoteLayerTreeTransaction.h:
+        (WebKit::RemoteLayerTreeTransaction::renderTreeSize):
+        (WebKit::RemoteLayerTreeTransaction::setRenderTreeSize):
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::encode):
+        (WebKit::RemoteLayerTreeTransaction::decode):
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
+        (WebKit::RemoteLayerTreeDrawingArea::flushLayers):
+        Send the render tree size along with remote layer tree commits,
+        so that we can act upon it (to hide snapshots) in the UI process
+        in sync with layer commits.
+
+        * UIProcess/API/Cocoa/WKViewPrivate.h:
+        We want allowsBackForwardNavigationGestures for both platforms.
+
+        * UIProcess/API/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::takeViewSnapshot):
+        * UIProcess/API/ios/WKContentView.h:
+        * UIProcess/API/ios/WKContentView.mm:
+        (-[WKContentView _takeViewSnapshot]):
+        * UIProcess/API/ios/WKContentViewInternal.h:
+        Plumb snapshotting through to WKViewIOS.
+
+        * UIProcess/API/ios/WKViewIOS.mm:
+        (-[WKView setAllowsBackForwardNavigationGestures:]):
+        (-[WKView allowsBackForwardNavigationGestures]):
+        Create/destroy the gesture controller when we turn on/off back-forward swipe.
+        Tell WebPageProxy to save snapshots if swipe is enabled.
+
+        (-[WKView contentView:didCommitLayerTree:]):
+        Forward the current transaction's render tree size to ViewGestureController.
+
+        (-[WKView takeViewSnapshotForContentView:]):
+        Snapshot the view. This is not the best SPI to use, we should consider
+        using one of those which returns an IOSurface and plumbing it through
+        to ViewSnapshotStore, but all of our PageClient abstraction makes that annoying.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::recordNavigationSnapshot):
+        Record snapshots on iOS as well.
+
+        * UIProcess/ios/ViewGestureControllerIOS.mm: Added.
+        (-[WKSwipeInteractiveTransitionDelegate initWithViewGestureController:WebKit::swipingView:]):
+        (-[WKSwipeInteractiveTransitionDelegate WebKit::ViewGestureController::directionForTransition:]):
+        (-[WKSwipeInteractiveTransitionDelegate startInteractiveTransition:]):
+        (-[WKSwipeInteractiveTransitionDelegate shouldBeginInteractiveTransition:]):
+        (-[WKSwipeInteractiveTransitionDelegate interactiveTransition:gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
+        (-[WKSwipeInteractiveTransitionDelegate interactiveTransition:gestureRecognizer:shouldReceiveTouch:]):
+        (-[WKSwipeInteractiveTransitionDelegate gestureRecognizerForInteractiveTransition:WithTarget:action:]):
+        (WebKit::ViewGestureController::ViewGestureController):
+        (WebKit::ViewGestureController::~ViewGestureController):
+        (WebKit::ViewGestureController::installSwipeHandler):
+        (WebKit::ViewGestureController::beginSwipeGesture):
+        (WebKit::ViewGestureController::canSwipeInDirection):
+        (WebKit::ViewGestureController::endSwipeGesture):
+        (WebKit::ViewGestureController::setRenderTreeSize):
+        (WebKit::ViewGestureController::swipeSnapshotWatchdogTimerFired):
+        (WebKit::ViewGestureController::removeSwipeSnapshot):
+
+        * UIProcess/mac/ViewGestureController.h:
+        Add iOS-specific methods, and don't include all of the Mac-specific code.
+        We can move towards sharing more logic in the future.
+
+        * UIProcess/mac/ViewGestureController.messages.in:
+        * UIProcess/mac/ViewGestureControllerMac.mm:
+        (WebKit::ViewGestureController::ViewGestureController):
+        * UIProcess/mac/ViewSnapshotStore.h:
+        * UIProcess/mac/ViewSnapshotStore.mm:
+        (WebKit::ViewSnapshotStore::recordSnapshot):
+        (WebKit::ViewSnapshotStore::snapshotAndRenderTreeSize):
+        Make ViewSnapshotStore build/work without IOSurface.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+
</ins><span class="cx"> 2014-02-07  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Implement more of WKPreferences
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacRemoteLayerTreeTransactionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h (163665 => 163666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h        2014-02-08 00:55:15 UTC (rev 163665)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h        2014-02-08 00:58:08 UTC (rev 163666)
</span><span class="lines">@@ -160,6 +160,9 @@
</span><span class="cx"> 
</span><span class="cx">     double pageScaleFactor() const { return m_pageScaleFactor; }
</span><span class="cx">     void setPageScaleFactor(double pageScaleFactor) { m_pageScaleFactor = pageScaleFactor; }
</span><ins>+    
+    uint64_t renderTreeSize() const { return m_renderTreeSize; }
+    void setRenderTreeSize(uint64_t renderTreeSize) { m_renderTreeSize = renderTreeSize; }
</ins><span class="cx"> 
</span><span class="cx">     double minimumScaleFactor() const { return m_minimumScaleFactor; }
</span><span class="cx">     void setMinimumScaleFactor(double scale) { m_minimumScaleFactor = scale; }
</span><span class="lines">@@ -177,6 +180,7 @@
</span><span class="cx">     Vector&lt;WebCore::GraphicsLayer::PlatformLayerID&gt; m_destroyedLayerIDs;
</span><span class="cx">     WebCore::IntSize m_contentsSize;
</span><span class="cx">     double m_pageScaleFactor;
</span><ins>+    uint64_t m_renderTreeSize;
</ins><span class="cx">     double m_minimumScaleFactor;
</span><span class="cx">     double m_maximumScaleFactor;
</span><span class="cx">     bool m_allowsUserScaling;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacRemoteLayerTreeTransactionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm (163665 => 163666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm        2014-02-08 00:55:15 UTC (rev 163665)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm        2014-02-08 00:58:08 UTC (rev 163666)
</span><span class="lines">@@ -353,6 +353,7 @@
</span><span class="cx">     encoder &lt;&lt; m_minimumScaleFactor;
</span><span class="cx">     encoder &lt;&lt; m_maximumScaleFactor;
</span><span class="cx">     encoder &lt;&lt; m_allowsUserScaling;
</span><ins>+    encoder &lt;&lt; m_renderTreeSize;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool RemoteLayerTreeTransaction::decode(IPC::ArgumentDecoder&amp; decoder, RemoteLayerTreeTransaction&amp; result)
</span><span class="lines">@@ -390,6 +391,9 @@
</span><span class="cx"> 
</span><span class="cx">     if (!decoder.decode(result.m_allowsUserScaling))
</span><span class="cx">         return false;
</span><ins>+    
+    if (!decoder.decode(result.m_renderTreeSize))
+        return false;
</ins><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKView.h (163665 => 163666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKView.h        2014-02-08 00:55:15 UTC (rev 163665)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKView.h        2014-02-08 00:58:08 UTC (rev 163666)
</span><span class="lines">@@ -65,6 +65,8 @@
</span><span class="cx"> 
</span><span class="cx"> @property BOOL drawsBackground;
</span><span class="cx"> @property BOOL drawsTransparentBackground;
</span><ins>+    
+@property (readwrite) BOOL allowsBackForwardNavigationGestures;
</ins><span class="cx"> 
</span><span class="cx"> #if TARGET_OS_IPHONE
</span><span class="cx"> @property (nonatomic, readonly) UIScrollView *scrollView;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKViewPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h (163665 => 163666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h        2014-02-08 00:55:15 UTC (rev 163665)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h        2014-02-08 00:58:08 UTC (rev 163666)
</span><span class="lines">@@ -70,7 +70,6 @@
</span><span class="cx"> @property (readonly, getter=isUsingUISideCompositing) BOOL usingUISideCompositing;
</span><span class="cx"> @property (readwrite) BOOL allowsMagnification;
</span><span class="cx"> @property (readwrite) double magnification;
</span><del>-@property (readwrite) BOOL allowsBackForwardNavigationGestures;
</del><span class="cx"> 
</span><span class="cx"> @property(copy, nonatomic) NSColor *underlayColor;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIiosPageClientImplIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/ios/PageClientImplIOS.mm (163665 => 163666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/ios/PageClientImplIOS.mm        2014-02-08 00:55:15 UTC (rev 163665)
+++ trunk/Source/WebKit2/UIProcess/API/ios/PageClientImplIOS.mm        2014-02-08 00:58:08 UTC (rev 163666)
</span><span class="lines">@@ -325,8 +325,7 @@
</span><span class="cx"> 
</span><span class="cx"> RetainPtr&lt;CGImageRef&gt; PageClientImpl::takeViewSnapshot()
</span><span class="cx"> {
</span><del>-    notImplemented();
-    return nullptr;
</del><ins>+    return [m_view _takeViewSnapshot];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PageClientImpl::wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&amp; event)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIiosWKContentViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.h (163665 => 163666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.h        2014-02-08 00:55:15 UTC (rev 163665)
+++ trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.h        2014-02-08 00:58:08 UTC (rev 163666)
</span><span class="lines">@@ -23,11 +23,12 @@
</span><span class="cx">  * THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx">  */
</span><span class="cx"> 
</span><ins>+#import &quot;WKBase.h&quot;
+#import &quot;WKBrowsingContextController.h&quot;
+#import &quot;WKBrowsingContextGroup.h&quot;
+#import &quot;WKProcessGroup.h&quot;
</ins><span class="cx"> #import &lt;UIKit/UIKit.h&gt;
</span><del>-#import &lt;WebKit2/WKBase.h&gt;
-#import &lt;WebKit2/WKBrowsingContextController.h&gt;
-#import &lt;WebKit2/WKBrowsingContextGroup.h&gt;
-#import &lt;WebKit2/WKProcessGroup.h&gt;
</del><ins>+#import &lt;wtf/RetainPtr.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> @class WKContentView;
</span><span class="cx"> @class WKWebViewConfiguration;
</span><span class="lines">@@ -40,6 +41,9 @@
</span><span class="cx"> @optional
</span><span class="cx"> - (void)contentViewDidCommitLoadForMainFrame:(WKContentView *)contentView;
</span><span class="cx"> - (void)contentView:(WKContentView *)contentView didCommitLayerTree:(const WebKit::RemoteLayerTreeTransaction&amp;)layerTreeTransaction;
</span><ins>+
+// FIXME: This doesn't belong in a 'delegate'.
+- (RetainPtr&lt;CGImageRef&gt;)takeViewSnapshotForContentView:(WKContentView *)contentView;
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> WK_API_CLASS
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIiosWKContentViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.mm (163665 => 163666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.mm        2014-02-08 00:55:15 UTC (rev 163665)
+++ trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.mm        2014-02-08 00:58:08 UTC (rev 163666)
</span><span class="lines">@@ -46,6 +46,10 @@
</span><span class="cx"> #import &lt;WebCore/ViewportArguments.h&gt;
</span><span class="cx"> #import &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> 
</span><ins>+#if USE(IOSURFACE)
+#import &lt;IOSurface/IOSurface.h&gt;
+#endif
+
</ins><span class="cx"> #if __has_include(&lt;QuartzCore/QuartzCorePrivate.h&gt;)
</span><span class="cx"> #import &lt;QuartzCore/QuartzCorePrivate.h&gt;
</span><span class="cx"> #endif
</span><span class="lines">@@ -358,4 +362,9 @@
</span><span class="cx">     // [[wrapper(_page-&gt;process().context()) _geolocationProvider] decidePolicyForGeolocationRequestFromOrigin:toAPI(&amp;origin) frame:toAPI(&amp;frame) request:toAPI(&amp;permissionRequest) window:[self window]];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (RetainPtr&lt;CGImageRef&gt;)_takeViewSnapshot
+{
+    return [_delegate takeViewSnapshotForContentView:self];
+}
+
</ins><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIiosWKContentViewInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/ios/WKContentViewInternal.h (163665 => 163666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/ios/WKContentViewInternal.h        2014-02-08 00:55:15 UTC (rev 163665)
+++ trunk/Source/WebKit2/UIProcess/API/ios/WKContentViewInternal.h        2014-02-08 00:58:08 UTC (rev 163666)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> 
</span><span class="cx"> #import &quot;WKContentView.h&quot;
</span><span class="cx"> #import &lt;wtf/Forward.h&gt;
</span><ins>+#import &lt;wtf/RetainPtr.h&gt;
</ins><span class="cx"> #import &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -69,4 +70,6 @@
</span><span class="cx"> - (void)_positionInformationDidChange:(const WebKit::InteractionInformationAtPosition&amp;)info;
</span><span class="cx"> - (void)_decidePolicyForGeolocationRequestFromOrigin:(WebKit::WebSecurityOrigin&amp;)origin frame:(WebKit::WebFrameProxy&amp;)frame request:(WebKit::GeolocationPermissionRequestProxy&amp;)permissionRequest;
</span><span class="cx"> 
</span><ins>+- (RetainPtr&lt;CGImageRef&gt;)_takeViewSnapshot;
+
</ins><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIiosWKViewIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm (163665 => 163666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm        2014-02-08 00:55:15 UTC (rev 163665)
+++ trunk/Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm        2014-02-08 00:58:08 UTC (rev 163666)
</span><span class="lines">@@ -26,15 +26,22 @@
</span><span class="cx"> #import &quot;config.h&quot;
</span><span class="cx"> #import &quot;WKViewPrivate.h&quot;
</span><span class="cx"> 
</span><ins>+#import &quot;RemoteLayerTreeTransaction.h&quot;
+#import &quot;ViewGestureController.h&quot;
+#import &quot;WebPageProxy.h&quot;
</ins><span class="cx"> #import &quot;WKBrowsingContextGroupPrivate.h&quot;
</span><span class="cx"> #import &quot;WKContentView.h&quot;
</span><span class="cx"> #import &quot;WKProcessGroupPrivate.h&quot;
</span><span class="cx"> #import &quot;WKScrollView.h&quot;
</span><ins>+#import &quot;WKAPICast.h&quot;
+#import &lt;UIKit/UIImage_Private.h&gt;
</ins><span class="cx"> #import &lt;UIKit/UIScreen.h&gt;
</span><span class="cx"> #import &lt;UIKit/UIScrollView_Private.h&gt;
</span><del>-#import &lt;WebKit2/RemoteLayerTreeTransaction.h&gt;
</del><ins>+#import &lt;UIKit/UIWindow_Private.h&gt;
</ins><span class="cx"> #import &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> 
</span><ins>+using namespace WebKit;
+
</ins><span class="cx"> @interface WKView () &lt;UIScrollViewDelegate, WKContentViewDelegate&gt;
</span><span class="cx"> - (void)_setDocumentScale:(CGFloat)newScale;
</span><span class="cx"> @end
</span><span class="lines">@@ -44,6 +51,10 @@
</span><span class="cx">     RetainPtr&lt;WKContentView&gt; _contentView;
</span><span class="cx"> 
</span><span class="cx">     BOOL _isWaitingForNewLayerTreeAfterDidCommitLoad;
</span><ins>+    std::unique_ptr&lt;ViewGestureController&gt; _gestureController;
+    
+    BOOL _allowsBackForwardNavigationGestures;
+
</ins><span class="cx">     BOOL _hasStaticMinimumLayoutSize;
</span><span class="cx">     CGSize _minimumLayoutSizeOverride;
</span><span class="cx"> }
</span><span class="lines">@@ -97,6 +108,26 @@
</span><span class="cx">     return [_contentView browsingContextController];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)setAllowsBackForwardNavigationGestures:(BOOL)allowsBackForwardNavigationGestures
+{
+    _allowsBackForwardNavigationGestures = allowsBackForwardNavigationGestures;
+    
+    WebPageProxy *webPageProxy = toImpl([_contentView _pageRef]);
+    
+    if (allowsBackForwardNavigationGestures &amp;&amp; !_gestureController) {
+        _gestureController = std::make_unique&lt;ViewGestureController&gt;(*webPageProxy);
+        _gestureController-&gt;installSwipeHandler(self);
+    } else
+        _gestureController = nullptr;
+    
+    webPageProxy-&gt;setShouldRecordNavigationSnapshots(allowsBackForwardNavigationGestures);
+}
+
+- (BOOL)allowsBackForwardNavigationGestures
+{
+    return _allowsBackForwardNavigationGestures;
+}
+
</ins><span class="cx"> #pragma mark WKContentViewDelegate
</span><span class="cx"> 
</span><span class="cx"> - (void)contentViewDidCommitLoadForMainFrame:(WKContentView *)contentView
</span><span class="lines">@@ -104,13 +135,16 @@
</span><span class="cx">     _isWaitingForNewLayerTreeAfterDidCommitLoad = YES;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)contentView:(WKContentView *)contentView didCommitLayerTree:(const WebKit::RemoteLayerTreeTransaction&amp;)layerTreeTransaction
</del><ins>+- (void)contentView:(WKContentView *)contentView didCommitLayerTree:(const RemoteLayerTreeTransaction&amp;)layerTreeTransaction
</ins><span class="cx"> {
</span><span class="cx">     [_scrollView setMinimumZoomScale:layerTreeTransaction.minimumScaleFactor()];
</span><span class="cx">     [_scrollView setMaximumZoomScale:layerTreeTransaction.maximumScaleFactor()];
</span><span class="cx">     [_scrollView setZoomEnabled:layerTreeTransaction.allowsUserScaling()];
</span><span class="cx">     if (![_scrollView isZooming] &amp;&amp; ![_scrollView isZoomBouncing])
</span><span class="cx">         [_scrollView setZoomScale:layerTreeTransaction.pageScaleFactor()];
</span><ins>+    
+    if (_gestureController)
+        _gestureController-&gt;setRenderTreeSize(layerTreeTransaction.renderTreeSize());
</ins><span class="cx"> 
</span><span class="cx">     if (_isWaitingForNewLayerTreeAfterDidCommitLoad) {
</span><span class="cx">         UIEdgeInsets inset = [_scrollView contentInset];
</span><span class="lines">@@ -219,6 +253,17 @@
</span><span class="cx">     [_scrollView setContentOffset:contentOffset];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+
+- (RetainPtr&lt;CGImageRef&gt;)takeViewSnapshotForContentView:(WKContentView *)contentView
+{
+    // FIXME: We should be able to use acquire an IOSurface directly, instead of going to CGImage here and back in ViewSnapshotStore.
+    UIGraphicsBeginImageContextWithOptions(self.bounds.size, YES, self.window.screen.scale);
+    [self drawViewHierarchyInRect:[self bounds] afterScreenUpdates:NO];
+    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
+    UIGraphicsEndImageContext();
+    return image.CGImage;
+}
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @implementation WKView (Private)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (163665 => 163666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2014-02-08 00:55:15 UTC (rev 163665)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2014-02-08 00:58:08 UTC (rev 163666)
</span><span class="lines">@@ -781,7 +781,7 @@
</span><span class="cx">     if (!m_shouldRecordNavigationSnapshots)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-#if PLATFORM(MAC) &amp;&amp; !PLATFORM(IOS)
</del><ins>+#if PLATFORM(MAC)
</ins><span class="cx">     ViewSnapshotStore::shared().recordSnapshot(*this);
</span><span class="cx"> #endif
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosViewGestureControllerIOSmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm (0 => 163666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm        2014-02-08 00:58:08 UTC (rev 163666)
</span><span class="lines">@@ -0,0 +1,276 @@
</span><ins>+/*
+ * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &quot;config.h&quot;
+#import &quot;ViewGestureController.h&quot;
+
+#import &quot;WebPageGroup.h&quot;
+#import &quot;ViewGestureControllerMessages.h&quot;
+#import &quot;ViewGestureGeometryCollectorMessages.h&quot;
+#import &quot;ViewSnapshotStore.h&quot;
+#import &quot;WebBackForwardList.h&quot;
+#import &quot;WebPageMessages.h&quot;
+#import &quot;WebPageProxy.h&quot;
+#import &quot;WebProcessProxy.h&quot;
+#import &lt;QuartzCore/QuartzCore.h&gt;
+#import &lt;UIKit/UIApplication_Private.h&gt;
+#import &lt;UIKit/UIScreenEdgePanGestureRecognizer.h&gt;
+#import &lt;UIKit/UIViewControllerTransitioning_Private.h&gt;
+#import &lt;UIKit/UIWebTouchEventsGestureRecognizer.h&gt;
+#import &lt;UIKit/_UINavigationInteractiveTransition.h&gt;
+#import &lt;UIKit/_UINavigationParallaxTransition.h&gt;
+
+#if USE(IOSURFACE)
+#import &lt;IOSurface/IOSurface.h&gt;
+#import &lt;IOSurface/IOSurfacePrivate.h&gt;
+#endif
+
+using namespace WebCore;
+
+@interface WKSwipeTransitionController : NSObject &lt;_UINavigationInteractiveTransitionBaseDelegate&gt;
+- (instancetype)initWithViewGestureController:(WebKit::ViewGestureController*)gestureController swipingView:(UIView *)view;
+@end
+
+@implementation WKSwipeTransitionController
+{
+    WebKit::ViewGestureController *_gestureController;
+    RetainPtr&lt;_UINavigationInteractiveTransitionBase&gt; _backTransitionController;
+}
+
+static const float swipeSnapshotRemovalRenderTreeSizeTargetFraction = 0.5;
+static const std::chrono::seconds swipeSnapshotRemovalWatchdogDuration = 3_s;
+
+- (instancetype)initWithViewGestureController:(WebKit::ViewGestureController*)gestureController swipingView:(UIView *)view
+{
+    self = [super init];
+    if (self) {
+        _gestureController = gestureController;
+
+        _backTransitionController = adoptNS([_UINavigationInteractiveTransitionBase alloc]);
+        _backTransitionController = [_backTransitionController initWithGestureRecognizerView:view animator:nil delegate:self];
+    }
+    return self;
+}
+
+- (WebKit::ViewGestureController::SwipeDirection)directionForTransition:(_UINavigationInteractiveTransitionBase *)transition
+{
+    return transition == _backTransitionController ? WebKit::ViewGestureController::SwipeDirection::Left : WebKit::ViewGestureController::SwipeDirection::Right;
+}
+
+- (void)startInteractiveTransition:(_UINavigationInteractiveTransitionBase *)transition
+{
+    _gestureController-&gt;beginSwipeGesture(transition, [self directionForTransition:transition]);
+}
+
+- (BOOL)shouldBeginInteractiveTransition:(_UINavigationInteractiveTransitionBase *)transition
+{
+    return _gestureController-&gt;canSwipeInDirection([self directionForTransition:transition]);
+}
+
+- (BOOL)interactiveTransition:(_UINavigationInteractiveTransitionBase *)transition gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
+{
+    return [otherGestureRecognizer isKindOfClass:[UITapGestureRecognizer class]];
+}
+
+- (BOOL)interactiveTransition:(_UINavigationInteractiveTransitionBase *)transition gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
+{
+    return YES;
+}
+
+- (UIPanGestureRecognizer *)gestureRecognizerForInteractiveTransition:(_UINavigationInteractiveTransitionBase *)transition WithTarget:(id)target action:(SEL)action
+{
+    UIScreenEdgePanGestureRecognizer *recognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:target action:action];
+    switch ([self directionForTransition:transition]) {
+    case WebKit::ViewGestureController::SwipeDirection::Left:
+        [recognizer setEdges:UIMinXEdge];
+        break;
+    case WebKit::ViewGestureController::SwipeDirection::Right:
+        [recognizer setEdges:UIMaxXEdge];
+        break;
+    }
+    return recognizer;
+}
+
+@end
+
+namespace WebKit {
+
+ViewGestureController::ViewGestureController(WebPageProxy&amp; webPageProxy)
+    : m_webPageProxy(webPageProxy)
+    , m_activeGestureType(ViewGestureType::None)
+    , m_swipeWatchdogTimer(this, &amp;ViewGestureController::swipeSnapshotWatchdogTimerFired)
+    , m_targetRenderTreeSize(0)
+{
+}
+
+ViewGestureController::~ViewGestureController()
+{
+}
+
+void ViewGestureController::installSwipeHandler(UIView *view)
+{
+    ASSERT(!m_swipeInteractiveTransitionDelegate);
+    m_swipeInteractiveTransitionDelegate = adoptNS([[WKSwipeTransitionController alloc] initWithViewGestureController:this swipingView:view]);
+    m_liveSwipeView = view;
+}
+
+void ViewGestureController::beginSwipeGesture(_UINavigationInteractiveTransitionBase *transition, SwipeDirection direction)
+{
+    if (m_activeGestureType != ViewGestureType::None)
+        return;
+
+    WebKit::WebBackForwardListItem* targetItem = direction == SwipeDirection::Left ? m_webPageProxy.backForwardList().backItem() : m_webPageProxy.backForwardList().forwardItem();
+
+    auto snapshot = WebKit::ViewSnapshotStore::shared().snapshotAndRenderTreeSize(targetItem).first;
+
+    RetainPtr&lt;UIViewController&gt; snapshotViewController = adoptNS([[UIViewController alloc] init]);
+    m_snapshotView = adoptNS([[UIView alloc] initWithFrame:[m_liveSwipeView bounds]]);
+    if (snapshot) {
+#if USE(IOSURFACE)
+        uint32_t purgeabilityState = kIOSurfacePurgeableNonVolatile;
+        IOSurfaceSetPurgeable(snapshot.get(), kIOSurfacePurgeableNonVolatile, &amp;purgeabilityState);
+        
+        if (purgeabilityState != kIOSurfacePurgeableEmpty)
+            [m_snapshotView layer].contents = (id)snapshot.get();
+#else
+        [m_snapshotView layer].contents = (id)snapshot.get();
+#endif
+    }
+    [m_snapshotView setBackgroundColor:[UIColor whiteColor]];
+    [m_snapshotView layer].contentsGravity = @&quot;topLeft&quot;;
+    [m_snapshotView layer].contentsScale = m_liveSwipeView.window.screen.scale;
+    [snapshotViewController setView:m_snapshotView.get()];
+
+    m_transitionContainerView = adoptNS([[UIView alloc] initWithFrame:[m_liveSwipeView frame]]);
+
+    [m_liveSwipeView.superview insertSubview:m_transitionContainerView.get() belowSubview:m_liveSwipeView];
+    [m_transitionContainerView addSubview:m_liveSwipeView];
+
+    RetainPtr&lt;UIViewController&gt; targettedViewController = adoptNS([[UIViewController alloc] init]);
+    [targettedViewController setView:m_liveSwipeView];
+
+    m_originalLiveSwipeViewFrame = m_liveSwipeView.frame;
+    m_liveSwipeView.frame = m_liveSwipeView.bounds;
+    
+    UINavigationControllerOperation transitionOperation = direction == SwipeDirection::Left ? UINavigationControllerOperationPop : UINavigationControllerOperationPush;
+    RetainPtr&lt;_UINavigationParallaxTransition&gt; animationController = adoptNS([[_UINavigationParallaxTransition alloc] initWithCurrentOperation:transitionOperation]);
+
+    RetainPtr&lt;_UIViewControllerOneToOneTransitionContext&gt; transitionContext = adoptNS([[_UIViewControllerOneToOneTransitionContext alloc] init]);
+    [transitionContext _setFromViewController:targettedViewController.get()];
+    [transitionContext _setToViewController:snapshotViewController.get()];
+    [transitionContext _setContainerView:m_transitionContainerView.get()];
+    [transitionContext _setFromStartFrame:[m_liveSwipeView bounds]];
+    [transitionContext _setToEndFrame:[m_liveSwipeView bounds]];
+    [transitionContext _setToStartFrame:CGRectZero];
+    [transitionContext _setFromEndFrame:CGRectZero];
+    [transitionContext _setAnimator:animationController.get()];
+    [transitionContext _setInteractor:transition];
+    [transitionContext _setTransitionIsInFlight:YES];
+    [transitionContext _setCompletionHandler:^(_UIViewControllerTransitionContext *context, BOOL didComplete) { endSwipeGesture(targetItem, context, !didComplete); }];
+
+    [transition setAnimationController:animationController.get()];
+    [transition startInteractiveTransition:transitionContext.get()];
+
+    m_activeGestureType = ViewGestureType::Swipe;
+}
+
+bool ViewGestureController::canSwipeInDirection(SwipeDirection direction)
+{
+    if (direction == SwipeDirection::Left)
+        return !!m_webPageProxy.backForwardList().backItem();
+    return !!m_webPageProxy.backForwardList().forwardItem();
+}
+
+void ViewGestureController::endSwipeGesture(WebBackForwardListItem* targetItem, _UIViewControllerTransitionContext *context, bool cancelled)
+{
+    [context _setTransitionIsInFlight:NO];
+    [context _setInteractor:nil];
+    [context _setAnimator:nil];
+    
+    [[m_transitionContainerView superview] insertSubview:m_snapshotView.get() aboveSubview:m_transitionContainerView.get()];
+    [[m_transitionContainerView superview] insertSubview:m_liveSwipeView aboveSubview:m_transitionContainerView.get()];
+    [m_transitionContainerView removeFromSuperview];
+    m_transitionContainerView = nullptr;
+    
+    [m_liveSwipeView setFrame:m_originalLiveSwipeViewFrame];
+    [m_snapshotView setFrame:m_originalLiveSwipeViewFrame];
+    
+    if (cancelled) {
+        removeSwipeSnapshot();
+        return;
+    }
+    
+    m_targetRenderTreeSize = ViewSnapshotStore::shared().snapshotAndRenderTreeSize(targetItem).second * swipeSnapshotRemovalRenderTreeSizeTargetFraction;
+    
+    // We don't want to replace the current back-forward item's snapshot
+    // like we normally would when going back or forward, because we are
+    // displaying the destination item's snapshot.
+    ViewSnapshotStore::shared().disableSnapshotting();
+    m_webPageProxy.goToBackForwardItem(targetItem);
+    ViewSnapshotStore::shared().enableSnapshotting();
+    
+    if (!m_targetRenderTreeSize) {
+        removeSwipeSnapshot();
+        return;
+    }
+
+    m_swipeWatchdogTimer.startOneShot(swipeSnapshotRemovalWatchdogDuration.count());
+}
+    
+void ViewGestureController::setRenderTreeSize(uint64_t renderTreeSize)
+{
+    if (m_activeGestureType != ViewGestureType::Swipe)
+        return;
+
+    if (m_targetRenderTreeSize &amp;&amp; renderTreeSize &gt; m_targetRenderTreeSize)
+        removeSwipeSnapshot();
+}
+
+void ViewGestureController::swipeSnapshotWatchdogTimerFired(Timer&lt;ViewGestureController&gt;*)
+{
+    removeSwipeSnapshot();
+}
+
+void ViewGestureController::removeSwipeSnapshot()
+{
+    m_swipeWatchdogTimer.stop();
+
+    if (m_activeGestureType != ViewGestureType::Swipe)
+        return;
+    
+#if USE(IOSURFACE)
+    IOSurfaceRef snapshotSurface = (IOSurfaceRef)[m_snapshotView layer].contents;
+    if (snapshotSurface)
+        IOSurfaceSetPurgeable(snapshotSurface, kIOSurfacePurgeableVolatile, nullptr);
+#endif
+    
+    [m_snapshotView removeFromSuperview];
+    m_snapshotView = nullptr;
+    
+    m_targetRenderTreeSize = 0;
+    m_activeGestureType = ViewGestureType::None;
+}
+
+} // namespace WebKit
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewGestureControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h (163665 => 163666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h        2014-02-08 00:55:15 UTC (rev 163665)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h        2014-02-08 00:58:08 UTC (rev 163666)
</span><span class="lines">@@ -26,16 +26,22 @@
</span><span class="cx"> #ifndef ViewGestureController_h
</span><span class="cx"> #define ViewGestureController_h
</span><span class="cx"> 
</span><del>-#if !PLATFORM(IOS)
-
</del><span class="cx"> #include &quot;MessageReceiver.h&quot;
</span><span class="cx"> #include &lt;WebCore/FloatRect.h&gt;
</span><span class="cx"> #include &lt;WebCore/Timer.h&gt;
</span><span class="cx"> #include &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> 
</span><span class="cx"> OBJC_CLASS CALayer;
</span><ins>+
+#if PLATFORM(IOS)
+OBJC_CLASS UIView;
+OBJC_CLASS WKSwipeTransitionController;
+OBJC_CLASS _UIViewControllerTransitionContext;
+OBJC_CLASS _UINavigationInteractiveTransitionBase;
+#else
</ins><span class="cx"> OBJC_CLASS NSEvent;
</span><span class="cx"> OBJC_CLASS NSView;
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="lines">@@ -47,55 +53,75 @@
</span><span class="cx"> public:
</span><span class="cx">     ViewGestureController(WebPageProxy&amp;);
</span><span class="cx">     ~ViewGestureController();
</span><del>-
</del><ins>+    
+    enum class ViewGestureType {
+        None,
+#if !PLATFORM(IOS)
+        Magnification,
+        SmartMagnification,
+#endif
+        Swipe
+    };
+    
+    enum class SwipeTransitionStyle {
+        Overlap,
+        Push
+    };
+    
+    enum class SwipeDirection {
+        Left,
+        Right
+    };
+    
+#if !PLATFORM(IOS)
</ins><span class="cx">     double magnification() const;
</span><span class="cx"> 
</span><span class="cx">     void handleMagnificationGesture(double scale, WebCore::FloatPoint origin);
</span><span class="cx">     void handleSmartMagnificationGesture(WebCore::FloatPoint origin);
</span><span class="cx"> 
</span><span class="cx">     bool handleScrollWheelEvent(NSEvent *);
</span><del>-    void didHitRenderTreeSizeThreshold();
-
</del><span class="cx">     void wheelEventWasNotHandledByWebCore(NSEvent *);
</span><span class="cx"> 
</span><span class="cx">     void setCustomSwipeViews(Vector&lt;RetainPtr&lt;NSView&gt;&gt; views) { m_customSwipeViews = std::move(views); }
</span><span class="cx">     WebCore::FloatRect windowRelativeBoundsForCustomSwipeViews() const;
</span><span class="cx"> 
</span><span class="cx">     void endActiveGesture();
</span><ins>+#else
+    void installSwipeHandler(UIView *);
+    bool canSwipeInDirection(SwipeDirection);
+    void beginSwipeGesture(_UINavigationInteractiveTransitionBase *, SwipeDirection);
+    void endSwipeGesture(WebBackForwardListItem* targetItem, _UIViewControllerTransitionContext *, bool cancelled);
+    void setRenderTreeSize(uint64_t);
+#endif
</ins><span class="cx"> 
</span><del>-    enum class ViewGestureType {
-        None,
-        Magnification,
-        SmartMagnification,
-        Swipe
-    };
-
-    enum class SwipeTransitionStyle {
-        Overlap,
-        Push
-    };
-
</del><span class="cx"> private:
</span><span class="cx">     // IPC::MessageReceiver.
</span><span class="cx">     virtual void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&amp;) override;
</span><ins>+    
+    void removeSwipeSnapshot();
+    void swipeSnapshotWatchdogTimerFired(WebCore::Timer&lt;ViewGestureController&gt;*);
</ins><span class="cx"> 
</span><ins>+#if !PLATFORM(IOS)
</ins><span class="cx">     // Message handlers.
</span><span class="cx">     void didCollectGeometryForMagnificationGesture(WebCore::FloatRect visibleContentBounds, bool frameHandlesMagnificationGesture);
</span><span class="cx">     void didCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool isReplacedElement, bool frameHandlesMagnificationGesture);
</span><ins>+    void didHitRenderTreeSizeThreshold();
</ins><span class="cx"> 
</span><span class="cx">     void endMagnificationGesture();
</span><span class="cx">     WebCore::FloatPoint scaledMagnificationOrigin(WebCore::FloatPoint origin, double scale);
</span><span class="cx"> 
</span><del>-    enum class SwipeDirection { Left, Right };
</del><span class="cx">     void trackSwipeGesture(NSEvent *, SwipeDirection);
</span><span class="cx">     void beginSwipeGesture(WebBackForwardListItem* targetItem, SwipeDirection);
</span><span class="cx">     void handleSwipeGesture(WebBackForwardListItem* targetItem, double progress, SwipeDirection);
</span><span class="cx">     void endSwipeGesture(WebBackForwardListItem* targetItem, bool cancelled);
</span><del>-    void removeSwipeSnapshot();
-    void swipeSnapshotWatchdogTimerFired(WebCore::Timer&lt;ViewGestureController&gt;*);
-
</del><ins>+#endif
+    
</ins><span class="cx">     WebPageProxy&amp; m_webPageProxy;
</span><ins>+    ViewGestureType m_activeGestureType;
+    
+    WebCore::Timer&lt;ViewGestureController&gt; m_swipeWatchdogTimer;
</ins><span class="cx"> 
</span><ins>+#if !PLATFORM(IOS)
</ins><span class="cx">     double m_magnification;
</span><span class="cx">     WebCore::FloatPoint m_magnificationOrigin;
</span><span class="cx"> 
</span><span class="lines">@@ -103,8 +129,6 @@
</span><span class="cx">     bool m_lastMagnificationGestureWasSmartMagnification;
</span><span class="cx">     WebCore::FloatPoint m_lastSmartMagnificationOrigin;
</span><span class="cx"> 
</span><del>-    ViewGestureType m_activeGestureType;
-
</del><span class="cx">     WebCore::FloatRect m_visibleContentRect;
</span><span class="cx">     bool m_visibleContentRectIsValid;
</span><span class="cx">     bool m_frameHandlesMagnificationGesture;
</span><span class="lines">@@ -113,7 +137,6 @@
</span><span class="cx">     Vector&lt;RetainPtr&lt;CALayer&gt;&gt; m_currentSwipeLiveLayers;
</span><span class="cx"> 
</span><span class="cx">     SwipeTransitionStyle m_swipeTransitionStyle;
</span><del>-    WebCore::Timer&lt;ViewGestureController&gt; m_swipeWatchdogTimer;
</del><span class="cx">     Vector&lt;RetainPtr&lt;NSView&gt;&gt; m_customSwipeViews;
</span><span class="cx">     WebCore::FloatRect m_currentSwipeCustomViewBounds;
</span><span class="cx"> 
</span><span class="lines">@@ -121,10 +144,17 @@
</span><span class="cx">     // the scroll event that would have started a swipe, we'll fill these in.
</span><span class="cx">     bool m_hasPendingSwipe;
</span><span class="cx">     SwipeDirection m_pendingSwipeDirection;
</span><ins>+#else
+    CGRect m_originalLiveSwipeViewFrame;
+    
+    UIView *m_liveSwipeView;
+    RetainPtr&lt;UIView&gt; m_snapshotView;
+    RetainPtr&lt;UIView&gt; m_transitionContainerView;
+    RetainPtr&lt;WKSwipeTransitionController&gt; m_swipeInteractiveTransitionDelegate;
+    uint64_t m_targetRenderTreeSize;
+#endif
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><del>-#endif // !PLATFORM(IOS)
-
</del><span class="cx"> #endif // ViewGestureController_h
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewGestureControllermessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.messages.in (163665 => 163666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.messages.in        2014-02-08 00:55:15 UTC (rev 163665)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.messages.in        2014-02-08 00:58:08 UTC (rev 163666)
</span><span class="lines">@@ -20,12 +20,10 @@
</span><span class="cx"> # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
</span><span class="cx"> # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> 
</span><del>-#if !PLATFORM(IOS)
-
</del><span class="cx"> messages -&gt; ViewGestureController {
</span><ins>+#if !PLATFORM(IOS)
</ins><span class="cx">     DidCollectGeometryForMagnificationGesture(WebCore::FloatRect visibleContentBounds, bool frameHandlesMagnificationGesture)
</span><span class="cx">     DidCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool isReplacedElement, bool frameHandlesMagnificationGesture)
</span><span class="cx">     DidHitRenderTreeSizeThreshold()
</span><del>-}
-
</del><span class="cx"> #endif
</span><ins>+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewGestureControllerMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm (163665 => 163666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm        2014-02-08 00:55:15 UTC (rev 163665)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm        2014-02-08 00:58:08 UTC (rev 163666)
</span><span class="lines">@@ -93,12 +93,13 @@
</span><span class="cx"> 
</span><span class="cx"> ViewGestureController::ViewGestureController(WebPageProxy&amp; webPageProxy)
</span><span class="cx">     : m_webPageProxy(webPageProxy)
</span><ins>+    , m_activeGestureType(ViewGestureType::None)
+    , m_swipeWatchdogTimer(this, &amp;ViewGestureController::swipeSnapshotWatchdogTimerFired)
</ins><span class="cx">     , m_lastMagnificationGestureWasSmartMagnification(false)
</span><del>-    , m_activeGestureType(ViewGestureType::None)
</del><span class="cx">     , m_visibleContentRectIsValid(false)
</span><span class="cx">     , m_frameHandlesMagnificationGesture(false)
</span><span class="cx">     , m_swipeTransitionStyle(SwipeTransitionStyle::Overlap)
</span><del>-    , m_swipeWatchdogTimer(this, &amp;ViewGestureController::swipeSnapshotWatchdogTimerFired)
</del><ins>+    
</ins><span class="cx">     , m_hasPendingSwipe(false)
</span><span class="cx"> {
</span><span class="cx">     m_webPageProxy.process().addMessageReceiver(Messages::ViewGestureController::messageReceiverName(), m_webPageProxy.pageID(), *this);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewSnapshotStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h (163665 => 163666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h        2014-02-08 00:55:15 UTC (rev 163665)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h        2014-02-08 00:58:08 UTC (rev 163666)
</span><span class="lines">@@ -26,14 +26,16 @@
</span><span class="cx"> #ifndef ViewSnapshotStore_h
</span><span class="cx"> #define ViewSnapshotStore_h
</span><span class="cx"> 
</span><del>-#if !PLATFORM(IOS)
-
</del><span class="cx"> #include &lt;chrono&gt;
</span><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><span class="cx"> #include &lt;wtf/Noncopyable.h&gt;
</span><span class="cx"> #include &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><ins>+#if USE(IOSURFACE)
+#include &lt;IOSurface/IOSurface.h&gt;
+#endif
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> class WebBackForwardListItem;
</span><span class="lines">@@ -48,7 +50,11 @@
</span><span class="cx">     static ViewSnapshotStore&amp; shared();
</span><span class="cx"> 
</span><span class="cx">     void recordSnapshot(WebPageProxy&amp;);
</span><ins>+#if USE(IOSURFACE)
</ins><span class="cx">     std::pair&lt;RetainPtr&lt;IOSurfaceRef&gt;, uint64_t&gt; snapshotAndRenderTreeSize(WebBackForwardListItem*);
</span><ins>+#else
+    std::pair&lt;RetainPtr&lt;CGImageRef&gt;, uint64_t&gt; snapshotAndRenderTreeSize(WebBackForwardListItem*);
+#endif
</ins><span class="cx"> 
</span><span class="cx">     void disableSnapshotting() { m_enabled = false; }
</span><span class="cx">     void enableSnapshotting() { m_enabled = true; }
</span><span class="lines">@@ -57,8 +63,12 @@
</span><span class="cx">     void pruneSnapshots(WebPageProxy&amp;);
</span><span class="cx"> 
</span><span class="cx">     struct Snapshot {
</span><ins>+#if USE(IOSURFACE)
</ins><span class="cx">         RetainPtr&lt;IOSurfaceRef&gt; surface;
</span><span class="cx">         RetainPtr&lt;CGContextRef&gt; surfaceContext;
</span><ins>+#else
+        RetainPtr&lt;CGImageRef&gt; image;
+#endif
</ins><span class="cx"> 
</span><span class="cx">         std::chrono::steady_clock::time_point creationTime;
</span><span class="cx">     };
</span><span class="lines">@@ -71,6 +81,4 @@
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><del>-#endif // !PLATFORM(IOS)
-
</del><span class="cx"> #endif // ViewSnapshotStore_h
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewSnapshotStoremm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm (163665 => 163666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm        2014-02-08 00:55:15 UTC (rev 163665)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm        2014-02-08 00:58:08 UTC (rev 163666)
</span><span class="lines">@@ -26,18 +26,17 @@
</span><span class="cx"> #import &quot;config.h&quot;
</span><span class="cx"> #import &quot;ViewSnapshotStore.h&quot;
</span><span class="cx"> 
</span><del>-#if !PLATFORM(IOS)
-
</del><span class="cx"> #import &quot;WebBackForwardList.h&quot;
</span><span class="cx"> #import &quot;WebPageProxy.h&quot;
</span><span class="cx"> #import &lt;CoreGraphics/CoreGraphics.h&gt;
</span><del>-#import &lt;IOSurface/IOSurface.h&gt;
</del><span class="cx"> #import &lt;WebCore/UUID.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if defined(__has_include) &amp;&amp; __has_include(&lt;CoreGraphics/CoreGraphicsPrivate.h&gt;)
</span><span class="cx"> #import &lt;CoreGraphics/CoreGraphicsPrivate.h&gt;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if USE(IOSURFACE)
+#import &lt;IOSurface/IOSurface.h&gt;
</ins><span class="cx"> extern &quot;C&quot; CGContextRef CGIOSurfaceContextCreate(IOSurfaceRef surface, size_t width, size_t height, size_t bitsPerComponent, size_t bitsPerPixel, CGColorSpaceRef space, CGBitmapInfo bitmapInfo);
</span><span class="cx"> 
</span><span class="cx"> #if defined(__has_include) &amp;&amp; __has_include(&lt;IOSurface/IOSurfacePrivate.h&gt;)
</span><span class="lines">@@ -48,9 +47,10 @@
</span><span class="cx"> };
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 1090
</del><ins>+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 1090
</ins><span class="cx"> extern &quot;C&quot; IOReturn IOSurfaceSetPurgeable(IOSurfaceRef buffer, uint32_t newState, uint32_t *oldState);
</span><span class="cx"> #endif
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="lines">@@ -118,6 +118,7 @@
</span><span class="cx">     m_snapshotMap.remove(oldestSnapshotUUID);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if USE(IOSURFACE)
</ins><span class="cx"> static std::pair&lt;RetainPtr&lt;IOSurfaceRef&gt;, RetainPtr&lt;CGContextRef&gt;&gt; createIOSurfaceFromImage(CGImageRef image)
</span><span class="cx"> {
</span><span class="cx">     unsigned pixelFormat = 'BGRA';
</span><span class="lines">@@ -149,6 +150,7 @@
</span><span class="cx"> 
</span><span class="cx">     return std::make_pair(surface, surfaceContext);
</span><span class="cx"> }
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx"> void ViewSnapshotStore::recordSnapshot(WebPageProxy&amp; webPageProxy)
</span><span class="cx"> {
</span><span class="lines">@@ -173,23 +175,30 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     item-&gt;setSnapshotUUID(createCanonicalUUIDString());
</span><ins>+    
+    Snapshot snapshot;
+    snapshot.creationTime = std::chrono::steady_clock::now();
</ins><span class="cx"> 
</span><ins>+#if USE(IOSURFACE)
</ins><span class="cx">     auto surfaceAndContext = createIOSurfaceFromImage(snapshotImage.get());
</span><del>-
-    Snapshot snapshot;
</del><span class="cx">     snapshot.surface = surfaceAndContext.first;
</span><span class="cx">     snapshot.surfaceContext = surfaceAndContext.second;
</span><del>-    snapshot.creationTime = std::chrono::steady_clock::now();
-
-#if __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 1090
</del><ins>+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 1090
</ins><span class="cx">     IOSurfaceSetPurgeable(snapshot.surface.get(), kIOSurfacePurgeableVolatile, nullptr);
</span><span class="cx"> #endif
</span><ins>+#else
+    snapshot.image = snapshotImage;
+#endif
</ins><span class="cx"> 
</span><span class="cx">     m_snapshotMap.add(item-&gt;snapshotUUID(), snapshot);
</span><span class="cx">     m_renderTreeSizeMap.add(item-&gt;snapshotUUID(), webPageProxy.renderTreeSize());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if USE(IOSURFACE)
</ins><span class="cx"> std::pair&lt;RetainPtr&lt;IOSurfaceRef&gt;, uint64_t&gt; ViewSnapshotStore::snapshotAndRenderTreeSize(WebBackForwardListItem* item)
</span><ins>+#else
+std::pair&lt;RetainPtr&lt;CGImageRef&gt;, uint64_t&gt; ViewSnapshotStore::snapshotAndRenderTreeSize(WebBackForwardListItem* item)
+#endif
</ins><span class="cx"> {
</span><span class="cx">     if (item-&gt;snapshotUUID().isEmpty())
</span><span class="cx">         return std::make_pair(nullptr, 0);
</span><span class="lines">@@ -199,14 +208,15 @@
</span><span class="cx">         return std::make_pair(nullptr, 0);
</span><span class="cx"> 
</span><span class="cx">     const auto&amp; snapshot = m_snapshotMap.find(item-&gt;snapshotUUID());
</span><del>-    RetainPtr&lt;IOSurfaceRef&gt; surface;
</del><span class="cx"> 
</span><del>-    if (snapshot != m_snapshotMap.end())
-        surface = snapshot-&gt;value.surface;
-
-    return std::make_pair(surface, renderTreeSize-&gt;value);
</del><ins>+    if (snapshot == m_snapshotMap.end())
+        return std::make_pair(nullptr, renderTreeSize-&gt;value);
+    
+#if USE(IOSURFACE)
+    return std::make_pair(snapshot-&gt;value.surface, renderTreeSize-&gt;value);
+#else
+    return std::make_pair(snapshot-&gt;value.image, renderTreeSize-&gt;value);
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span><del>-
-#endif
</del></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (163665 => 163666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-02-08 00:55:15 UTC (rev 163665)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-02-08 00:58:08 UTC (rev 163666)
</span><span class="lines">@@ -484,6 +484,7 @@
</span><span class="cx">                 2DA944BD188511E700ED86DB /* NetworkProcessIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DA944BC188511E700ED86DB /* NetworkProcessIOS.mm */; };
</span><span class="cx">                 2DDE0AFA18298CC900F97EAA /* RemoteLayerTreePropertyApplier.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DDE0AF818298CC900F97EAA /* RemoteLayerTreePropertyApplier.h */; };
</span><span class="cx">                 2DDE0AFB18298CC900F97EAA /* RemoteLayerTreePropertyApplier.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DDE0AF918298CC900F97EAA /* RemoteLayerTreePropertyApplier.mm */; };
</span><ins>+                2DF9593B18A42412009785A1 /* ViewGestureControllerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DF9593418A42412009785A1 /* ViewGestureControllerIOS.mm */; };
</ins><span class="cx">                 31099973146C75A20029DEB9 /* WebNotificationClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31099971146C759B0029DEB9 /* WebNotificationClient.cpp */; };
</span><span class="cx">                 310999C7146C9E3D0029DEB9 /* WebNotificationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 31099968146C71F50029DEB9 /* WebNotificationClient.h */; };
</span><span class="cx">                 312C0C4A146DDC8A0016C911 /* WKNotificationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 312C0C49146DDC8A0016C911 /* WKNotificationProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -2185,6 +2186,7 @@
</span><span class="cx">                 2DA944BC188511E700ED86DB /* NetworkProcessIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = NetworkProcessIOS.mm; path = NetworkProcess/ios/NetworkProcessIOS.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2DDE0AF818298CC900F97EAA /* RemoteLayerTreePropertyApplier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteLayerTreePropertyApplier.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2DDE0AF918298CC900F97EAA /* RemoteLayerTreePropertyApplier.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteLayerTreePropertyApplier.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                2DF9593418A42412009785A1 /* ViewGestureControllerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ViewGestureControllerIOS.mm; path = ios/ViewGestureControllerIOS.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 31099968146C71F50029DEB9 /* WebNotificationClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebNotificationClient.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 31099971146C759B0029DEB9 /* WebNotificationClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebNotificationClient.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 312C0C49146DDC8A0016C911 /* WKNotificationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNotificationProvider.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -4222,6 +4224,7 @@
</span><span class="cx">                 2DA944A81884E9AB00ED86DB /* ios */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                2DF9593418A42412009785A1 /* ViewGestureControllerIOS.mm */,
</ins><span class="cx">                                 2DA944A91884E9BA00ED86DB /* TextCheckerIOS.mm */,
</span><span class="cx">                                 2DA944AA1884E9BA00ED86DB /* WebInspectorProxyIOS.mm */,
</span><span class="cx">                                 2DA944AB1884E9BA00ED86DB /* WebPageProxyIOS.mm */,
</span><span class="lines">@@ -7874,6 +7877,7 @@
</span><span class="cx">                                 51D130531382EAC000351EDD /* SecItemRequestData.cpp in Sources */,
</span><span class="cx">                                 51D130551382EAC000351EDD /* SecItemResponseData.cpp in Sources */,
</span><span class="cx">                                 E179088D169BAA62006904C7 /* SecItemShim.cpp in Sources */,
</span><ins>+                                2DF9593B18A42412009785A1 /* ViewGestureControllerIOS.mm in Sources */,
</ins><span class="cx">                                 E1790890169BAA7F006904C7 /* SecItemShimMessageReceiver.cpp in Sources */,
</span><span class="cx">                                 E18E690B169B563F009B6670 /* SecItemShimProxy.cpp in Sources */,
</span><span class="cx">                                 E18E6917169B667B009B6670 /* SecItemShimProxyMessageReceiver.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacRemoteLayerTreeDrawingAreamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm (163665 => 163666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm        2014-02-08 00:55:15 UTC (rev 163665)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm        2014-02-08 00:58:08 UTC (rev 163666)
</span><span class="lines">@@ -323,6 +323,7 @@
</span><span class="cx">     m_remoteLayerTreeContext-&gt;buildTransaction(layerTransaction, *m_rootLayer);
</span><span class="cx">     layerTransaction.setContentsSize(m_webPage-&gt;corePage()-&gt;mainFrame().view()-&gt;contentsSize());
</span><span class="cx">     layerTransaction.setPageScaleFactor(m_webPage-&gt;corePage()-&gt;pageScaleFactor());
</span><ins>+    layerTransaction.setRenderTreeSize(m_webPage-&gt;corePage()-&gt;renderTreeSize());
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     layerTransaction.setMinimumScaleFactor(m_webPage-&gt;minimumPageScaleFactor());
</span><span class="cx">     layerTransaction.setMaximumScaleFactor(m_webPage-&gt;maximumPageScaleFactor());
</span></span></pre>
</div>
</div>

</body>
</html>