Changeset 238829 in webkit


Ignore:
Timestamp:
Dec 3, 2018 4:15:22 PM (5 years ago)
Author:
Devin Rousso
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:
Location:
trunk/Source/WebInspectorUI
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r238825 r238829  
     12018-12-03  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Canvas: add singular localized string for "Record first %s frames"
     4        https://bugs.webkit.org/show_bug.cgi?id=192189
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * UserInterface/Views/CanvasOverviewContentView.js:
     9        (WI.CanvasOverviewContentView):
     10        (WI.CanvasOverviewContentView.prototype._setRecordingAutoCaptureFrameCount):
     11        (WI.CanvasOverviewContentView.prototype._updateRecordingAutoCaptureCheckboxLabel): Added.
     12        (WI.CanvasOverviewContentView.prototype._handleRecordingAutoCaptureInput):
     13        (WI.CanvasOverviewContentView.prototype._handleCanvasRecordingAutoCaptureFrameCountChanged):
     14        (WI.CanvasOverviewContentView.prototype.initialLayout): Deleted.
     15        Drive-by: update the auto-capture navigation item when the view is first created so there is
     16        no flashing of in the navigation bar (before `initialLayout` is called).
     17
     18        * UserInterface/Views/CheckboxNavigationItem.js:
     19        (WI.CheckboxNavigationItem):
     20        (WI.CheckboxNavigationItem.prototype.set label): Added.
     21
     22        * Localizations/en.lproj/localizedStrings.js:
     23
    1242018-12-03  Matt Baker  <mattbaker@apple.com>
    225
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r238743 r238829  
    702702localizedStrings["Reasons for compositing"] = "Reasons for compositing";
    703703localizedStrings["Reasons for compositing:"] = "Reasons for compositing:";
     704localizedStrings["Record first %s frame"] = "Record first %s frame";
    704705localizedStrings["Record first %s frames"] = "Record first %s frames";
    705706localizedStrings["Recording"] = "Recording";
  • trunk/Source/WebInspectorUI/UserInterface/Views/CanvasOverviewContentView.js

    r238198 r238829  
    5252            this._recordingAutoCaptureFrameCountInputElement.addEventListener("input", this._handleRecordingAutoCaptureInput.bind(this));
    5353
    54             let label = document.createDocumentFragment();
    55             String.format(WI.UIString("Record first %s frames"), [this._recordingAutoCaptureFrameCountInputElement], String.standardFormatters, label, (a, b) => {
    56                 a.append(b);
    57                 return a;
    58             });
    59 
     54            const label = null;
    6055            this._recordingAutoCaptureNavigationItem = new WI.CheckboxNavigationItem("canvas-recording-auto-capture", label, !!WI.settings.canvasRecordingAutoCaptureEnabled.value);
    6156            this._recordingAutoCaptureNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
    6257            this._recordingAutoCaptureNavigationItem.addEventListener(WI.CheckboxNavigationItem.Event.CheckedDidChange, this._handleRecordingAutoCaptureCheckedDidChange, this);
     58
     59            let frameCount = this._updateRecordingAutoCaptureInputElementSize();
     60            this._setRecordingAutoCaptureFrameCount(frameCount);
     61            this._updateRecordingAutoCaptureCheckboxLabel(frameCount);
    6362        }
    6463
     
    9897
    9998    // Protected
    100 
    101     initialLayout()
    102     {
    103         super.initialLayout();
    104 
    105         if (WI.CanvasManager.supportsRecordingAutoCapture()) {
    106             this._updateRecordingAutoCaptureInputElementSize();
    107             this._setRecordingAutoCaptureFrameCount();
    108         }
    109     }
    11099
    111100    contentViewAdded(contentView)
     
    199188    }
    200189
    201     _setRecordingAutoCaptureFrameCount()
    202     {
    203         let frameCount = parseInt(this._recordingAutoCaptureFrameCountInputElement.value);
     190    _setRecordingAutoCaptureFrameCount(frameCount)
     191    {
     192        if (isNaN(frameCount))
     193            frameCount = parseInt(this._recordingAutoCaptureFrameCountInputElement.value);
     194
    204195        console.assert(!isNaN(frameCount) && frameCount >= 0);
    205196
     
    210201
    211202        WI.canvasManager.setRecordingAutoCaptureFrameCount(enabled, frameCount);
     203    }
     204
     205    _updateRecordingAutoCaptureCheckboxLabel(frameCount)
     206    {
     207        if (isNaN(frameCount))
     208            frameCount = parseInt(this._recordingAutoCaptureFrameCountInputElement.value);
     209
     210        let label = frameCount === 1 ? WI.UIString("Record first %s frame") : WI.UIString("Record first %s frames");
     211
     212        let selectionStart = this._recordingAutoCaptureFrameCountInputElement.selectionStart;
     213        let selectionEnd = this._recordingAutoCaptureFrameCountInputElement.selectionEnd;
     214        let direction = this._recordingAutoCaptureFrameCountInputElement.direction;
     215
     216        let fragment = document.createDocumentFragment();
     217        String.format(label, [this._recordingAutoCaptureFrameCountInputElement], String.standardFormatters, fragment, (a, b) => {
     218            a.append(b);
     219            return a;
     220        });
     221
     222        this._recordingAutoCaptureNavigationItem.label = fragment;
     223
     224        this._recordingAutoCaptureFrameCountInputElement.selectionStart = selectionStart;
     225        this._recordingAutoCaptureFrameCountInputElement.selectionEnd = selectionEnd;
     226        this._recordingAutoCaptureFrameCountInputElement.direction = direction;
    212227    }
    213228
     
    241256        this._recordingAutoCaptureNavigationItem.checked = !!frameCount;
    242257
     258        this._setRecordingAutoCaptureFrameCount(frameCount);
     259    }
     260
     261    _handleRecordingAutoCaptureCheckedDidChange(event)
     262    {
    243263        this._setRecordingAutoCaptureFrameCount();
    244264    }
    245265
    246     _handleRecordingAutoCaptureCheckedDidChange(event)
    247     {
    248         this._setRecordingAutoCaptureFrameCount();
    249     }
    250 
    251266    _handleCanvasRecordingAutoCaptureEnabledChanged(event)
    252267    {
     
    257272    {
    258273        this._recordingAutoCaptureFrameCountInputElement.value = WI.settings.canvasRecordingAutoCaptureFrameCount.value;
     274
     275        this._updateRecordingAutoCaptureCheckboxLabel(WI.settings.canvasRecordingAutoCaptureFrameCount.value);
    259276    }
    260277
  • trunk/Source/WebInspectorUI/UserInterface/Views/CheckboxNavigationItem.js

    r237670 r238829  
    3838        this._checkboxLabel = this.element.appendChild(document.createElement("label"));
    3939        this._checkboxLabel.className = "toggle";
    40         this._checkboxLabel.append(label);
    4140        this._checkboxLabel.setAttribute("for", this._checkboxElement.id);
    4241        this._checkboxLabel.addEventListener("click", this._handleLabelClick.bind(this));
     42
     43        this.label = label;
    4344    }
    4445
     
    5354    {
    5455        this._checkboxElement.checked = flag;
     56    }
     57
     58    set label(label)
     59    {
     60        this._checkboxLabel.removeChildren();
     61
     62        if (label);
     63            this._checkboxLabel.append(label);
    5564    }
    5665
Note: See TracChangeset for help on using the changeset viewer.