Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.VBox} | 7 * @extends {WebInspector.VBox} |
| 8 * @implements {WebInspector.TargetManager.Observer} | 8 * @implements {WebInspector.TargetManager.Observer} |
| 9 */ | 9 */ |
| 10 WebInspector.AnimationTimeline = function() | 10 WebInspector.AnimationTimeline = function() |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 684 this._animation = animation; | 684 this._animation = animation; |
| 685 this._timeline = timeline; | 685 this._timeline = timeline; |
| 686 this._parentElement = parentElement; | 686 this._parentElement = parentElement; |
| 687 | 687 |
| 688 if (this._animation.source().keyframesRule()) | 688 if (this._animation.source().keyframesRule()) |
| 689 this._keyframes = this._animation.source().keyframesRule().keyframes(); | 689 this._keyframes = this._animation.source().keyframesRule().keyframes(); |
| 690 | 690 |
| 691 this._nameElement = parentElement.createChild("div", "animation-name"); | 691 this._nameElement = parentElement.createChild("div", "animation-name"); |
| 692 this._nameElement.textContent = this._animation.name(); | 692 this._nameElement.textContent = this._animation.name(); |
| 693 | 693 |
| 694 this._bezierIconElement = WebInspector.BezierPopoverIcon.createIcon(parentEl ement); | |
| 695 this._bezierIconElement.style.backgroundColor = this._color(); | |
| 696 this._stylesPopoverHelper = new WebInspector.StylesPopoverHelper(); | |
|
dgozman
2015/05/23 00:53:26
Animations should not depend on StylesPopoverHelpe
samli
2015/05/25 01:55:38
Done. I've had to duplicate some of the code, ptal
| |
| 697 this._bezierEditor = new WebInspector.BezierEditor(); | |
| 698 this._bezierIconElement.addEventListener("mousedown", this._toggleBezierEdit or.bind(this)); | |
| 699 | |
| 694 this._svg = parentElement.createSVGChild("svg", "animation-ui"); | 700 this._svg = parentElement.createSVGChild("svg", "animation-ui"); |
| 695 this._svg.setAttribute("height", WebInspector.AnimationUI.Options.AnimationS VGHeight); | 701 this._svg.setAttribute("height", WebInspector.AnimationUI.Options.AnimationS VGHeight); |
| 696 this._svg.style.marginLeft = "-" + WebInspector.AnimationUI.Options.Animatio nMargin + "px"; | 702 this._svg.style.marginLeft = "-" + WebInspector.AnimationUI.Options.Animatio nMargin + "px"; |
| 697 this._svg.addEventListener("mousedown", this._mouseDown.bind(this, WebInspec tor.AnimationUI.MouseEvents.AnimationDrag, null)); | 703 this._svg.addEventListener("mousedown", this._mouseDown.bind(this, WebInspec tor.AnimationUI.MouseEvents.AnimationDrag, null)); |
| 698 this._activeIntervalGroup = this._svg.createSVGChild("g"); | 704 this._activeIntervalGroup = this._svg.createSVGChild("g"); |
| 705 this._activeIntervalGroup.addEventListener("mouseover", this._toggleBezierIc on.bind(this, true)); | |
| 706 this._activeIntervalGroup.addEventListener("mouseout", this._toggleBezierIco n.bind(this, false)); | |
| 699 | 707 |
| 700 /** @type {!Array.<{group: ?Element, animationLine: ?Element, keyframePoints : !Object.<number, !Element>, keyframeRender: !Object.<number, !Element>}>} */ | 708 /** @type {!Array.<{group: ?Element, animationLine: ?Element, keyframePoints : !Object.<number, !Element>, keyframeRender: !Object.<number, !Element>}>} */ |
| 701 this._cachedElements = []; | 709 this._cachedElements = []; |
| 702 | 710 |
| 703 this._movementInMs = 0; | 711 this._movementInMs = 0; |
| 704 this.redraw(); | 712 this.redraw(); |
| 705 } | 713 } |
| 706 | 714 |
| 707 /** | 715 /** |
| 708 * @enum {string} | 716 * @enum {string} |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 861 var durationWithDelay = this._delay() + this._duration() * this._animati on.source().iterations() + this._animation.source().endDelay(); | 869 var durationWithDelay = this._delay() + this._duration() * this._animati on.source().iterations() + this._animation.source().endDelay(); |
| 862 var leftMargin = ((this._animation.startTime() - this._timeline.startTim e()) * this._timeline.pixelMsRatio()); | 870 var leftMargin = ((this._animation.startTime() - this._timeline.startTim e()) * this._timeline.pixelMsRatio()); |
| 863 var maxWidth = this._timeline.width() - WebInspector.AnimationUI.Options .AnimationMargin - leftMargin; | 871 var maxWidth = this._timeline.width() - WebInspector.AnimationUI.Options .AnimationMargin - leftMargin; |
| 864 var svgWidth = Math.min(maxWidth, durationWithDelay * this._timeline.pix elMsRatio()); | 872 var svgWidth = Math.min(maxWidth, durationWithDelay * this._timeline.pix elMsRatio()); |
| 865 | 873 |
| 866 this._svg.classList.toggle("animation-ui-canceled", this._animation.play State() === "idle"); | 874 this._svg.classList.toggle("animation-ui-canceled", this._animation.play State() === "idle"); |
| 867 this._svg.setAttribute("width", (svgWidth + 2 * WebInspector.AnimationUI .Options.AnimationMargin).toFixed(2)); | 875 this._svg.setAttribute("width", (svgWidth + 2 * WebInspector.AnimationUI .Options.AnimationMargin).toFixed(2)); |
| 868 this._svg.style.transform = "translateX(" + leftMargin.toFixed(2) + "px )"; | 876 this._svg.style.transform = "translateX(" + leftMargin.toFixed(2) + "px )"; |
| 869 this._activeIntervalGroup.style.transform = "translateX(" + (this._delay () * this._timeline.pixelMsRatio()).toFixed(2) + "px)"; | 877 this._activeIntervalGroup.style.transform = "translateX(" + (this._delay () * this._timeline.pixelMsRatio()).toFixed(2) + "px)"; |
| 870 | 878 |
| 871 this._nameElement.style.transform = "translateX(" + (leftMargin + this._ delay() * this._timeline.pixelMsRatio() + WebInspector.AnimationUI.Options.Anima tionMargin).toFixed(2) + "px)"; | 879 var leftPosition = (leftMargin + this._delay() * this._timeline.pixelMsR atio() + WebInspector.AnimationUI.Options.AnimationMargin).toFixed(2); |
| 880 this._nameElement.style.transform = "translateX(" + leftPosition + "px)" ; | |
| 881 this._bezierIconElement.style.marginLeft = leftPosition + "px"; | |
| 872 this._nameElement.style.width = (this._duration() * this._timeline.pixel MsRatio().toFixed(2)) + "px"; | 882 this._nameElement.style.width = (this._duration() * this._timeline.pixel MsRatio().toFixed(2)) + "px"; |
| 873 this._drawDelayLine(this._svg); | 883 this._drawDelayLine(this._svg); |
| 874 | 884 |
| 875 if (this._animation.type() === "CSSTransition") { | 885 if (this._animation.type() === "CSSTransition") { |
| 876 this._renderTransition(); | 886 this._renderTransition(); |
| 877 return; | 887 return; |
| 878 } | 888 } |
| 879 | 889 |
| 880 this._renderIteration(this._activeIntervalGroup, 0); | 890 this._renderIteration(this._activeIntervalGroup, 0); |
| 881 if (!this._tailGroup) | 891 if (!this._tailGroup) |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1023 this._parentElement.ownerDocument.removeEventListener("mousemove", this. _mouseMoveHandler); | 1033 this._parentElement.ownerDocument.removeEventListener("mousemove", this. _mouseMoveHandler); |
| 1024 this._parentElement.ownerDocument.removeEventListener("mouseup", this._m ouseUpHandler); | 1034 this._parentElement.ownerDocument.removeEventListener("mouseup", this._m ouseUpHandler); |
| 1025 delete this._mouseMoveHandler; | 1035 delete this._mouseMoveHandler; |
| 1026 delete this._mouseUpHandler; | 1036 delete this._mouseUpHandler; |
| 1027 delete this._mouseEventType; | 1037 delete this._mouseEventType; |
| 1028 delete this._downMouseX; | 1038 delete this._downMouseX; |
| 1029 delete this._keyframeMoved; | 1039 delete this._keyframeMoved; |
| 1030 }, | 1040 }, |
| 1031 | 1041 |
| 1032 /** | 1042 /** |
| 1043 * @param {boolean} show | |
| 1044 */ | |
| 1045 _toggleBezierIcon: function(show) | |
| 1046 { | |
| 1047 var bezier = WebInspector.Geometry.CubicBezier.parse(this._animation.sou rce().easing()); | |
| 1048 if (show && (this._animation.playState() === "idle" || !bezier)) | |
| 1049 return; | |
| 1050 this._bezierIconElement.classList.toggle("shown", show); | |
| 1051 }, | |
| 1052 | |
| 1053 /** | |
| 1054 * @param {!Event} event | |
| 1055 */ | |
| 1056 _toggleBezierEditor: function(event) | |
| 1057 { | |
| 1058 if (this._stylesPopoverHelper.isShowing()) { | |
| 1059 this._stylesPopoverHelper.hide(); | |
| 1060 } else { | |
| 1061 this._originalEasing = this._animation.source().easing(); | |
| 1062 var bezier = WebInspector.Geometry.CubicBezier.parse(this._originalE asing); | |
| 1063 this._bezierEditor.setBezier(bezier); | |
| 1064 this._bezierEditor.addEventListener(WebInspector.BezierEditor.Events .BezierChanged, this._bezierChanged, this); | |
| 1065 this._stylesPopoverHelper.show(this._bezierEditor, this._bezierIconE lement, this._onPopoverHidden.bind(this)); | |
| 1066 this._bezierIconElement.classList.add("bezier-editor-open"); | |
| 1067 } | |
| 1068 event.stopPropagation(); | |
| 1069 event.preventDefault(); | |
| 1070 }, | |
| 1071 | |
| 1072 /** | |
| 1073 * @param {!WebInspector.Event} event | |
| 1074 */ | |
| 1075 _bezierChanged: function(event) | |
| 1076 { | |
| 1077 this._setEasing(/** @type {string} */ (event.data)); | |
| 1078 }, | |
| 1079 | |
| 1080 /** | |
| 1081 * @param {boolean} commitEdit | |
| 1082 */ | |
| 1083 _onPopoverHidden: function(commitEdit) | |
| 1084 { | |
| 1085 this._bezierIconElement.classList.remove("bezier-editor-open"); | |
| 1086 this._bezierEditor.removeEventListener(WebInspector.BezierEditor.Events. BezierChanged, this._bezierChanged, this); | |
| 1087 if (!commitEdit) | |
| 1088 this._setEasing(this._originalEasing); | |
| 1089 }, | |
| 1090 | |
| 1091 /** | |
| 1092 * @param {string} value | |
| 1093 */ | |
| 1094 _setEasing: function(value) | |
| 1095 { | |
| 1096 if (!this._node || this._animation.source().easing() == value) | |
| 1097 return; | |
| 1098 | |
| 1099 this._animation.source().setEasing(value); | |
| 1100 this.redraw(); | |
| 1101 | |
| 1102 var animationType = this._animation.type(); | |
| 1103 if (animationType !== "CSSAnimation") { | |
| 1104 var target = WebInspector.targetManager.mainTarget(); | |
| 1105 if (target) | |
| 1106 target.animationAgent().setEasing(this._animation.id(), value); | |
| 1107 } | |
| 1108 | |
| 1109 if (animationType !== "WebAnimation") | |
| 1110 this._setNodeStyle(animationType === "CSSTransition" ? "transition-t iming-function" : "animation-timing-function", value); | |
| 1111 }, | |
| 1112 | |
| 1113 /** | |
| 1033 * @param {number} value | 1114 * @param {number} value |
| 1034 */ | 1115 */ |
| 1035 _setDelay: function(value) | 1116 _setDelay: function(value) |
| 1036 { | 1117 { |
| 1037 if (!this._node || this._animation.source().delay() == this._delay()) | 1118 if (!this._node || this._animation.source().delay() == this._delay()) |
| 1038 return; | 1119 return; |
| 1039 | 1120 |
| 1040 this._animation.source().setDelay(this._delay()); | 1121 this._animation.source().setDelay(this._delay()); |
| 1041 var propertyName; | 1122 var propertyName; |
| 1042 if (this._animation.type() == "CSSTransition") | 1123 if (this._animation.type() == "CSSTransition") |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 1070 /** | 1151 /** |
| 1071 * @param {string} name | 1152 * @param {string} name |
| 1072 * @param {string} value | 1153 * @param {string} value |
| 1073 */ | 1154 */ |
| 1074 _setNodeStyle: function(name, value) | 1155 _setNodeStyle: function(name, value) |
| 1075 { | 1156 { |
| 1076 var style = this._node.getAttribute("style") || ""; | 1157 var style = this._node.getAttribute("style") || ""; |
| 1077 if (style) | 1158 if (style) |
| 1078 style = style.replace(new RegExp("\\s*(-webkit-)?" + name + ":[^;]*; ?\\s*", "g"), ""); | 1159 style = style.replace(new RegExp("\\s*(-webkit-)?" + name + ":[^;]*; ?\\s*", "g"), ""); |
| 1079 var valueString = name + ": " + value; | 1160 var valueString = name + ": " + value; |
| 1080 this._node.setAttributeValue("style", style + " " + valueString + "; -we bkit-" + valueString + ";"); | 1161 this._node.setAttributeValue("style", style + " " + valueString + ";"); |
| 1081 }, | 1162 }, |
| 1082 | 1163 |
| 1083 /** | 1164 /** |
| 1084 * @return {string} | 1165 * @return {string} |
| 1085 */ | 1166 */ |
| 1086 _color: function() | 1167 _color: function() |
| 1087 { | 1168 { |
| 1088 /** | 1169 /** |
| 1089 * @param {string} string | 1170 * @param {string} string |
| 1090 * @return {number} | 1171 * @return {number} |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1119 "Light Blue": WebInspector.Color.parse("#03A9F4"), | 1200 "Light Blue": WebInspector.Color.parse("#03A9F4"), |
| 1120 "Deep Orange": WebInspector.Color.parse("#FF5722"), | 1201 "Deep Orange": WebInspector.Color.parse("#FF5722"), |
| 1121 "Blue": WebInspector.Color.parse("#5677FC"), | 1202 "Blue": WebInspector.Color.parse("#5677FC"), |
| 1122 "Lime": WebInspector.Color.parse("#CDDC39"), | 1203 "Lime": WebInspector.Color.parse("#CDDC39"), |
| 1123 "Blue Grey": WebInspector.Color.parse("#607D8B"), | 1204 "Blue Grey": WebInspector.Color.parse("#607D8B"), |
| 1124 "Pink": WebInspector.Color.parse("#E91E63"), | 1205 "Pink": WebInspector.Color.parse("#E91E63"), |
| 1125 "Green": WebInspector.Color.parse("#0F9D58"), | 1206 "Green": WebInspector.Color.parse("#0F9D58"), |
| 1126 "Brown": WebInspector.Color.parse("#795548"), | 1207 "Brown": WebInspector.Color.parse("#795548"), |
| 1127 "Cyan": WebInspector.Color.parse("#00BCD4") | 1208 "Cyan": WebInspector.Color.parse("#00BCD4") |
| 1128 } | 1209 } |
| OLD | NEW |