Chromium Code Reviews| Index: Source/devtools/front_end/elements/AnimationTimeline.js |
| diff --git a/Source/devtools/front_end/elements/AnimationTimeline.js b/Source/devtools/front_end/elements/AnimationTimeline.js |
| index 173fc306ab9e04f46ce4b0e56b812bf9ff2f4c7f..efeda62f41b2a25a11aa71da744393397e564f74 100644 |
| --- a/Source/devtools/front_end/elements/AnimationTimeline.js |
| +++ b/Source/devtools/front_end/elements/AnimationTimeline.js |
| @@ -29,6 +29,9 @@ WebInspector.AnimationTimeline = function() |
| this._symbol = Symbol("animationTimeline"); |
| /** @type {!Map.<string, !WebInspector.AnimationModel.AnimationPlayer>} */ |
| this._animationsMap = new Map(); |
| + this._editorPopoverHelper = new WebInspector.EditorPopoverHelper(); |
| + this._bezierEditor = new WebInspector.BezierEditor(); |
| + |
| WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._mainFrameNavigated, this); |
| WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebInspector.DOMModel.Events.NodeRemoved, this._nodeRemoved, this); |
| @@ -597,7 +600,7 @@ WebInspector.AnimationTimeline.NodeUI = function(animationNode) { |
| { |
| this._node = node; |
| this._description.appendChild(WebInspector.DOMPresentationUtils.linkifyNodeReference(node)); |
| - this.element.addEventListener("click", WebInspector.Revealer.reveal.bind(WebInspector.Revealer, node, undefined), false); |
| + this.element.addEventListener("mousedown", WebInspector.Revealer.reveal.bind(WebInspector.Revealer, node, undefined), false); |
| } |
| this._rows = []; |
| @@ -711,11 +714,17 @@ WebInspector.AnimationUI = function(animation, timeline, parentElement) { |
| this._nameElement = parentElement.createChild("div", "animation-name"); |
| this._nameElement.textContent = this._animation.name(); |
| + this._bezierIconElement = WebInspector.BezierPopoverIcon.createIcon(parentElement); |
| + this._bezierIconElement.style.backgroundColor = this._color(); |
| + this._bezierIconElement.addEventListener("mousedown", this._toggleBezierEditor.bind(this)); |
| + |
| this._svg = parentElement.createSVGChild("svg", "animation-ui"); |
| this._svg.setAttribute("height", WebInspector.AnimationUI.Options.AnimationSVGHeight); |
| this._svg.style.marginLeft = "-" + WebInspector.AnimationUI.Options.AnimationMargin + "px"; |
| this._svg.addEventListener("mousedown", this._mouseDown.bind(this, WebInspector.AnimationUI.MouseEvents.AnimationDrag, null)); |
| this._activeIntervalGroup = this._svg.createSVGChild("g"); |
| + this._activeIntervalGroup.addEventListener("mouseover", this._toggleBezierIcon.bind(this, true)); |
| + this._activeIntervalGroup.addEventListener("mouseout", this._toggleBezierIcon.bind(this, false)); |
| /** @type {!Array.<{group: ?Element, animationLine: ?Element, keyframePoints: !Object.<number, !Element>, keyframeRender: !Object.<number, !Element>}>} */ |
| this._cachedElements = []; |
| @@ -888,7 +897,9 @@ WebInspector.AnimationUI.prototype = { |
| this._svg.style.transform = "translateX(" + leftMargin.toFixed(2) + "px)"; |
| this._activeIntervalGroup.style.transform = "translateX(" + (this._delay() * this._timeline.pixelMsRatio()).toFixed(2) + "px)"; |
| - this._nameElement.style.transform = "translateX(" + (leftMargin + this._delay() * this._timeline.pixelMsRatio() + WebInspector.AnimationUI.Options.AnimationMargin).toFixed(2) + "px)"; |
| + var leftPosition = (leftMargin + this._delay() * this._timeline.pixelMsRatio() + WebInspector.AnimationUI.Options.AnimationMargin).toFixed(2); |
| + this._nameElement.style.transform = "translateX(" + leftPosition + "px)"; |
| + this._bezierIconElement.style.marginLeft = leftPosition + "px"; |
| this._nameElement.style.width = (this._duration() * this._timeline.pixelMsRatio().toFixed(2)) + "px"; |
| this._drawDelayLine(this._svg); |
| @@ -907,7 +918,6 @@ WebInspector.AnimationUI.prototype = { |
| this._cachedElements.pop().group.remove(); |
| }, |
| - |
| _renderTransition: function() |
| { |
| if (!this._cachedElements[0]) |
| @@ -1050,6 +1060,75 @@ WebInspector.AnimationUI.prototype = { |
| }, |
| /** |
| + * @param {boolean} show |
| + */ |
| + _toggleBezierIcon: function(show) |
|
dgozman
2015/05/28 11:04:03
Code below this line looks like exact copy of Bezi
samli
2015/05/29 04:32:11
This function is not in BezierPopoverIcon.
Bezier
|
| + { |
| + var bezier = WebInspector.Geometry.CubicBezier.parse(this._animation.source().easing()); |
| + if (show && (this._animation.playState() === "idle" || !bezier)) |
| + return; |
| + this._bezierIconElement.classList.toggle("shown", show); |
| + }, |
| + |
| + /** |
| + * @param {!Event} event |
| + */ |
| + _toggleBezierEditor: function(event) |
| + { |
| + var popover = this._timeline._editorPopoverHelper; |
| + var shouldShow = !popover.isShowing() || this._bezierIconElement !== popover.anchorElement(); |
| + |
| + if (popover.isShowing()) |
| + popover.hide(); |
| + |
| + if (shouldShow) { |
| + this._originalEasing = this._animation.source().easing(); |
| + var bezier = WebInspector.Geometry.CubicBezier.parse(this._originalEasing); |
| + this._timeline._bezierEditor.setBezier(bezier); |
| + this._timeline._bezierEditor.addEventListener(WebInspector.BezierEditor.Events.BezierChanged, this._bezierChanged, this); |
| + popover.show(this._timeline._bezierEditor, this._bezierIconElement, this._onPopoverHidden.bind(this)); |
| + this._bezierIconElement.classList.add("bezier-editor-open"); |
| + } |
| + |
| + event.stopPropagation(); |
| + event.preventDefault(); |
| + }, |
| + |
| + /** |
| + * @param {!WebInspector.Event} event |
| + */ |
| + _bezierChanged: function(event) |
| + { |
| + this._setEasing(/** @type {string} */ (event.data)); |
| + }, |
| + |
| + /** |
| + * @param {boolean} commitEdit |
| + */ |
| + _onPopoverHidden: function(commitEdit) |
| + { |
| + this._bezierIconElement.classList.remove("bezier-editor-open"); |
| + this._timeline._bezierEditor.removeEventListener(WebInspector.BezierEditor.Events.BezierChanged, this._bezierChanged, this); |
| + if (!commitEdit) |
| + this._setEasing(this._originalEasing); |
| + }, |
| + |
| + /** |
| + * @param {string} value |
| + */ |
| + _setEasing: function(value) |
| + { |
| + if (!this._node || this._animation.source().easing() === value) |
| + return; |
| + |
| + this._animation.source().setEasing(value, this._animation.id(), this._animation.type() !== "CSSAnimation"); |
| + this.redraw(); |
| + |
| + if (this._animation.type() !== "WebAnimation") |
| + this._setNodeStyle(this._animation.type() === "CSSTransition" ? "transition-timing-function" : "animation-timing-function", value); |
| + }, |
| + |
| + /** |
| * @param {number} value |
| */ |
| _setDelay: function(value) |
| @@ -1097,7 +1176,7 @@ WebInspector.AnimationUI.prototype = { |
| if (style) |
| style = style.replace(new RegExp("\\s*(-webkit-)?" + name + ":[^;]*;?\\s*", "g"), ""); |
| var valueString = name + ": " + value; |
| - this._node.setAttributeValue("style", style + " " + valueString + "; -webkit-" + valueString + ";"); |
| + this._node.setAttributeValue("style", style + " " + valueString + ";"); |
| }, |
| /** |