Title: [195835] trunk/Source/WebInspectorUI
Revision
195835
Author
[email protected]
Date
2016-01-29 12:35:30 -0800 (Fri, 29 Jan 2016)

Log Message

Web Inspector: Duplicate tab-types being saved to setting, causing duplicate tabs to be opened
https://bugs.webkit.org/show_bug.cgi?id=153659
<rdar://problem/24413157>

Patch by Joseph Pecoraro <[email protected]> on 2016-01-29
Reviewed by Brian Burg.

* UserInterface/Base/Main.js:
(WebInspector.contentLoaded):
(WebInspector._rememberOpenTabs):
De-duplicate the setting when building the list of tabs for existing
cases where the setting has duplicates and de-duplicate storing into
the setting, which was causing the issue to begin with.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (195834 => 195835)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-01-29 20:27:05 UTC (rev 195834)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-01-29 20:35:30 UTC (rev 195835)
@@ -1,3 +1,18 @@
+2016-01-29  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Duplicate tab-types being saved to setting, causing duplicate tabs to be opened
+        https://bugs.webkit.org/show_bug.cgi?id=153659
+        <rdar://problem/24413157>
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Base/Main.js:
+        (WebInspector.contentLoaded):
+        (WebInspector._rememberOpenTabs):
+        De-duplicate the setting when building the list of tabs for existing
+        cases where the setting has duplicates and de-duplicate storing into
+        the setting, which was causing the issue to begin with.
+
 2016-01-29  Devin Rousso  <[email protected]>
 
         Web Inspector: Add font-variant-* to the visual styles sidebar

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (195834 => 195835)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2016-01-29 20:27:05 UTC (rev 195834)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2016-01-29 20:35:30 UTC (rev 195835)
@@ -390,10 +390,17 @@
 
     this._pendingOpenTabs = [];
 
+    // Previously we may have stored duplicates in this setting. Avoid creating duplicate tabs.
     let openTabTypes = this._openTabsSetting.value;
+    let seenTabTypes = new Set;
 
     for (let i = 0; i < openTabTypes.length; ++i) {
         let tabType = openTabTypes[i];
+
+        if (seenTabTypes.has(tabType))
+            continue;
+        seenTabTypes.add(tabType);
+
         if (!this.isTabTypeAllowed(tabType)) {
             this._pendingOpenTabs.push({tabType, index: i});
             continue;
@@ -467,6 +474,7 @@
 
 WebInspector._rememberOpenTabs = function()
 {
+    let seenTabTypes = new Set;
     let openTabs = [];
 
     for (let tabBarItem of this.tabBar.tabBarItems) {
@@ -477,11 +485,16 @@
             continue;
         console.assert(tabContentView.type, "Tab type can't be null, undefined, or empty string", tabContentView.type, tabContentView);
         openTabs.push(tabContentView.type);
+        seenTabTypes.add(tabContentView.type);
     }
 
     // Keep currently unsupported tabs in the setting at their previous index.
-    for (let {tabType, index} of this._pendingOpenTabs)
+    for (let {tabType, index} of this._pendingOpenTabs) {
+        if (seenTabTypes.has(tabType))
+            continue;
         openTabs.insertAtIndex(tabType, index);
+        seenTabTypes.add(tabType);
+    }
 
     this._openTabsSetting.value = openTabs;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to