<!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>[202383] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/202383">202383</a></dd>
<dt>Author</dt> <dd>joepeck@webkit.org</dd>
<dt>Date</dt> <dd>2016-06-23 11:52:54 -0700 (Thu, 23 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: Snapshots should be cleared at some point
https://bugs.webkit.org/show_bug.cgi?id=157907
&lt;rdar://problem/26373610&gt;

Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

* heap/HeapSnapshotBuilder.h:
* heap/HeapSnapshotBuilder.cpp:
(JSC::HeapSnapshotBuilder::resetNextAvailableObjectIdentifier):
Provide a way to reset the object identifier counter.

* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
(Inspector::InspectorHeapAgent::clearHeapSnapshots):
Make clearHeapSnapshots protected, so it can be called from a
a PageHeapAgent on page navigations.

Source/WebCore:

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* inspector/InspectorAllInOne.cpp:
New specialized agent.

* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
Construct a specialized HeapAgent.

* inspector/PageHeapAgent.h:
* inspector/PageHeapAgent.cpp:
(WebCore::PageHeapAgent::PageHeapAgent):
(WebCore::PageHeapAgent::enable):
(WebCore::PageHeapAgent::disable):
(WebCore::PageHeapAgent::mainFrameNavigated):
Clear backend snapshots on page navigations.
Set the PageHeapAgent instrumenting agent on enable/disable.

* inspector/InstrumentingAgents.cpp:
(WebCore::InstrumentingAgents::reset):
* inspector/InstrumentingAgents.h:
(WebCore::InstrumentingAgents::pageHeapAgent):
(WebCore::InstrumentingAgents::setPageHeapAgent):
Active PageHeapAgent.

* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::didCommitLoadImpl):
Inform the PageHeapAgent when the mainframe navigates.

Source/WebInspectorUI:

Invalidate HeapSnapshotProxy objects when the page navigates.
This allows us to clear our frontend data for the snapshots.
When a snapshot is invalidated, it is disabled in the UI.
This means you cannot select the snapshot or see content
views for the snapshot. If you are in a snapshot when it is
invalidated, you are taken out to the snapshot list.

* UserInterface/Main.html:
New files.

* UserInterface/Proxies/HeapSnapshotProxy.js:
(WebInspector.HeapSnapshotProxy):
(WebInspector.HeapSnapshotProxy.invalidateSnapshotProxies):
(WebInspector.HeapSnapshotProxy.prototype.get invalid):
(WebInspector.HeapSnapshotProxy.prototype._invalidate):
Keep track of valid snapshots, and provide a static method to invalidate them.

(WebInspector.HeapSnapshotProxy.prototype.updateForCollectionEvent):
(WebInspector.HeapSnapshotProxy.prototype.allocationBucketCounts):
(WebInspector.HeapSnapshotProxy.prototype.instancesWithClassName):
(WebInspector.HeapSnapshotProxy.prototype.update):
(WebInspector.HeapSnapshotProxy.prototype.nodeWithIdentifier):
UI should only act on valid snapshots.

* UserInterface/Proxies/HeapSnapshotDiffProxy.js:
(WebInspector.HeapSnapshotDiffProxy.prototype.get invalid):
(WebInspector.HeapSnapshotDiffProxy.prototype.updateForCollectionEvent):
(WebInspector.HeapSnapshotDiffProxy.prototype.allocationBucketCounts):
(WebInspector.HeapSnapshotDiffProxy.prototype.instancesWithClassName):
(WebInspector.HeapSnapshotDiffProxy.prototype.update):
(WebInspector.HeapSnapshotDiffProxy.prototype.nodeWithIdentifier):
UI should only act on valid snapshots.

* UserInterface/Proxies/HeapSnapshotWorkerProxy.js:
(WebInspector.HeapSnapshotWorkerProxy.prototype._mainResourceDidChange):
Invalidate and discard snapshots when the main frame navigates.

(WebInspector.HeapSnapshotWorkerProxy.prototype._handleMessage):
(WebInspector.HeapSnapshotWorkerProxy):
* UserInterface/Workers/HeapSnapshot/HeapSnapshotWorker.js:
(HeapSnapshotWorker.prototype.clearSnapshots):
(HeapSnapshotWorker.prototype._handleMessage):
(HeapSnapshotWorker):
A message may come in for a snapshot before it has been cleared.
If that is the case, the object may not exist. Return an error so
that the callback can be deleted on the calling side.

* UserInterface/Views/HeapAllocationsTimelineDataGridNodePathComponent.js:
(WebInspector.HeapAllocationsTimelineDataGridNodePathComponent.prototype.get previousSibling):
(WebInspector.HeapAllocationsTimelineDataGridNodePathComponent.prototype.get nextSibling):
(WebInspector.HeapAllocationsTimelineDataGridNodePathComponent):
Don't show invalid snapshots in page component picker.

* UserInterface/Views/HeapAllocationsTimelineOverviewGraph.css:
(.timeline-overview-graph.heap-allocations &gt; img.snapshot.invalid):
* UserInterface/Views/HeapAllocationsTimelineDataGridNode.js:
(WebInspector.HeapAllocationsTimelineDataGridNode):
(WebInspector.HeapAllocationsTimelineDataGridNode.prototype.createCellContent):
(WebInspector.HeapAllocationsTimelineDataGridNode.prototype.createCells):
(WebInspector.HeapAllocationsTimelineDataGridNode.prototype._heapSnapshotInvalidated):
Give invalid snapshots an invalidated appearance in the snapshot list.

* UserInterface/Views/HeapAllocationsTimelineOverviewGraph.js:
(WebInspector.HeapAllocationsTimelineOverviewGraph.prototype.layout):
* UserInterface/Views/HeapAllocationsTimelineView.css:
(.timeline-view.heap-allocations &gt; .data-grid tr.invalid):
(.timeline-view.heap-allocations &gt; .data-grid:not(:focus, .force-focus) tr.selected.invalid):
Give invalid snapshots an invalidated appearance in the overview graph.

* UserInterface/Views/HeapAllocationsTimelineView.js:
(WebInspector.HeapAllocationsTimelineView):
(WebInspector.HeapAllocationsTimelineView.prototype.get selectionPathComponents):
(WebInspector.HeapAllocationsTimelineView.prototype.closed):
(WebInspector.HeapAllocationsTimelineView.prototype._heapSnapshotCollectionEvent.updateHeapSnapshotForEvent):
(WebInspector.HeapAllocationsTimelineView.prototype._heapSnapshotCollectionEvent):
(WebInspector.HeapAllocationsTimelineView.prototype._heapSnapshotInvalidated):
(WebInspector.HeapAllocationsTimelineView.prototype._updateCompareHeapSnapshotButton):
(WebInspector.HeapAllocationsTimelineView.prototype._dataGridNodeSelected):
Handle interactions when snapshots in the list are invalidated.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapHeapSnapshotBuildercpp">trunk/Source/JavaScriptCore/heap/HeapSnapshotBuilder.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapHeapSnapshotBuilderh">trunk/Source/JavaScriptCore/heap/HeapSnapshotBuilder.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectoragentsInspectorHeapAgentcpp">trunk/Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectoragentsInspectorHeapAgenth">trunk/Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.h</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorAllInOnecpp">trunk/Source/WebCore/inspector/InspectorAllInOne.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorControllercpp">trunk/Source/WebCore/inspector/InspectorController.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorInstrumentationcpp">trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInstrumentingAgentscpp">trunk/Source/WebCore/inspector/InstrumentingAgents.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInstrumentingAgentsh">trunk/Source/WebCore/inspector/InstrumentingAgents.h</a></li>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceMainhtml">trunk/Source/WebInspectorUI/UserInterface/Main.html</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceProxiesHeapSnapshotDiffProxyjs">trunk/Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotDiffProxy.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceProxiesHeapSnapshotProxyjs">trunk/Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotProxy.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceProxiesHeapSnapshotWorkerProxyjs">trunk/Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotWorkerProxy.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsHeapAllocationsTimelineDataGridNodejs">trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineDataGridNode.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsHeapAllocationsTimelineOverviewGraphcss">trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineOverviewGraph.css</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsHeapAllocationsTimelineOverviewGraphjs">trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineOverviewGraph.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsHeapAllocationsTimelineViewcss">trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineView.css</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsHeapAllocationsTimelineViewjs">trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineView.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceWorkersHeapSnapshotHeapSnapshotWorkerjs">trunk/Source/WebInspectorUI/UserInterface/Workers/HeapSnapshot/HeapSnapshotWorker.js</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreinspectorPageHeapAgentcpp">trunk/Source/WebCore/inspector/PageHeapAgent.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorPageHeapAgenth">trunk/Source/WebCore/inspector/PageHeapAgent.h</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsHeapAllocationsTimelineDataGridNodePathComponentjs">trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineDataGridNodePathComponent.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2016-06-23  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Web Inspector: Snapshots should be cleared at some point
+        https://bugs.webkit.org/show_bug.cgi?id=157907
+        &lt;rdar://problem/26373610&gt;
+
+        Reviewed by Timothy Hatcher.
+
+        * heap/HeapSnapshotBuilder.h:
+        * heap/HeapSnapshotBuilder.cpp:
+        (JSC::HeapSnapshotBuilder::resetNextAvailableObjectIdentifier):
+        Provide a way to reset the object identifier counter.
+
+        * inspector/agents/InspectorHeapAgent.h:
+        * inspector/agents/InspectorHeapAgent.cpp:
+        (Inspector::InspectorHeapAgent::clearHeapSnapshots):
+        Make clearHeapSnapshots protected, so it can be called from a
+        a PageHeapAgent on page navigations.
+
</ins><span class="cx"> 2016-06-22  Saam barati  &lt;sbarati@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         TypeProfiler and TypeProfilerLog don't play nicely with the concurrent JIT
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapHeapSnapshotBuildercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/HeapSnapshotBuilder.cpp (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/HeapSnapshotBuilder.cpp        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/JavaScriptCore/heap/HeapSnapshotBuilder.cpp        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx">     
</span><span class="cx"> unsigned HeapSnapshotBuilder::nextAvailableObjectIdentifier = 1;
</span><span class="cx"> unsigned HeapSnapshotBuilder::getNextObjectIdentifier() { return nextAvailableObjectIdentifier++; }
</span><ins>+void HeapSnapshotBuilder::resetNextAvailableObjectIdentifier() { HeapSnapshotBuilder::nextAvailableObjectIdentifier = 1; }
</ins><span class="cx"> 
</span><span class="cx"> HeapSnapshotBuilder::HeapSnapshotBuilder(HeapProfiler&amp; profiler)
</span><span class="cx">     : m_profiler(profiler)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapHeapSnapshotBuilderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/HeapSnapshotBuilder.h (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/HeapSnapshotBuilder.h        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/JavaScriptCore/heap/HeapSnapshotBuilder.h        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -106,7 +106,8 @@
</span><span class="cx">     ~HeapSnapshotBuilder();
</span><span class="cx"> 
</span><span class="cx">     static unsigned nextAvailableObjectIdentifier;
</span><del>-    static unsigned getNextObjectIdentifier();    
</del><ins>+    static unsigned getNextObjectIdentifier();
+    static void resetNextAvailableObjectIdentifier();
</ins><span class="cx"> 
</span><span class="cx">     // Performs a garbage collection that builds a snapshot of all live cells.
</span><span class="cx">     void buildSnapshot();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectoragentsInspectorHeapAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.cpp (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.cpp        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.cpp        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -185,7 +185,7 @@
</span><span class="cx"> 
</span><span class="cx">     // FIXME: Provide preview information for Internal Objects? CodeBlock, Executable, etc.
</span><span class="cx"> 
</span><del>-    Structure* structure = cell-&gt;structure(m_environment.vm());
</del><ins>+    Structure* structure = cell-&gt;structure(vm);
</ins><span class="cx">     if (!structure) {
</span><span class="cx">         errorString = ASCIILiteral(&quot;Unable to get object details - Structure&quot;);
</span><span class="cx">         return;
</span><span class="lines">@@ -226,7 +226,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     JSCell* cell = optionalNode-&gt;cell;
</span><del>-    Structure* structure = cell-&gt;structure(m_environment.vm());
</del><ins>+    Structure* structure = cell-&gt;structure(vm);
</ins><span class="cx">     if (!structure) {
</span><span class="cx">         errorString = ASCIILiteral(&quot;Unable to get object details&quot;);
</span><span class="cx">         return;
</span><span class="lines">@@ -301,8 +301,13 @@
</span><span class="cx"> 
</span><span class="cx"> void InspectorHeapAgent::clearHeapSnapshots()
</span><span class="cx"> {
</span><del>-    if (HeapProfiler* heapProfiler = m_environment.vm().heapProfiler())
</del><ins>+    VM&amp; vm = m_environment.vm();
+    JSLockHolder lock(vm);
+
+    if (HeapProfiler* heapProfiler = vm.heapProfiler()) {
</ins><span class="cx">         heapProfiler-&gt;clearSnapshots();
</span><ins>+        HeapSnapshotBuilder::resetNextAvailableObjectIdentifier();
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace Inspector
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectoragentsInspectorHeapAgenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.h (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.h        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.h        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -39,7 +39,7 @@
</span><span class="cx"> class InjectedScriptManager;
</span><span class="cx"> typedef String ErrorString;
</span><span class="cx"> 
</span><del>-class JS_EXPORT_PRIVATE InspectorHeapAgent final : public InspectorAgentBase, public HeapBackendDispatcherHandler, public JSC::HeapObserver {
</del><ins>+class JS_EXPORT_PRIVATE InspectorHeapAgent : public InspectorAgentBase, public HeapBackendDispatcherHandler, public JSC::HeapObserver {
</ins><span class="cx">     WTF_MAKE_NONCOPYABLE(InspectorHeapAgent);
</span><span class="cx"> public:
</span><span class="cx">     InspectorHeapAgent(AgentContext&amp;);
</span><span class="lines">@@ -51,20 +51,21 @@
</span><span class="cx">     // HeapBackendDispatcherHandler
</span><span class="cx">     void enable(ErrorString&amp;) override;
</span><span class="cx">     void disable(ErrorString&amp;) override;
</span><del>-    void gc(ErrorString&amp;) override;
-    void snapshot(ErrorString&amp;, double* timestamp, String* snapshotData) override;
-    void startTracking(ErrorString&amp;) override;
-    void stopTracking(ErrorString&amp;) override;
-    void getPreview(ErrorString&amp;, int heapObjectId, Inspector::Protocol::OptOutput&lt;String&gt;* resultString, RefPtr&lt;Inspector::Protocol::Debugger::FunctionDetails&gt;&amp; functionDetails, RefPtr&lt;Inspector::Protocol::Runtime::ObjectPreview&gt;&amp; objectPreview) override;
-    void getRemoteObject(ErrorString&amp;, int heapObjectId, const String* optionalObjectGroup, RefPtr&lt;Inspector::Protocol::Runtime::RemoteObject&gt;&amp; result) override;
</del><ins>+    void gc(ErrorString&amp;) final;
+    void snapshot(ErrorString&amp;, double* timestamp, String* snapshotData) final;
+    void startTracking(ErrorString&amp;) final;
+    void stopTracking(ErrorString&amp;) final;
+    void getPreview(ErrorString&amp;, int heapObjectId, Inspector::Protocol::OptOutput&lt;String&gt;* resultString, RefPtr&lt;Inspector::Protocol::Debugger::FunctionDetails&gt;&amp; functionDetails, RefPtr&lt;Inspector::Protocol::Runtime::ObjectPreview&gt;&amp; objectPreview) final;
+    void getRemoteObject(ErrorString&amp;, int heapObjectId, const String* optionalObjectGroup, RefPtr&lt;Inspector::Protocol::Runtime::RemoteObject&gt;&amp; result) final;
</ins><span class="cx"> 
</span><span class="cx">     // HeapObserver
</span><span class="cx">     void willGarbageCollect() override;
</span><span class="cx">     void didGarbageCollect(JSC::HeapOperation) override;
</span><span class="cx"> 
</span><del>-private:
</del><ins>+protected:
</ins><span class="cx">     void clearHeapSnapshots();
</span><span class="cx"> 
</span><ins>+private:
</ins><span class="cx">     Optional&lt;JSC::HeapSnapshotNode&gt; nodeForHeapObjectIdentifier(ErrorString&amp;, unsigned heapObjectIdentifier);
</span><span class="cx"> 
</span><span class="cx">     InjectedScriptManager&amp; m_injectedScriptManager;
</span></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -1895,6 +1895,7 @@
</span><span class="cx">     inspector/NetworkResourcesData.cpp
</span><span class="cx">     inspector/PageConsoleAgent.cpp
</span><span class="cx">     inspector/PageDebuggerAgent.cpp
</span><ins>+    inspector/PageHeapAgent.cpp
</ins><span class="cx">     inspector/PageRuntimeAgent.cpp
</span><span class="cx">     inspector/PageScriptDebugServer.cpp
</span><span class="cx">     inspector/TimelineRecordFactory.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/WebCore/ChangeLog        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -1,5 +1,42 @@
</span><span class="cx"> 2016-06-23  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Web Inspector: Snapshots should be cleared at some point
+        https://bugs.webkit.org/show_bug.cgi?id=157907
+        &lt;rdar://problem/26373610&gt;
+
+        Reviewed by Timothy Hatcher.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * inspector/InspectorAllInOne.cpp:
+        New specialized agent.
+
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::InspectorController):
+        Construct a specialized HeapAgent.
+
+        * inspector/PageHeapAgent.h:
+        * inspector/PageHeapAgent.cpp:
+        (WebCore::PageHeapAgent::PageHeapAgent):
+        (WebCore::PageHeapAgent::enable):
+        (WebCore::PageHeapAgent::disable):
+        (WebCore::PageHeapAgent::mainFrameNavigated):
+        Clear backend snapshots on page navigations.
+        Set the PageHeapAgent instrumenting agent on enable/disable.
+
+        * inspector/InstrumentingAgents.cpp:
+        (WebCore::InstrumentingAgents::reset):
+        * inspector/InstrumentingAgents.h:
+        (WebCore::InstrumentingAgents::pageHeapAgent):
+        (WebCore::InstrumentingAgents::setPageHeapAgent):
+        Active PageHeapAgent.
+
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::didCommitLoadImpl):
+        Inform the PageHeapAgent when the mainframe navigates.
+
+2016-06-23  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
</ins><span class="cx">         CSSComputedStyleDeclaration::length should recalculate styles if needed to provide the correct value
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=159053
</span><span class="cx">         &lt;rdar://problem/26638119&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -4286,6 +4286,8 @@
</span><span class="cx">                 A5F36D3A18F758720054C024 /* PageScriptDebugServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5F36D3818F758720054C024 /* PageScriptDebugServer.cpp */; };
</span><span class="cx">                 A5F36D3B18F758720054C024 /* PageScriptDebugServer.h in Headers */ = {isa = PBXBuildFile; fileRef = A5F36D3918F758720054C024 /* PageScriptDebugServer.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 A5F6E16B132ED46E008EDAE3 /* Autocapitalize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5F6E16C132ED46E008EDAE3 /* Autocapitalize.cpp */; };
</span><ins>+                A5F8CD121D18F32E00AC0E53 /* PageHeapAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = A5F8CD111D18EEC300AC0E53 /* PageHeapAgent.h */; };
+                A5F8CD131D18F33100AC0E53 /* PageHeapAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5F8CD101D18EEC300AC0E53 /* PageHeapAgent.cpp */; };
</ins><span class="cx">                 A6148A6212E41D3A0044A784 /* DOMHTMLKeygenElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = A6148A6112E41D3A0044A784 /* DOMHTMLKeygenElementInternal.h */; };
</span><span class="cx">                 A6148A6712E41D940044A784 /* DOMHTMLKeygenElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A6148A6512E41D940044A784 /* DOMHTMLKeygenElement.h */; };
</span><span class="cx">                 A6148A6812E41D940044A784 /* DOMHTMLKeygenElement.mm in Sources */ = {isa = PBXBuildFile; fileRef = A6148A6612E41D940044A784 /* DOMHTMLKeygenElement.mm */; };
</span><span class="lines">@@ -12077,6 +12079,8 @@
</span><span class="cx">                 A5F36D3818F758720054C024 /* PageScriptDebugServer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageScriptDebugServer.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A5F36D3918F758720054C024 /* PageScriptDebugServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageScriptDebugServer.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A5F6E16C132ED46E008EDAE3 /* Autocapitalize.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Autocapitalize.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                A5F8CD101D18EEC300AC0E53 /* PageHeapAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageHeapAgent.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                A5F8CD111D18EEC300AC0E53 /* PageHeapAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageHeapAgent.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 A6148A6112E41D3A0044A784 /* DOMHTMLKeygenElementInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMHTMLKeygenElementInternal.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A6148A6512E41D940044A784 /* DOMHTMLKeygenElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMHTMLKeygenElement.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A6148A6612E41D940044A784 /* DOMHTMLKeygenElement.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMHTMLKeygenElement.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -16559,6 +16563,8 @@
</span><span class="cx">                                 F382088B147D35F90010BC06 /* PageConsoleAgent.h */,
</span><span class="cx">                                 F34742DA134362F000531BC2 /* PageDebuggerAgent.cpp */,
</span><span class="cx">                                 F34742DB134362F000531BC2 /* PageDebuggerAgent.h */,
</span><ins>+                                A5F8CD101D18EEC300AC0E53 /* PageHeapAgent.cpp */,
+                                A5F8CD111D18EEC300AC0E53 /* PageHeapAgent.h */,
</ins><span class="cx">                                 F382088C147D35F90010BC06 /* PageRuntimeAgent.cpp */,
</span><span class="cx">                                 F382088D147D35F90010BC06 /* PageRuntimeAgent.h */,
</span><span class="cx">                                 A5F36D3818F758720054C024 /* PageScriptDebugServer.cpp */,
</span><span class="lines">@@ -27461,6 +27467,7 @@
</span><span class="cx">                                 CD61FE681794AADB004101EB /* MediaSourceRegistry.h in Headers */,
</span><span class="cx">                                 07C59B6917F784BA000FBCBB /* MediaSourceSettings.h in Headers */,
</span><span class="cx">                                 078E091517D14D1C00420AA1 /* MediaStream.h in Headers */,
</span><ins>+                                A5F8CD121D18F32E00AC0E53 /* PageHeapAgent.h in Headers */,
</ins><span class="cx">                                 078E094C17D1709600420AA1 /* MediaStreamAudioDestinationNode.h in Headers */,
</span><span class="cx">                                 0783228518013ED800999E0C /* MediaStreamAudioSource.h in Headers */,
</span><span class="cx">                                 FD671A78159BB07000197559 /* MediaStreamAudioSourceNode.h in Headers */,
</span><span class="lines">@@ -31721,6 +31728,7 @@
</span><span class="cx">                                 9BD0BF9412A42BF50072FD43 /* ScopedEventQueue.cpp in Sources */,
</span><span class="cx">                                 BCEC01BD0C274DAC009F4EC9 /* Screen.cpp in Sources */,
</span><span class="cx">                                 A84D82C211D3474800972990 /* ScriptableDocumentParser.cpp in Sources */,
</span><ins>+                                A5F8CD131D18F33100AC0E53 /* PageHeapAgent.cpp in Sources */,
</ins><span class="cx">                                 41F1D2200EF35C2A00DA8753 /* ScriptCachedFrameData.cpp in Sources */,
</span><span class="cx">                                 93B70D6F09EB0C7C009D8468 /* ScriptController.cpp in Sources */,
</span><span class="cx">                                 A83E1C740E49042C00140B9C /* ScriptControllerMac.mm in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorAllInOnecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorAllInOne.cpp (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorAllInOne.cpp        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/WebCore/inspector/InspectorAllInOne.cpp        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -54,6 +54,7 @@
</span><span class="cx"> #include &quot;NetworkResourcesData.cpp&quot;
</span><span class="cx"> #include &quot;PageConsoleAgent.cpp&quot;
</span><span class="cx"> #include &quot;PageDebuggerAgent.cpp&quot;
</span><ins>+#include &quot;PageHeapAgent.cpp&quot;
</ins><span class="cx"> #include &quot;PageRuntimeAgent.cpp&quot;
</span><span class="cx"> #include &quot;PageScriptDebugServer.cpp&quot;
</span><span class="cx"> #include &quot;TimelineRecordFactory.cpp&quot;
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorController.cpp        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/WebCore/inspector/InspectorController.cpp        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -59,6 +59,7 @@
</span><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;PageConsoleAgent.h&quot;
</span><span class="cx"> #include &quot;PageDebuggerAgent.h&quot;
</span><ins>+#include &quot;PageHeapAgent.h&quot;
</ins><span class="cx"> #include &quot;PageRuntimeAgent.h&quot;
</span><span class="cx"> #include &quot;PageScriptDebugServer.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><span class="lines">@@ -70,7 +71,6 @@
</span><span class="cx"> #include &lt;inspector/InspectorFrontendDispatchers.h&gt;
</span><span class="cx"> #include &lt;inspector/InspectorFrontendRouter.h&gt;
</span><span class="cx"> #include &lt;inspector/agents/InspectorAgent.h&gt;
</span><del>-#include &lt;inspector/agents/InspectorHeapAgent.h&gt;
</del><span class="cx"> #include &lt;inspector/agents/InspectorScriptProfilerAgent.h&gt;
</span><span class="cx"> #include &lt;runtime/JSLock.h&gt;
</span><span class="cx"> #include &lt;wtf/Stopwatch.h&gt;
</span><span class="lines">@@ -157,7 +157,7 @@
</span><span class="cx">     InspectorDOMStorageAgent* domStorageAgent = domStorageAgentPtr.get();
</span><span class="cx">     m_agents.append(WTFMove(domStorageAgentPtr));
</span><span class="cx"> 
</span><del>-    auto heapAgentPtr = std::make_unique&lt;InspectorHeapAgent&gt;(pageContext);
</del><ins>+    auto heapAgentPtr = std::make_unique&lt;PageHeapAgent&gt;(pageContext);
</ins><span class="cx">     InspectorHeapAgent* heapAgent = heapAgentPtr.get();
</span><span class="cx">     m_agents.append(WTFMove(heapAgentPtr));
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorInstrumentationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -56,6 +56,7 @@
</span><span class="cx"> #include &quot;MainFrame.h&quot;
</span><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;PageDebuggerAgent.h&quot;
</span><ins>+#include &quot;PageHeapAgent.h&quot;
</ins><span class="cx"> #include &quot;PageRuntimeAgent.h&quot;
</span><span class="cx"> #include &quot;RenderObject.h&quot;
</span><span class="cx"> #include &quot;RenderView.h&quot;
</span><span class="lines">@@ -742,6 +743,9 @@
</span><span class="cx"> 
</span><span class="cx">         if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
</span><span class="cx">             pageDebuggerAgent-&gt;mainFrameNavigated();
</span><ins>+
+        if (PageHeapAgent* pageHeapAgent = instrumentingAgents.pageHeapAgent())
+            pageHeapAgent-&gt;mainFrameNavigated();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (InspectorDOMAgent* domAgent = instrumentingAgents.inspectorDOMAgent())
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInstrumentingAgentscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InstrumentingAgents.cpp (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InstrumentingAgents.cpp        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/WebCore/inspector/InstrumentingAgents.cpp        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -64,6 +64,7 @@
</span><span class="cx">     m_inspectorApplicationCacheAgent = nullptr;
</span><span class="cx">     m_inspectorDebuggerAgent = nullptr;
</span><span class="cx">     m_pageDebuggerAgent = nullptr;
</span><ins>+    m_pageHeapAgent = nullptr;
</ins><span class="cx">     m_inspectorDOMDebuggerAgent = nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInstrumentingAgentsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InstrumentingAgents.h (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InstrumentingAgents.h        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/WebCore/inspector/InstrumentingAgents.h        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -58,6 +58,7 @@
</span><span class="cx"> class InspectorTimelineAgent;
</span><span class="cx"> class Page;
</span><span class="cx"> class PageDebuggerAgent;
</span><ins>+class PageHeapAgent;
</ins><span class="cx"> class PageRuntimeAgent;
</span><span class="cx"> class WebConsoleAgent;
</span><span class="cx"> 
</span><span class="lines">@@ -128,6 +129,9 @@
</span><span class="cx">     PageDebuggerAgent* pageDebuggerAgent() const { return m_pageDebuggerAgent; }
</span><span class="cx">     void setPageDebuggerAgent(PageDebuggerAgent* agent) { m_pageDebuggerAgent = agent; }
</span><span class="cx"> 
</span><ins>+    PageHeapAgent* pageHeapAgent() const { return m_pageHeapAgent; }
+    void setPageHeapAgent(PageHeapAgent* agent) { m_pageHeapAgent = agent; }
+
</ins><span class="cx">     InspectorDOMDebuggerAgent* inspectorDOMDebuggerAgent() const { return m_inspectorDOMDebuggerAgent; }
</span><span class="cx">     void setInspectorDOMDebuggerAgent(InspectorDOMDebuggerAgent* agent) { m_inspectorDOMDebuggerAgent = agent; }
</span><span class="cx"> 
</span><span class="lines">@@ -160,6 +164,7 @@
</span><span class="cx">     InspectorApplicationCacheAgent* m_inspectorApplicationCacheAgent { nullptr };
</span><span class="cx">     Inspector::InspectorDebuggerAgent* m_inspectorDebuggerAgent { nullptr };
</span><span class="cx">     PageDebuggerAgent* m_pageDebuggerAgent { nullptr };
</span><ins>+    PageHeapAgent* m_pageHeapAgent { nullptr };
</ins><span class="cx">     InspectorDOMDebuggerAgent* m_inspectorDOMDebuggerAgent { nullptr };
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorPageHeapAgentcppfromrev202382trunkSourceWebInspectorUIUserInterfaceViewsHeapAllocationsTimelineViewcss"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/inspector/PageHeapAgent.cpp (from rev 202382, trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineView.css) (0 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/PageHeapAgent.cpp                                (rev 0)
+++ trunk/Source/WebCore/inspector/PageHeapAgent.cpp        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -0,0 +1,56 @@
</span><ins>+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;PageHeapAgent.h&quot;
+
+using namespace Inspector;
+
+namespace WebCore {
+
+PageHeapAgent::PageHeapAgent(PageAgentContext&amp; context)
+    : InspectorHeapAgent(context)
+    , m_instrumentingAgents(context.instrumentingAgents)
+{
+}
+
+void PageHeapAgent::enable(ErrorString&amp; errorString)
+{
+    InspectorHeapAgent::enable(errorString);
+    m_instrumentingAgents.setPageHeapAgent(this);
+}
+
+void PageHeapAgent::disable(ErrorString&amp; errorString)
+{
+    InspectorHeapAgent::disable(errorString);
+    m_instrumentingAgents.setPageHeapAgent(nullptr);
+}
+
+void PageHeapAgent::mainFrameNavigated()
+{
+    clearHeapSnapshots();
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoreinspectorPageHeapAgenthfromrev202382trunkSourceWebInspectorUIUserInterfaceViewsHeapAllocationsTimelineOverviewGraphcss"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/inspector/PageHeapAgent.h (from rev 202382, trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineOverviewGraph.css) (0 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/PageHeapAgent.h                                (rev 0)
+++ trunk/Source/WebCore/inspector/PageHeapAgent.h        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+/*
+ * Copyright (C) 2016 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.
+ */
+
+#pragma once
+
+#include &quot;InspectorWebAgentBase.h&quot;
+#include &quot;InstrumentingAgents.h&quot;
+#include &lt;inspector/agents/InspectorHeapAgent.h&gt;
+
+namespace WebCore {
+
+typedef String ErrorString;
+
+class PageHeapAgent final : public Inspector::InspectorHeapAgent {
+    WTF_MAKE_NONCOPYABLE(PageHeapAgent);
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    PageHeapAgent(PageAgentContext&amp;);
+    virtual ~PageHeapAgent() { }
+
+    void enable(ErrorString&amp;) override;
+    void disable(ErrorString&amp;) override;
+
+    void mainFrameNavigated();
+
+private:
+    InstrumentingAgents&amp; m_instrumentingAgents;
+};
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/WebInspectorUI/ChangeLog        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -1,3 +1,91 @@
</span><ins>+2016-06-23  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Web Inspector: Snapshots should be cleared at some point
+        https://bugs.webkit.org/show_bug.cgi?id=157907
+        &lt;rdar://problem/26373610&gt;
+
+        Reviewed by Timothy Hatcher.
+
+        Invalidate HeapSnapshotProxy objects when the page navigates.
+        This allows us to clear our frontend data for the snapshots.
+        When a snapshot is invalidated, it is disabled in the UI.
+        This means you cannot select the snapshot or see content
+        views for the snapshot. If you are in a snapshot when it is
+        invalidated, you are taken out to the snapshot list.
+
+        * UserInterface/Main.html:
+        New files.
+
+        * UserInterface/Proxies/HeapSnapshotProxy.js:
+        (WebInspector.HeapSnapshotProxy):
+        (WebInspector.HeapSnapshotProxy.invalidateSnapshotProxies):
+        (WebInspector.HeapSnapshotProxy.prototype.get invalid):
+        (WebInspector.HeapSnapshotProxy.prototype._invalidate):
+        Keep track of valid snapshots, and provide a static method to invalidate them.
+
+        (WebInspector.HeapSnapshotProxy.prototype.updateForCollectionEvent):
+        (WebInspector.HeapSnapshotProxy.prototype.allocationBucketCounts):
+        (WebInspector.HeapSnapshotProxy.prototype.instancesWithClassName):
+        (WebInspector.HeapSnapshotProxy.prototype.update):
+        (WebInspector.HeapSnapshotProxy.prototype.nodeWithIdentifier):
+        UI should only act on valid snapshots.
+
+        * UserInterface/Proxies/HeapSnapshotDiffProxy.js:
+        (WebInspector.HeapSnapshotDiffProxy.prototype.get invalid):
+        (WebInspector.HeapSnapshotDiffProxy.prototype.updateForCollectionEvent):
+        (WebInspector.HeapSnapshotDiffProxy.prototype.allocationBucketCounts):
+        (WebInspector.HeapSnapshotDiffProxy.prototype.instancesWithClassName):
+        (WebInspector.HeapSnapshotDiffProxy.prototype.update):
+        (WebInspector.HeapSnapshotDiffProxy.prototype.nodeWithIdentifier):
+        UI should only act on valid snapshots.
+
+        * UserInterface/Proxies/HeapSnapshotWorkerProxy.js:
+        (WebInspector.HeapSnapshotWorkerProxy.prototype._mainResourceDidChange):
+        Invalidate and discard snapshots when the main frame navigates.
+
+        (WebInspector.HeapSnapshotWorkerProxy.prototype._handleMessage):
+        (WebInspector.HeapSnapshotWorkerProxy):
+        * UserInterface/Workers/HeapSnapshot/HeapSnapshotWorker.js:
+        (HeapSnapshotWorker.prototype.clearSnapshots):
+        (HeapSnapshotWorker.prototype._handleMessage):
+        (HeapSnapshotWorker):
+        A message may come in for a snapshot before it has been cleared.
+        If that is the case, the object may not exist. Return an error so
+        that the callback can be deleted on the calling side.
+
+        * UserInterface/Views/HeapAllocationsTimelineDataGridNodePathComponent.js:
+        (WebInspector.HeapAllocationsTimelineDataGridNodePathComponent.prototype.get previousSibling):
+        (WebInspector.HeapAllocationsTimelineDataGridNodePathComponent.prototype.get nextSibling):
+        (WebInspector.HeapAllocationsTimelineDataGridNodePathComponent):
+        Don't show invalid snapshots in page component picker.
+
+        * UserInterface/Views/HeapAllocationsTimelineOverviewGraph.css:
+        (.timeline-overview-graph.heap-allocations &gt; img.snapshot.invalid):
+        * UserInterface/Views/HeapAllocationsTimelineDataGridNode.js:
+        (WebInspector.HeapAllocationsTimelineDataGridNode):
+        (WebInspector.HeapAllocationsTimelineDataGridNode.prototype.createCellContent):
+        (WebInspector.HeapAllocationsTimelineDataGridNode.prototype.createCells):
+        (WebInspector.HeapAllocationsTimelineDataGridNode.prototype._heapSnapshotInvalidated):
+        Give invalid snapshots an invalidated appearance in the snapshot list.
+
+        * UserInterface/Views/HeapAllocationsTimelineOverviewGraph.js:
+        (WebInspector.HeapAllocationsTimelineOverviewGraph.prototype.layout):
+        * UserInterface/Views/HeapAllocationsTimelineView.css:
+        (.timeline-view.heap-allocations &gt; .data-grid tr.invalid):
+        (.timeline-view.heap-allocations &gt; .data-grid:not(:focus, .force-focus) tr.selected.invalid):
+        Give invalid snapshots an invalidated appearance in the overview graph.
+
+        * UserInterface/Views/HeapAllocationsTimelineView.js:
+        (WebInspector.HeapAllocationsTimelineView):
+        (WebInspector.HeapAllocationsTimelineView.prototype.get selectionPathComponents):
+        (WebInspector.HeapAllocationsTimelineView.prototype.closed):
+        (WebInspector.HeapAllocationsTimelineView.prototype._heapSnapshotCollectionEvent.updateHeapSnapshotForEvent):
+        (WebInspector.HeapAllocationsTimelineView.prototype._heapSnapshotCollectionEvent):
+        (WebInspector.HeapAllocationsTimelineView.prototype._heapSnapshotInvalidated):
+        (WebInspector.HeapAllocationsTimelineView.prototype._updateCompareHeapSnapshotButton):
+        (WebInspector.HeapAllocationsTimelineView.prototype._dataGridNodeSelected):
+        Handle interactions when snapshots in the list are invalidated.
+
</ins><span class="cx"> 2016-06-22  Brian Burg  &lt;bburg@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: don't start auto capturing if the Inspector window is not visible
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceMainhtml"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Main.html (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Main.html        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/WebInspectorUI/UserInterface/Main.html        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -427,6 +427,7 @@
</span><span class="cx">     &lt;script src=&quot;Views/ObjectTreeBaseTreeElement.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Views/SourceCodeTreeElement.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Views/StorageTreeElement.js&quot;&gt;&lt;/script&gt;
</span><ins>+    &lt;script src=&quot;Views/TimelineDataGridNodePathComponent.js&quot;&gt;&lt;/script&gt;
</ins><span class="cx">     &lt;script src=&quot;Views/TimelineOverview.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Views/TimelineRecordTreeElement.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Views/TimelineTreeElement.js&quot;&gt;&lt;/script&gt;
</span><span class="lines">@@ -526,6 +527,7 @@
</span><span class="cx">     &lt;script src=&quot;Views/GradientEditor.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Views/GradientSlider.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Views/HeapAllocationsTimelineDataGridNode.js&quot;&gt;&lt;/script&gt;
</span><ins>+    &lt;script src=&quot;Views/HeapAllocationsTimelineDataGridNodePathComponent.js&quot;&gt;&lt;/script&gt;
</ins><span class="cx">     &lt;script src=&quot;Views/HeapAllocationsTimelineOverviewGraph.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Views/HeapAllocationsTimelineView.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Views/HeapSnapshotClassDataGridNode.js&quot;&gt;&lt;/script&gt;
</span><span class="lines">@@ -623,7 +625,6 @@
</span><span class="cx">     &lt;script src=&quot;Views/TextContentView.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Views/TextNavigationItem.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Views/TextResourceContentView.js&quot;&gt;&lt;/script&gt;
</span><del>-    &lt;script src=&quot;Views/TimelineDataGridNodePathComponent.js&quot;&gt;&lt;/script&gt;
</del><span class="cx">     &lt;script src=&quot;Views/TimelineRecordBar.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Views/TimelineRecordFrame.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Views/TimelineRecordingContentView.js&quot;&gt;&lt;/script&gt;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceProxiesHeapSnapshotDiffProxyjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotDiffProxy.js (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotDiffProxy.js        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotDiffProxy.js        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -61,9 +61,11 @@
</span><span class="cx">     get totalSize() { return this._totalSize; }
</span><span class="cx">     get totalObjectCount() { return this._totalObjectCount; }
</span><span class="cx">     get categories() { return this._categories; }
</span><ins>+    get invalid() { return this._snapshot1.invalid || this._snapshot2.invalid; }
</ins><span class="cx"> 
</span><span class="cx">     updateForCollectionEvent(event)
</span><span class="cx">     {
</span><ins>+        console.assert(!this.invalid);
</ins><span class="cx">         if (!event.data.affectedSnapshots.includes(this._snapshot2._identifier))
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="lines">@@ -74,11 +76,13 @@
</span><span class="cx"> 
</span><span class="cx">     allocationBucketCounts(bucketSizes, callback)
</span><span class="cx">     {
</span><ins>+        console.assert(!this.invalid);
</ins><span class="cx">         WebInspector.HeapSnapshotWorkerProxy.singleton().callMethod(this._proxyObjectId, &quot;allocationBucketCounts&quot;, bucketSizes, callback);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     instancesWithClassName(className, callback)
</span><span class="cx">     {
</span><ins>+        console.assert(!this.invalid);
</ins><span class="cx">         WebInspector.HeapSnapshotWorkerProxy.singleton().callMethod(this._proxyObjectId, &quot;instancesWithClassName&quot;, className, (serializedNodes) =&gt; {
</span><span class="cx">             callback(serializedNodes.map(WebInspector.HeapSnapshotNodeProxy.deserialize.bind(null, this._proxyObjectId)));
</span><span class="cx">         });
</span><span class="lines">@@ -86,6 +90,7 @@
</span><span class="cx"> 
</span><span class="cx">     update(callback)
</span><span class="cx">     {
</span><ins>+        console.assert(!this.invalid);
</ins><span class="cx">         WebInspector.HeapSnapshotWorkerProxy.singleton().callMethod(this._proxyObjectId, &quot;update&quot;, ({liveSize, categories}) =&gt; {
</span><span class="cx">             this._categories = Map.fromObject(categories);
</span><span class="cx">             callback();
</span><span class="lines">@@ -94,6 +99,7 @@
</span><span class="cx"> 
</span><span class="cx">     nodeWithIdentifier(nodeIdentifier, callback)
</span><span class="cx">     {
</span><ins>+        console.assert(!this.invalid);
</ins><span class="cx">         WebInspector.HeapSnapshotWorkerProxy.singleton().callMethod(this._proxyObjectId, &quot;nodeWithIdentifier&quot;, nodeIdentifier, (serializedNode) =&gt; {
</span><span class="cx">             callback(WebInspector.HeapSnapshotNodeProxy.deserialize(this._proxyObjectId, serializedNode));
</span><span class="cx">         });
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceProxiesHeapSnapshotProxyjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotProxy.js (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotProxy.js        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotProxy.js        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -37,6 +37,12 @@
</span><span class="cx">         this._totalObjectCount = totalObjectCount;
</span><span class="cx">         this._liveSize = liveSize;
</span><span class="cx">         this._categories = Map.fromObject(categories);
</span><ins>+
+        console.assert(!this.invalid);
+
+        if (!WebInspector.HeapSnapshotProxy.ValidSnapshotProxies)
+            WebInspector.HeapSnapshotProxy.ValidSnapshotProxies = [];
+        WebInspector.HeapSnapshotProxy.ValidSnapshotProxies.push(this);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Static
</span><span class="lines">@@ -47,6 +53,17 @@
</span><span class="cx">         return new WebInspector.HeapSnapshotProxy(objectId, identifier, title, totalSize, totalObjectCount, liveSize, categories);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    static invalidateSnapshotProxies()
+    {
+        if (!WebInspector.HeapSnapshotProxy.ValidSnapshotProxies)
+            return;
+
+        for (let snapshotProxy of WebInspector.HeapSnapshotProxy.ValidSnapshotProxies)
+            snapshotProxy._invalidate();
+
+        WebInspector.HeapSnapshotProxy.ValidSnapshotProxies = null;
+    }
+
</ins><span class="cx">     // Public
</span><span class="cx"> 
</span><span class="cx">     get proxyObjectId() { return this._proxyObjectId; }
</span><span class="lines">@@ -56,9 +73,11 @@
</span><span class="cx">     get totalObjectCount() { return this._totalObjectCount; }
</span><span class="cx">     get liveSize() { return this._liveSize; }
</span><span class="cx">     get categories() { return this._categories; }
</span><ins>+    get invalid() { return this._proxyObjectId === 0; }
</ins><span class="cx"> 
</span><span class="cx">     updateForCollectionEvent(event)
</span><span class="cx">     {
</span><ins>+        console.assert(!this.invalid);
</ins><span class="cx">         if (!event.data.affectedSnapshots.includes(this._identifier))
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="lines">@@ -69,11 +88,13 @@
</span><span class="cx"> 
</span><span class="cx">     allocationBucketCounts(bucketSizes, callback)
</span><span class="cx">     {
</span><ins>+        console.assert(!this.invalid);
</ins><span class="cx">         WebInspector.HeapSnapshotWorkerProxy.singleton().callMethod(this._proxyObjectId, &quot;allocationBucketCounts&quot;, bucketSizes, callback);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     instancesWithClassName(className, callback)
</span><span class="cx">     {
</span><ins>+        console.assert(!this.invalid);
</ins><span class="cx">         WebInspector.HeapSnapshotWorkerProxy.singleton().callMethod(this._proxyObjectId, &quot;instancesWithClassName&quot;, className, (serializedNodes) =&gt; {
</span><span class="cx">             callback(serializedNodes.map(WebInspector.HeapSnapshotNodeProxy.deserialize.bind(null, this._proxyObjectId)));
</span><span class="cx">         });
</span><span class="lines">@@ -81,6 +102,7 @@
</span><span class="cx"> 
</span><span class="cx">     update(callback)
</span><span class="cx">     {
</span><ins>+        console.assert(!this.invalid);
</ins><span class="cx">         WebInspector.HeapSnapshotWorkerProxy.singleton().callMethod(this._proxyObjectId, &quot;update&quot;, ({liveSize, categories}) =&gt; {
</span><span class="cx">             this._liveSize = liveSize;
</span><span class="cx">             this._categories = Map.fromObject(categories);
</span><span class="lines">@@ -90,12 +112,24 @@
</span><span class="cx"> 
</span><span class="cx">     nodeWithIdentifier(nodeIdentifier, callback)
</span><span class="cx">     {
</span><ins>+        console.assert(!this.invalid);
</ins><span class="cx">         WebInspector.HeapSnapshotWorkerProxy.singleton().callMethod(this._proxyObjectId, &quot;nodeWithIdentifier&quot;, nodeIdentifier, (serializedNode) =&gt; {
</span><span class="cx">             callback(WebInspector.HeapSnapshotNodeProxy.deserialize(this._proxyObjectId, serializedNode));
</span><span class="cx">         });
</span><span class="cx">     }
</span><ins>+
+    // Private
+
+    _invalidate()
+    {
+        this._proxyObjectId = 0;
+        this._liveSize = 0;
+
+        this.dispatchEventToListeners(WebInspector.HeapSnapshotProxy.Event.Invalidated);
+    }
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> WebInspector.HeapSnapshotProxy.Event = {
</span><del>-    CollectedNodes: &quot;heap-snapshot-proxy-did-collect-nodes&quot;
</del><ins>+    CollectedNodes: &quot;heap-snapshot-proxy-collected-nodes&quot;,
+    Invalidated: &quot;heap-snapshot-proxy-invalidated&quot;,
</ins><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceProxiesHeapSnapshotWorkerProxyjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotWorkerProxy.js (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotWorkerProxy.js        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotWorkerProxy.js        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -100,7 +100,9 @@
</span><span class="cx">         if (!event.target.isMainFrame())
</span><span class="cx">             return;
</span><span class="cx"> 
</span><del>-        this.clearSnapshots(function(){});
</del><ins>+        this.clearSnapshots(() =&gt; {
+            WebInspector.HeapSnapshotProxy.invalidateSnapshotProxies();
+        });
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     _postMessage()
</span><span class="lines">@@ -112,6 +114,13 @@
</span><span class="cx">     {
</span><span class="cx">         let data = event.data;
</span><span class="cx"> 
</span><ins>+        // Error.
+        if (data.error) {
+            console.assert(data.callId);
+            this._callbacks.delete(data.callId);
+            return;
+        }
+
</ins><span class="cx">         // Event.
</span><span class="cx">         if (data.eventName) {
</span><span class="cx">             this.dispatchEventToListeners(data.eventName, data.eventData);
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsHeapAllocationsTimelineDataGridNodejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineDataGridNode.js (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineDataGridNode.js        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineDataGridNode.js        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         this._record.heapSnapshot.addEventListener(WebInspector.HeapSnapshotProxy.Event.CollectedNodes, this._heapSnapshotCollectedNodes, this);
</span><ins>+        this._record.heapSnapshot.addEventListener(WebInspector.HeapSnapshotProxy.Event.Invalidated, this._heapSnapshotInvalidated, this);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Public
</span><span class="lines">@@ -56,10 +57,12 @@
</span><span class="cx">             let fragment = document.createDocumentFragment();
</span><span class="cx">             let titleElement = fragment.appendChild(document.createElement(&quot;span&quot;));
</span><span class="cx">             titleElement.textContent = this._data.name;
</span><del>-            let goToButton = fragment.appendChild(WebInspector.createGoToArrowButton());
-            goToButton.addEventListener(&quot;click&quot;, (event) =&gt; {
-                this._heapAllocationsView.showHeapSnapshotTimelineRecord(this._record);
-            });
</del><ins>+            if (!this._record.heapSnapshot.invalid) {
+                let goToButton = fragment.appendChild(WebInspector.createGoToArrowButton());
+                goToButton.addEventListener(&quot;click&quot;, (event) =&gt; {
+                    this._heapAllocationsView.showHeapSnapshotTimelineRecord(this._record);
+                });
+            }
</ins><span class="cx">             return fragment;
</span><span class="cx"> 
</span><span class="cx">         case &quot;timestamp&quot;:
</span><span class="lines">@@ -92,6 +95,16 @@
</span><span class="cx">         this.needsRefresh();
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    // Protected
+
+    createCells()
+    {
+        super.createCells();
+
+        if (this._record.heapSnapshot.invalid)
+            this.element.classList.add(&quot;invalid&quot;);
+    }
+
</ins><span class="cx">     // Private
</span><span class="cx"> 
</span><span class="cx">     _heapSnapshotCollectedNodes()
</span><span class="lines">@@ -106,4 +119,11 @@
</span><span class="cx">         this._data.liveSize = newSize;
</span><span class="cx">         this.needsRefresh();
</span><span class="cx">     }
</span><ins>+
+    _heapSnapshotInvalidated()
+    {
+        this._data.liveSize = 0;
+
+        this.needsRefresh();
+    }
</ins><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsHeapAllocationsTimelineDataGridNodePathComponentjsfromrev202382trunkSourceWebInspectorUIUserInterfaceViewsHeapAllocationsTimelineOverviewGraphcss"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineDataGridNodePathComponent.js (from rev 202382, trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineOverviewGraph.css) (0 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineDataGridNodePathComponent.js                                (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineDataGridNodePathComponent.js        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -0,0 +1,53 @@
</span><ins>+/*
+ * Copyright (C) 2016 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.
+ */
+
+WebInspector.HeapAllocationsTimelineDataGridNodePathComponent = class HeapAllocationsTimelineDataGridNodePathComponent extends WebInspector.TimelineDataGridNodePathComponent
+{
+    // Protected
+
+    get previousSibling()
+    {
+        let previousSibling = this.timelineDataGridNode.previousSibling;
+        while (previousSibling &amp;&amp; (previousSibling.hidden || previousSibling.record.heapSnapshot.invalid))
+            previousSibling = previousSibling.previousSibling;
+
+        if (!previousSibling)
+            return null;
+
+        return new WebInspector.HeapAllocationsTimelineDataGridNodePathComponent(previousSibling);
+    }
+
+    get nextSibling()
+    {
+        let nextSibling = this.timelineDataGridNode.nextSibling;
+        while (nextSibling &amp;&amp; (nextSibling.hidden || nextSibling.record.heapSnapshot.invalid))
+            nextSibling = nextSibling.nextSibling;
+
+        if (!nextSibling)
+            return null;
+
+        return new WebInspector.HeapAllocationsTimelineDataGridNodePathComponent(nextSibling);
+    }
+};
</ins></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsHeapAllocationsTimelineOverviewGraphcss"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineOverviewGraph.css (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineOverviewGraph.css        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineOverviewGraph.css        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -35,6 +35,10 @@
</span><span class="cx">     height: 16px;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.timeline-overview-graph.heap-allocations &gt; img.snapshot.invalid {
+    opacity: 0.7;
+}
+
</ins><span class="cx"> .timeline-overview-graph.heap-allocations &gt; img.snapshot.selected {
</span><span class="cx">     content: url(../Images/HeapSnapshotSelected.svg);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsHeapAllocationsTimelineOverviewGraphjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineOverviewGraph.js (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineOverviewGraph.js        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineOverviewGraph.js        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -54,8 +54,12 @@
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         this.element.removeChildren();
</span><del>-        this._selectedImageElement = null;
</del><span class="cx"> 
</span><ins>+        if (this._selectedImageElement) {
+            this._selectedImageElement.classList.remove(&quot;selected&quot;);
+            this._selectedImageElement = null;
+        }
+
</ins><span class="cx">         // This may display records past the current time marker.
</span><span class="cx">         let visibleRecords = this._heapAllocationsTimeline.recordsInTimeRange(this.startTime, this.endTime);
</span><span class="cx">         if (!visibleRecords.length)
</span><span class="lines">@@ -76,14 +80,20 @@
</span><span class="cx"> 
</span><span class="cx">             let imageElement = record[WebInspector.HeapAllocationsTimelineOverviewGraph.RecordElementAssociationSymbol];
</span><span class="cx">             if (!imageElement) {
</span><del>-                imageElement = document.createElement(&quot;img&quot;);
</del><ins>+                imageElement = record[WebInspector.HeapAllocationsTimelineOverviewGraph.RecordElementAssociationSymbol] = document.createElement(&quot;img&quot;);
</ins><span class="cx">                 imageElement.classList.add(&quot;snapshot&quot;);
</span><del>-                imageElement.addEventListener(&quot;click&quot;, () =&gt; { this.selectedRecord = record; });
-                record[WebInspector.HeapAllocationsTimelineOverviewGraph.RecordElementAssociationSymbol] = imageElement;
</del><ins>+                imageElement.addEventListener(&quot;click&quot;, () =&gt; {
+                    if (record.heapSnapshot.invalid)
+                        return;
+                    this.selectedRecord = record;
+                });
</ins><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             imageElement.style.left = x + &quot;px&quot;;
</span><span class="cx"> 
</span><ins>+            if (record.heapSnapshot.invalid)
+                imageElement.classList.add(&quot;invalid&quot;);
+
</ins><span class="cx">             this.element.appendChild(imageElement);
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsHeapAllocationsTimelineViewcss"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineView.css (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineView.css        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineView.css        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -35,6 +35,14 @@
</span><span class="cx">     content: url(../Images/HeapSnapshot.svg);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.timeline-view.heap-allocations &gt; .data-grid tr.invalid {
+    color: gray;
+}
+
+.timeline-view.heap-allocations &gt; .data-grid:not(:focus, .force-focus) tr.selected.invalid {
+    color: gray !important;
+}
+
</ins><span class="cx"> .timeline-view.heap-allocations &gt; .data-grid tr.baseline {
</span><span class="cx">     background: hsl(129, 29%, 77%);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsHeapAllocationsTimelineViewjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineView.js (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineView.js        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineView.js        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -99,6 +99,7 @@
</span><span class="cx"> 
</span><span class="cx">         timeline.addEventListener(WebInspector.Timeline.Event.RecordAdded, this._heapAllocationsTimelineRecordAdded, this);
</span><span class="cx"> 
</span><ins>+        WebInspector.HeapSnapshotProxy.addEventListener(WebInspector.HeapSnapshotProxy.Event.Invalidated, this._heapSnapshotInvalidated, this);
</ins><span class="cx">         WebInspector.HeapSnapshotWorkerProxy.singleton().addEventListener(&quot;HeapSnapshot.CollectionEvent&quot;, this._heapSnapshotCollectionEvent, this);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -191,12 +192,10 @@
</span><span class="cx">             let secondSnapshotIdentifier = this._heapSnapshotDiff.snapshot2.identifier;
</span><span class="cx">             let diffComponent = new WebInspector.HierarchicalPathComponent(WebInspector.UIString(&quot;Snapshot Comparison (%d and %d)&quot;).format(firstSnapshotIdentifier, secondSnapshotIdentifier), &quot;snapshot-diff-icon&quot;, &quot;snapshot-diff&quot;);
</span><span class="cx">             components.push(diffComponent);
</span><del>-        } else {
-            if (this._dataGrid.selectedNode) {
-                let heapSnapshotPathComponent = new WebInspector.TimelineDataGridNodePathComponent(this._dataGrid.selectedNode);
-                heapSnapshotPathComponent.addEventListener(WebInspector.HierarchicalPathComponent.Event.SiblingWasSelected, this._snapshotPathComponentSelected, this);
-                components.push(heapSnapshotPathComponent);
-            }
</del><ins>+        } else if (this._dataGrid.selectedNode) {
+            let heapSnapshotPathComponent = new WebInspector.HeapAllocationsTimelineDataGridNodePathComponent(this._dataGrid.selectedNode);
+            heapSnapshotPathComponent.addEventListener(WebInspector.HierarchicalPathComponent.Event.SiblingWasSelected, this._snapshotPathComponentSelected, this);
+            components.push(heapSnapshotPathComponent);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         return components.concat(this._contentViewContainer.currentContentView.selectionPathComponents);
</span><span class="lines">@@ -240,6 +239,7 @@
</span><span class="cx">         this._contentViewContainer.closeAllContentViews();
</span><span class="cx"> 
</span><span class="cx">         WebInspector.ContentView.removeEventListener(null, null, this);
</span><ins>+        WebInspector.HeapSnapshotProxy.removeEventListener(null, null, this);
</ins><span class="cx">         WebInspector.HeapSnapshotWorkerProxy.singleton().removeEventListener(&quot;HeapSnapshot.CollectionEvent&quot;, this._heapSnapshotCollectionEvent, this);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -294,6 +294,8 @@
</span><span class="cx">     _heapSnapshotCollectionEvent(event)
</span><span class="cx">     {
</span><span class="cx">         function updateHeapSnapshotForEvent(heapSnapshot) {
</span><ins>+            if (heapSnapshot.invalid)
+                return;
</ins><span class="cx">             heapSnapshot.updateForCollectionEvent(event);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -329,22 +331,42 @@
</span><span class="cx">         this.dispatchEventToListeners(WebInspector.ContentView.Event.SelectionPathComponentsDidChange);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    _heapSnapshotInvalidated(event)
+    {
+        let heapSnapshot = event.target;
+
+        if (this._baselineHeapSnapshotTimelineRecord) {
+            if (heapSnapshot === this._baselineHeapSnapshotTimelineRecord.heapSnapshot)
+                this._cancelSelectComparisonHeapSnapshots();
+        }
+
+        if (this._heapSnapshotDiff) {
+            if (heapSnapshot === this._heapSnapshotDiff.snapshot1 || heapSnapshot === this._heapSnapshotDiff.snapshot2)
+                this.showHeapSnapshotList();
+        } else if (this._dataGrid.selectedNode) {
+            if (heapSnapshot === this._dataGrid.selectedNode.record.heapSnapshot)
+                this.showHeapSnapshotList();
+        }
+
+        this._updateCompareHeapSnapshotButton();
+    }
+
</ins><span class="cx">     _updateCompareHeapSnapshotButton()
</span><span class="cx">     {
</span><del>-        let hasAtLeastTwoSnapshots = false;
</del><ins>+        let hasAtLeastTwoValidSnapshots = false;
</ins><span class="cx"> 
</span><span class="cx">         let count = 0;
</span><span class="cx">         for (let node of this._dataGrid.children) {
</span><del>-            if (node.revealed &amp;&amp; !node.hidden) {
</del><ins>+            if (node.revealed &amp;&amp; !node.hidden &amp;&amp; !node.record.heapSnapshot.invalid) {
</ins><span class="cx">                 count++;
</span><span class="cx">                 if (count === 2) {
</span><del>-                    hasAtLeastTwoSnapshots = true;
</del><ins>+                    hasAtLeastTwoValidSnapshots = true;
</ins><span class="cx">                     break;
</span><span class="cx">                 }
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        this._compareHeapSnapshotsButtonItem.enabled = hasAtLeastTwoSnapshots;
</del><ins>+        this._compareHeapSnapshotsButtonItem.enabled = hasAtLeastTwoValidSnapshots;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     _takeHeapSnapshotClicked()
</span><span class="lines">@@ -405,7 +427,9 @@
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         let heapAllocationsTimelineRecord = dataGridNode.record;
</span><del>-        if (this._baselineHeapSnapshotTimelineRecord === heapAllocationsTimelineRecord) {
</del><ins>+
+        // Cancel the selection if the heap snapshot is invalid, or was already selected as the baseline.
+        if (heapAllocationsTimelineRecord.heapSnapshot.invalid || this._baselineHeapSnapshotTimelineRecord === heapAllocationsTimelineRecord) {
</ins><span class="cx">             this._dataGrid.selectedNode.deselect();
</span><span class="cx">             return;
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceWorkersHeapSnapshotHeapSnapshotWorkerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Workers/HeapSnapshot/HeapSnapshotWorker.js (202382 => 202383)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Workers/HeapSnapshot/HeapSnapshotWorker.js        2016-06-23 18:43:43 UTC (rev 202382)
+++ trunk/Source/WebInspectorUI/UserInterface/Workers/HeapSnapshot/HeapSnapshotWorker.js        2016-06-23 18:52:54 UTC (rev 202383)
</span><span class="lines">@@ -42,8 +42,7 @@
</span><span class="cx"> 
</span><span class="cx">     clearSnapshots()
</span><span class="cx">     {
</span><del>-        // FIXME: &lt;https://webkit.org/b/157907&gt; Web Inspector: Snapshots should be cleared at some point
-        // this._objects.clear();
</del><ins>+        this._objects.clear();
</ins><span class="cx"> 
</span><span class="cx">         this._snapshots = [];
</span><span class="cx">     }
</span><span class="lines">@@ -105,8 +104,12 @@
</span><span class="cx">         if (data.methodName) {
</span><span class="cx">             console.assert(data.objectId, &quot;Must have an objectId to call the method on&quot;);
</span><span class="cx">             let object = this._objects.get(data.objectId);
</span><del>-            let result = object[data.methodName](...data.methodArguments);
-            self.postMessage({callId: data.callId, result});
</del><ins>+            if (!object)
+                self.postMessage({callId: data.callId, error: &quot;No such object.&quot;});
+            else {
+                let result = object[data.methodName](...data.methodArguments);
+                self.postMessage({callId: data.callId, result});
+            }
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>