Title: [204642] trunk/Source/WebInspectorUI
Revision
204642
Author
[email protected]
Date
2016-08-19 11:41:08 -0700 (Fri, 19 Aug 2016)

Log Message

Web Inspector: Console log counter on the dashboard should be better at displaying large numbers
https://bugs.webkit.org/show_bug.cgi?id=160054

Patch by Devin Rousso <[email protected]> on 2016-08-19
Reviewed by Matt Baker.

* Localizations/en.lproj/localizedStrings.js:

* UserInterface/Base/Utilities.js:
(Number.abbreviate):
Add logic for formatting a number as "#K", "#M", and "#B" when it is very large.

* UserInterface/Views/DefaultDashboardView.js:
(WebInspector.DefaultDashboardView.prototype._updateDisplay):
(WebInspector.DefaultDashboardView.prototype._formatPossibleLargeNumber): Deleted.
(WebInspector.DefaultDashboardView.prototype._setConsoleItemValue):

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (204641 => 204642)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-08-19 18:30:10 UTC (rev 204641)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-08-19 18:41:08 UTC (rev 204642)
@@ -1,3 +1,21 @@
+2016-08-19  Devin Rousso  <[email protected]>
+
+        Web Inspector: Console log counter on the dashboard should be better at displaying large numbers
+        https://bugs.webkit.org/show_bug.cgi?id=160054
+
+        Reviewed by Matt Baker.
+
+        * Localizations/en.lproj/localizedStrings.js:
+
+        * UserInterface/Base/Utilities.js:
+        (Number.abbreviate):
+        Add logic for formatting a number as "#K", "#M", and "#B" when it is very large.
+
+        * UserInterface/Views/DefaultDashboardView.js:
+        (WebInspector.DefaultDashboardView.prototype._updateDisplay):
+        (WebInspector.DefaultDashboardView.prototype._formatPossibleLargeNumber): Deleted.
+        (WebInspector.DefaultDashboardView.prototype._setConsoleItemValue):
+
 2016-08-17  Matt Baker  <[email protected]>
 
         Web Inspector: Network Tab should not layout if not visible

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


--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2016-08-19 18:30:10 UTC (rev 204641)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2016-08-19 18:41:08 UTC (rev 204642)
@@ -7,6 +7,9 @@
 localizedStrings["%.1f KB"] = "%.1f KB";
 localizedStrings["%.1f MB"] = "%.1f MB";
 localizedStrings["%.1f days"] = "%.1f days";
+localizedStrings["%.1fB"] = "%.1fB";
+localizedStrings["%.1fK"] = "%.1fK";
+localizedStrings["%.1fM"] = "%.1fM";
 localizedStrings["%.1fhrs"] = "%.1fhrs";
 localizedStrings["%.1fmin"] = "%.1fmin";
 localizedStrings["%.1fms"] = "%.1fms";
@@ -44,7 +47,6 @@
 localizedStrings["(uninitialized)"] = "(uninitialized)";
 localizedStrings[", "] = ", ";
 localizedStrings["1 match"] = "1 match";
-localizedStrings["999+"] = "999+";
 localizedStrings["Accessibility"] = "Accessibility";
 localizedStrings["Action"] = "Action";
 localizedStrings["Activity Viewer"] = "Activity Viewer";

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js (204641 => 204642)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js	2016-08-19 18:30:10 UTC (rev 204641)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js	2016-08-19 18:41:08 UTC (rev 204642)
@@ -1036,6 +1036,23 @@
     }
 });
 
+Object.defineProperty(Number, "abbreviate",
+{
+    value: function(num)
+    {
+        if (num < 1000)
+            return num;
+
+        if (num < 1000000)
+            return WebInspector.UIString("%.1fK").format(Math.round(num / 100) / 10);
+
+        if (num < 1000000000)
+            return WebInspector.UIString("%.1fM").format(Math.round(num / 100000) / 10);
+
+        return WebInspector.UIString("%.1fB").format(Math.round(num / 100000000) / 10);
+    }
+});
+
 Object.defineProperty(Uint32Array, "isLittleEndian",
 {
     value: function()

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DefaultDashboardView.js (204641 => 204642)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DefaultDashboardView.js	2016-08-19 18:30:10 UTC (rev 204641)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DefaultDashboardView.js	2016-08-19 18:41:08 UTC (rev 204642)
@@ -87,7 +87,7 @@
         this._setItemEnabled(timeItem, dashboard.time > 0);
 
         var countItem = this._items.resourcesCount;
-        countItem.text = this._formatPossibleLargeNumber(dashboard.resourcesCount);
+        countItem.text = Number.abbreviate(dashboard.resourcesCount);
         this._setItemEnabled(countItem, dashboard.resourcesCount > 0);
 
         var sizeItem = this._items.resourcesSize;
@@ -95,11 +95,6 @@
         this._setItemEnabled(sizeItem, dashboard.resourcesSize > 0);
     }
 
-    _formatPossibleLargeNumber(number)
-    {
-        return number > 999 ? WebInspector.UIString("999+") : number;
-    }
-
     _appendElementForNamedItem(name)
     {
         var item = this._items[name];
@@ -164,7 +159,7 @@
         this[iVarName] = newValue;
 
         var item = this._items[itemName];
-        item.text = this._formatPossibleLargeNumber(newValue);
+        item.text = Number.abbreviate(newValue);
         this._setItemEnabled(item, newValue > 0);
 
         if (newValue <= previousValue)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to