Title: [238829] trunk/Source/WebInspectorUI
Revision
238829
Author
[email protected]
Date
2018-12-03 16:15:22 -0800 (Mon, 03 Dec 2018)

Log Message

Web Inspector: Canvas: add singular localized string for "Record first %s frames"
https://bugs.webkit.org/show_bug.cgi?id=192189

Reviewed by Joseph Pecoraro.

* UserInterface/Views/CanvasOverviewContentView.js:
(WI.CanvasOverviewContentView):
(WI.CanvasOverviewContentView.prototype._setRecordingAutoCaptureFrameCount):
(WI.CanvasOverviewContentView.prototype._updateRecordingAutoCaptureCheckboxLabel): Added.
(WI.CanvasOverviewContentView.prototype._handleRecordingAutoCaptureInput):
(WI.CanvasOverviewContentView.prototype._handleCanvasRecordingAutoCaptureFrameCountChanged):
(WI.CanvasOverviewContentView.prototype.initialLayout): Deleted.
Drive-by: update the auto-capture navigation item when the view is first created so there is
no flashing of in the navigation bar (before `initialLayout` is called).

* UserInterface/Views/CheckboxNavigationItem.js:
(WI.CheckboxNavigationItem):
(WI.CheckboxNavigationItem.prototype.set label): Added.

* Localizations/en.lproj/localizedStrings.js:

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (238828 => 238829)


--- trunk/Source/WebInspectorUI/ChangeLog	2018-12-04 00:08:42 UTC (rev 238828)
+++ trunk/Source/WebInspectorUI/ChangeLog	2018-12-04 00:15:22 UTC (rev 238829)
@@ -1,3 +1,26 @@
+2018-12-03  Devin Rousso  <[email protected]>
+
+        Web Inspector: Canvas: add singular localized string for "Record first %s frames"
+        https://bugs.webkit.org/show_bug.cgi?id=192189
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Views/CanvasOverviewContentView.js:
+        (WI.CanvasOverviewContentView):
+        (WI.CanvasOverviewContentView.prototype._setRecordingAutoCaptureFrameCount):
+        (WI.CanvasOverviewContentView.prototype._updateRecordingAutoCaptureCheckboxLabel): Added.
+        (WI.CanvasOverviewContentView.prototype._handleRecordingAutoCaptureInput):
+        (WI.CanvasOverviewContentView.prototype._handleCanvasRecordingAutoCaptureFrameCountChanged):
+        (WI.CanvasOverviewContentView.prototype.initialLayout): Deleted.
+        Drive-by: update the auto-capture navigation item when the view is first created so there is
+        no flashing of in the navigation bar (before `initialLayout` is called).
+
+        * UserInterface/Views/CheckboxNavigationItem.js:
+        (WI.CheckboxNavigationItem):
+        (WI.CheckboxNavigationItem.prototype.set label): Added.
+
+        * Localizations/en.lproj/localizedStrings.js:
+
 2018-12-03  Matt Baker  <[email protected]>
 
         Web Inspector: REGRESSION(r238599): Multiple Selection: restoring selection when opening WebInspector puts the TreeElement into a permanent selected state

Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (238828 => 238829)


--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2018-12-04 00:08:42 UTC (rev 238828)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2018-12-04 00:15:22 UTC (rev 238829)
@@ -701,6 +701,7 @@
 localizedStrings["Readonly"] = "Readonly";
 localizedStrings["Reasons for compositing"] = "Reasons for compositing";
 localizedStrings["Reasons for compositing:"] = "Reasons for compositing:";
+localizedStrings["Record first %s frame"] = "Record first %s frame";
 localizedStrings["Record first %s frames"] = "Record first %s frames";
 localizedStrings["Recording"] = "Recording";
 localizedStrings["Recording %d"] = "Recording %d";

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CanvasOverviewContentView.js (238828 => 238829)


--- trunk/Source/WebInspectorUI/UserInterface/Views/CanvasOverviewContentView.js	2018-12-04 00:08:42 UTC (rev 238828)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CanvasOverviewContentView.js	2018-12-04 00:15:22 UTC (rev 238829)
@@ -51,15 +51,14 @@
             this._recordingAutoCaptureFrameCountInputElement.value = WI.settings.canvasRecordingAutoCaptureFrameCount.value;
             this._recordingAutoCaptureFrameCountInputElement.addEventListener("input", this._handleRecordingAutoCaptureInput.bind(this));
 
-            let label = document.createDocumentFragment();
-            String.format(WI.UIString("Record first %s frames"), [this._recordingAutoCaptureFrameCountInputElement], String.standardFormatters, label, (a, b) => {
-                a.append(b);
-                return a;
-            });
-
+            const label = null;
             this._recordingAutoCaptureNavigationItem = new WI.CheckboxNavigationItem("canvas-recording-auto-capture", label, !!WI.settings.canvasRecordingAutoCaptureEnabled.value);
             this._recordingAutoCaptureNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
             this._recordingAutoCaptureNavigationItem.addEventListener(WI.CheckboxNavigationItem.Event.CheckedDidChange, this._handleRecordingAutoCaptureCheckedDidChange, this);
+
+            let frameCount = this._updateRecordingAutoCaptureInputElementSize();
+            this._setRecordingAutoCaptureFrameCount(frameCount);
+            this._updateRecordingAutoCaptureCheckboxLabel(frameCount);
         }
 
         this._importButtonNavigationItem = new WI.ButtonNavigationItem("import-recording", WI.UIString("Import"), "Images/Import.svg", 15, 15);
@@ -98,16 +97,6 @@
 
     // Protected
 
-    initialLayout()
-    {
-        super.initialLayout();
-
-        if (WI.CanvasManager.supportsRecordingAutoCapture()) {
-            this._updateRecordingAutoCaptureInputElementSize();
-            this._setRecordingAutoCaptureFrameCount();
-        }
-    }
-
     contentViewAdded(contentView)
     {
         contentView.element.addEventListener("mouseenter", this._contentViewMouseEnter);
@@ -198,9 +187,11 @@
         WI.domManager.hideDOMNodeHighlight();
     }
 
-    _setRecordingAutoCaptureFrameCount()
+    _setRecordingAutoCaptureFrameCount(frameCount)
     {
-        let frameCount = parseInt(this._recordingAutoCaptureFrameCountInputElement.value);
+        if (isNaN(frameCount))
+            frameCount = parseInt(this._recordingAutoCaptureFrameCountInputElement.value);
+
         console.assert(!isNaN(frameCount) && frameCount >= 0);
 
         if (this._recordingAutoCaptureNavigationItem.checked)
@@ -211,6 +202,30 @@
         WI.canvasManager.setRecordingAutoCaptureFrameCount(enabled, frameCount);
     }
 
+    _updateRecordingAutoCaptureCheckboxLabel(frameCount)
+    {
+        if (isNaN(frameCount))
+            frameCount = parseInt(this._recordingAutoCaptureFrameCountInputElement.value);
+
+        let label = frameCount === 1 ? WI.UIString("Record first %s frame") : WI.UIString("Record first %s frames");
+
+        let selectionStart = this._recordingAutoCaptureFrameCountInputElement.selectionStart;
+        let selectionEnd = this._recordingAutoCaptureFrameCountInputElement.selectionEnd;
+        let direction = this._recordingAutoCaptureFrameCountInputElement.direction;
+
+        let fragment = document.createDocumentFragment();
+        String.format(label, [this._recordingAutoCaptureFrameCountInputElement], String.standardFormatters, fragment, (a, b) => {
+            a.append(b);
+            return a;
+        });
+
+        this._recordingAutoCaptureNavigationItem.label = fragment;
+
+        this._recordingAutoCaptureFrameCountInputElement.selectionStart = selectionStart;
+        this._recordingAutoCaptureFrameCountInputElement.selectionEnd = selectionEnd;
+        this._recordingAutoCaptureFrameCountInputElement.direction = direction;
+    }
+
     _updateRecordingAutoCaptureInputElementSize()
     {
         let frameCount = parseInt(this._recordingAutoCaptureFrameCountInputElement.value);
@@ -240,7 +255,7 @@
         let frameCount = this._updateRecordingAutoCaptureInputElementSize();
         this._recordingAutoCaptureNavigationItem.checked = !!frameCount;
 
-        this._setRecordingAutoCaptureFrameCount();
+        this._setRecordingAutoCaptureFrameCount(frameCount);
     }
 
     _handleRecordingAutoCaptureCheckedDidChange(event)
@@ -256,6 +271,8 @@
     _handleCanvasRecordingAutoCaptureFrameCountChanged(event)
     {
         this._recordingAutoCaptureFrameCountInputElement.value = WI.settings.canvasRecordingAutoCaptureFrameCount.value;
+
+        this._updateRecordingAutoCaptureCheckboxLabel(WI.settings.canvasRecordingAutoCaptureFrameCount.value);
     }
 
     _handleImportButtonNavigationItemClicked(event)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CheckboxNavigationItem.js (238828 => 238829)


--- trunk/Source/WebInspectorUI/UserInterface/Views/CheckboxNavigationItem.js	2018-12-04 00:08:42 UTC (rev 238828)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CheckboxNavigationItem.js	2018-12-04 00:15:22 UTC (rev 238829)
@@ -37,9 +37,10 @@
 
         this._checkboxLabel = this.element.appendChild(document.createElement("label"));
         this._checkboxLabel.className = "toggle";
-        this._checkboxLabel.append(label);
         this._checkboxLabel.setAttribute("for", this._checkboxElement.id);
         this._checkboxLabel.addEventListener("click", this._handleLabelClick.bind(this));
+
+        this.label = label;
     }
 
     // Public
@@ -54,6 +55,14 @@
         this._checkboxElement.checked = flag;
     }
 
+    set label(label)
+    {
+        this._checkboxLabel.removeChildren();
+
+        if (label);
+            this._checkboxLabel.append(label);
+    }
+
     // Protected
 
     get additionalClassNames()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to