Bug 1315598 - Part 1: Edge of animation graph is diagonal sometimes. r=pbro draft
authorDaisuke Akatsuka <daisuke@mozilla-japan.org>
Mon, 28 Nov 2016 11:26:16 +0900
changeset 444482 c846ac767042b82e075f21b04e33ea42141c9ab8
parent 444478 05328d3102efd4d5fc0696489734d7771d24459f
child 444483 117b2763d2633db85dd87a7787809a310c37f66b
push id37242
push userbmo:daisuke@mozilla-japan.org
push dateMon, 28 Nov 2016 02:27:24 +0000
reviewerspbro
bugs1315598
milestone53.0a1
Bug 1315598 - Part 1: Edge of animation graph is diagonal sometimes. r=pbro MozReview-Commit-ID: 6HmsFklqzyK
devtools/client/animationinspector/components/animation-time-block.js
--- a/devtools/client/animationinspector/components/animation-time-block.js
+++ b/devtools/client/animationinspector/components/animation-time-block.js
@@ -19,16 +19,19 @@ const L10N =
 // smoothly progress if this resolution is not high enough.
 // So, if the difference of animation progress between 2 divisions is more than
 // MIN_PROGRESS_THRESHOLD, then createPathSegments re-divides
 // by DURATION_RESOLUTION.
 // DURATION_RESOLUTION shoud be integer and more than 2.
 const DURATION_RESOLUTION = 4;
 // MIN_PROGRESS_THRESHOLD shoud be between more than 0 to 1.
 const MIN_PROGRESS_THRESHOLD = 0.1;
+// BOUND_EXCLUDING_TIME should be less than 1ms and is used to exclude start
+// and end bounds when dividing  duration in createPathSegments.
+const BOUND_EXCLUDING_TIME = 0.001;
 // Show max 10 iterations for infinite animations
 // to give users a clue that the animation does repeat.
 const MAX_INFINITE_ANIMATIONS_ITERATIONS = 10;
 // SVG namespace
 const SVG_NS = "http://www.w3.org/2000/svg";
 
 /**
  * UI component responsible for displaying a single animation timeline, which
@@ -671,19 +674,20 @@ function createPathSegments(startTime, e
       segmentHelper.getSegment(startTime + index * interval);
 
     // If the distance between the Y coordinate (the animation's progress) of
     // the previous segment and the Y coordinate of the current segment is too
     // large, then recurse with a smaller duration to get more details
     // in the graph.
     if (Math.abs(currentSegment.y - previousSegment.y) > minProgressThreshold) {
       // Divide the current interval (excluding start and end bounds
-      // by adding/subtracting 1ms).
+      // by adding/subtracting BOUND_EXCLUDING_TIME).
       pathSegments = pathSegments.concat(
-        createPathSegments(previousSegment.x + 1, currentSegment.x - 1,
+        createPathSegments(previousSegment.x + BOUND_EXCLUDING_TIME,
+                           currentSegment.x - BOUND_EXCLUDING_TIME,
                            minSegmentDuration, minProgressThreshold,
                            segmentHelper));
     }
 
     pathSegments.push(currentSegment);
     previousSegment = currentSegment;
   }