Changeset 214405 in webkit


Ignore:
Timestamp:
Mar 25, 2017, 4:08:37 PM (8 years ago)
Author:
BJ Burg
Message:

Web Inspector: RTL: number scripts are used inconsistently throughout the UI
https://bugs.webkit.org/show_bug.cgi?id=168290

Reviewed by Joseph Pecoraro.

Original patch by Devin Rousso.

  • Localizations/en.lproj/localizedStrings.js: Add new string for FPS bars.
  • UserInterface/Base/Utilities.js:

(value.d):
(value):
Localize %d formatted values by default. If that's not desired, then you need to stringify
the number outside of String.format and Number.abbreviate and pass it as %s instead.
Also add a global variable for zwsp (zero-width space) and use it in DataGridNode.

  • UserInterface/Views/ConsoleMessageView.js:

(WebInspector.ConsoleMessageView.prototype._renderRepeatCount): Abbreviate the repeat count,
and cause it to be localized.

  • UserInterface/Views/DataGridNode.js:

(WebInspector.DataGridNode.prototype.createCellContent):
If we don't know anything about a cell's data other than that it's a number,
run the number through toLocaleString().

  • UserInterface/Views/HeapSnapshotInstanceDataGridNode.js:

Don't localize @%d tags for snapshot objects since this is not done elsewhere in the UI.

  • UserInterface/Views/IndexedDatabaseDetailsSidebarPanel.js: Localize integer version number.

(WebInspector.IndexedDatabaseDetailsSidebarPanel.prototype.layout):

  • UserInterface/Views/MemoryTimelineView.js:

(WebInspector.MemoryTimelineView.prototype._updateMaxComparisonLegend): Use Number.percentageString().

  • UserInterface/Views/RenderingFrameTimelineOverviewGraph.js:

(WebInspector.RenderingFrameTimelineOverviewGraph.prototype._updateDividers.createDividerAtPosition):
(WebInspector.RenderingFrameTimelineOverviewGraph.prototype._updateDividers):
Localize "%d fps" markers.

  • UserInterface/Views/TimelineOverview.js:

(WebInspector.TimelineOverview.prototype._viewModeDidChange):
Localize frame label numbers.

Location:
trunk/Source/WebInspectorUI
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r214387 r214405  
     12017-03-24  Brian Burg  <bburg@apple.com>
     2
     3        Web Inspector: RTL: number scripts are used inconsistently throughout the UI
     4        https://bugs.webkit.org/show_bug.cgi?id=168290
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        Original patch by Devin Rousso.
     9
     10        * Localizations/en.lproj/localizedStrings.js: Add new string for FPS bars.
     11        * UserInterface/Base/Utilities.js:
     12        (value.d):
     13        (value):
     14        Localize %d formatted values by default. If that's not desired, then you need to stringify
     15        the number outside of String.format and Number.abbreviate and pass it as %s instead.
     16        Also add a global variable for zwsp (zero-width space) and use it in DataGridNode.
     17
     18        * UserInterface/Views/ConsoleMessageView.js:
     19        (WebInspector.ConsoleMessageView.prototype._renderRepeatCount): Abbreviate the repeat count,
     20        and cause it to be localized.
     21
     22        * UserInterface/Views/DataGridNode.js:
     23        (WebInspector.DataGridNode.prototype.createCellContent):
     24        If we don't know anything about a cell's data other than that it's a number,
     25        run the number through toLocaleString().
     26
     27        * UserInterface/Views/HeapSnapshotInstanceDataGridNode.js:
     28        Don't localize @%d tags for snapshot objects since this is not done elsewhere in the UI.
     29
     30        * UserInterface/Views/IndexedDatabaseDetailsSidebarPanel.js: Localize integer version number.
     31        (WebInspector.IndexedDatabaseDetailsSidebarPanel.prototype.layout):
     32
     33        * UserInterface/Views/MemoryTimelineView.js:
     34        (WebInspector.MemoryTimelineView.prototype._updateMaxComparisonLegend): Use Number.percentageString().
     35
     36        * UserInterface/Views/RenderingFrameTimelineOverviewGraph.js:
     37        (WebInspector.RenderingFrameTimelineOverviewGraph.prototype._updateDividers.createDividerAtPosition):
     38        (WebInspector.RenderingFrameTimelineOverviewGraph.prototype._updateDividers):
     39        Localize "%d fps" markers.
     40
     41        * UserInterface/Views/TimelineOverview.js:
     42        (WebInspector.TimelineOverview.prototype._viewModeDidChange):
     43        Localize frame label numbers.
     44
    1452017-03-24  Nikita Vasilyev  <nvasilyev@apple.com>
    246
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r214371 r214405  
    2828localizedStrings["%d \xd7 %d pixels"] = "%d \xd7 %d pixels";
    2929localizedStrings["%d \xd7 %d pixels (Natural: %d \xd7 %d pixels)"] = "%d \xd7 %d pixels (Natural: %d \xd7 %d pixels)";
     30localizedStrings["%d fps"] = "%d fps";
    3031localizedStrings["%d matches"] = "%d matches";
    3132localizedStrings["%dpx"] = "%dpx";
  • trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js

    r213890 r214405  
    2828var figureDash = "\u2012";
    2929var ellipsis = "\u2026";
     30var zeroWidthSpace = "\u200b";
    3031
    3132Object.defineProperty(Object, "shallowCopy",
     
    790791        d: function(substitution)
    791792        {
    792             return parseInt(substitution);
     793            return parseInt(substitution).toLocaleString();
    793794        },
    794795
     
    10921093    {
    10931094        if (num < 1000)
    1094             return num;
     1095            return num.toLocaleString();
    10951096
    10961097        if (num < 1000000)
  • trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js

    r214093 r214405  
    147147        }
    148148
    149         this._repeatCountElement.textContent = count;
     149        this._repeatCountElement.textContent = Number.abbreviate(count);
    150150    }
    151151
  • trunk/Source/WebInspectorUI/UserInterface/Views/DataGridNode.js

    r214354 r214405  
    11/*
    2  * Copyright (C) 2008, 2013-2016 Apple Inc. All Rights Reserved.
     2 * Copyright (C) 2008, 2013-2017 Apple Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    384384    createCellContent(columnIdentifier)
    385385    {
    386         return this.data[columnIdentifier] || "\u200b"; // Zero width space to keep the cell from collapsing.
     386        let data = this.data[columnIdentifier];
     387        if (!data)
     388            return zeroWidthSpace; // Zero width space to keep the cell from collapsing.
     389
     390        return (typeof data === "number") ? data.maxDecimals(2).toLocaleString() : data;
    387391    }
    388392
  • trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstanceDataGridNode.js

    r209709 r214405  
    5555        let heapObjectIdentifier = node.id;
    5656        let shouldRevealConsole = true;
    57         let text = WebInspector.UIString("Heap Snapshot Object (@%d)").format(heapObjectIdentifier);
     57        let text = WebInspector.UIString("Heap Snapshot Object (%s)").format("@" + heapObjectIdentifier);
    5858
    5959        node.shortestGCRootPath((gcRootPath) => {
  • trunk/Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseDetailsSidebarPanel.js

    r205043 r214405  
    105105            this._databaseSecurityOriginRow.value = this._database.securityOrigin;
    106106            this._databaseNameRow.value = this._database.name;
    107             this._databaseVersionRow.value = this._database.version;
     107            this._databaseVersionRow.value = this._database.version.toLocaleString();
    108108        }
    109109
  • trunk/Source/WebInspectorUI/UserInterface/Views/MemoryTimelineView.js

    r205425 r214405  
    338338
    339339        // The chart will only show a perfect circle if the current and max are really the same value.
    340         // So do a little massaging to ensure 99.95 doesn't get rounded up to 100.
    341         let percent = ((currentSize / this._maxSize) * 100);
    342         totalElement.textContent = (percent === 100 ? percent : (percent - 0.05).toFixed(1)) + "%";
     340        // So do a little massaging to ensure 0.9995 doesn't get rounded up to 1.
     341        let percent = currentSize / this._maxSize;
     342        totalElement.textContent = Number.percentageString(percent === 1 ? percent : (percent - 0.0005));
    343343    }
    344344
  • trunk/Source/WebInspectorUI/UserInterface/Views/RenderingFrameTimelineOverviewGraph.js

    r214076 r214405  
    195195                var label = document.createElement("div");
    196196                label.classList.add("label");
    197                 label.innerText = framesPerSecond + " fps";
     197                label.innerText = WebInspector.UIString("%d fps").format(framesPerSecond);
    198198                divider.appendChild(label);
    199199
  • trunk/Source/WebInspectorUI/UserInterface/Views/TimelineOverview.js

    r213997 r214405  
    752752            this._timelineRuler.minimumSelectionDuration = 1;
    753753            this._timelineRuler.snapInterval = 1;
    754             this._timelineRuler.formatLabelCallback = (value) => value.toFixed(0);
     754            this._timelineRuler.formatLabelCallback = (value) => value.maxDecimals(0).toLocaleString();
    755755        } else {
    756756            this._timelineRuler.minimumSelectionDuration = 0.01;
Note: See TracChangeset for help on using the changeset viewer.