<!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>[170974] 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/170974">170974</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2014-07-10 13:33:05 -0700 (Thu, 10 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Store ViewSnapshots directly on the WebBackForwardListItem
https://bugs.webkit.org/show_bug.cgi?id=134667
&lt;rdar://problem/17082639&gt;

Reviewed by Dan Bernstein.

Make ViewSnapshot a refcounted class. Store it directly on the back-forward item
instead of in a side map referenced by UUID. Switch to a very simple LRU eviction model for now.
This fixes a ton of snapshot management bugs; for example, we would start throwing out snapshots
in the page that was actively being interacted with *first* when evicting snapshots, instead of
preferring older snapshots. Additionally, we would not throw away snapshots when back forward items
became unreachable.

There is definitely room for improvement of the eviction mechanism, but this is closer to a time-tested implementation.

* Shared/SessionState.h:
Keep a ViewSnapshot instead of a UUID on the BackForwardListItemState.

* Shared/WebBackForwardListItem.h:
Fix some indented namespace contents.

(WebKit::WebBackForwardListItem::snapshot):
(WebKit::WebBackForwardListItem::setSnapshot):
(WebKit::WebBackForwardListItem::setSnapshotUUID): Deleted.
(WebKit::WebBackForwardListItem::snapshotUUID): Deleted.
Switch the snapshot getter/setter to operate on ViewSnapshots instead of UUIDs.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _takeViewSnapshot]):
* UIProcess/API/Cocoa/WKWebViewInternal.h:
* UIProcess/API/mac/WKView.mm:
(-[WKView _takeViewSnapshot]):
* UIProcess/API/mac/WKViewInternal.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::takeViewSnapshot):
* UIProcess/WebPageProxy.h:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::takeViewSnapshot):
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::takeViewSnapshot):
Adopt ViewSnapshot::create, return a PassRefPtr, and class-ify ViewSnapshot.

* UIProcess/ios/ViewGestureControllerIOS.mm:
(WebKit::ViewGestureController::beginSwipeGesture):
(WebKit::ViewGestureController::endSwipeGesture):
* UIProcess/mac/ViewGestureController.h:
* UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::shouldUseSnapshotForSize):
(WebKit::ViewGestureController::beginSwipeGesture):
(WebKit::ViewGestureController::endSwipeGesture):
Grab the ViewSnapshot directly from the WebBackForwardListItem, and adopt the new functions.

* UIProcess/ios/WebMemoryPressureHandlerIOS.mm:
(WebKit::WebMemoryPressureHandler::WebMemoryPressureHandler):
Rename discardSnapshots to discardSnapshotImages, because we're really only discarding
the images; the render tree size/background color &quot;snapshot&quot; remains and is useful.

* UIProcess/mac/ViewSnapshotStore.h:
(WebKit::ViewSnapshot::setRenderTreeSize):
(WebKit::ViewSnapshot::renderTreeSize):
(WebKit::ViewSnapshot::setBackgroundColor):
(WebKit::ViewSnapshot::backgroundColor):
(WebKit::ViewSnapshot::setDeviceScaleFactor):
(WebKit::ViewSnapshot::deviceScaleFactor):
(WebKit::ViewSnapshot::imageSizeInBytes):
(WebKit::ViewSnapshot::surface):
(WebKit::ViewSnapshot::size):
(WebKit::ViewSnapshot::creationTime):
Make ViewSnapshot a refcounted class.
Add create functions which take an image (or slot ID), and relevant sizes.
It is expected that a ViewSnapshot is created with an image, and it is only possible
to remove that image, never to replace it. A new ViewSnapshot is required in that case.
Add setters for things that ViewSnapshotStore sets on the snapshot after the PageClient
retrieves it from the view. Add getters for things that the ViewGestureControllers need.

Remove removeSnapshotImage, getSnapshot, and the snapshot map.

* UIProcess/mac/ViewSnapshotStore.mm:
(WebKit::ViewSnapshotStore::~ViewSnapshotStore):
(WebKit::ViewSnapshotStore::didAddImageToSnapshot):
(WebKit::ViewSnapshotStore::willRemoveImageFromSnapshot):
Manage m_snapshotCacheSize and m_snapshotsWithImages via didAddImageToSnapshot and willRemoveImageFromSnapshot.
willRemoveImageFromSnapshot will -always- be called before the ViewSnapshot is destroyed.

(WebKit::ViewSnapshotStore::pruneSnapshots):
Switch to a simple LRU eviction model. As previously mentioned, it's possible to do better, but
this is much less broken than the previous implementation.

(WebKit::ViewSnapshotStore::recordSnapshot):
(WebKit::ViewSnapshotStore::discardSnapshotImages):
(WebKit::ViewSnapshot::create):
(WebKit::ViewSnapshot::ViewSnapshot):
(WebKit::ViewSnapshot::~ViewSnapshot):
(WebKit::ViewSnapshot::hasImage):
(WebKit::ViewSnapshot::clearImage):
(WebKit::ViewSnapshot::asLayerContents):
If a surface is Empty when it comes back from being volatile, throw away the surface
and notify the Store to remove it from m_snapshotCacheSize (via clearImage()).

(WebKit::ViewSnapshotStore::removeSnapshotImage): Deleted.
(WebKit::ViewSnapshotStore::getSnapshot): Deleted.
(WebKit::ViewSnapshotStore::discardSnapshots): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedSessionStateh">trunk/Source/WebKit2/Shared/SessionState.h</a></li>
<li><a href="#trunkSourceWebKit2SharedWebBackForwardListItemh">trunk/Source/WebKit2/Shared/WebBackForwardListItem.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewInternalh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h</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="#trunkSourceWebKit2UIProcessPageClienth">trunk/Source/WebKit2/UIProcess/PageClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosPageClientImplIOSh">trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosPageClientImplIOSmm">trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosViewGestureControllerIOSmm">trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWebMemoryPressureHandlerIOSmm">trunk/Source/WebKit2/UIProcess/ios/WebMemoryPressureHandlerIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacPageClientImplh">trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacPageClientImplmm">trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewGestureControllerh">trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h</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>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (170973 => 170974)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-07-10 20:24:12 UTC (rev 170973)
+++ trunk/Source/WebKit2/ChangeLog        2014-07-10 20:33:05 UTC (rev 170974)
</span><span class="lines">@@ -1,3 +1,111 @@
</span><ins>+2014-07-10  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Store ViewSnapshots directly on the WebBackForwardListItem
+        https://bugs.webkit.org/show_bug.cgi?id=134667
+        &lt;rdar://problem/17082639&gt;
+
+        Reviewed by Dan Bernstein.
+
+        Make ViewSnapshot a refcounted class. Store it directly on the back-forward item
+        instead of in a side map referenced by UUID. Switch to a very simple LRU eviction model for now.
+        This fixes a ton of snapshot management bugs; for example, we would start throwing out snapshots
+        in the page that was actively being interacted with *first* when evicting snapshots, instead of
+        preferring older snapshots. Additionally, we would not throw away snapshots when back forward items
+        became unreachable.
+
+        There is definitely room for improvement of the eviction mechanism, but this is closer to a time-tested implementation.
+
+        * Shared/SessionState.h:
+        Keep a ViewSnapshot instead of a UUID on the BackForwardListItemState.
+
+        * Shared/WebBackForwardListItem.h:
+        Fix some indented namespace contents.
+
+        (WebKit::WebBackForwardListItem::snapshot):
+        (WebKit::WebBackForwardListItem::setSnapshot):
+        (WebKit::WebBackForwardListItem::setSnapshotUUID): Deleted.
+        (WebKit::WebBackForwardListItem::snapshotUUID): Deleted.
+        Switch the snapshot getter/setter to operate on ViewSnapshots instead of UUIDs.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _takeViewSnapshot]):
+        * UIProcess/API/Cocoa/WKWebViewInternal.h:
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _takeViewSnapshot]):
+        * UIProcess/API/mac/WKViewInternal.h:
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::takeViewSnapshot):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::takeViewSnapshot):
+        * UIProcess/mac/PageClientImpl.h:
+        * UIProcess/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::takeViewSnapshot):
+        Adopt ViewSnapshot::create, return a PassRefPtr, and class-ify ViewSnapshot.
+
+        * UIProcess/ios/ViewGestureControllerIOS.mm:
+        (WebKit::ViewGestureController::beginSwipeGesture):
+        (WebKit::ViewGestureController::endSwipeGesture):
+        * UIProcess/mac/ViewGestureController.h:
+        * UIProcess/mac/ViewGestureControllerMac.mm:
+        (WebKit::ViewGestureController::shouldUseSnapshotForSize):
+        (WebKit::ViewGestureController::beginSwipeGesture):
+        (WebKit::ViewGestureController::endSwipeGesture):
+        Grab the ViewSnapshot directly from the WebBackForwardListItem, and adopt the new functions.
+
+        * UIProcess/ios/WebMemoryPressureHandlerIOS.mm:
+        (WebKit::WebMemoryPressureHandler::WebMemoryPressureHandler):
+        Rename discardSnapshots to discardSnapshotImages, because we're really only discarding
+        the images; the render tree size/background color &quot;snapshot&quot; remains and is useful.
+
+        * UIProcess/mac/ViewSnapshotStore.h:
+        (WebKit::ViewSnapshot::setRenderTreeSize):
+        (WebKit::ViewSnapshot::renderTreeSize):
+        (WebKit::ViewSnapshot::setBackgroundColor):
+        (WebKit::ViewSnapshot::backgroundColor):
+        (WebKit::ViewSnapshot::setDeviceScaleFactor):
+        (WebKit::ViewSnapshot::deviceScaleFactor):
+        (WebKit::ViewSnapshot::imageSizeInBytes):
+        (WebKit::ViewSnapshot::surface):
+        (WebKit::ViewSnapshot::size):
+        (WebKit::ViewSnapshot::creationTime):
+        Make ViewSnapshot a refcounted class.
+        Add create functions which take an image (or slot ID), and relevant sizes.
+        It is expected that a ViewSnapshot is created with an image, and it is only possible
+        to remove that image, never to replace it. A new ViewSnapshot is required in that case.
+        Add setters for things that ViewSnapshotStore sets on the snapshot after the PageClient
+        retrieves it from the view. Add getters for things that the ViewGestureControllers need.
+
+        Remove removeSnapshotImage, getSnapshot, and the snapshot map.
+
+        * UIProcess/mac/ViewSnapshotStore.mm:
+        (WebKit::ViewSnapshotStore::~ViewSnapshotStore):
+        (WebKit::ViewSnapshotStore::didAddImageToSnapshot):
+        (WebKit::ViewSnapshotStore::willRemoveImageFromSnapshot):
+        Manage m_snapshotCacheSize and m_snapshotsWithImages via didAddImageToSnapshot and willRemoveImageFromSnapshot.
+        willRemoveImageFromSnapshot will -always- be called before the ViewSnapshot is destroyed.
+
+        (WebKit::ViewSnapshotStore::pruneSnapshots):
+        Switch to a simple LRU eviction model. As previously mentioned, it's possible to do better, but
+        this is much less broken than the previous implementation.
+
+        (WebKit::ViewSnapshotStore::recordSnapshot):
+        (WebKit::ViewSnapshotStore::discardSnapshotImages):
+        (WebKit::ViewSnapshot::create):
+        (WebKit::ViewSnapshot::ViewSnapshot):
+        (WebKit::ViewSnapshot::~ViewSnapshot):
+        (WebKit::ViewSnapshot::hasImage):
+        (WebKit::ViewSnapshot::clearImage):
+        (WebKit::ViewSnapshot::asLayerContents):
+        If a surface is Empty when it comes back from being volatile, throw away the surface
+        and notify the Store to remove it from m_snapshotCacheSize (via clearImage()).
+
+        (WebKit::ViewSnapshotStore::removeSnapshotImage): Deleted.
+        (WebKit::ViewSnapshotStore::getSnapshot): Deleted.
+        (WebKit::ViewSnapshotStore::discardSnapshots): Deleted.
+
</ins><span class="cx"> 2014-07-10  Beth Dakin  &lt;bdakin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Need Setting/WKPreference that allows clients to prevent scrollbars from drawing 
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedSessionStateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/SessionState.h (170973 => 170974)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/SessionState.h        2014-07-10 20:24:12 UTC (rev 170973)
+++ trunk/Source/WebKit2/Shared/SessionState.h        2014-07-10 20:33:05 UTC (rev 170974)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #ifndef SessionState_h
</span><span class="cx"> #define SessionState_h
</span><span class="cx"> 
</span><ins>+#include &quot;ViewSnapshotStore.h&quot;
</ins><span class="cx"> #include &lt;WebCore/FloatRect.h&gt;
</span><span class="cx"> #include &lt;WebCore/IntRect.h&gt;
</span><span class="cx"> #include &lt;WebCore/URL.h&gt;
</span><span class="lines">@@ -120,8 +121,7 @@
</span><span class="cx">     uint64_t identifier;
</span><span class="cx"> 
</span><span class="cx">     PageState pageState;
</span><del>-    // FIXME: This should hold the snapshot itself, not its UUID.
-    String snapshotUUID;
</del><ins>+    RefPtr&lt;ViewSnapshot&gt; snapshot;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> struct BackForwardListState {
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebBackForwardListItemh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebBackForwardListItem.h (170973 => 170974)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebBackForwardListItem.h        2014-07-10 20:24:12 UTC (rev 170973)
+++ trunk/Source/WebKit2/Shared/WebBackForwardListItem.h        2014-07-10 20:33:05 UTC (rev 170974)
</span><span class="lines">@@ -36,8 +36,8 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> namespace IPC {
</span><del>-    class ArgumentDecoder;
-    class ArgumentEncoder;
</del><ins>+class ArgumentDecoder;
+class ArgumentEncoder;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="lines">@@ -56,10 +56,10 @@
</span><span class="cx">     const String&amp; originalURL() const { return m_itemState.pageState.mainFrameState.originalURLString; }
</span><span class="cx">     const String&amp; url() const { return m_itemState.pageState.mainFrameState.urlString; }
</span><span class="cx">     const String&amp; title() const { return m_itemState.pageState.title; }
</span><del>-    
-    void setSnapshotUUID(const String&amp; uuid) { m_itemState.snapshotUUID = uuid; }
-    const String&amp; snapshotUUID() const { return m_itemState.snapshotUUID; }
</del><span class="cx"> 
</span><ins>+    ViewSnapshot* snapshot() const { return m_itemState.snapshot.get(); }
+    void setSnapshot(PassRefPtr&lt;ViewSnapshot&gt; snapshot) { m_itemState.snapshot = snapshot; }
+
</ins><span class="cx">     static uint64_t highedUsedItemID();
</span><span class="cx"> 
</span><span class="cx"> private:
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (170973 => 170974)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2014-07-10 20:24:12 UTC (rev 170973)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2014-07-10 20:33:05 UTC (rev 170974)
</span><span class="lines">@@ -899,24 +899,23 @@
</span><span class="cx">     _scaleToRestore = scale;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (WebKit::ViewSnapshot)_takeViewSnapshot
</del><ins>+- (PassRefPtr&lt;WebKit::ViewSnapshot&gt;)_takeViewSnapshot
</ins><span class="cx"> {
</span><span class="cx">     float deviceScale = WKGetScreenScaleFactor();
</span><span class="cx">     CGSize snapshotSize = self.bounds.size;
</span><span class="cx">     snapshotSize.width *= deviceScale;
</span><span class="cx">     snapshotSize.height *= deviceScale;
</span><span class="cx"> 
</span><del>-    WebKit::ViewSnapshot snapshot;
-    snapshot.slotID = [WebKit::ViewSnapshotStore::snapshottingContext() createImageSlot:snapshotSize hasAlpha:YES];
</del><ins>+    uint32_t slotID = [WebKit::ViewSnapshotStore::snapshottingContext() createImageSlot:snapshotSize hasAlpha:YES];
</ins><span class="cx"> 
</span><ins>+    if (!slotID)
+        return nullptr;
+
</ins><span class="cx">     CATransform3D transform = CATransform3DMakeScale(deviceScale, deviceScale, 1);
</span><del>-    CARenderServerCaptureLayerWithTransform(MACH_PORT_NULL, self.layer.context.contextId, (uint64_t)self.layer, snapshot.slotID, 0, 0, &amp;transform);
</del><ins>+    CARenderServerCaptureLayerWithTransform(MACH_PORT_NULL, self.layer.context.contextId, (uint64_t)self.layer, slotID, 0, 0, &amp;transform);
</ins><span class="cx"> 
</span><del>-    snapshot.size = WebCore::expandedIntSize(WebCore::FloatSize(snapshotSize));
-    snapshot.imageSizeInBytes = snapshotSize.width * snapshotSize.height * 4;
-    snapshot.backgroundColor = _page-&gt;pageExtendedBackgroundColor();
-
-    return snapshot;
</del><ins>+    WebCore::IntSize imageSize = WebCore::expandedIntSize(WebCore::FloatSize(snapshotSize));
+    return WebKit::ViewSnapshot::create(slotID, imageSize, imageSize.width() * imageSize.height() * 4);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_zoomToPoint:(WebCore::FloatPoint)point atScale:(double)scale
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h (170973 => 170974)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h        2014-07-10 20:24:12 UTC (rev 170973)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h        2014-07-10 20:33:05 UTC (rev 170974)
</span><span class="lines">@@ -50,9 +50,9 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><ins>+class ViewSnapshot;
</ins><span class="cx"> class WebPageProxy;
</span><span class="cx"> struct PrintInfo;
</span><del>-struct ViewSnapshot;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> @class _WKFrameHandle;
</span><span class="lines">@@ -78,7 +78,7 @@
</span><span class="cx"> - (void)_restorePageStateToExposedRect:(WebCore::FloatRect)exposedRect scale:(double)scale;
</span><span class="cx"> - (void)_restorePageStateToUnobscuredCenter:(WebCore::FloatPoint)center scale:(double)scale;
</span><span class="cx"> 
</span><del>-- (WebKit::ViewSnapshot)_takeViewSnapshot;
</del><ins>+- (PassRefPtr&lt;WebKit::ViewSnapshot&gt;)_takeViewSnapshot;
</ins><span class="cx"> 
</span><span class="cx"> - (void)_scrollToContentOffset:(WebCore::FloatPoint)contentOffset;
</span><span class="cx"> - (BOOL)_scrollToRect:(WebCore::FloatRect)targetRect origin:(WebCore::FloatPoint)origin minimumScrollDistance:(float)minimumScrollDistance;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (170973 => 170974)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2014-07-10 20:24:12 UTC (rev 170973)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2014-07-10 20:33:05 UTC (rev 170974)
</span><span class="lines">@@ -3101,15 +3101,13 @@
</span><span class="cx">     return _data-&gt;_rootLayer.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (ViewSnapshot)_takeViewSnapshot
</del><ins>+- (PassRefPtr&lt;ViewSnapshot&gt;)_takeViewSnapshot
</ins><span class="cx"> {
</span><span class="cx">     NSWindow *window = self.window;
</span><span class="cx"> 
</span><del>-    ViewSnapshot snapshot;
-
</del><span class="cx">     CGSWindowID windowID = (CGSWindowID)[window windowNumber];
</span><span class="cx">     if (!windowID || ![window isVisible])
</span><del>-        return snapshot;
</del><ins>+        return nullptr;
</ins><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;CGImageRef&gt; windowSnapshotImage = adoptCF(CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, windowID, kCGWindowImageBoundsIgnoreFraming | kCGWindowImageShouldBeOpaque));
</span><span class="cx"> 
</span><span class="lines">@@ -3141,15 +3139,12 @@
</span><span class="cx"> 
</span><span class="cx">     auto croppedSnapshotImage = adoptCF(CGImageCreateWithImageInRect(windowSnapshotImage.get(), NSRectToCGRect([window convertRectToBacking:croppedImageRect])));
</span><span class="cx"> 
</span><del>-    snapshot.surface = IOSurface::createFromImage(croppedSnapshotImage.get());
-    snapshot.surface-&gt;setIsVolatile(true);
</del><ins>+    auto surface = IOSurface::createFromImage(croppedSnapshotImage.get());
+    if (!surface)
+        return nullptr;
+    surface-&gt;setIsVolatile(true);
</ins><span class="cx"> 
</span><del>-    IntSize imageSize(CGImageGetWidth(croppedSnapshotImage.get()), CGImageGetHeight(croppedSnapshotImage.get()));
-    snapshot.size = imageSize;
-    snapshot.imageSizeInBytes = imageSize.width() * imageSize.height() * 4;
-    snapshot.backgroundColor = _data-&gt;_page-&gt;pageExtendedBackgroundColor();
-
-    return snapshot;
</del><ins>+    return ViewSnapshot::create(surface.get(), surface-&gt;size(), surface-&gt;totalBytes());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_wheelEventWasNotHandledByWebCore:(NSEvent *)event
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h (170973 => 170974)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h        2014-07-10 20:24:12 UTC (rev 170973)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h        2014-07-10 20:33:05 UTC (rev 170974)
</span><span class="lines">@@ -47,10 +47,10 @@
</span><span class="cx"> class DrawingAreaProxy;
</span><span class="cx"> class FindIndicator;
</span><span class="cx"> class LayerTreeContext;
</span><ins>+class ViewSnapshot;
</ins><span class="cx"> class WebContext;
</span><span class="cx"> struct ColorSpaceData;
</span><span class="cx"> struct EditorState;
</span><del>-struct ViewSnapshot;
</del><span class="cx"> struct WebPageConfiguration;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -83,7 +83,7 @@
</span><span class="cx"> - (void)_setAcceleratedCompositingModeRootLayer:(CALayer *)rootLayer;
</span><span class="cx"> - (CALayer *)_acceleratedCompositingModeRootLayer;
</span><span class="cx"> 
</span><del>-- (WebKit::ViewSnapshot)_takeViewSnapshot;
</del><ins>+- (PassRefPtr&lt;WebKit::ViewSnapshot&gt;)_takeViewSnapshot;
</ins><span class="cx"> - (void)_wheelEventWasNotHandledByWebCore:(NSEvent *)event;
</span><span class="cx"> 
</span><span class="cx"> - (void)_setAccessibilityWebProcessToken:(NSData *)data;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessPageClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (170973 => 170974)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/PageClient.h        2014-07-10 20:24:12 UTC (rev 170973)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h        2014-07-10 20:33:05 UTC (rev 170974)
</span><span class="lines">@@ -57,10 +57,10 @@
</span><span class="cx"> class FindIndicator;
</span><span class="cx"> class NativeWebKeyboardEvent;
</span><span class="cx"> class RemoteLayerTreeTransaction;
</span><ins>+class ViewSnapshot;
</ins><span class="cx"> class WebContextMenuProxy;
</span><span class="cx"> class WebEditCommandProxy;
</span><span class="cx"> class WebPopupMenuProxy;
</span><del>-struct ViewSnapshot;
</del><span class="cx"> 
</span><span class="cx"> #if ENABLE(TOUCH_EVENTS)
</span><span class="cx"> class NativeWebTouchEvent;
</span><span class="lines">@@ -180,7 +180,7 @@
</span><span class="cx">     virtual void makeFirstResponder() = 0;
</span><span class="cx">     virtual void setAcceleratedCompositingRootLayer(LayerOrView *) = 0;
</span><span class="cx">     virtual LayerOrView *acceleratedCompositingRootLayer() const = 0;
</span><del>-    virtual ViewSnapshot takeViewSnapshot() = 0;
</del><ins>+    virtual PassRefPtr&lt;ViewSnapshot&gt; takeViewSnapshot() = 0;
</ins><span class="cx">     virtual void wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&amp;) = 0;
</span><span class="cx">     virtual void clearCustomSwipeViews() = 0;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (170973 => 170974)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2014-07-10 20:24:12 UTC (rev 170973)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2014-07-10 20:33:05 UTC (rev 170974)
</span><span class="lines">@@ -4944,7 +4944,7 @@
</span><span class="cx"> #endif // PLATFORM(MAC)
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><del>-ViewSnapshot WebPageProxy::takeViewSnapshot()
</del><ins>+PassRefPtr&lt;ViewSnapshot&gt; WebPageProxy::takeViewSnapshot()
</ins><span class="cx"> {
</span><span class="cx">     return m_pageClient.takeViewSnapshot();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (170973 => 170974)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-07-10 20:24:12 UTC (rev 170973)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-07-10 20:33:05 UTC (rev 170974)
</span><span class="lines">@@ -152,6 +152,7 @@
</span><span class="cx"> class RemoteLayerTreeTransaction;
</span><span class="cx"> class RemoteScrollingCoordinatorProxy;
</span><span class="cx"> class StringPairVector;
</span><ins>+class ViewSnapshot;
</ins><span class="cx"> class VisitedLinkProvider;
</span><span class="cx"> class WebBackForwardList;
</span><span class="cx"> class WebBackForwardListItem;
</span><span class="lines">@@ -173,7 +174,6 @@
</span><span class="cx"> struct EditorState;
</span><span class="cx"> struct PlatformPopupMenuData;
</span><span class="cx"> struct PrintInfo;
</span><del>-struct ViewSnapshot;
</del><span class="cx"> struct WebPopupItem;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIBRATION)
</span><span class="lines">@@ -884,7 +884,7 @@
</span><span class="cx">     void recordNavigationSnapshot();
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><del>-    ViewSnapshot takeViewSnapshot();
</del><ins>+    PassRefPtr&lt;ViewSnapshot&gt; takeViewSnapshot();
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SUBTLE_CRYPTO)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosPageClientImplIOSh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h (170973 => 170974)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h        2014-07-10 20:24:12 UTC (rev 170973)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h        2014-07-10 20:33:05 UTC (rev 170974)
</span><span class="lines">@@ -105,7 +105,7 @@
</span><span class="cx">     virtual LayerOrView *acceleratedCompositingRootLayer() const override;
</span><span class="cx">     virtual LayerHostingMode viewLayerHostingMode() override { return LayerHostingMode::OutOfProcess; }
</span><span class="cx"> 
</span><del>-    virtual ViewSnapshot takeViewSnapshot() override;
</del><ins>+    virtual PassRefPtr&lt;ViewSnapshot&gt; takeViewSnapshot() override;
</ins><span class="cx">     virtual void wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&amp;) override;
</span><span class="cx">     virtual void clearCustomSwipeViews() override;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosPageClientImplIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (170973 => 170974)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2014-07-10 20:24:12 UTC (rev 170973)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2014-07-10 20:33:05 UTC (rev 170974)
</span><span class="lines">@@ -470,7 +470,7 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ViewSnapshot PageClientImpl::takeViewSnapshot()
</del><ins>+PassRefPtr&lt;ViewSnapshot&gt; PageClientImpl::takeViewSnapshot()
</ins><span class="cx"> {
</span><span class="cx">     return [m_webView _takeViewSnapshot];
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosViewGestureControllerIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm (170973 => 170974)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm        2014-07-10 20:24:12 UTC (rev 170973)
+++ trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm        2014-07-10 20:33:05 UTC (rev 170974)
</span><span class="lines">@@ -168,14 +168,13 @@
</span><span class="cx">     m_snapshotView = adoptNS([[UIView alloc] initWithFrame:liveSwipeViewFrame]);
</span><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;UIColor&gt; backgroundColor = [UIColor whiteColor];
</span><del>-    ViewSnapshot snapshot;
-    if (ViewSnapshotStore::shared().getSnapshot(targetItem, snapshot)) {
</del><ins>+    if (ViewSnapshot* snapshot = targetItem-&gt;snapshot()) {
</ins><span class="cx">         float deviceScaleFactor = m_webPageProxy.deviceScaleFactor();
</span><span class="cx">         FloatSize swipeLayerSizeInDeviceCoordinates(liveSwipeViewFrame.size);
</span><span class="cx">         swipeLayerSizeInDeviceCoordinates.scale(deviceScaleFactor);
</span><del>-        if (snapshot.hasImage() &amp;&amp; snapshot.size == swipeLayerSizeInDeviceCoordinates &amp;&amp; deviceScaleFactor == snapshot.deviceScaleFactor)
-            [m_snapshotView layer].contents = snapshot.asLayerContents();
-        Color coreColor = snapshot.backgroundColor;
</del><ins>+        if (snapshot-&gt;hasImage() &amp;&amp; snapshot-&gt;size() == swipeLayerSizeInDeviceCoordinates &amp;&amp; deviceScaleFactor == snapshot-&gt;deviceScaleFactor())
+            [m_snapshotView layer].contents = snapshot-&gt;asLayerContents();
+        Color coreColor = snapshot-&gt;backgroundColor();
</ins><span class="cx">         if (coreColor.isValid())
</span><span class="cx">             backgroundColor = adoptNS([[UIColor alloc] initWithCGColor:cachedCGColor(coreColor, ColorSpaceDeviceRGB)]);
</span><span class="cx">     }
</span><span class="lines">@@ -244,10 +243,9 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ViewSnapshot snapshot;
</del><span class="cx">     m_snapshotRemovalTargetRenderTreeSize = 0;
</span><del>-    if (ViewSnapshotStore::shared().getSnapshot(targetItem, snapshot))
-        m_snapshotRemovalTargetRenderTreeSize = snapshot.renderTreeSize * swipeSnapshotRemovalRenderTreeSizeTargetFraction;
</del><ins>+    if (ViewSnapshot* snapshot = targetItem-&gt;snapshot())
+        m_snapshotRemovalTargetRenderTreeSize = snapshot-&gt;renderTreeSize() * swipeSnapshotRemovalRenderTreeSizeTargetFraction;
</ins><span class="cx"> 
</span><span class="cx">     // We don't want to replace the current back-forward item's snapshot
</span><span class="cx">     // like we normally would when going back or forward, because we are
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWebMemoryPressureHandlerIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WebMemoryPressureHandlerIOS.mm (170973 => 170974)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WebMemoryPressureHandlerIOS.mm        2014-07-10 20:24:12 UTC (rev 170973)
+++ trunk/Source/WebKit2/UIProcess/ios/WebMemoryPressureHandlerIOS.mm        2014-07-10 20:33:05 UTC (rev 170974)
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx">     dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MEMORYSTATUS, 0, DISPATCH_MEMORYSTATUS_PRESSURE_WARN, dispatch_get_main_queue());
</span><span class="cx">     dispatch_set_context(source, this);
</span><span class="cx">     dispatch_source_set_event_handler(source, ^{
</span><del>-        ViewSnapshotStore::shared().discardSnapshots();
</del><ins>+        ViewSnapshotStore::shared().discardSnapshotImages();
</ins><span class="cx">     });
</span><span class="cx">     dispatch_resume(source);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacPageClientImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h (170973 => 170974)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2014-07-10 20:24:12 UTC (rev 170973)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2014-07-10 20:33:05 UTC (rev 170974)
</span><span class="lines">@@ -124,7 +124,7 @@
</span><span class="cx">     virtual void exitAcceleratedCompositingMode();
</span><span class="cx">     virtual void updateAcceleratedCompositingMode(const LayerTreeContext&amp;);
</span><span class="cx"> 
</span><del>-    virtual ViewSnapshot takeViewSnapshot() override;
</del><ins>+    virtual PassRefPtr&lt;ViewSnapshot&gt; takeViewSnapshot() override;
</ins><span class="cx">     virtual void wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&amp;) override;
</span><span class="cx">     virtual void clearCustomSwipeViews() override;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacPageClientImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (170973 => 170974)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2014-07-10 20:24:12 UTC (rev 170973)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2014-07-10 20:33:05 UTC (rev 170974)
</span><span class="lines">@@ -507,7 +507,7 @@
</span><span class="cx">     return m_wkView._acceleratedCompositingModeRootLayer;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ViewSnapshot PageClientImpl::takeViewSnapshot()
</del><ins>+PassRefPtr&lt;ViewSnapshot&gt; PageClientImpl::takeViewSnapshot()
</ins><span class="cx"> {
</span><span class="cx">     return [m_wkView _takeViewSnapshot];
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewGestureControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h (170973 => 170974)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h        2014-07-10 20:24:12 UTC (rev 170973)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h        2014-07-10 20:33:05 UTC (rev 170974)
</span><span class="lines">@@ -50,7 +50,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><del>-struct ViewSnapshot;
</del><ins>+class ViewSnapshot;
</ins><span class="cx"> class WebBackForwardListItem;
</span><span class="cx"> class WebPageProxy;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewGestureControllerMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm (170973 => 170974)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm        2014-07-10 20:24:12 UTC (rev 170973)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm        2014-07-10 20:33:05 UTC (rev 170974)
</span><span class="lines">@@ -454,12 +454,12 @@
</span><span class="cx"> bool ViewGestureController::shouldUseSnapshotForSize(ViewSnapshot&amp; snapshot, FloatSize swipeLayerSize, float topContentInset)
</span><span class="cx"> {
</span><span class="cx">     float deviceScaleFactor = m_webPageProxy.deviceScaleFactor();
</span><del>-    if (snapshot.deviceScaleFactor != deviceScaleFactor)
</del><ins>+    if (snapshot.deviceScaleFactor() != deviceScaleFactor)
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     FloatSize unobscuredSwipeLayerSizeInDeviceCoordinates = swipeLayerSize - FloatSize(0, topContentInset);
</span><span class="cx">     unobscuredSwipeLayerSizeInDeviceCoordinates.scale(deviceScaleFactor);
</span><del>-    if (snapshot.size != unobscuredSwipeLayerSizeInDeviceCoordinates)
</del><ins>+    if (snapshot.size() != unobscuredSwipeLayerSizeInDeviceCoordinates)
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="lines">@@ -526,16 +526,15 @@
</span><span class="cx">     bool geometryIsFlippedToRoot = layerGeometryFlippedToRoot(snapshotLayerParent);
</span><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;CGColorRef&gt; backgroundColor = CGColorGetConstantColor(kCGColorWhite);
</span><del>-    ViewSnapshot snapshot;
-    if (ViewSnapshotStore::shared().getSnapshot(targetItem, snapshot)) {
-        if (shouldUseSnapshotForSize(snapshot, swipeArea.size(), topContentInset))
-            [m_swipeSnapshotLayer setContents:snapshot.asLayerContents()];
</del><ins>+    if (ViewSnapshot* snapshot = targetItem-&gt;snapshot()) {
+        if (shouldUseSnapshotForSize(*snapshot, swipeArea.size(), topContentInset))
+            [m_swipeSnapshotLayer setContents:snapshot-&gt;asLayerContents()];
</ins><span class="cx"> 
</span><del>-        Color coreColor = snapshot.backgroundColor;
</del><ins>+        Color coreColor = snapshot-&gt;backgroundColor();
</ins><span class="cx">         if (coreColor.isValid())
</span><span class="cx">             backgroundColor = cachedCGColor(coreColor, ColorSpaceDeviceRGB);
</span><span class="cx"> #if USE_IOSURFACE_VIEW_SNAPSHOTS
</span><del>-        m_currentSwipeSnapshotSurface = snapshot.surface;
</del><ins>+        m_currentSwipeSnapshotSurface = snapshot-&gt;surface();
</ins><span class="cx"> #endif
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -630,10 +629,9 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ViewSnapshot snapshot;
</del><span class="cx">     uint64_t renderTreeSize = 0;
</span><del>-    if (ViewSnapshotStore::shared().getSnapshot(targetItem, snapshot))
-        renderTreeSize = snapshot.renderTreeSize;
</del><ins>+    if (ViewSnapshot* snapshot = targetItem-&gt;snapshot())
+        renderTreeSize = snapshot-&gt;renderTreeSize();
</ins><span class="cx"> 
</span><span class="cx">     m_webPageProxy.process().send(Messages::ViewGestureGeometryCollector::SetRenderTreeSizeNotificationThreshold(renderTreeSize * swipeSnapshotRemovalRenderTreeSizeTargetFraction), m_webPageProxy.pageID());
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewSnapshotStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h (170973 => 170974)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h        2014-07-10 20:24:12 UTC (rev 170973)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h        2014-07-10 20:33:05 UTC (rev 170974)
</span><span class="lines">@@ -29,49 +29,84 @@
</span><span class="cx"> #include &lt;WebCore/Color.h&gt;
</span><span class="cx"> #include &lt;WebCore/IntSize.h&gt;
</span><span class="cx"> #include &lt;WebCore/IOSurface.h&gt;
</span><del>-#include &lt;chrono&gt;
-#include &lt;wtf/HashMap.h&gt;
</del><ins>+#include &lt;wtf/ListHashSet.h&gt;
</ins><span class="cx"> #include &lt;wtf/Noncopyable.h&gt;
</span><ins>+#include &lt;wtf/RefCounted.h&gt;
</ins><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><span class="cx"> OBJC_CLASS CAContext;
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span><del>-#define USE_IOSURFACE_VIEW_SNAPSHOTS true
-#define USE_RENDER_SERVER_VIEW_SNAPSHOTS false
</del><ins>+#define USE_IOSURFACE_VIEW_SNAPSHOTS 1
+#define USE_RENDER_SERVER_VIEW_SNAPSHOTS 0
</ins><span class="cx"> #else
</span><del>-#define USE_IOSURFACE_VIEW_SNAPSHOTS false
-#define USE_RENDER_SERVER_VIEW_SNAPSHOTS true
</del><ins>+#define USE_IOSURFACE_VIEW_SNAPSHOTS 0
+#define USE_RENDER_SERVER_VIEW_SNAPSHOTS 1
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+namespace WebCore {
+class IOSurface;
+}
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><ins>+class ViewSnapshotStore;
</ins><span class="cx"> class WebBackForwardListItem;
</span><span class="cx"> class WebPageProxy;
</span><span class="cx"> 
</span><del>-struct ViewSnapshot {
</del><ins>+class ViewSnapshot : public RefCounted&lt;ViewSnapshot&gt; {
+public:
</ins><span class="cx"> #if USE_IOSURFACE_VIEW_SNAPSHOTS
</span><del>-    RefPtr&lt;WebCore::IOSurface&gt; surface;
</del><ins>+    static PassRefPtr&lt;ViewSnapshot&gt; create(WebCore::IOSurface*, WebCore::IntSize, size_t imageSizeInBytes);
+#elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
+    static PassRefPtr&lt;ViewSnapshot&gt; create(uint32_t slotID, WebCore::IntSize, size_t imageSizeInBytes);
</ins><span class="cx"> #endif
</span><del>-#if USE_RENDER_SERVER_VIEW_SNAPSHOTS
-    uint32_t slotID = 0;
-#endif
</del><span class="cx"> 
</span><del>-    std::chrono::steady_clock::time_point creationTime;
-    uint64_t renderTreeSize;
-    float deviceScaleFactor;
-    WebCore::IntSize size;
-    size_t imageSizeInBytes = 0;
-    WebCore::Color backgroundColor;
</del><ins>+    ~ViewSnapshot();
</ins><span class="cx"> 
</span><span class="cx">     void clearImage();
</span><span class="cx">     bool hasImage() const;
</span><span class="cx">     id asLayerContents();
</span><ins>+
+    void setRenderTreeSize(uint64_t renderTreeSize) { m_renderTreeSize = renderTreeSize; }
+    uint64_t renderTreeSize() const { return m_renderTreeSize; }
+
+    void setBackgroundColor(WebCore::Color color) { m_backgroundColor = color; }
+    WebCore::Color backgroundColor() const { return m_backgroundColor; }
+
+    void setDeviceScaleFactor(float deviceScaleFactor) { m_deviceScaleFactor = deviceScaleFactor; }
+    float deviceScaleFactor() const { return m_deviceScaleFactor; }
+
+    size_t imageSizeInBytes() const { return m_imageSizeInBytes; }
+#if USE_IOSURFACE_VIEW_SNAPSHOTS
+    WebCore::IOSurface* surface() const { return m_surface.get(); }
+#endif
+    WebCore::IntSize size() const { return m_size; }
+
+private:
+#if USE_IOSURFACE_VIEW_SNAPSHOTS
+    explicit ViewSnapshot(WebCore::IOSurface*, WebCore::IntSize, size_t imageSizeInBytes);
+#elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
+    explicit ViewSnapshot(uint32_t slotID, WebCore::IntSize, size_t imageSizeInBytes);
+#endif
+
+#if USE_IOSURFACE_VIEW_SNAPSHOTS
+    RefPtr&lt;WebCore::IOSurface&gt; m_surface;
+#elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
+    uint32_t m_slotID;
+#endif
+
+    size_t m_imageSizeInBytes;
+    uint64_t m_renderTreeSize;
+    float m_deviceScaleFactor;
+    WebCore::IntSize m_size;
+    WebCore::Color m_backgroundColor;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class ViewSnapshotStore {
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(ViewSnapshotStore);
</span><ins>+    friend class ViewSnapshot;
</ins><span class="cx"> public:
</span><span class="cx">     ViewSnapshotStore();
</span><span class="cx">     ~ViewSnapshotStore();
</span><span class="lines">@@ -79,25 +114,25 @@
</span><span class="cx">     static ViewSnapshotStore&amp; shared();
</span><span class="cx"> 
</span><span class="cx">     void recordSnapshot(WebPageProxy&amp;);
</span><del>-    bool getSnapshot(WebBackForwardListItem*, ViewSnapshot&amp;);
</del><span class="cx"> 
</span><span class="cx">     void disableSnapshotting() { m_enabled = false; }
</span><span class="cx">     void enableSnapshotting() { m_enabled = true; }
</span><span class="cx"> 
</span><del>-    void discardSnapshots();
</del><ins>+    void discardSnapshotImages();
</ins><span class="cx"> 
</span><del>-#if PLATFORM(IOS)
</del><ins>+#if USE_RENDER_SERVER_VIEW_SNAPSHOTS
</ins><span class="cx">     static CAContext *snapshottingContext();
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    void didAddImageToSnapshot(ViewSnapshot&amp;);
+    void willRemoveImageFromSnapshot(ViewSnapshot&amp;);
</ins><span class="cx">     void pruneSnapshots(WebPageProxy&amp;);
</span><del>-    void removeSnapshotImage(ViewSnapshot&amp;);
</del><span class="cx"> 
</span><del>-    HashMap&lt;String, ViewSnapshot&gt; m_snapshotMap;
-
</del><span class="cx">     bool m_enabled;
</span><span class="cx">     size_t m_snapshotCacheSize;
</span><ins>+
+    ListHashSet&lt;ViewSnapshot*&gt; m_snapshotsWithImages;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewSnapshotStoremm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm (170973 => 170974)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm        2014-07-10 20:24:12 UTC (rev 170973)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm        2014-07-10 20:33:05 UTC (rev 170974)
</span><span class="lines">@@ -30,7 +30,6 @@
</span><span class="cx"> #import &quot;WebPageProxy.h&quot;
</span><span class="cx"> #import &lt;CoreGraphics/CoreGraphics.h&gt;
</span><span class="cx"> #import &lt;WebCore/IOSurface.h&gt;
</span><del>-#import &lt;WebCore/UUID.h&gt;
</del><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> #import &lt;QuartzCore/QuartzCorePrivate.h&gt;
</span><span class="lines">@@ -55,7 +54,7 @@
</span><span class="cx"> 
</span><span class="cx"> ViewSnapshotStore::~ViewSnapshotStore()
</span><span class="cx"> {
</span><del>-    discardSnapshots();
</del><ins>+    discardSnapshotImages();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ViewSnapshotStore&amp; ViewSnapshotStore::shared()
</span><span class="lines">@@ -64,7 +63,7 @@
</span><span class="cx">     return store;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if PLATFORM(IOS)
</del><ins>+#if USE_RENDER_SERVER_VIEW_SNAPSHOTS
</ins><span class="cx"> CAContext *ViewSnapshotStore::snapshottingContext()
</span><span class="cx"> {
</span><span class="cx">     static CAContext *context;
</span><span class="lines">@@ -82,13 +81,18 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-void ViewSnapshotStore::removeSnapshotImage(ViewSnapshot&amp; snapshot)
</del><ins>+void ViewSnapshotStore::didAddImageToSnapshot(ViewSnapshot&amp; snapshot)
</ins><span class="cx"> {
</span><del>-    if (!snapshot.hasImage())
-        return;
</del><ins>+    bool isNewEntry = m_snapshotsWithImages.add(&amp;snapshot).isNewEntry;
+    ASSERT_UNUSED(isNewEntry, isNewEntry);
+    m_snapshotCacheSize += snapshot.imageSizeInBytes();
+}
</ins><span class="cx"> 
</span><del>-    m_snapshotCacheSize -= snapshot.imageSizeInBytes;
-    snapshot.clearImage();
</del><ins>+void ViewSnapshotStore::willRemoveImageFromSnapshot(ViewSnapshot&amp; snapshot)
+{
+    bool removed = m_snapshotsWithImages.remove(&amp;snapshot);
+    ASSERT_UNUSED(removed, removed);
+    m_snapshotCacheSize -= snapshot.imageSizeInBytes();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ViewSnapshotStore::pruneSnapshots(WebPageProxy&amp; webPageProxy)
</span><span class="lines">@@ -96,54 +100,11 @@
</span><span class="cx">     if (m_snapshotCacheSize &lt;= maximumSnapshotCacheSize)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    uint32_t currentIndex = webPageProxy.backForwardList().currentIndex();
-    uint32_t maxDistance = 0;
-    auto mostDistantSnapshotIter = m_snapshotMap.end();
-    auto backForwardEntries = webPageProxy.backForwardList().entries();
</del><ins>+    ASSERT(!m_snapshotsWithImages.isEmpty());
</ins><span class="cx"> 
</span><del>-    // First, try to evict the snapshot for the page farthest from the current back-forward item.
-    for (uint32_t i = 0, entryCount = webPageProxy.backForwardList().entries().size(); i &lt; entryCount; i++) {
-        uint32_t distance = std::max(currentIndex, i) - std::min(currentIndex, i);
</del><ins>+    // FIXME: We have enough information to do smarter-than-LRU eviction (making use of the back-forward lists, etc.)
</ins><span class="cx"> 
</span><del>-        if (i == currentIndex || distance &lt; maxDistance)
-            continue;
-
-        WebBackForwardListItem* item = backForwardEntries[i].get();
-        String snapshotUUID = item-&gt;snapshotUUID();
-        if (snapshotUUID.isEmpty())
-            continue;
-
-        const auto&amp; snapshotIter = m_snapshotMap.find(snapshotUUID);
-        if (snapshotIter == m_snapshotMap.end())
-            continue;
-
-        // We're only interested in evicting snapshots that still have images.
-        if (!snapshotIter-&gt;value.hasImage())
-            continue;
-
-        mostDistantSnapshotIter = snapshotIter;
-        maxDistance = distance;
-    }
-
-    if (mostDistantSnapshotIter != m_snapshotMap.end()) {
-        removeSnapshotImage(mostDistantSnapshotIter-&gt;value);
-        return;
-    }
-
-    // If we can't find a most distant item (perhaps because all the snapshots are from
-    // a different WebPageProxy's back-forward list), we should evict the the oldest item.
-    std::chrono::steady_clock::time_point oldestSnapshotTime = std::chrono::steady_clock::time_point::max();
-    String oldestSnapshotUUID;
-
-    for (const auto&amp; uuidAndSnapshot : m_snapshotMap) {
-        if (uuidAndSnapshot.value.creationTime &lt; oldestSnapshotTime &amp;&amp; uuidAndSnapshot.value.hasImage()) {
-            oldestSnapshotTime = uuidAndSnapshot.value.creationTime;
-            oldestSnapshotUUID = uuidAndSnapshot.key;
-        }
-    }
-
-    const auto&amp; snapshotIter = m_snapshotMap.find(oldestSnapshotUUID);
-    removeSnapshotImage(snapshotIter-&gt;value);
</del><ins>+    m_snapshotsWithImages.first()-&gt;clearImage();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ViewSnapshotStore::recordSnapshot(WebPageProxy&amp; webPageProxy)
</span><span class="lines">@@ -158,77 +119,94 @@
</span><span class="cx"> 
</span><span class="cx">     pruneSnapshots(webPageProxy);
</span><span class="cx"> 
</span><del>-    ViewSnapshot snapshot = webPageProxy.takeViewSnapshot();
-    if (!snapshot.hasImage())
</del><ins>+    RefPtr&lt;ViewSnapshot&gt; snapshot = webPageProxy.takeViewSnapshot();
+    if (!snapshot || !snapshot-&gt;hasImage())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    String oldSnapshotUUID = item-&gt;snapshotUUID();
-    if (!oldSnapshotUUID.isEmpty()) {
-        const auto&amp; oldSnapshotIter = m_snapshotMap.find(oldSnapshotUUID);
-        if (oldSnapshotIter != m_snapshotMap.end()) {
-            removeSnapshotImage(oldSnapshotIter-&gt;value);
-            m_snapshotMap.remove(oldSnapshotIter);
-        }
-    }
</del><ins>+    snapshot-&gt;setRenderTreeSize(webPageProxy.renderTreeSize());
+    snapshot-&gt;setDeviceScaleFactor(webPageProxy.deviceScaleFactor());
+    snapshot-&gt;setBackgroundColor(webPageProxy.pageExtendedBackgroundColor());
</ins><span class="cx"> 
</span><del>-    snapshot.creationTime = std::chrono::steady_clock::now();
-    snapshot.renderTreeSize = webPageProxy.renderTreeSize();
-    snapshot.deviceScaleFactor = webPageProxy.deviceScaleFactor();
</del><ins>+    item-&gt;setSnapshot(snapshot.release());
+}
</ins><span class="cx"> 
</span><del>-    item-&gt;setSnapshotUUID(createCanonicalUUIDString());
-
-    m_snapshotMap.add(item-&gt;snapshotUUID(), snapshot);
-    m_snapshotCacheSize += snapshot.imageSizeInBytes;
</del><ins>+void ViewSnapshotStore::discardSnapshotImages()
+{
+    while (!m_snapshotsWithImages.isEmpty())
+        m_snapshotsWithImages.first()-&gt;clearImage();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ViewSnapshotStore::getSnapshot(WebBackForwardListItem* item, ViewSnapshot&amp; snapshot)
</del><ins>+
+#if USE_IOSURFACE_VIEW_SNAPSHOTS
+PassRefPtr&lt;ViewSnapshot&gt; ViewSnapshot::create(IOSurface* surface, IntSize size, size_t imageSizeInBytes)
</ins><span class="cx"> {
</span><del>-    if (item-&gt;snapshotUUID().isEmpty())
-        return false;
</del><ins>+    return adoptRef(new ViewSnapshot(surface, size, imageSizeInBytes));
+}
+#elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
+PassRefPtr&lt;ViewSnapshot&gt; ViewSnapshot::create(uint32_t slotID, IntSize size, size_t imageSizeInBytes)
+{
+    return adoptRef(new ViewSnapshot(slotID, size, imageSizeInBytes));
+}
+#endif
</ins><span class="cx"> 
</span><del>-    const auto&amp; snapshotIterator = m_snapshotMap.find(item-&gt;snapshotUUID());
-    if (snapshotIterator == m_snapshotMap.end())
-        return false;
-    snapshot = snapshotIterator-&gt;value;
-    return true;
</del><ins>+#if USE_IOSURFACE_VIEW_SNAPSHOTS
+ViewSnapshot::ViewSnapshot(IOSurface* surface, IntSize size, size_t imageSizeInBytes)
+    : m_surface(surface)
+#elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
+ViewSnapshot::ViewSnapshot(uint32_t slotID, IntSize size, size_t imageSizeInBytes)
+    : m_slotID(slotID)
+#endif
+    , m_imageSizeInBytes(imageSizeInBytes)
+    , m_size(size)
+{
+    if (hasImage())
+        ViewSnapshotStore::shared().didAddImageToSnapshot(*this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ViewSnapshotStore::discardSnapshots()
</del><ins>+ViewSnapshot::~ViewSnapshot()
</ins><span class="cx"> {
</span><del>-    for (auto&amp; snapshot : m_snapshotMap.values())
-        removeSnapshotImage(snapshot);
</del><ins>+    clearImage();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool ViewSnapshot::hasImage() const
</span><span class="cx"> {
</span><del>-    return imageSizeInBytes;
</del><ins>+#if USE_IOSURFACE_VIEW_SNAPSHOTS
+    return m_surface;
+#elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
+    return m_slotID;
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ViewSnapshot::clearImage()
</span><span class="cx"> {
</span><ins>+    if (!hasImage())
+        return;
+
+    ViewSnapshotStore::shared().willRemoveImageFromSnapshot(*this);
+
</ins><span class="cx"> #if USE_IOSURFACE_VIEW_SNAPSHOTS
</span><del>-    surface = nullptr;
</del><ins>+    m_surface = nullptr;
</ins><span class="cx"> #elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
</span><del>-    if (slotID)
-        [ViewSnapshotStore::snapshottingContext() deleteSlot:slotID];
-    slotID = 0;
</del><ins>+    [ViewSnapshotStore::snapshottingContext() deleteSlot:m_slotID];
+    m_slotID = 0;
</ins><span class="cx"> #endif
</span><del>-    imageSizeInBytes = 0;
</del><ins>+    m_imageSizeInBytes = 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> id ViewSnapshot::asLayerContents()
</span><span class="cx"> {
</span><span class="cx"> #if USE_IOSURFACE_VIEW_SNAPSHOTS
</span><del>-    if (!surface)
</del><ins>+    if (!m_surface)
</ins><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    // FIXME: This should destroy the surface and inform the ViewSnapshotStore to reduce m_snapshotCacheSize.
-    if (surface-&gt;setIsVolatile(false) != IOSurface::SurfaceState::Valid)
</del><ins>+    if (m_surface-&gt;setIsVolatile(false) != IOSurface::SurfaceState::Valid) {
+        clearImage();
</ins><span class="cx">         return nullptr;
</span><ins>+    }
</ins><span class="cx"> 
</span><del>-    return (id)surface-&gt;surface();
</del><ins>+    return (id)m_surface-&gt;surface();
</ins><span class="cx"> #elif USE_RENDER_SERVER_VIEW_SNAPSHOTS
</span><del>-    return [CAContext objectForSlot:slotID];
</del><ins>+    return [CAContext objectForSlot:m_slotID];
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>