Title: [120331] trunk/Source/WebCore
Revision
120331
Author
[email protected]
Date
2012-06-14 09:49:10 -0700 (Thu, 14 Jun 2012)

Log Message

Web Inspector: refactor settings screen to move user agent and experiments out of general tab.
https://bugs.webkit.org/show_bug.cgi?id=89101

Reviewed by Vsevolod Vlasov.

See image attached to the bug.

* English.lproj/localizedStrings.js:
* inspector/front-end/SettingsScreen.js:
(WebInspector.SettingsScreen.prototype.selectTab):
(WebInspector.SettingsScreen.prototype._tabSelected):
(WebInspector.SettingsScreen.prototype.set wasShown):
(WebInspector.SettingsScreen.prototype.willHide):
(WebInspector.SettingsTab):
(WebInspector.SettingsTab.prototype._appendSection):
(WebInspector.SettingsTab.prototype._createCustomSetting):
(WebInspector.GenericSettingsTab):
(WebInspector.GenericSettingsTab.prototype._showPaintRectsChanged):
(WebInspector.GenericSettingsTab.prototype.get _updateScriptDisabledCheckbox):
(WebInspector.GenericSettingsTab.prototype._javaScriptDisabledChanged):
(WebInspector.UserAgentSettingsTab):
(WebInspector.UserAgentSettingsTab.prototype._createUserAgentSelectRowElement.get const):
(WebInspector.UserAgentSettingsTab.prototype._createUserAgentSelectRowElement.textDoubleClicked):
(WebInspector.UserAgentSettingsTab.prototype._createUserAgentSelectRowElement.textChanged):
(WebInspector.UserAgentSettingsTab.prototype._createUserAgentSelectRowElement.set checkboxClicked):
(WebInspector.UserAgentSettingsTab.prototype._createDeviceMetricsElement):
(WebInspector.ExperimentsSettingsTab):
(WebInspector.ExperimentsSettingsTab.prototype._createExperimentsWarningSubsection):
(WebInspector.ExperimentsSettingsTab.prototype._createExperimentCheckbox.listener):
(WebInspector.ExperimentsSettingsTab.prototype._createExperimentCheckbox):
* inspector/front-end/ShortcutsScreen.js:
* inspector/front-end/TabbedPane.js:
(WebInspector.TabbedPane.prototype.get headerContentsElement):
* inspector/front-end/helpScreen.css:
(.settings-tab.help-container):
(.settings-tab .help-block):
(.help-content fieldset):
(#settings-screen .tabbed-pane-header-tabs):
(#settings-screen .tabbed-pane-header-tab):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (120330 => 120331)


--- trunk/Source/WebCore/ChangeLog	2012-06-14 16:44:25 UTC (rev 120330)
+++ trunk/Source/WebCore/ChangeLog	2012-06-14 16:49:10 UTC (rev 120331)
@@ -1,3 +1,45 @@
+2012-06-14  Pavel Feldman  <[email protected]>
+
+        Web Inspector: refactor settings screen to move user agent and experiments out of general tab.
+        https://bugs.webkit.org/show_bug.cgi?id=89101
+
+        Reviewed by Vsevolod Vlasov.
+
+        See image attached to the bug.
+
+        * English.lproj/localizedStrings.js:
+        * inspector/front-end/SettingsScreen.js:
+        (WebInspector.SettingsScreen.prototype.selectTab):
+        (WebInspector.SettingsScreen.prototype._tabSelected):
+        (WebInspector.SettingsScreen.prototype.set wasShown):
+        (WebInspector.SettingsScreen.prototype.willHide):
+        (WebInspector.SettingsTab):
+        (WebInspector.SettingsTab.prototype._appendSection):
+        (WebInspector.SettingsTab.prototype._createCustomSetting):
+        (WebInspector.GenericSettingsTab):
+        (WebInspector.GenericSettingsTab.prototype._showPaintRectsChanged):
+        (WebInspector.GenericSettingsTab.prototype.get _updateScriptDisabledCheckbox):
+        (WebInspector.GenericSettingsTab.prototype._javaScriptDisabledChanged):
+        (WebInspector.UserAgentSettingsTab):
+        (WebInspector.UserAgentSettingsTab.prototype._createUserAgentSelectRowElement.get const):
+        (WebInspector.UserAgentSettingsTab.prototype._createUserAgentSelectRowElement.textDoubleClicked):
+        (WebInspector.UserAgentSettingsTab.prototype._createUserAgentSelectRowElement.textChanged):
+        (WebInspector.UserAgentSettingsTab.prototype._createUserAgentSelectRowElement.set checkboxClicked):
+        (WebInspector.UserAgentSettingsTab.prototype._createDeviceMetricsElement):
+        (WebInspector.ExperimentsSettingsTab):
+        (WebInspector.ExperimentsSettingsTab.prototype._createExperimentsWarningSubsection):
+        (WebInspector.ExperimentsSettingsTab.prototype._createExperimentCheckbox.listener):
+        (WebInspector.ExperimentsSettingsTab.prototype._createExperimentCheckbox):
+        * inspector/front-end/ShortcutsScreen.js:
+        * inspector/front-end/TabbedPane.js:
+        (WebInspector.TabbedPane.prototype.get headerContentsElement):
+        * inspector/front-end/helpScreen.css:
+        (.settings-tab.help-container):
+        (.settings-tab .help-block):
+        (.help-content fieldset):
+        (#settings-screen .tabbed-pane-header-tabs):
+        (#settings-screen .tabbed-pane-header-tab):
+
 2012-06-13  Mark Hahnenberg  <[email protected]>
 
         Worker tear-down can re-enter JSC during GC finalization pt. 2

Modified: trunk/Source/WebCore/English.lproj/localizedStrings.js (120330 => 120331)


--- trunk/Source/WebCore/English.lproj/localizedStrings.js	2012-06-14 16:44:25 UTC (rev 120330)
+++ trunk/Source/WebCore/English.lproj/localizedStrings.js	2012-06-14 16:49:10 UTC (rev 120331)
@@ -199,7 +199,7 @@
 localizedStrings["Expected Content Length"] = "Expected Content Length";
 localizedStrings["Expires"] = "Expires";
 localizedStrings["File size"] = "File size";
-localizedStrings["Fit window"] = "Fit window";
+localizedStrings["Fit in window"] = "Fit in window";
 localizedStrings["Go to the panel to the left/right"] = "Go to the panel to the left/right";
 localizedStrings["Go back/forward in panel history"] = "Go back/forward in panel history";
 localizedStrings["Finish Loading"] = "Finish Loading";
@@ -605,8 +605,7 @@
 localizedStrings["Search interrupted."] = "Search interrupted.";
 localizedStrings["Add to Watch"] = "Add to Watch";
 localizedStrings["Add to watch"] = "Add to watch";
-localizedStrings["Text editor"] = "Text editor";
-localizedStrings["Indent"] = "Indent";
+localizedStrings["Indentation"] = "Indentation";
 localizedStrings["2 spaces"] = "2 spaces";
 localizedStrings["4 spaces"] = "4 spaces";
 localizedStrings["8 spaces"] = "8 spaces";

Modified: trunk/Source/WebCore/inspector/front-end/SettingsScreen.js (120330 => 120331)


--- trunk/Source/WebCore/inspector/front-end/SettingsScreen.js	2012-06-14 16:44:25 UTC (rev 120330)
+++ trunk/Source/WebCore/inspector/front-end/SettingsScreen.js	2012-06-14 16:49:10 UTC (rev 120331)
@@ -40,123 +40,44 @@
 
     /** @type {!function()} */
     this._onHide = onHide;
-}
 
-WebInspector.SettingsScreen.prototype = {
+    this._tabbedPane = new WebInspector.TabbedPane();
+    this._tabbedPane.element.addStyleClass("help-window-main");
+    this._tabbedPane.element.appendChild(this._createCloseButton());
+    this._tabbedPane.appendTab(WebInspector.SettingsScreen.Tabs.General, WebInspector.UIString("General"), new WebInspector.GenericSettingsTab());
+    this._tabbedPane.appendTab(WebInspector.SettingsScreen.Tabs.UserAgent, WebInspector.UIString("User agent"), new WebInspector.UserAgentSettingsTab());
+    if (WebInspector.experimentsSettings.experimentsEnabled)
+        this._tabbedPane.appendTab(WebInspector.SettingsScreen.Tabs.Experiments, WebInspector.UIString("Experiments"), new WebInspector.ExperimentsSettingsTab());
+    this._tabbedPane.appendTab(WebInspector.SettingsScreen.Tabs.Shortcuts, WebInspector.UIString("Shortcuts"), WebInspector.shortcutsScreen.createShortcutsTabView());
+    this._tabbedPane.shrinkableTabs = true;
 
-    /**
-     * @return {!WebInspector.View}
-     */
-    _createSettingsTabView: function()
-    {
-        var view = new WebInspector.View();
+    this._lastSelectedTabSetting = WebInspector.settings.createSetting("lastSelectedSettingsTab", WebInspector.SettingsScreen.Tabs.General);
+    this.selectTab(this._lastSelectedTabSetting.get());
+    this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSelected, this._tabSelected, this);
+}
 
-        var container = view.element;
-        container.id = "settings";
-        container.className = "help-content help-container";
+WebInspector.SettingsScreen.Tabs = {
+    General: "General",
+    UserAgent: "UserAgent",
+    Experiments: "Experiments",
+    Shortcuts: "Shortcuts"
+}
 
-        /**
-         *  @param {string} name
-         *  @return {!Element}
-         */
-        function appendSection(name)
-        {
-            var block = container.createChild("div", "help-block");
-            block.createChild("div", "help-section-title").textContent = name;
-            return block;
-        }
-
-        var p = appendSection(WebInspector.UIString("General"));
-        if (Preferences.showDockToRight)
-            p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Dock to right"), WebInspector.settings.dockToRight));
-        if (Preferences.exposeDisableCache)
-            p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Disable cache"), WebInspector.settings.cacheDisabled));
-        var disableJSElement = this._createCheckboxSetting(WebInspector.UIString("Disable _javascript_"), WebInspector.settings._javascript_Disabled);
-        p.appendChild(disableJSElement);
-        WebInspector.settings._javascript_Disabled.addChangeListener(this._javaScriptDisabledChanged, this);
-        this._disableJSCheckbox = disableJSElement.getElementsByTagName("input")[0];
-        this._updateScriptDisabledCheckbox();
-        
-        p = appendSection(WebInspector.UIString("Rendering"));
-        p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show paint rectangles"), WebInspector.settings.showPaintRects));
-        WebInspector.settings.showPaintRects.addChangeListener(this._showPaintRectsChanged, this);
-
-        p = appendSection(WebInspector.UIString("Elements"));
-        p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Word wrap"), WebInspector.settings.domWordWrap));
-
-        p = appendSection(WebInspector.UIString("Styles"));
-        p.appendChild(this._createRadioSetting(WebInspector.UIString("Color format"), [
-            [ WebInspector.StylesSidebarPane.ColorFormat.Original, WebInspector.UIString("As authored") ],
-            [ WebInspector.StylesSidebarPane.ColorFormat.HEX, "HEX: #DAC0DE" ],
-            [ WebInspector.StylesSidebarPane.ColorFormat.RGB, "RGB: rgb(128, 255, 255)" ],
-            [ WebInspector.StylesSidebarPane.ColorFormat.HSL, "HSL: hsl(300, 80%, 90%)" ] ], WebInspector.settings.colorFormat));
-        p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show user agent styles"), WebInspector.settings.showUserAgentStyles));
-
-        p = appendSection(WebInspector.UIString("Text editor"));
-        p.appendChild(this._createSelectSetting(WebInspector.UIString("Indent"), [
-                [ WebInspector.UIString("2 spaces"), WebInspector.TextEditorModel.Indent.TwoSpaces ],
-                [ WebInspector.UIString("4 spaces"), WebInspector.TextEditorModel.Indent.FourSpaces ],
-                [ WebInspector.UIString("8 spaces"), WebInspector.TextEditorModel.Indent.EightSpaces ],
-                [ WebInspector.UIString("Tab character"), WebInspector.TextEditorModel.Indent.TabCharacter ]
-            ], WebInspector.settings.textEditorIndent));
-
-        p = appendSection(WebInspector.UIString("User Agent"));
-        p.appendChild(this._createUserAgentControl());
-        if (Capabilities.canOverrideDeviceMetrics)
-            p.appendChild(this._createDeviceMetricsControl());
-        p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Emulate touch events"), WebInspector.settings.emulateTouchEvents));
-
-        p = appendSection(WebInspector.UIString("Scripts"));
-        p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show script folders"), WebInspector.settings.showScriptFolders));
-        p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Search in content scripts"), WebInspector.settings.searchInContentScripts));
-        p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Enable source maps"), WebInspector.settings.sourceMapsEnabled));
-
-        p = appendSection(WebInspector.UIString("Profiler"));
-        p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show objects' hidden properties"), WebInspector.settings.showHeapSnapshotObjectsHiddenProperties));
-
-        p = appendSection(WebInspector.UIString("Console"));
-        p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Log XMLHttpRequests"), WebInspector.settings.monitoringXHREnabled));
-        p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Preserve log upon navigation"), WebInspector.settings.preserveConsoleLog));
-
-        if (WebInspector.extensionServer.hasExtensions()) {
-            var handlerSelector = new WebInspector.HandlerSelector(WebInspector.openAnchorLocationRegistry);
-            p = appendSection(WebInspector.UIString("Extensions"));
-            p.appendChild(this._createCustomSetting(WebInspector.UIString("Open links in"), handlerSelector.element));
-        }
-
-        var experiments = WebInspector.experimentsSettings.experiments;
-        if (WebInspector.experimentsSettings.experimentsEnabled && experiments.length) {
-            var experimentsSection = appendSection(WebInspector.UIString("Experiments"));
-            experimentsSection.appendChild(this._createExperimentsWarningSubsection());
-            for (var i = 0; i < experiments.length; ++i)
-                experimentsSection.appendChild(this._createExperimentCheckbox(experiments[i]));
-        }
-
-        return view;
-    },
-
+WebInspector.SettingsScreen.prototype = {
     /**
-     * return {!WebInspector.SettingsScreenTabbedPane}
+     * @param {!string} tabId
      */
-    _getOrCreateTabbedPane: function()
+    selectTab: function(tabId)
     {
-        if (this._tabbedPane)
-            return this._tabbedPane;
-
-        var tabbedPane = new WebInspector.SettingsScreenTabbedPane(this._createCloseButton());
-        tabbedPane.appendTab(WebInspector.SettingsScreen.Tabs.Settings, WebInspector.UIString("Settings"), this._createSettingsTabView());
-        tabbedPane.appendTab(WebInspector.SettingsScreen.Tabs.Shortcuts, WebInspector.UIString("Keyboard Shortcuts"), WebInspector.shortcutsScreen._createShortcutsTabView());
-
-        this._tabbedPane = tabbedPane;
-        return tabbedPane;
+        this._tabbedPane.selectTab(tabId);
     },
 
     /**
-     * @param {!string} tabId
+     * @param {WebInspector.Event} event
      */
-    selectTab: function(tabId)
+    _tabSelected: function(event)
     {
-        this._getOrCreateTabbedPane().selectTab(tabId);
+        this._lastSelectedTabSetting.set(this._tabbedPane.selectedTabId);
     },
 
     /**
@@ -164,7 +85,7 @@
      */
     wasShown: function()
     {
-        this._getOrCreateTabbedPane().show(this.element);
+        this._tabbedPane.show(this.element);
         WebInspector.HelpScreen.prototype.wasShown.call(this);
     },
 
@@ -186,28 +107,41 @@
     {
         this._onHide();
         WebInspector.HelpScreen.prototype.willHide.call(this);
-    },
+    }
+}
 
+WebInspector.SettingsScreen.prototype.__proto__ = WebInspector.HelpScreen.prototype;
+
+/**
+ * @constructor
+ * @extends {WebInspector.View}
+ */
+WebInspector.SettingsTab = function()
+{
+    WebInspector.View.call(this);
+    this.element.className = "settings-tab help-content help-container";
+}
+
+WebInspector.SettingsTab.prototype = {
     /**
-     * @return {Element} element
+     *  @param {string=} name
+     *  @return {!Element}
      */
-    _createExperimentsWarningSubsection: function()
+    _appendSection: function(name)
     {
-        var subsection = document.createElement("div");
-        var warning = subsection.createChild("span", "settings-experiments-warning-subsection-warning");
-        warning.textContent = WebInspector.UIString("WARNING:");
-        subsection.appendChild(document.createTextNode(" "));
-        var message = subsection.createChild("span", "settings-experiments-warning-subsection-message");
-        message.textContent = WebInspector.UIString("These experiments could be dangerous and may require restart.");
-        return subsection;
+        var block = this.element.createChild("div", "help-block");
+        if (name)
+            block.createChild("div", "help-section-title").textContent = name;
+        return block;
     },
 
     /**
      * @param {boolean=} omitParagraphElement
+     * @param {Element=} inputElement
      */
-    _createCheckboxSetting: function(name, setting, omitParagraphElement)
+    _createCheckboxSetting: function(name, setting, omitParagraphElement, inputElement)
     {
-        var input = document.createElement("input");
+        var input = inputElement || document.createElement("input");
         input.type = "checkbox";
         input.name = name;
         input.checked = setting.get();
@@ -229,26 +163,6 @@
         return p;
     },
 
-    _createExperimentCheckbox: function(experiment)
-    {
-        var input = document.createElement("input");
-        input.type = "checkbox";
-        input.name = experiment.name;
-        input.checked = experiment.isEnabled();
-        function listener()
-        {
-            experiment.setEnabled(input.checked);
-        }
-        input.addEventListener("click", listener, false);
-
-        var p = document.createElement("p");
-        var label = document.createElement("label");
-        label.appendChild(input);
-        label.appendChild(document.createTextNode(WebInspector.UIString(experiment.title)));
-        p.appendChild(label);
-        return p;
-    },
-
     _createSelectSetting: function(name, options, setting)
     {
         var fieldsetElement = document.createElement("fieldset");
@@ -322,8 +236,123 @@
         fieldsetElement.appendChild(element);
         p.appendChild(fieldsetElement);
         return p;
+    }
+}
+
+WebInspector.SettingsTab.prototype.__proto__ = WebInspector.View.prototype;
+
+/**
+ * @constructor
+ * @extends {WebInspector.SettingsTab}
+ */
+WebInspector.GenericSettingsTab = function()
+{
+    WebInspector.SettingsTab.call(this);
+
+    var p = this._appendSection();
+    if (Preferences.showDockToRight)
+        p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Dock to right"), WebInspector.settings.dockToRight));
+    if (Preferences.exposeDisableCache)
+        p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Disable cache"), WebInspector.settings.cacheDisabled));
+    var disableJSElement = this._createCheckboxSetting(WebInspector.UIString("Disable _javascript_"), WebInspector.settings._javascript_Disabled);
+    p.appendChild(disableJSElement);
+    WebInspector.settings._javascript_Disabled.addChangeListener(this._javaScriptDisabledChanged, this);
+    this._disableJSCheckbox = disableJSElement.getElementsByTagName("input")[0];
+    this._updateScriptDisabledCheckbox();
+    
+    p = this._appendSection(WebInspector.UIString("Elements"));
+    p.appendChild(this._createRadioSetting(WebInspector.UIString("Color format"), [
+        [ WebInspector.StylesSidebarPane.ColorFormat.Original, WebInspector.UIString("As authored") ],
+        [ WebInspector.StylesSidebarPane.ColorFormat.HEX, "HEX: #DAC0DE" ],
+        [ WebInspector.StylesSidebarPane.ColorFormat.RGB, "RGB: rgb(128, 255, 255)" ],
+        [ WebInspector.StylesSidebarPane.ColorFormat.HSL, "HSL: hsl(300, 80%, 90%)" ] ], WebInspector.settings.colorFormat));
+    p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show user agent styles"), WebInspector.settings.showUserAgentStyles));
+    p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Word wrap"), WebInspector.settings.domWordWrap));
+
+    p = this._appendSection(WebInspector.UIString("Rendering"));
+    p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show paint rectangles"), WebInspector.settings.showPaintRects));
+    WebInspector.settings.showPaintRects.addChangeListener(this._showPaintRectsChanged, this);
+
+    p = this._appendSection(WebInspector.UIString("Sources"));
+    p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show folders"), WebInspector.settings.showScriptFolders));
+    p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Search in content scripts"), WebInspector.settings.searchInContentScripts));
+    p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Enable source maps"), WebInspector.settings.sourceMapsEnabled));
+    p.appendChild(this._createSelectSetting(WebInspector.UIString("Indentation"), [
+            [ WebInspector.UIString("2 spaces"), WebInspector.TextEditorModel.Indent.TwoSpaces ],
+            [ WebInspector.UIString("4 spaces"), WebInspector.TextEditorModel.Indent.FourSpaces ],
+            [ WebInspector.UIString("8 spaces"), WebInspector.TextEditorModel.Indent.EightSpaces ],
+            [ WebInspector.UIString("Tab character"), WebInspector.TextEditorModel.Indent.TabCharacter ]
+        ], WebInspector.settings.textEditorIndent));
+
+    p = this._appendSection(WebInspector.UIString("Profiler"));
+    p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show objects' hidden properties"), WebInspector.settings.showHeapSnapshotObjectsHiddenProperties));
+
+    p = this._appendSection(WebInspector.UIString("Console"));
+    p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Log XMLHttpRequests"), WebInspector.settings.monitoringXHREnabled));
+    p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Preserve log upon navigation"), WebInspector.settings.preserveConsoleLog));
+
+    if (WebInspector.extensionServer.hasExtensions()) {
+        var handlerSelector = new WebInspector.HandlerSelector(WebInspector.openAnchorLocationRegistry);
+        p = this._appendSection(WebInspector.UIString("Extensions"));
+        p.appendChild(this._createCustomSetting(WebInspector.UIString("Open links in"), handlerSelector.element));
+    }
+}
+
+WebInspector.GenericSettingsTab.prototype = {
+    _showPaintRectsChanged: function()
+    {
+        PageAgent.setShowPaintRects(WebInspector.settings.showPaintRects.get());
     },
 
+    _updateScriptDisabledCheckbox: function()
+    {
+        function executionStatusCallback(error, status)
+        {
+            if (error || !status)
+                return;
+
+            switch (status) {
+            case "forbidden":
+                this._disableJSCheckbox.checked = true;
+                this._disableJSCheckbox.disabled = true;
+                break;
+            case "disabled":
+                this._disableJSCheckbox.checked = true;
+                break;
+            default:
+                this._disableJSCheckbox.checked = false;
+                break;
+            }
+        }
+
+        PageAgent.getScriptExecutionStatus(executionStatusCallback.bind(this));
+    },
+
+    _javaScriptDisabledChanged: function()
+    {
+        // We need to manually update the checkbox state, since enabling _javascript_ in the page can actually uncover the "forbidden" state.
+        PageAgent.setScriptExecutionDisabled(WebInspector.settings._javascript_Disabled.get(), this._updateScriptDisabledCheckbox.bind(this));
+    }
+}
+
+WebInspector.GenericSettingsTab.prototype.__proto__ = WebInspector.SettingsTab.prototype;
+
+/**
+ * @constructor
+ * @extends {WebInspector.SettingsTab}
+ */
+WebInspector.UserAgentSettingsTab = function()
+{
+    WebInspector.SettingsTab.call(this);
+
+    var p = this._appendSection();
+    p.appendChild(this._createUserAgentControl());
+    if (Capabilities.canOverrideDeviceMetrics)
+        p.appendChild(this._createDeviceMetricsControl());
+    p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Emulate touch events"), WebInspector.settings.emulateTouchEvents));
+}
+
+WebInspector.UserAgentSettingsTab.prototype = {
     _createUserAgentControl: function()
     {
         var userAgent = WebInspector.settings.userAgent.get();
@@ -333,29 +362,12 @@
         var checkboxElement = labelElement.createChild("input");
         checkboxElement.type = "checkbox";
         checkboxElement.checked = !!userAgent;
-        checkboxElement.addEventListener("click", checkboxClicked.bind(this), false);
         labelElement.appendChild(document.createTextNode("Override User Agent"));
-
-        var selectSectionElement;
-        function checkboxClicked()
-        {
-            if (checkboxElement.checked) {
-                selectSectionElement = this._createUserAgentSelectRowElement();
-                p.appendChild(selectSectionElement);
-            } else {
-                if (selectSectionElement) {
-                    p.removeChild(selectSectionElement);
-                    selectSectionElement = null;
-                }
-                WebInspector.settings.userAgent.set("");
-            }
-        }
-
-        checkboxClicked.call(this);
+        p.appendChild(this._createUserAgentSelectRowElement(checkboxElement));
         return p;
     },
 
-    _createUserAgentSelectRowElement: function()
+    _createUserAgentSelectRowElement: function(checkboxElement)
     {
         var userAgent = WebInspector.settings.userAgent.get();
 
@@ -390,75 +402,83 @@
         ];
 
         var fieldsetElement = document.createElement("fieldset");
-        var selectElement = fieldsetElement.createChild("select");
-        var otherUserAgentElement = fieldsetElement.createChild("input");
-        otherUserAgentElement.value = userAgent;
-        otherUserAgentElement.title = userAgent;
+        this._selectElement = fieldsetElement.createChild("select");
+        this._otherUserAgentElement = fieldsetElement.createChild("input");
+        this._otherUserAgentElement.value = userAgent;
+        this._otherUserAgentElement.title = userAgent;
 
         var selectionRestored = false;
         for (var i = 0; i < userAgents.length; ++i) {
             var agent = userAgents[i];
             var option = new Option(agent[0], agent[1]);
             option._metrics = agent[2] ? agent[2] : "";
-            selectElement.add(option);
+            this._selectElement.add(option);
             if (userAgent === agent[1]) {
-                selectElement.selectedIndex = i;
+                this._selectElement.selectedIndex = i;
                 selectionRestored = true;
             }
         }
 
         if (!selectionRestored) {
             if (!userAgent)
-                selectElement.selectedIndex = 0;
+                this._selectElement.selectedIndex = 0;
             else
-                selectElement.selectedIndex = userAgents.length - 1;
+              this._selectElement.selectedIndex = userAgents.length - 1;
         }
 
-        selectElement.addEventListener("change", selectionChanged.bind(this, true), false);
+        this._selectElement.addEventListener("change", this._selectionChanged.bind(this, true), false);
 
-        /**
-         * @param {boolean=} isUserGesture
-         */
-        function selectionChanged(isUserGesture)
-        {
-            var value = selectElement.options[selectElement.selectedIndex].value;
-            if (value !== "Other") {
-                WebInspector.settings.userAgent.set(value);
-                otherUserAgentElement.value = value;
-                otherUserAgentElement.title = value;
-                otherUserAgentElement.disabled = true;
-            } else {
-                otherUserAgentElement.disabled = false;
-                otherUserAgentElement.focus();
-            }
-
-            if (isUserGesture && Capabilities.canOverrideDeviceMetrics) {
-                var metrics = selectElement.options[selectElement.selectedIndex]._metrics;
-                this._setDeviceMetricsOverride(WebInspector.UserAgentSupport.DeviceMetrics.parseSetting(metrics), false, true);
-            }
-        }
-
         fieldsetElement.addEventListener("dblclick", textDoubleClicked.bind(this), false);
-        otherUserAgentElement.addEventListener("blur", textChanged.bind(this), false);
+        this._otherUserAgentElement.addEventListener("blur", textChanged.bind(this), false);
 
         function textDoubleClicked()
         {
-            selectElement.selectedIndex = userAgents.length - 1;
-            selectionChanged.call(this);
+            this._selectElement.selectedIndex = userAgents.length - 1;
+            this._selectionChanged();
         }
 
         function textChanged()
         {
-            WebInspector.settings.userAgent.set(otherUserAgentElement.value);
+            WebInspector.settings.userAgent.set(this._otherUserAgentElement.value);
         }
 
-        selectionChanged.call(this);
+        function checkboxClicked()
+        {
+            if (checkboxElement.checked) {
+                this._selectElement.disabled = false;
+                this._selectionChanged();
+            } else {
+                this._selectElement.disabled = true;
+                this._otherUserAgentElement.disabled = true;
+                WebInspector.settings.userAgent.set("");
+            }
+        }
+        checkboxElement.addEventListener("click", checkboxClicked.bind(this), false);
+
+        checkboxClicked.call(this);
         return fieldsetElement;
     },
 
-    _showPaintRectsChanged: function()
+    /**
+     * @param {boolean=} isUserGesture
+     */
+    _selectionChanged: function(isUserGesture)
     {
-        PageAgent.setShowPaintRects(WebInspector.settings.showPaintRects.get());
+        var value = this._selectElement.options[this._selectElement.selectedIndex].value;
+        if (value !== "Other") {
+            WebInspector.settings.userAgent.set(value);
+            this._otherUserAgentElement.value = value;
+            this._otherUserAgentElement.title = value;
+            this._otherUserAgentElement.disabled = true;
+        } else {
+            this._otherUserAgentElement.disabled = false;
+            this._otherUserAgentElement.focus();
+        }
+
+        if (isUserGesture && Capabilities.canOverrideDeviceMetrics) {
+            var metrics = this._selectElement.options[this._selectElement.selectedIndex]._metrics;
+            this._setDeviceMetricsOverride(WebInspector.UserAgentSupport.DeviceMetrics.parseSetting(metrics), false, true);
+        }
     },
 
     _updateScriptDisabledCheckbox: function()
@@ -485,12 +505,6 @@
         PageAgent.getScriptExecutionStatus(executionStatusCallback.bind(this));
     },
 
-    _javaScriptDisabledChanged: function()
-    {
-        // We need to manually update the checkbox state, since enabling _javascript_ in the page can actually uncover the "forbidden" state.
-        PageAgent.setScriptExecutionDisabled(WebInspector.settings._javascript_Disabled.get(), this._updateScriptDisabledCheckbox.bind(this));
-    },
-
     _createDeviceMetricsControl: function()
     {
         const metricsSetting = WebInspector.settings.deviceMetrics.get();
@@ -517,15 +531,20 @@
 
     _onMetricsCheckboxClicked: function()
     {
+        var controlsDisabled = !this._metricsCheckboxElement.checked;
+        this._widthOverrideElement.disabled = controlsDisabled;
+        this._heightOverrideElement.disabled = controlsDisabled;
+        this._fontScaleFactorOverrideElement.disabled = controlsDisabled;
+        this._swapDimensionsElement.disabled = controlsDisabled;
+        this._fitWindowCheckboxElement.disabled = controlsDisabled;
+
         if (this._metricsCheckboxElement.checked) {
-            this._metricsSectionElement.removeStyleClass("hidden");
             var metrics = WebInspector.UserAgentSupport.DeviceMetrics.parseUserInput(this._widthOverrideElement.value, this._heightOverrideElement.value, this._fontScaleFactorOverrideElement.value);
             if (metrics && metrics.isValid() && metrics.width && metrics.height)
                 this._setDeviceMetricsOverride(metrics, false, false);
             if (!this._widthOverrideElement.value)
                 this._widthOverrideElement.focus();
         } else {
-            this._metricsSectionElement.addStyleClass("hidden");
             if (WebInspector.settings.deviceMetrics.get())
                 WebInspector.settings.deviceMetrics.set("");
         }
@@ -612,10 +631,10 @@
         cellElement.appendChild(document.createTextNode(" \u00D7 ")); // MULTIPLICATION SIGN.
         this._heightOverrideElement = createInput.call(this, cellElement, "metrics-override-height", String(metrics.height || screen.height));
         cellElement.appendChild(document.createTextNode(" \u2014 ")); // EM DASH.
-        var swapDimensionsElement = cellElement.createChild("button");
-        swapDimensionsElement.appendChild(document.createTextNode(" \u21C4 ")); // RIGHTWARDS ARROW OVER LEFTWARDS ARROW.
-        swapDimensionsElement.title = WebInspector.UIString("Swap dimensions");
-        swapDimensionsElement.addEventListener("click", swapDimensionsClicked.bind(this), false);
+        this._swapDimensionsElement = cellElement.createChild("button");
+        this._swapDimensionsElement.appendChild(document.createTextNode(" \u21C4 ")); // RIGHTWARDS ARROW OVER LEFTWARDS ARROW.
+        this._swapDimensionsElement.title = WebInspector.UIString("Swap dimensions");
+        this._swapDimensionsElement.addEventListener("click", swapDimensionsClicked.bind(this), false);
 
         rowElement = tableElement.createChild("tr");
         cellElement = rowElement.createChild("td");
@@ -626,34 +645,70 @@
         rowElement = tableElement.createChild("tr");
         cellElement = rowElement.createChild("td");
         cellElement.colspan = 2;
-        cellElement.appendChild(this._createCheckboxSetting(WebInspector.UIString("Fit window"), WebInspector.settings.deviceFitWindow, true));
+        this._fitWindowCheckboxElement = document.createElement("input");
+        cellElement.appendChild(this._createCheckboxSetting(WebInspector.UIString("Fit in window"), WebInspector.settings.deviceFitWindow, true, this._fitWindowCheckboxElement));
 
         return fieldsetElement;
     }
 }
 
-WebInspector.SettingsScreen.prototype.__proto__ = WebInspector.HelpScreen.prototype;
+WebInspector.UserAgentSettingsTab.prototype.__proto__ = WebInspector.SettingsTab.prototype;
 
-WebInspector.SettingsScreen.Tabs = {
-    Settings: "Settings",
-    Shortcuts: "Shortcuts"
-}
-
 /**
  * @constructor
- * @extends {WebInspector.TabbedPane}
- * @param {!Element} closeButton
+ * @extends {WebInspector.SettingsTab}
  */
-WebInspector.SettingsScreenTabbedPane = function(closeButton)
+WebInspector.ExperimentsSettingsTab = function()
 {
-    WebInspector.TabbedPane.call(this);
-    this.element.addStyleClass("help-window-main");
+    WebInspector.SettingsTab.call(this);
 
-    this._headerContentsElement.insertBefore(closeButton, this._headerContentsElement.firstChild);
+    var experiments = WebInspector.experimentsSettings.experiments;
+    if (experiments.length) {
+        var experimentsSection = this._appendSection();
+        experimentsSection.appendChild(this._createExperimentsWarningSubsection());
+        for (var i = 0; i < experiments.length; ++i)
+            experimentsSection.appendChild(this._createExperimentCheckbox(experiments[i]));
+    }
 }
 
-WebInspector.SettingsScreenTabbedPane.prototype.__proto__ = WebInspector.TabbedPane.prototype;
+WebInspector.ExperimentsSettingsTab.prototype = {
+    /**
+     * @return {Element} element
+     */
+    _createExperimentsWarningSubsection: function()
+    {
+        var subsection = document.createElement("div");
+        var warning = subsection.createChild("span", "settings-experiments-warning-subsection-warning");
+        warning.textContent = WebInspector.UIString("WARNING:");
+        subsection.appendChild(document.createTextNode(" "));
+        var message = subsection.createChild("span", "settings-experiments-warning-subsection-message");
+        message.textContent = WebInspector.UIString("These experiments could be dangerous and may require restart.");
+        return subsection;
+    },
 
+    _createExperimentCheckbox: function(experiment)
+    {
+        var input = document.createElement("input");
+        input.type = "checkbox";
+        input.name = experiment.name;
+        input.checked = experiment.isEnabled();
+        function listener()
+        {
+            experiment.setEnabled(input.checked);
+        }
+        input.addEventListener("click", listener, false);
+
+        var p = document.createElement("p");
+        var label = document.createElement("label");
+        label.appendChild(input);
+        label.appendChild(document.createTextNode(WebInspector.UIString(experiment.title)));
+        p.appendChild(label);
+        return p;
+    }
+}
+
+WebInspector.ExperimentsSettingsTab.prototype.__proto__ = WebInspector.SettingsTab.prototype;
+
 /**
  * @constructor
  */
@@ -705,5 +760,11 @@
     {
         if (this._settingsScreen)
             this._settingsScreen.hide();
+    },
+
+    resize: function()
+    {
+        if (this._settingsScreen && this._settingsScreen.isShowing())
+            this._settingsScreen.doResize();
     }
 }

Modified: trunk/Source/WebCore/inspector/front-end/ShortcutsScreen.js (120330 => 120331)


--- trunk/Source/WebCore/inspector/front-end/ShortcutsScreen.js	2012-06-14 16:44:25 UTC (rev 120330)
+++ trunk/Source/WebCore/inspector/front-end/ShortcutsScreen.js	2012-06-14 16:49:10 UTC (rev 120331)
@@ -45,7 +45,7 @@
         return section;
     },
 
-    _createShortcutsTabView: function()
+    createShortcutsTabView: function()
     {
         var orderedSections = [];
         for (var section in this._sections)

Modified: trunk/Source/WebCore/inspector/front-end/TabbedPane.js (120330 => 120331)


--- trunk/Source/WebCore/inspector/front-end/TabbedPane.js	2012-06-14 16:44:25 UTC (rev 120330)
+++ trunk/Source/WebCore/inspector/front-end/TabbedPane.js	2012-06-14 16:49:10 UTC (rev 120331)
@@ -373,7 +373,8 @@
         for (var tabId in this._tabs)
             measuredWidths.push(this._tabs[tabId].measuredWidth);
         
-        var maxWidth = this._calculateMaxWidth(measuredWidths, this._headerContentsElement.offsetWidth);
+        const roundingError = 5;
+        var maxWidth = this._calculateMaxWidth(measuredWidths, this._headerContentsElement.offsetWidth - 5);
         
         for (var tabId in this._tabs) {
             var tab = this._tabs[tabId];

Modified: trunk/Source/WebCore/inspector/front-end/helpScreen.css (120330 => 120331)


--- trunk/Source/WebCore/inspector/front-end/helpScreen.css	2012-06-14 16:44:25 UTC (rev 120330)
+++ trunk/Source/WebCore/inspector/front-end/helpScreen.css	2012-06-14 16:49:10 UTC (rev 120331)
@@ -85,7 +85,6 @@
     border-radius: 8px;
     height: 16px;
     width: 16px;
-    margin: 10px 0;
 }
 
 body.compact .help-content {
@@ -126,12 +125,12 @@
     width: 330px;
 }
 
-#settings.help-container {
-    -webkit-column-width: 240px;
+.settings-tab.help-container {
+    -webkit-column-width: 410px;
 }
 
-#settings .help-block {
-    width: 240px;
+.settings-tab .help-block {
+    width: 410px;
 }
 
 .help-line {
@@ -185,7 +184,7 @@
 
 .help-content fieldset {
     border: none;
-    margin-left: 9px;
+    margin-left: 7px;
 }
 
 .help-content fieldset p {
@@ -259,7 +258,7 @@
 }
 
 #settings-screen .tabbed-pane-header-tabs {
-    padding-top: 9px;
+    padding-top: 6px;
 }
 
 #settings-screen .tabbed-pane-header-tab {
@@ -268,15 +267,16 @@
     top: 1px;
     text-shadow: none;
     color: rgb(255, 255, 255);
-    height: 19px;
+    height: 22px;
     font-size: 13px;
-    padding: 0 4px;
+    padding: 1px 10px;
     margin: 0;
 }
 
 #settings-screen .help-close-button {
-    margin-top: 6px;
-    margin-bottom: 6px;
+    position: absolute;
+    top: 6px;
+    right: 6px;
 }
 
 #settings-screen .tabbed-pane-header-tab.selected {

Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (120330 => 120331)


--- trunk/Source/WebCore/inspector/front-end/inspector.js	2012-06-14 16:44:25 UTC (rev 120330)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js	2012-06-14 16:49:10 UTC (rev 120331)
@@ -584,6 +584,7 @@
     WebInspector.inspectorView.doResize();
     WebInspector.drawer.resize();
     WebInspector.toolbar.resize();
+    WebInspector.settingsController.resize();
 }
 
 WebInspector.setDockingUnavailable = function(unavailable)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to