Web Inspector: RTL: inherit system layout direction by default
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Apr 2017 23:44:56 +0000 (23:44 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Apr 2017 23:44:56 +0000 (23:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=171402
<rdar://problem/30753626>

Reviewed by Joseph Pecoraro.

Web Inspector's layout direction should follow the system layout direction
by default now that most RTL bugs seem to be fixed. We are ready for more
feedback.

* UserInterface/Base/Main.js:
* UserInterface/Base/Setting.js:
Rename the existing "layout-direction" setting so that the new default
value is set properly even for people who have overridden the layout
direction while the setting was exposed to everyone.

* UserInterface/Views/GeneralSettingsView.js:
(WebInspector.GeneralSettingsView.prototype.initialLayout):
(WebInspector.GeneralSettingsView.prototype.layout):
(WebInspector.GeneralSettingsView):
Make the layout direction override setting only visible when DebugUI
is turned on. This remains only for engineers to quickly check layout bugs.

* UserInterface/Views/SettingsView.js:
(WebInspector.SettingsView.prototype.addGroupWithCustomSetting):
(WebInspector.SettingsView.prototype.addCustomSetting): Deleted.
Refactor the convenience method to return both the group and the
custom setting. This allows us to toggle .hidden on the entire
row for the Layout Direction setting (label and editor).

* Localizations/en.lproj/localizedStrings.js:
Unlocalize the setting strings since they are only shown in engineering builds now.

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Base/Setting.js
Source/WebInspectorUI/UserInterface/Views/GeneralSettingsView.js
Source/WebInspectorUI/UserInterface/Views/SettingsView.js

index ad88967..622187d 100644 (file)
@@ -1,5 +1,40 @@
 2017-04-27  Brian Burg  <bburg@apple.com>
 
+        Web Inspector: RTL: inherit system layout direction by default
+        https://bugs.webkit.org/show_bug.cgi?id=171402
+        <rdar://problem/30753626>
+
+        Reviewed by Joseph Pecoraro.
+
+        Web Inspector's layout direction should follow the system layout direction
+        by default now that most RTL bugs seem to be fixed. We are ready for more
+        feedback.
+
+        * UserInterface/Base/Main.js:
+        * UserInterface/Base/Setting.js:
+        Rename the existing "layout-direction" setting so that the new default
+        value is set properly even for people who have overridden the layout
+        direction while the setting was exposed to everyone.
+
+        * UserInterface/Views/GeneralSettingsView.js:
+        (WebInspector.GeneralSettingsView.prototype.initialLayout):
+        (WebInspector.GeneralSettingsView.prototype.layout):
+        (WebInspector.GeneralSettingsView):
+        Make the layout direction override setting only visible when DebugUI
+        is turned on. This remains only for engineers to quickly check layout bugs.
+
+        * UserInterface/Views/SettingsView.js:
+        (WebInspector.SettingsView.prototype.addGroupWithCustomSetting):
+        (WebInspector.SettingsView.prototype.addCustomSetting): Deleted.
+        Refactor the convenience method to return both the group and the
+        custom setting. This allows us to toggle .hidden on the entire
+        row for the Layout Direction setting (label and editor).
+
+        * Localizations/en.lproj/localizedStrings.js:
+        Unlocalize the setting strings since they are only shown in engineering builds now.
+
+2017-04-27  Brian Burg  <bburg@apple.com>
+
         Web Inspector: RTL: fix alignment of "truncated call stack" message
         https://bugs.webkit.org/show_bug.cgi?id=170477
 
index 6a38935..03987f4 100644 (file)
@@ -483,10 +483,8 @@ localizedStrings["Layer Info"] = "Layer Info";
 localizedStrings["Layers"] = "Layers";
 localizedStrings["Layout"] = "Layout";
 localizedStrings["Layout & Rendering"] = "Layout & Rendering";
-localizedStrings["Layout Direction:"] = "Layout Direction:";
 localizedStrings["Layout Invalidated"] = "Layout Invalidated";
 localizedStrings["Left"] = "Left";
-localizedStrings["Left to Right (LTR)"] = "Left to Right (LTR)";
 localizedStrings["Letter"] = "Letter";
 localizedStrings["Ligatures"] = "Ligatures";
 localizedStrings["Line %d"] = "Line %d";
@@ -697,7 +695,6 @@ localizedStrings["Reveal in Debugger Tab"] = "Reveal in Debugger Tab";
 localizedStrings["Reveal in Original Resource"] = "Reveal in Original Resource";
 localizedStrings["Reveal in Resources Tab"] = "Reveal in Resources Tab";
 localizedStrings["Right"] = "Right";
-localizedStrings["Right to Left (RTL)"] = "Right to Left (RTL)";
 localizedStrings["Role"] = "Role";
 localizedStrings["Rule"] = "Rule";
 localizedStrings["Samples"] = "Samples";
@@ -820,7 +817,6 @@ localizedStrings["Styles \u2014 Visual"] = "Styles \u2014 Visual";
 localizedStrings["Stylesheet"] = "Stylesheet";
 localizedStrings["Stylesheets"] = "Stylesheets";
 localizedStrings["Subtree Modified"] = "Subtree Modified";
-localizedStrings["System Default"] = "System Default";
 localizedStrings["Tab width:"] = "Tab width:";
 localizedStrings["Tabs"] = "Tabs";
 localizedStrings["Take snapshot"] = "Take snapshot";
index 550c464..c62602b 100644 (file)
@@ -112,9 +112,7 @@ WebInspector.settings = {
     clearLogOnNavigate: new WebInspector.Setting("clear-log-on-navigate", true),
     clearNetworkOnNavigate: new WebInspector.Setting("clear-network-on-navigate", true),
     zoomFactor: new WebInspector.Setting("zoom-factor", 1),
-    // FIXME: change initial value to 'system' once we are happy with RTL support.
-    // This will cause Web Inspector to use the system user interface layout direction.
-    layoutDirection: new WebInspector.Setting("layout-direction", "ltr"),
+    layoutDirection: new WebInspector.Setting("layout-direction-override", "system"),
     stylesShowInlineWarnings: new WebInspector.Setting("styles-show-inline-warning", true),
     stylesInsertNewline: new WebInspector.Setting("styles-insert-newline", true),
     stylesSelectOnFirstClick: new WebInspector.Setting("styles-select-on-first-click", true),
index 368f2f7..35b4024 100644 (file)
@@ -36,7 +36,7 @@ WebInspector.GeneralSettingsView = class GeneralSettingsView extends WebInspecto
     {
         const indentValues = [WebInspector.UIString("Tabs"), WebInspector.UIString("Spaces")];
 
-        let indentEditor = this.addCustomSetting(WebInspector.UIString("Prefer indent using:"), WebInspector.SettingEditor.Type.Select, {values: indentValues});
+        let [/* unused */, indentEditor] = this.addGroupWithCustomSetting(WebInspector.UIString("Prefer indent using:"), WebInspector.SettingEditor.Type.Select, {values: indentValues});
         indentEditor.value = indentValues[WebInspector.settings.indentWithTabs.value ? 0 : 1];
         indentEditor.addEventListener(WebInspector.SettingEditor.Event.ValueDidChange, () => {
             WebInspector.settings.indentWithTabs.value = indentEditor.value === indentValues[0];
@@ -78,20 +78,27 @@ WebInspector.GeneralSettingsView = class GeneralSettingsView extends WebInspecto
         const zoomLevels = [0.6, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2, 2.2, 2.4];
         const zoomValues = zoomLevels.map((level) => [level, Number.percentageString(level, 0)]);
 
-        let zoomEditor = this.addCustomSetting(WebInspector.UIString("Zoom:"), WebInspector.SettingEditor.Type.Select, {values: zoomValues});
+        let [/* unused */, zoomEditor] = this.addGroupWithCustomSetting(WebInspector.UIString("Zoom:"), WebInspector.SettingEditor.Type.Select, {values: zoomValues});
         zoomEditor.value = WebInspector.settings.zoomFactor.value;
         zoomEditor.addEventListener(WebInspector.SettingEditor.Event.ValueDidChange, () => { WebInspector.setZoomFactor(zoomEditor.value); });
 
         this.addSeparator();
 
+        // This setting is only ever shown in engineering builds, so its strings are unlocalized.
         const layoutDirectionValues = [
-            [WebInspector.LayoutDirection.System, WebInspector.UIString("System Default")],
-            [WebInspector.LayoutDirection.LTR, WebInspector.UIString("Left to Right (LTR)")],
-            [WebInspector.LayoutDirection.RTL, WebInspector.UIString("Right to Left (RTL)")],
+            [WebInspector.LayoutDirection.System, WebInspector.unlocalizedString("System Default")],
+            [WebInspector.LayoutDirection.LTR, WebInspector.unlocalizedString("Left to Right (LTR)")],
+            [WebInspector.LayoutDirection.RTL, WebInspector.unlocalizedString("Right to Left (RTL)")],
         ];
 
-        let layoutDirectionEditor = this.addCustomSetting(WebInspector.UIString("Layout Direction:"), WebInspector.SettingEditor.Type.Select, {values: layoutDirectionValues});
+        let [layoutDirectionGroup, layoutDirectionEditor] = this.addGroupWithCustomSetting(WebInspector.unlocalizedString("Layout Direction:"), WebInspector.SettingEditor.Type.Select, {values: layoutDirectionValues});
+        this._layoutDirectionGroup = layoutDirectionGroup;
         layoutDirectionEditor.value = WebInspector.settings.layoutDirection.value;
         layoutDirectionEditor.addEventListener(WebInspector.SettingEditor.Event.ValueDidChange, () => { WebInspector.setLayoutDirection(layoutDirectionEditor.value); });
     }
+
+    layout()
+    {
+        this._layoutDirectionGroup.element.classList.toggle("hidden", !WebInspector.isDebugUIEnabled());
+    }
 };
index 105e3c0..b3361f0 100644 (file)
@@ -46,10 +46,11 @@ WebInspector.SettingsView = class SettingsView extends WebInspector.View
         return settingsGroup.addSetting(setting, label, options);
     }
 
-    addCustomSetting(title, editorType, options)
+    addGroupWithCustomSetting(title, editorType, options)
     {
         let settingsGroup = this.addGroup(title);
-        return settingsGroup.addCustomSetting(editorType, options);
+        let customSetting = settingsGroup.addCustomSetting(editorType, options);
+        return [settingsGroup, customSetting];
     }
 
     addGroup(title)