Web Inspector: Use initialLayout for Settings tab
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 May 2017 18:02:32 +0000 (18:02 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 May 2017 18:02:32 +0000 (18:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=172304

Reviewed by Matt Baker.

* UserInterface/Views/GeneralSettingsView.js:
(WebInspector.GeneralSettingsView.prototype.initialLayout):
Move listener for zoom factor to only update that editor.

* UserInterface/Views/SettingsTabContentView.js:
(WebInspector.SettingsTabContentView):
(WebInspector.SettingsTabContentView.prototype.initialLayout): Added.
It is not necessary to create the UI for editing settings until the Settings tab is shown.
Use initialLayout to ensure UI gets created exactly once, after the tab is selected.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217132 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/GeneralSettingsView.js
Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js

index 56d8b34..9b912a8 100644 (file)
@@ -1,3 +1,20 @@
+2017-05-19  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Use initialLayout for Settings tab
+        https://bugs.webkit.org/show_bug.cgi?id=172304
+
+        Reviewed by Matt Baker.
+
+        * UserInterface/Views/GeneralSettingsView.js:
+        (WebInspector.GeneralSettingsView.prototype.initialLayout):
+        Move listener for zoom factor to only update that editor.
+
+        * UserInterface/Views/SettingsTabContentView.js:
+        (WebInspector.SettingsTabContentView):
+        (WebInspector.SettingsTabContentView.prototype.initialLayout): Added.
+        It is not necessary to create the UI for editing settings until the Settings tab is shown.
+        Use initialLayout to ensure UI gets created exactly once, after the tab is selected.
+
 2017-05-18  Devin Rousso  <drousso@apple.com>
 
         REGRESSION (r?): Web Inspector: Shift-click on color square in Styles sidebar should not select text
index 35b4024..37fae42 100644 (file)
@@ -79,8 +79,9 @@ WebInspector.GeneralSettingsView = class GeneralSettingsView extends WebInspecto
         const zoomValues = zoomLevels.map((level) => [level, Number.percentageString(level, 0)]);
 
         let [/* unused */, zoomEditor] = this.addGroupWithCustomSetting(WebInspector.UIString("Zoom:"), WebInspector.SettingEditor.Type.Select, {values: zoomValues});
-        zoomEditor.value = WebInspector.settings.zoomFactor.value;
+        zoomEditor.value = WebInspector.getZoomFactor();
         zoomEditor.addEventListener(WebInspector.SettingEditor.Event.ValueDidChange, () => { WebInspector.setZoomFactor(zoomEditor.value); });
+        WebInspector.settings.zoomFactor.addEventListener(WebInspector.Setting.Event.Changed, () => { zoomEditor.value = WebInspector.getZoomFactor().maxDecimals(2); });
 
         this.addSeparator();
 
index 51a1641..ed7a4ef 100644 (file)
@@ -35,22 +35,8 @@ WebInspector.SettingsTabContentView = class SettingsTabContentView extends WebIn
         // Ensures that the Settings tab is displayable from a pinned tab bar item.
         tabBarItem.representedObject = this;
 
-        let boundNeedsLayout = this.needsLayout.bind(this, WebInspector.View.LayoutReason.Dirty);
-        WebInspector.notifications.addEventListener(WebInspector.Notification.DebugUIEnabledDidChange, boundNeedsLayout);
-        WebInspector.settings.zoomFactor.addEventListener(WebInspector.Setting.Event.Changed, boundNeedsLayout);
-
-        this._navigationBar = new WebInspector.NavigationBar;
-        this._navigationBar.addEventListener(WebInspector.NavigationBar.Event.NavigationItemSelected, this._navigationItemSelected, this);
-
         this._selectedSettingsView = null;
         this._settingsViews = [];
-
-        this.addSubview(this._navigationBar);
-
-        let generalSettingsView = new WebInspector.GeneralSettingsView;
-        this.addSettingsView(generalSettingsView);
-
-        this.selectedSettingsView = generalSettingsView;
     }
 
     static tabInfo()
@@ -166,6 +152,23 @@ WebInspector.SettingsTabContentView = class SettingsTabContentView extends WebIn
         }
     }
 
+    // Protected
+
+    initialLayout()
+    {
+        this._navigationBar = new WebInspector.NavigationBar;
+        this._navigationBar.addEventListener(WebInspector.NavigationBar.Event.NavigationItemSelected, this._navigationItemSelected, this);
+
+        this.addSubview(this._navigationBar);
+
+        let generalSettingsView = new WebInspector.GeneralSettingsView;
+        this.addSettingsView(generalSettingsView);
+
+        this.selectedSettingsView = generalSettingsView;
+
+        WebInspector.notifications.addEventListener(WebInspector.Notification.DebugUIEnabledDidChange, this.needsLayout.bind(this, WebInspector.View.LayoutReason.Dirty));
+    }
+
     // Private
 
     _updateNavigationBarVisibility()