- Revision
- 184508
- Author
- [email protected]
- Date
- 2015-05-18 12:53:28 -0700 (Mon, 18 May 2015)
Log Message
Web Inspector: Tab Restoration incorrectly makes ContentViews "shown" in background tabs
https://bugs.webkit.org/show_bug.cgi?id=145080
Patch by Joseph Pecoraro <[email protected]> on 2015-05-18
Reviewed by Timothy Hatcher.
Many tabs have their own content browser / navigation sidebar. During
state restoration, each tab would immediately try to restore an
appropriate ContentView after the load / navigation. However, in doing
so, we weren't respecting whether or not the Tab the ContentBrowser
was in was hidden or not, so ContentViews in background tags were
still being treated as shown/visible.
This patch changes state restoration to only affect the foreground
tab, and be delayed on all background tabs until that tab is shown.
This reduces the amount of work on load and navigation to just a
single tab instead of all tabs. Most importantly, it avoids having
performing work on ContentBrowsers that are non-visible, so state
restoration only happens for visible ContentBrowsers.
For simplicity, in the case of a delayed tab restoration triggered
by the user switching tabs, we don't try twice (like we occasionally
do on load/reload). We could add back some hueristic here if needed.
* UserInterface/Base/Main.js:
(WebInspector.contentLoaded):
(WebInspector.activateExtraDomains):
(WebInspector._mainResourceDidChange):
(WebInspector._restoreCookieForOpenTabs):
* UserInterface/Views/NavigationSidebarPanel.js:
* UserInterface/Views/TabContentView.js:
(WebInspector.TabContentView.prototype.shown):
(WebInspector.TabContentView.prototype.restoreStateFromCookie):
(WebInspector.TabContentView.prototype.saveStateToCookie):
When asked to restore state, save that logic until the next time the tab is shown.
* UserInterface/Views/TextEditor.js:
(WebInspector.TextEditor.prototype.get visible):
* UserInterface/Views/SourceCodeTextEditor.js:
(WebInspector.SourceCodeTextEditor.prototype.editingControllerDidStartEditing):
(WebInspector.SourceCodeTextEditor.prototype._setTypeTokenAnnotatorEnabledState): Deleted.
Although this didn't actually catch the issue, it could potentially
catch other issues in the future. We don't want to enable the annotators
in a non-visible text editor, as it could be a performance issue.
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (184507 => 184508)
--- trunk/Source/WebInspectorUI/ChangeLog 2015-05-18 19:35:03 UTC (rev 184507)
+++ trunk/Source/WebInspectorUI/ChangeLog 2015-05-18 19:53:28 UTC (rev 184508)
@@ -1,3 +1,50 @@
+2015-05-18 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: Tab Restoration incorrectly makes ContentViews "shown" in background tabs
+ https://bugs.webkit.org/show_bug.cgi?id=145080
+
+ Reviewed by Timothy Hatcher.
+
+ Many tabs have their own content browser / navigation sidebar. During
+ state restoration, each tab would immediately try to restore an
+ appropriate ContentView after the load / navigation. However, in doing
+ so, we weren't respecting whether or not the Tab the ContentBrowser
+ was in was hidden or not, so ContentViews in background tags were
+ still being treated as shown/visible.
+
+ This patch changes state restoration to only affect the foreground
+ tab, and be delayed on all background tabs until that tab is shown.
+ This reduces the amount of work on load and navigation to just a
+ single tab instead of all tabs. Most importantly, it avoids having
+ performing work on ContentBrowsers that are non-visible, so state
+ restoration only happens for visible ContentBrowsers.
+
+ For simplicity, in the case of a delayed tab restoration triggered
+ by the user switching tabs, we don't try twice (like we occasionally
+ do on load/reload). We could add back some hueristic here if needed.
+
+ * UserInterface/Base/Main.js:
+ (WebInspector.contentLoaded):
+ (WebInspector.activateExtraDomains):
+ (WebInspector._mainResourceDidChange):
+ (WebInspector._restoreCookieForOpenTabs):
+ * UserInterface/Views/NavigationSidebarPanel.js:
+
+ * UserInterface/Views/TabContentView.js:
+ (WebInspector.TabContentView.prototype.shown):
+ (WebInspector.TabContentView.prototype.restoreStateFromCookie):
+ (WebInspector.TabContentView.prototype.saveStateToCookie):
+ When asked to restore state, save that logic until the next time the tab is shown.
+
+ * UserInterface/Views/TextEditor.js:
+ (WebInspector.TextEditor.prototype.get visible):
+ * UserInterface/Views/SourceCodeTextEditor.js:
+ (WebInspector.SourceCodeTextEditor.prototype.editingControllerDidStartEditing):
+ (WebInspector.SourceCodeTextEditor.prototype._setTypeTokenAnnotatorEnabledState): Deleted.
+ Although this didn't actually catch the issue, it could potentially
+ catch other issues in the future. We don't want to enable the annotators
+ in a non-visible text editor, as it could be a performance issue.
+
2015-05-15 Matt Baker <[email protected]>
Web Inspector: empty timeline should not use previous timeline's zoom interval
Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (184507 => 184508)
--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js 2015-05-18 19:35:03 UTC (rev 184507)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js 2015-05-18 19:53:28 UTC (rev 184508)
@@ -41,6 +41,12 @@
WebInspector.SelectedSidebarPanelCookieKey = "selected-sidebar-panel";
WebInspector.TypeIdentifierCookieKey = "represented-object-type";
+WebInspector.StateRestorationType = {
+ Load: "state-restoration-load",
+ Navigation: "state-restoration-navigation",
+ Delayed: "state-restoration-delayed",
+};
+
WebInspector.loaded = function()
{
// Initialize WebSocket to communication.
@@ -343,7 +349,7 @@
this.tabBrowser.addTabForContentView(tabContentView, true);
}
- this._restoreCookieForOpenTabs();
+ this._restoreCookieForOpenTabs(WebInspector.StateRestorationType.Load);
this.tabBar.selectedTabBarItem = this._selectedTabIndexSetting.value;
@@ -508,7 +514,7 @@
this.tabBrowser.addTabForContentView(tabContentView, true);
- tabContentView.restoreStateFromCookie();
+ tabContentView.restoreStateFromCookie(WebInspector.StateRestorationType.Load);
}
this._pendingOpenTabTypes = stillPendingOpenTabTypes;
@@ -1129,7 +1135,7 @@
// Run cookie restoration after we are sure all of the Tabs and NavigationSidebarPanels
// have updated with respect to the main resource change.
- setTimeout(this._restoreCookieForOpenTabs.bind(this, true));
+ setTimeout(this._restoreCookieForOpenTabs.bind(this, WebInspector.StateRestorationType.Navigation));
this._updateDownloadToolbarButton();
@@ -1146,13 +1152,13 @@
this._inProvisionalLoad = true;
};
-WebInspector._restoreCookieForOpenTabs = function(causedByNavigation)
+WebInspector._restoreCookieForOpenTabs = function(restorationType)
{
for (var tabBarItem of this.tabBar.tabBarItems) {
var tabContentView = tabBarItem.representedObject;
if (!(tabContentView instanceof WebInspector.TabContentView))
continue;
- tabContentView.restoreStateFromCookie(causedByNavigation);
+ tabContentView.restoreStateFromCookie(restorationType);
}
};
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js (184507 => 184508)
--- trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js 2015-05-18 19:35:03 UTC (rev 184507)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js 2015-05-18 19:53:28 UTC (rev 184508)
@@ -235,6 +235,9 @@
if (this._finalAttemptToRestoreViewStateTimeout)
clearTimeout(this._finalAttemptToRestoreViewStateTimeout);
+ if (relaxedMatchDelay === 0)
+ return;
+
function finalAttemptToRestoreViewStateFromCookie()
{
delete this._finalAttemptToRestoreViewStateTimeout;
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js (184507 => 184508)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js 2015-05-18 19:35:03 UTC (rev 184507)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js 2015-05-18 19:53:28 UTC (rev 184508)
@@ -1648,6 +1648,8 @@
return;
if (shouldActivate) {
+ console.assert(this.visible, "Annotators should not be enabled if the TextEditor is not visible");
+
RuntimeAgent.enableTypeProfiler();
this._typeTokenAnnotator.reset();
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TabContentView.js (184507 => 184508)
--- trunk/Source/WebInspectorUI/UserInterface/Views/TabContentView.js 2015-05-18 19:35:03 UTC (rev 184507)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TabContentView.js 2015-05-18 19:53:28 UTC (rev 184508)
@@ -107,15 +107,30 @@
return false;
},
- restoreStateFromCookie: function(causedByNavigation)
+ shown: function()
{
+ if (this._shouldRestoreStateWhenShown)
+ this.restoreStateFromCookie(WebInspector.StateRestorationType.Delayed);
+ },
+
+ restoreStateFromCookie: function(restorationType)
+ {
if (!this.navigationSidebarPanel)
return;
- var matchTypeOnlyDelayForNavigation = 2000;
- var matchTypeOnlyDelayForReopen = 1000;
+ if (!this.visible) {
+ this._shouldRestoreStateWhenShown = true;
+ return;
+ }
- var relaxMatchDelay = causedByNavigation ? matchTypeOnlyDelayForNavigation : matchTypeOnlyDelayForReopen;
+ this._shouldRestoreStateWhenShown = false;
+
+ var relaxMatchDelay = 0;
+ if (restorationType === WebInspector.StateRestorationType.Load)
+ relaxMatchDelay = 1000;
+ else if (restorationType === WebInspector.StateRestorationType.Navigation)
+ relaxMatchDelay = 2000;
+
this.navigationSidebarPanel.restoreStateFromCookie(this._cookieSetting.value || {}, relaxMatchDelay);
},
@@ -124,6 +139,9 @@
if (!this.navigationSidebarPanel)
return;
+ if (this._shouldRestoreStateWhenShown)
+ return;
+
var cookie = {};
this.navigationSidebarPanel.saveStateToCookie(cookie);
this._cookieSetting.value = cookie;
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js (184507 => 184508)
--- trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js 2015-05-18 19:35:03 UTC (rev 184507)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js 2015-05-18 19:53:28 UTC (rev 184508)
@@ -76,6 +76,11 @@
return this._element;
}
+ get visible()
+ {
+ return this._visible;
+ }
+
get string()
{
return this._codeMirror.getValue();