Bug 1371849 - move source map pref checkbox into "advanced" area in options panel; r?bgrins draft
authorTom Tromey <tom@tromey.com>
Fri, 15 Sep 2017 09:07:37 -0600
changeset 666486 9e5b45478eb5e22fafebebbcc4a3d5b5800eb600
parent 666445 a2cc74795c35da97f64f42fd2758bf9d5ef1e073
child 732130 0d08ba3a7d3e0cbf55382717cf5e407064210fdc
push id80434
push userbmo:ttromey@mozilla.com
push dateMon, 18 Sep 2017 21:00:24 +0000
reviewersbgrins
bugs1371849
milestone57.0a1
Bug 1371849 - move source map pref checkbox into "advanced" area in options panel; r?bgrins MozReview-Commit-ID: E76CBevu12g
devtools/client/framework/toolbox-options.js
devtools/client/framework/toolbox-options.xhtml
devtools/client/locales/en-US/toolbox.dtd
--- a/devtools/client/framework/toolbox-options.js
+++ b/devtools/client/framework/toolbox-options.js
@@ -95,34 +95,40 @@ OptionsPanel.prototype = {
     this.isReady = true;
     this.emit("ready");
     return this;
   }),
 
   _addListeners: function () {
     Services.prefs.addObserver("devtools.cache.disabled", this._prefChanged);
     Services.prefs.addObserver("devtools.theme", this._prefChanged);
+    Services.prefs.addObserver("devtools.source-map.client-service.enabled",
+                               this._prefChanged);
     gDevTools.on("theme-registered", this._themeRegistered);
     gDevTools.on("theme-unregistered", this._themeUnregistered);
   },
 
   _removeListeners: function () {
     Services.prefs.removeObserver("devtools.cache.disabled", this._prefChanged);
     Services.prefs.removeObserver("devtools.theme", this._prefChanged);
+    Services.prefs.removeObserver("devtools.source-map.client-service.enabled",
+                                  this._prefChanged);
     gDevTools.off("theme-registered", this._themeRegistered);
     gDevTools.off("theme-unregistered", this._themeUnregistered);
   },
 
   _prefChanged: function (subject, topic, prefName) {
     if (prefName === "devtools.cache.disabled") {
       let cacheDisabled = GetPref(prefName);
       let cbx = this.panelDoc.getElementById("devtools-disable-cache");
       cbx.checked = cacheDisabled;
     } else if (prefName === "devtools.theme") {
       this.updateCurrentTheme();
+    } else if (prefName === "devtools.source-map.client-service.enabled") {
+      this.updateSourceMapPref();
     }
   },
 
   _themeRegistered: function (event, themeId) {
     this.setupThemeList();
   },
 
   _themeUnregistered: function (event, theme) {
@@ -342,16 +348,17 @@ OptionsPanel.prototype = {
       inputLabel.appendChild(inputSpanLabel);
 
       return inputLabel;
     };
 
     for (let prefDefinition of prefDefinitions) {
       let parent = this.panelDoc.getElementById(prefDefinition.parentId);
       parent.appendChild(createPreferenceOption(prefDefinition));
+      parent.removeAttribute("hidden");
     }
   },
 
   populatePreferences: Task.async(function* () {
     let prefCheckboxes = this.panelDoc.querySelectorAll(
       "input[type=checkbox][data-pref]");
     for (let prefCheckbox of prefCheckboxes) {
       if (GetPref(prefCheckbox.getAttribute("data-pref"))) {
@@ -420,16 +427,23 @@ OptionsPanel.prototype = {
       themeRadioInput.checked = true;
     } else {
       // If the current theme does not exist anymore, switch to light theme
       let lightThemeInputRadio = themeBox.querySelector("[value=light]");
       lightThemeInputRadio.checked = true;
     }
   },
 
+  updateSourceMapPref: function () {
+    const prefName = "devtools.source-map.client-service.enabled";
+    let enabled = GetPref(prefName);
+    let box = this.panelDoc.querySelector(`[data-pref="${prefName}"]`);
+    box.checked = enabled;
+  },
+
   /**
    * Disables JavaScript for the currently loaded tab. We force a page refresh
    * here because setting docShell.allowJavascript to true fails to block JS
    * execution from event listeners added using addEventListener(), AJAX calls
    * and timers. The page refresh prevents these things from being added in the
    * first place.
    *
    * @param {Event} event
--- a/devtools/client/framework/toolbox-options.xhtml
+++ b/devtools/client/framework/toolbox-options.xhtml
@@ -71,33 +71,22 @@
         <label title="&options.timestampMessages.tooltip;">
           <input type="checkbox"
                  id="webconsole-timestamp-messages"
                  data-pref="devtools.webconsole.timestampMessages"/>
           <span>&options.timestampMessages.label;</span>
         </label>
       </fieldset>
 
-      <fieldset id="debugger-options" class="options-groupbox">
+      <fieldset id="debugger-options" class="options-groupbox" hidden="true">
         <legend>&options.debugger.label;</legend>
-        <label title="&options.sourceMaps.tooltip;">
-          <input type="checkbox"
-                 id="debugger-sourcemaps"
-                 data-pref="devtools.debugger.client-source-maps-enabled"/>
-          <span>&options.sourceMaps.label;</span>
-        </label>
       </fieldset>
 
       <fieldset id="styleeditor-options" class="options-groupbox">
         <legend>&options.styleeditor.label;</legend>
-        <label title="&options.stylesheetSourceMaps.tooltip;">
-          <input type="checkbox"
-                 data-pref="devtools.source-map.client-service.enabled"/>
-          <span>&options.stylesheetSourceMaps.label;</span>
-        </label>
         <label title="&options.stylesheetAutocompletion.tooltip;">
           <input type="checkbox"
                  data-pref="devtools.styleeditor.autocompletion-enabled"/>
           <span>&options.stylesheetAutocompletion.label;</span>
         </label>
       </fieldset>
 
       <fieldset id="screenshot-options" class="options-groupbox">
@@ -156,16 +145,21 @@
             <option value="emacs">Emacs</option>
             <option value="sublime">Sublime Text</option>
           </select>
         </label>
       </fieldset>
 
       <fieldset id="context-options" class="options-groupbox">
         <legend>&options.context.advancedSettings;</legend>
+          <label title="&options.sourceMaps.tooltip1;">
+            <input type="checkbox"
+                   data-pref="devtools.source-map.client-service.enabled"/>
+            <span>&options.sourceMaps.label;</span>
+          </label>
          <label title="&options.showPlatformData.tooltip;">
             <input type="checkbox"
                    id="devtools-show-gecko-data"
                    data-pref="devtools.performance.ui.show-platform-data"/>
             <span>&options.showPlatformData.label;</span>
           </label>
           <label title="&options.disableHTTPCache.tooltip;">
             <input type="checkbox"
--- a/devtools/client/locales/en-US/toolbox.dtd
+++ b/devtools/client/locales/en-US/toolbox.dtd
@@ -140,30 +140,25 @@
 <!ENTITY options.timestampMessages.label      "Enable timestamps">
 <!ENTITY options.timestampMessages.tooltip    "If you enable this option commands and output in the Web Console will display a timestamp">
 
 <!-- LOCALIZATION NOTE (options.debugger.label): This is the label for the
   -  heading of the group of Debugger preferences in the options panel. -->
 <!ENTITY options.debugger.label            "Debugger">
 
 <!-- LOCALIZATION NOTE (options.sourceMap.label): This is the
-   - label for the checkbox that toggles source maps in the Debugger -->
+   - label for the checkbox that toggles source maps in all tools -->
 <!ENTITY options.sourceMaps.label      "Enable Source Maps">
-<!ENTITY options.sourceMaps.tooltip    "If you enable this option sources will be mapped in the Debugger and Console.">
+<!ENTITY options.sourceMaps.tooltip1   "If you enable this option sources will be mapped in the tools.">
 
 <!-- LOCALIZATION NOTE (options.styleeditor.label): This is the label for the
   -  heading of the group of Style Editor preferences in the options
   -  panel. -->
 <!ENTITY options.styleeditor.label            "Style Editor">
 
-<!-- LOCALIZATION NOTE (options.stylesheetSourceMaps.label): This is the
-   - label for the checkbox that toggles showing original sources in the Style Editor -->
-<!ENTITY options.stylesheetSourceMaps.label      "Show original sources">
-<!ENTITY options.stylesheetSourceMaps.tooltip    "Show original sources (e.g. Sass files) in the Style Editor and Inspector">
-
 <!-- LOCALIZATION NOTE (options.stylesheetAutocompletion.label): This is the
    - label for the checkbox that toggles autocompletion of css in the Style Editor -->
 <!ENTITY options.stylesheetAutocompletion.label      "Autocomplete CSS">
 <!ENTITY options.stylesheetAutocompletion.tooltip    "Autocomplete CSS properties, values and selectors in Style Editor as you type">
 
 <!-- LOCALIZATION NOTE (options.screenshot.label): This is the label for the
    -  heading of the group of Screenshot preferences in the options
    -  panel. -->