Web Inspector: Avoid "100.00ms" vs "100.0ms" jitter in TimelineRuler labels
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Oct 2017 07:59:43 +0000 (07:59 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Oct 2017 07:59:43 +0000 (07:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=178143

Reviewed by Brian Burg.

* UserInterface/Base/Utilities.js:
Allow a small slop factor that wouldn't have changed the display value's
significant figures anyways. This addresses cases where 100.0000000000001
were being treated slightly differently from 100.0.

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/Utilities.js

index f260e19..80e44ac 100644 (file)
@@ -1,5 +1,17 @@
 2017-10-11  Joseph Pecoraro  <pecoraro@apple.com>
 
+        Web Inspector: Avoid "100.00ms" vs "100.0ms" jitter in TimelineRuler labels
+        https://bugs.webkit.org/show_bug.cgi?id=178143
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Base/Utilities.js:
+        Allow a small slop factor that wouldn't have changed the display value's
+        significant figures anyways. This addresses cases where 100.0000000000001
+        were being treated slightly differently from 100.0.
+
+2017-10-11  Joseph Pecoraro  <pecoraro@apple.com>
+
         Web Inspector: Network Tab - Show initially loaded resources even if network info not logged
         https://bugs.webkit.org/show_bug.cgi?id=178098
         <rdar://problem/34073529>
index 927af1b..112a7a8 100644 (file)
@@ -1089,19 +1089,21 @@ Object.defineProperty(Number, "secondsToString",
         if (!ms)
             return WI.UIString("%.0fms").format(0);
 
-        if (Math.abs(ms) < 10) {
+        const epsilon = 0.0001;
+
+        if (Math.abs(ms) < (10 + epsilon)) {
             if (higherResolution)
                 return WI.UIString("%.3fms").format(ms);
             return WI.UIString("%.2fms").format(ms);
         }
 
-        if (Math.abs(ms) < 100) {
+        if (Math.abs(ms) < (100 + epsilon)) {
             if (higherResolution)
                 return WI.UIString("%.2fms").format(ms);
             return WI.UIString("%.1fms").format(ms);
         }
 
-        if (Math.abs(ms) < 1000) {
+        if (Math.abs(ms) < (1000 + epsilon)) {
             if (higherResolution)
                 return WI.UIString("%.1fms").format(ms);
             return WI.UIString("%.0fms").format(ms);