Bug 1468495 - Reset the inspector widths for the first run of 3 pane inspector. r=pbro
authorGabriel Luong <gabriel.luong@gmail.com>
Tue, 19 Jun 2018 10:13:37 -0400
changeset 422978 130fd3919bd9ebf17c2c1c244aaeec5da183564c
parent 422977 72bd48d00704bf1c1d30cc945898b57d73081511
child 422979 5d7ff9efd67fb15ec6ce70e8e49f37fd57061a87
push id34160
push userdluca@mozilla.com
push dateTue, 19 Jun 2018 21:55:15 +0000
treeherdermozilla-central@e429320fcdd2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbro
bugs1468495
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1468495 - Reset the inspector widths for the first run of 3 pane inspector. r=pbro
devtools/client/inspector/inspector.js
devtools/client/preferences/devtools-client.js
--- a/devtools/client/inspector/inspector.js
+++ b/devtools/client/inspector/inspector.js
@@ -49,16 +49,17 @@ const INITIAL_SIDEBAR_SIZE = 350;
 // If the toolbox's width is smaller than the given amount of pixels, the sidebar
 // automatically switches from 'landscape/horizontal' to 'portrait/vertical' mode.
 const PORTRAIT_MODE_WIDTH_THRESHOLD = 700;
 // If the toolbox's width docked to the side is smaller than the given amount of pixels,
 // the sidebar automatically switches from 'landscape/horizontal' to 'portrait/vertical'
 // mode.
 const SIDE_PORTAIT_MODE_WIDTH_THRESHOLD = 1000;
 
+const THREE_PANE_FIRST_RUN_PREF = "devtools.inspector.three-pane-first-run";
 const SHOW_THREE_PANE_ONBOARDING_PREF = "devtools.inspector.show-three-pane-tooltip";
 const THREE_PANE_ENABLED_PREF = "devtools.inspector.three-pane-enabled";
 const THREE_PANE_ENABLED_SCALAR = "devtools.inspector.three_pane_enabled";
 
 const TELEMETRY_EYEDROPPER_OPENED = "devtools.toolbar.eyedropper.opened";
 
 /**
  * Represents an open instance of the Inspector for a tab.
@@ -115,16 +116,17 @@ function Inspector(toolbox) {
   this.reflowTracker = new ReflowTracker(this._target);
   this.styleChangeTracker = new InspectorStyleChangeTracker(this);
 
   // Store the URL of the target page prior to navigation in order to ensure
   // telemetry counts in the Grid Inspector are not double counted on reload.
   this.previousURL = this.target.url;
 
   this.is3PaneModeEnabled = Services.prefs.getBoolPref(THREE_PANE_ENABLED_PREF);
+  this.is3PaneModeFirstRun = Services.prefs.getBoolPref(THREE_PANE_FIRST_RUN_PREF);
   this.show3PaneTooltip = Services.prefs.getBoolPref(SHOW_THREE_PANE_ONBOARDING_PREF);
 
   this.nodeMenuTriggerInfo = null;
 
   this._clearSearchResultsLabel = this._clearSearchResultsLabel.bind(this);
   this._handleRejectionIfNotDestroyed = this._handleRejectionIfNotDestroyed.bind(this);
   this._onBeforeNavigate = this._onBeforeNavigate.bind(this);
   this._onContextMenu = this._onContextMenu.bind(this);
@@ -245,16 +247,24 @@ Inspector.prototype = {
 
     if (this.target.isLocalTab) {
       this.target.on("thread-paused", this._updateDebuggerPausedWarning);
       this.target.on("thread-resumed", this._updateDebuggerPausedWarning);
       this.toolbox.on("select", this._updateDebuggerPausedWarning);
       this._updateDebuggerPausedWarning();
     }
 
+    // Resets the inspector sidebar widths if this is the first run of the 3 pane mode.
+    if (this.is3PaneModeFirstRun) {
+      Services.prefs.clearUserPref("devtools.toolsidebar-width.inspector");
+      Services.prefs.clearUserPref("devtools.toolsidebar-height.inspector");
+      Services.prefs.clearUserPref("devtools.toolsidebar-width.inspector.splitsidebar");
+      Services.prefs.setBoolPref(THREE_PANE_FIRST_RUN_PREF, false);
+    }
+
     this._initMarkup();
     this.isReady = false;
 
     this.setupSearchBox();
 
     // Setup the splitter before the sidebar is displayed so,
     // we don't miss any events.
     this.setupSplitter();
@@ -1391,16 +1401,17 @@ Inspector.prototype = {
     this.reflowTracker.destroy();
     this.styleChangeTracker.destroy();
 
     this._notificationBox = null;
     this._target = null;
     this._toolbox = null;
     this.breadcrumbs = null;
     this.is3PaneModeEnabled = null;
+    this.is3PaneModeFirstRun = null;
     this.panelDoc = null;
     this.panelWin.inspector = null;
     this.panelWin = null;
     this.resultsLength = null;
     this.searchBox = null;
     this.show3PaneTooltip = null;
     this.sidebar = null;
     this.store = null;
--- a/devtools/client/preferences/devtools-client.js
+++ b/devtools/client/preferences/devtools-client.js
@@ -39,17 +39,19 @@ pref("devtools.inspector.remote", false)
 // Show the 3 pane onboarding tooltip in the inspector only in release or beta builds.
 #if defined(RELEASE_OR_BETA)
 pref("devtools.inspector.show-three-pane-tooltip", true);
 #else
 pref("devtools.inspector.show-three-pane-tooltip", false);
 #endif
 // Enable the 3 pane mode in the inspector
 pref("devtools.inspector.three-pane-enabled", true);
-
+// Whether or not this is the first run of the 3 pane mode. Used to reset the default
+// inspector sidebar widths for its first run.
+pref("devtools.inspector.three-pane-first-run", true);
 // Collapse pseudo-elements by default in the rule-view
 pref("devtools.inspector.show_pseudo_elements", false);
 // The default size for image preview tooltips in the rule-view/computed-view/markup-view
 pref("devtools.inspector.imagePreviewTooltipSize", 300);
 // Enable user agent style inspection in rule-view
 pref("devtools.inspector.showUserAgentStyles", false);
 // Show all native anonymous content (like controls in <video> tags)
 pref("devtools.inspector.showAllAnonymousContent", false);