Bug 1309468 - Part 4: Make ProgressGraphHelper's usage to fit to SummaryGraphHelper. r=pbro
MozReview-Commit-ID: 5g9HFPLaYSS
--- a/devtools/client/animationinspector/components/keyframes.js
+++ b/devtools/client/animationinspector/components/keyframes.js
@@ -4,17 +4,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const EventEmitter = require("devtools/shared/event-emitter");
const {createNode, createSVGNode} =
require("devtools/client/animationinspector/utils");
-const {ProgressGraphHelper, appendPathElement, getPreferredKeyframesProgressThreshold} =
+const {ProgressGraphHelper, getPreferredKeyframesProgressThreshold} =
require("devtools/client/animationinspector/graph-helper.js");
// Counter for linearGradient ID.
let LINEAR_GRADIENT_ID_COUNTER = 0;
/**
* UI component responsible for displaying a list of keyframes.
* Also, shows a graphical graph for the animation progress of one iteration.
@@ -108,25 +108,25 @@ Keyframes.prototype = {
*/
function renderPropertyGraph(parentEl, duration, minSegmentDuration,
minProgressThreshold, graphHelper) {
const segments = graphHelper.createPathSegments(0, duration, minSegmentDuration,
minProgressThreshold);
const graphType = graphHelper.getGraphType();
if (graphType !== "color") {
- appendPathElement(parentEl, segments, graphType);
+ graphHelper.appendPathElement(parentEl, segments, graphType);
return;
}
// Append the color to the path.
segments.forEach(segment => {
segment.y = 1;
});
- const path = appendPathElement(parentEl, segments, graphType);
+ const path = graphHelper.appendPathElement(parentEl, segments, graphType);
const defEl = createSVGNode({
parent: parentEl,
nodeType: "def"
});
const id = `color-property-${ LINEAR_GRADIENT_ID_COUNTER++ }`;
const linearGradientEl = createSVGNode({
parent: defEl,
nodeType: "linearGradient",
--- a/devtools/client/animationinspector/graph-helper.js
+++ b/devtools/client/animationinspector/graph-helper.js
@@ -236,16 +236,27 @@ ProgressGraphHelper.prototype = {
*/
createPathSegments: function (startTime, endTime,
minSegmentDuration, minProgressThreshold) {
return !this.valueHelperFunction
? createKeyframesPathSegments(endTime - startTime, this.devtoolsKeyframes)
: createPathSegments(startTime, endTime,
minSegmentDuration, minProgressThreshold, this);
},
+
+ /**
+ * Append path element.
+ * @param {Element} parentEl - Parent element of this appended path element.
+ * @param {Array} pathSegments - Path segments. Please see createPathSegments.
+ * @param {String} cls - Class name.
+ * @return {Element} path element.
+ */
+ appendPathElement: function (parentEl, pathSegments, cls) {
+ return appendPathElement(parentEl, pathSegments, cls);
+ },
};
exports.ProgressGraphHelper = ProgressGraphHelper;
/**
* This class is used for creating the summary graph in animation-timeline.
* The shape of the graph can be changed by using the following methods:
* setKeyframes:
@@ -475,17 +486,16 @@ function createPathSegments(startTime, e
}
pathSegments.push(currentSegment);
previousSegment = currentSegment;
}
return pathSegments;
}
-exports.createPathSegments = createPathSegments;
/**
* Append path element.
* @param {Element} parentEl - Parent element of this appended path element.
* @param {Array} pathSegments - Path segments. Please see createPathSegments.
* @param {String} cls - Class name.
* @param {bool} isClosePathNeeded - Set true if need to close the path. (default true)
* @return {Element} path element.
@@ -521,17 +531,16 @@ function appendPathElement(parentEl, pat
attributes: {
"d": path,
"class": cls,
"vector-effect": "non-scaling-stroke",
"transform": "scale(1, -1)"
}
});
}
-exports.appendPathElement = appendPathElement;
/**
* Create the path segments from given keyframes.
* @param {Number} duration - Duration of animation.
* @param {Object} Keyframes of devtool's format.
* @return {Array} path segments -
* [{x: {Number} time, y: {Number} distance,
* easing: {String} keyframe's easing,