<!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>[173407] trunk/Source/WebInspectorUI</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/173407">173407</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-09-08 17:02:02 -0700 (Mon, 08 Sep 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: Inspector frequently restores wrong view when opened (often Timelines instead of Resource)
https://bugs.webkit.org/show_bug.cgi?id=135965

Patch by Joseph Pecoraro &lt;pecoraro@apple.com&gt; on 2014-09-08
Reviewed by Timothy Hatcher.

There were numerous subtle race conditions in state restoration.
This patch intends to fix a number of them to get what feels
like sane behavior for selected sidebar state restoration.

1. Starting a Timeline recording no longer automatically switches to the TimelineContentView.
This was making every reload switch to Timelines. If you had
a resource selected (e.g. the DOM Tree) we should go back
to showing the DOM tree.

2. Background sidebars should not reveal and select tree elements.
This was making resources get selected in Timelines when reloading the page
because the background Resources sidebar was restoring selection of the resource.
That is an unexpected selection and breaks the experience of Timelines.

3. ContentView changes during page navigation / reload should not be saved, and improve Resource restoration.
If a TimelineContentView was in the ContentBrowser back/forward history,
a reload with a resource selected in the Resources sidebar would end up
showing the Timelines sidebar. This was because when ContentViews are
closed during the navigation, the ContentBrowser would fall back to the
remaining TimelineContentView and switch to its only allowed sidebar
(Timelines). ResourceSidebarPanel, knowing a resource was selected,
would select the MainFrame intending to stay in the Resource sidebar,
but the resource is okay with showing in any sidebar, so we stay on Timelines.

4. Resource sidebar state restoration should propertly restore selection.
On reload, state restoration would know the resource to re-select in the
Resources sidebar. As ResourceTreeElements are added to the sidebar
they are checked against the state restoration cookie. If they match,
they would select the element and delete the cookie. Unfortunately,
if this was the first TreeElement child being added to a FrameTreeElement,
the FrameTreeElement onpopulate would remove all children and re-add
them in a unique way. Unfortunately this means the TreeElement we
selected based on the cookie, immediately got thrown away and recreated,
and we no longer reveal and select it. This is a special case for
FrameTreeElements which use the onpopulate SPI. So, instead of starting
processing the new element queue, if this is the first time just trigger
the onpopulate and elements are made just once.

5. Show Error Console triggering early, could have unexpected sidebar behavior.
Opening Web Inspector directly to the console can run before
WebInspector.contentLoaded (DOMContentLoaded). So in that case
WebInspector.showFullHeightConsole was not handling if the contentBrowser
had no content view yet, and the sidebar might be-reopened later on
in contentLoaded based on the setting value.

6. Improve automatic resource selection for sidebars with multiple tree outlines.
Selecting a call frame tree element was unexpectedly changing the
selection to a Resource where the breakpoint was set. This was
because we were only looking at one of potentially many content
tree outlines in the sidebar to see if there was a user action.

* UserInterface/Base/Main.js:
(WebInspector.contentLoaded):
(WebInspector.showFullHeightConsole):
(WebInspector.toggleConsoleView):
(WebInspector._mainResourceDidChange):
(WebInspector._provisionalLoadStarted):
(WebInspector._revealAndSelectRepresentedObjectInNavigationSidebar):
(WebInspector._updateCookieForInspectorViewState):
(WebInspector._contentBrowserCurrentContentViewDidChange):
* UserInterface/Views/NavigationSidebarPanel.js:
(WebInspector.NavigationSidebarPanel.prototype._treeElementAddedOrChanged):
* UserInterface/Views/ResourceSidebarPanel.js:
(WebInspector.ResourceSidebarPanel.prototype._mainFrameMainResourceDidChange.delayedWork):
(WebInspector.ResourceSidebarPanel.prototype._mainFrameMainResourceDidChange):
* UserInterface/Views/TimelineSidebarPanel.js:
(WebInspector.TimelineSidebarPanel.prototype._recordingLoaded):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceBaseMainjs">trunk/Source/WebInspectorUI/UserInterface/Base/Main.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsFrameTreeElementjs">trunk/Source/WebInspectorUI/UserInterface/Views/FrameTreeElement.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsNavigationSidebarPaneljs">trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsResourceSidebarPaneljs">trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsTimelineSidebarPaneljs">trunk/Source/WebInspectorUI/UserInterface/Views/TimelineSidebarPanel.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (173406 => 173407)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2014-09-09 00:00:35 UTC (rev 173406)
+++ trunk/Source/WebInspectorUI/ChangeLog        2014-09-09 00:02:02 UTC (rev 173407)
</span><span class="lines">@@ -1,3 +1,78 @@
</span><ins>+2014-09-08  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Web Inspector: Inspector frequently restores wrong view when opened (often Timelines instead of Resource)
+        https://bugs.webkit.org/show_bug.cgi?id=135965
+
+        Reviewed by Timothy Hatcher.
+
+        There were numerous subtle race conditions in state restoration.
+        This patch intends to fix a number of them to get what feels
+        like sane behavior for selected sidebar state restoration.
+
+        1. Starting a Timeline recording no longer automatically switches to the TimelineContentView.
+        This was making every reload switch to Timelines. If you had
+        a resource selected (e.g. the DOM Tree) we should go back
+        to showing the DOM tree.
+
+        2. Background sidebars should not reveal and select tree elements.
+        This was making resources get selected in Timelines when reloading the page
+        because the background Resources sidebar was restoring selection of the resource.
+        That is an unexpected selection and breaks the experience of Timelines.
+
+        3. ContentView changes during page navigation / reload should not be saved, and improve Resource restoration.
+        If a TimelineContentView was in the ContentBrowser back/forward history,
+        a reload with a resource selected in the Resources sidebar would end up
+        showing the Timelines sidebar. This was because when ContentViews are
+        closed during the navigation, the ContentBrowser would fall back to the
+        remaining TimelineContentView and switch to its only allowed sidebar
+        (Timelines). ResourceSidebarPanel, knowing a resource was selected,
+        would select the MainFrame intending to stay in the Resource sidebar,
+        but the resource is okay with showing in any sidebar, so we stay on Timelines.
+
+        4. Resource sidebar state restoration should propertly restore selection.
+        On reload, state restoration would know the resource to re-select in the
+        Resources sidebar. As ResourceTreeElements are added to the sidebar
+        they are checked against the state restoration cookie. If they match,
+        they would select the element and delete the cookie. Unfortunately,
+        if this was the first TreeElement child being added to a FrameTreeElement,
+        the FrameTreeElement onpopulate would remove all children and re-add
+        them in a unique way. Unfortunately this means the TreeElement we
+        selected based on the cookie, immediately got thrown away and recreated,
+        and we no longer reveal and select it. This is a special case for
+        FrameTreeElements which use the onpopulate SPI. So, instead of starting
+        processing the new element queue, if this is the first time just trigger
+        the onpopulate and elements are made just once.
+
+        5. Show Error Console triggering early, could have unexpected sidebar behavior.
+        Opening Web Inspector directly to the console can run before
+        WebInspector.contentLoaded (DOMContentLoaded). So in that case
+        WebInspector.showFullHeightConsole was not handling if the contentBrowser
+        had no content view yet, and the sidebar might be-reopened later on
+        in contentLoaded based on the setting value.
+
+        6. Improve automatic resource selection for sidebars with multiple tree outlines.
+        Selecting a call frame tree element was unexpectedly changing the
+        selection to a Resource where the breakpoint was set. This was
+        because we were only looking at one of potentially many content
+        tree outlines in the sidebar to see if there was a user action.
+        
+        * UserInterface/Base/Main.js:
+        (WebInspector.contentLoaded):
+        (WebInspector.showFullHeightConsole):
+        (WebInspector.toggleConsoleView):
+        (WebInspector._mainResourceDidChange):
+        (WebInspector._provisionalLoadStarted):
+        (WebInspector._revealAndSelectRepresentedObjectInNavigationSidebar):
+        (WebInspector._updateCookieForInspectorViewState):
+        (WebInspector._contentBrowserCurrentContentViewDidChange):
+        * UserInterface/Views/NavigationSidebarPanel.js:
+        (WebInspector.NavigationSidebarPanel.prototype._treeElementAddedOrChanged):
+        * UserInterface/Views/ResourceSidebarPanel.js:
+        (WebInspector.ResourceSidebarPanel.prototype._mainFrameMainResourceDidChange.delayedWork):
+        (WebInspector.ResourceSidebarPanel.prototype._mainFrameMainResourceDidChange):
+        * UserInterface/Views/TimelineSidebarPanel.js:
+        (WebInspector.TimelineSidebarPanel.prototype._recordingLoaded):
+
</ins><span class="cx"> 2014-09-08  Matt Baker  &lt;mattbaker@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Add layout test for lowercase CSSProperty names
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceBaseMainjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (173406 => 173407)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js        2014-09-09 00:00:35 UTC (rev 173406)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js        2014-09-09 00:02:02 UTC (rev 173407)
</span><span class="lines">@@ -346,6 +346,8 @@
</span><span class="cx"> 
</span><span class="cx">     if (this._showingSplitConsoleSetting.value)
</span><span class="cx">         this.showSplitConsole();
</span><ins>+
+    this._contentLoaded = true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebInspector.sidebarPanelForCurrentContentView = function()
</span><span class="lines">@@ -610,7 +612,7 @@
</span><span class="cx"> 
</span><span class="cx">     this.consoleContentView.scopeBar.item(scope).selected = true;
</span><span class="cx"> 
</span><del>-    if (this.contentBrowser.currentContentView !== this.consoleContentView) {
</del><ins>+    if (!this.contentBrowser.currentContentView || this.contentBrowser.currentContentView !== this.consoleContentView) {
</ins><span class="cx">         this._wasShowingNavigationSidebarBeforeFullHeightConsole = !this.navigationSidebar.collapsed;
</span><span class="cx"> 
</span><span class="cx">         // Collapse the sidebar before showing the console view, so the check for the collapsed state in
</span><span class="lines">@@ -618,6 +620,11 @@
</span><span class="cx">         // tree elements in the current sidebar.
</span><span class="cx">         this.navigationSidebar.collapsed = true;
</span><span class="cx"> 
</span><ins>+        // If this is before the content has finished loading update the collapsed value setting
+        // ourselves so that we don't uncollapse the navigation sidebar when it is loaded.
+        if (!this._contentLoaded)
+            this._navigationSidebarCollapsedSetting.value = true;
+
</ins><span class="cx">         // Be sure to close any existing log view in the split content browser before showing it in the
</span><span class="cx">         // main content browser. We can only show a content view in one browser at a time.
</span><span class="cx">         this.splitContentBrowser.contentViewContainer.closeAllContentViewsOfPrototype(WebInspector.LogContentView);
</span><span class="lines">@@ -645,8 +652,11 @@
</span><span class="cx">     if (this.isShowingConsoleView()) {
</span><span class="cx">         if (this.contentBrowser.canGoBack())
</span><span class="cx">             this.contentBrowser.goBack();
</span><del>-        else
</del><ins>+        else {
+            if (!this.navigationSidebar.selectedSidebarPanel)
+                this.navigationSidebar.selectedSidebarPanel = this.resourceSidebarPanel;
</ins><span class="cx">             this.resourceSidebarPanel.showDefaultContentView();
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         if (this._wasShowingNavigationSidebarBeforeFullHeightConsole)
</span><span class="cx">             this.navigationSidebar.collapsed = false;
</span><span class="lines">@@ -762,6 +772,8 @@
</span><span class="cx">     if (!event.target.isMainFrame())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    this._inProvisionalLoad = false;
+
</ins><span class="cx">     this._restoreInspectorViewStateFromCookie(this._lastInspectorViewStateCookieSetting.value, true);
</span><span class="cx"> 
</span><span class="cx">     this.updateWindowTitle();
</span><span class="lines">@@ -773,6 +785,8 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     this._updateCookieForInspectorViewState();
</span><ins>+
+    this._inProvisionalLoad = true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebInspector._windowFocused = function(event)
</span><span class="lines">@@ -893,11 +907,13 @@
</span><span class="cx">     if (!selectedSidebarPanel)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    // If the tree outline is processing a selection currently then we can assume the selection does not
-    // need to be changed. This is needed to allow breakpoints tree elements to be selected without jumping
-    // back to selecting the resource tree element.
-    if (selectedSidebarPanel.contentTreeOutline.processingSelectionChange)
-        return;
</del><ins>+    // If a tree outline is processing a selection currently then we can assume the selection does not
+    // need to be changed. This is needed to allow breakpoint and call frame tree elements to be selected
+    // without jumping back to selecting the resource tree element.
+    for (var contentTreeOutline of selectedSidebarPanel.visibleContentTreeOutlines) {
+        if (contentTreeOutline.processingSelectionChange)
+            return;
+    }
</ins><span class="cx"> 
</span><span class="cx">     var treeElement = selectedSidebarPanel.treeElementForRepresentedObject(representedObject);
</span><span class="cx"> 
</span><span class="lines">@@ -1031,6 +1047,12 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    // Ignore saving the sidebar state for provisional loads. The currently selected sidebar
+    // may have been the result of content views closing as a result of a page navigation,
+    // but those content views may come back very soon.
+    if (this._inProvisionalLoad)
+        return;
+
</ins><span class="cx">     var selectedSidebarPanel = this.navigationSidebar.selectedSidebarPanel;
</span><span class="cx">     if (!selectedSidebarPanel)
</span><span class="cx">         return;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsFrameTreeElementjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/FrameTreeElement.js (173406 => 173407)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/FrameTreeElement.js        2014-09-09 00:00:35 UTC (rev 173406)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/FrameTreeElement.js        2014-09-09 00:02:02 UTC (rev 173407)
</span><span class="lines">@@ -304,6 +304,12 @@
</span><span class="cx"> 
</span><span class="cx">     _populateFromNewChildQueue: function()
</span><span class="cx">     {
</span><ins>+        if (!this.children.length) {
+            this._updateParentStatus();
+            this.shouldRefreshChildren = true;
+            return;
+        }
+
</ins><span class="cx">         for (var i = 0; i &lt; this._newChildQueue.length; ++i)
</span><span class="cx">             this._addChildForRepresentedObject(this._newChildQueue[i]);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsNavigationSidebarPaneljs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js (173406 => 173407)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js        2014-09-09 00:00:35 UTC (rev 173406)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js        2014-09-09 00:02:02 UTC (rev 173407)
</span><span class="lines">@@ -147,6 +147,11 @@
</span><span class="cx">         return this._contentTreeOutline;
</span><span class="cx">     },
</span><span class="cx"> 
</span><ins>+    get visibleContentTreeOutlines()
+    {
+        return this._visibleContentTreeOutlines;
+    },
+
</ins><span class="cx">     get hasSelectedElement()
</span><span class="cx">     {
</span><span class="cx">         return !!this._contentTreeOutline.selectedTreeElement;
</span><span class="lines">@@ -533,7 +538,9 @@
</span><span class="cx"> 
</span><span class="cx">         this._checkForEmptyFilterResults();
</span><span class="cx">         this._updateContentOverflowShadowVisibilitySoon();
</span><del>-        this._checkElementsForPendingViewStateCookie(treeElement);
</del><ins>+
+        if (this.selected)
+            this._checkElementsForPendingViewStateCookie(treeElement);
</ins><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     _treeElementExpandedOrCollapsed: function(treeElement)
</span><span class="lines">@@ -709,7 +716,7 @@
</span><span class="cx">         }, this);
</span><span class="cx"> 
</span><span class="cx">         if (matchedElement) {
</span><del>-            matchedElement.revealAndSelect(true, false);
</del><ins>+            matchedElement.revealAndSelect();
</ins><span class="cx"> 
</span><span class="cx">             delete this._pendingViewStateCookie;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsResourceSidebarPaneljs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js (173406 => 173407)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js        2014-09-09 00:00:35 UTC (rev 173406)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js        2014-09-09 00:02:02 UTC (rev 173407)
</span><span class="lines">@@ -553,9 +553,12 @@
</span><span class="cx"> 
</span><span class="cx">     _mainFrameMainResourceDidChange: function(event)
</span><span class="cx">     {
</span><ins>+        var wasShowingResourceSidebar = this.selected;
</ins><span class="cx">         var currentContentView = WebInspector.contentBrowser.currentContentView;
</span><span class="cx">         var wasShowingResourceContentView = currentContentView instanceof WebInspector.ResourceContentView
</span><del>-            || currentContentView instanceof WebInspector.FrameContentView || currentContentView instanceof WebInspector.ScriptContentView;
</del><ins>+            || currentContentView instanceof WebInspector.ResourceClusterContentView
+            || currentContentView instanceof WebInspector.FrameContentView
+            || currentContentView instanceof WebInspector.ScriptContentView;
</ins><span class="cx"> 
</span><span class="cx">         // Close all resource and frame content views since the main frame has navigated and all resources are cleared.
</span><span class="cx">         WebInspector.contentBrowser.contentViewContainer.closeAllContentViewsOfPrototype(WebInspector.ResourceClusterContentView);
</span><span class="lines">@@ -565,9 +568,18 @@
</span><span class="cx">         function delayedWork()
</span><span class="cx">         {
</span><span class="cx">             // Show the main frame since there is no content view showing or we were showing a resource before.
</span><del>-            // FIXME: We could try to select the same resource that was selected before in the case of a reload.
-            if (!WebInspector.contentBrowser.currentContentView || wasShowingResourceContentView)
</del><ins>+            // Cookie restoration will attempt to re-select the resource we were showing.
+            if (!WebInspector.contentBrowser.currentContentView || wasShowingResourceContentView) {
+                // If we were showing a resource inside of the ResourceSidebar, we should
+                // re-show the resource inside of the resource sidebar. It is possible that
+                // the sidebar panel could have switched to another view in the back-forward list.
+                if (wasShowingResourceSidebar)
+                    WebInspector.navigationSidebar.selectedSidebarPanel = this;
+
+                // NOTE: This selection, during provisional loading, won't be saved, so it is
+                // safe to do and not-clobber cookie restoration.
</ins><span class="cx">                 this._mainFrameTreeElement.revealAndSelect(true, false);
</span><ins>+            }
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Delay this work because other listeners of this event might not have fired yet. So selecting the main frame
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsTimelineSidebarPaneljs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineSidebarPanel.js (173406 => 173407)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineSidebarPanel.js        2014-09-09 00:00:35 UTC (rev 173406)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineSidebarPanel.js        2014-09-09 00:02:02 UTC (rev 173407)
</span><span class="lines">@@ -417,7 +417,9 @@
</span><span class="cx">     _recordingLoaded: function()
</span><span class="cx">     {
</span><span class="cx">         this._activeContentView = WebInspector.contentBrowser.contentViewForRepresentedObject(WebInspector.timelineManager.activeRecording);
</span><del>-        WebInspector.contentBrowser.showContentView(this._activeContentView);
</del><ins>+
+        if (this.selected)
+            WebInspector.contentBrowser.showContentView(this._activeContentView);
</ins><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     _recordGlyphMousedOver: function(event)
</span></span></pre>
</div>
</div>

</body>
</html>