Web Inspector: Audit: automatically add to tab bar when the experimental setting...
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Nov 2018 18:20:55 +0000 (18:20 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Nov 2018 18:20:55 +0000 (18:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191659

Reviewed by Joseph Pecoraro.

* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createExperimentalSettingsView):

* UserInterface/Base/Main.js:
(WI.loaded):
Drive-by: use existing constants instead of hard-coded strings for consistency.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238500 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js

index 8571477..46a02ba 100644 (file)
@@ -1,3 +1,17 @@
+2018-11-26  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Audit: automatically add to tab bar when the experimental setting is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=191659
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Views/SettingsTabContentView.js:
+        (WI.SettingsTabContentView.prototype._createExperimentalSettingsView):
+
+        * UserInterface/Base/Main.js:
+        (WI.loaded):
+        Drive-by: use existing constants instead of hard-coded strings for consistency.
+
 2018-11-25  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: Timelines: add Media timeline
index 10f9e26..2d30517 100644 (file)
@@ -138,7 +138,16 @@ WI.loaded = function()
 
     // Create settings.
     this._showingSplitConsoleSetting = new WI.Setting("showing-split-console", false);
-    this._openTabsSetting = new WI.Setting("open-tab-types", ["elements", "network", "debugger", "resources", "timeline", "storage", "canvas", "console"]);
+    this._openTabsSetting = new WI.Setting("open-tab-types", [
+        WI.ElementsTabContentView.Type,
+        WI.NetworkTabContentView.Type,
+        WI.DebuggerTabContentView.Type,
+        WI.ResourcesTabContentView.Type,
+        WI.TimelineTabContentView.Type,
+        WI.StorageTabContentView.Type,
+        WI.CanvasTabContentView.Type,
+        WI.ConsoleTabContentView.Type,
+    ]);
     this._selectedTabIndexSetting = new WI.Setting("selected-tab-index", 0);
 
     // State.
index 84bb248..decaee8 100644 (file)
@@ -247,11 +247,13 @@ WI.SettingsTabContentView = class SettingsTabContentView extends WI.TabContentVi
             experimentalSettingsView.addSeparator();
         }
 
+        let layerTabEnabled = window.LayerTreeAgent && WI.settings.experimentalEnableLayersTab.value;
         if (window.LayerTreeAgent) {
             experimentalSettingsView.addSetting(WI.UIString("Layers:"), WI.settings.experimentalEnableLayersTab, WI.UIString("Enable Layers Tab"));
             experimentalSettingsView.addSeparator();
         }
 
+        let auditTabEnabled = WI.settings.experimentalEnableAuditTab.value;
         experimentalSettingsView.addSetting(WI.UIString("Audit:"), WI.settings.experimentalEnableAuditTab, WI.UIString("Enable Audit Tab"));
         experimentalSettingsView.addSeparator();
 
@@ -260,7 +262,17 @@ WI.SettingsTabContentView = class SettingsTabContentView extends WI.TabContentVi
 
         let reloadInspectorButton = document.createElement("button");
         reloadInspectorButton.textContent = WI.UIString("Reload Web Inspector");
-        reloadInspectorButton.addEventListener("click", () => { InspectorFrontendHost.reopen(); });
+        reloadInspectorButton.addEventListener("click", (event) => {
+            // Force a copy so that WI.Setting sees it as a new value.
+            let newTabs = WI._openTabsSetting.value.slice();
+            if (!layerTabEnabled && window.LayerTreeAgent && WI.settings.experimentalEnableLayersTab.value)
+                newTabs.push(WI.LayersTabContentView.Type);
+            if (!auditTabEnabled && WI.settings.experimentalEnableAuditTab.value)
+                newTabs.push(WI.AuditTabContentView.Type);
+            WI._openTabsSetting.value = newTabs;
+
+            InspectorFrontendHost.reopen();
+        });
 
         let reloadInspectorContainerElement = experimentalSettingsView.addCenteredContainer(reloadInspectorButton, WI.UIString("for changes to take effect"));
         reloadInspectorContainerElement.classList.add("hidden");