Bug 1315598 - Part 1: Edge of animation graph is diagonal sometimes. r=pbro
authorDaisuke Akatsuka <daisuke@mozilla-japan.org>
Mon, 28 Nov 2016 11:26:16 +0900
changeset 324898 eef68eeb10c627989f5a16624a9abd147db33271
parent 324897 079ee7b41c3a5c33e1608c01ebaf17751f41d5f9
child 324899 dc202d732d647ef6cf4cf204aa60aa0be641d077
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +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;
   }