| 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 { | 279 { |
| 280 this._addAnimation(/** @type {!WebInspector.AnimationModel.AnimationPlay
er} */ (event.data.player), event.data.resetTimeline) | 280 this._addAnimation(/** @type {!WebInspector.AnimationModel.AnimationPlay
er} */ (event.data.player), event.data.resetTimeline) |
| 281 }, | 281 }, |
| 282 | 282 |
| 283 /** | 283 /** |
| 284 * @param {!WebInspector.AnimationModel.AnimationPlayer} animation | 284 * @param {!WebInspector.AnimationModel.AnimationPlayer} animation |
| 285 * @param {boolean} resetTimeline | 285 * @param {boolean} resetTimeline |
| 286 */ | 286 */ |
| 287 _addAnimation: function(animation, resetTimeline) | 287 _addAnimation: function(animation, resetTimeline) |
| 288 { | 288 { |
| 289 /** | |
| 290 * @param {?WebInspector.DOMNode} node | |
| 291 * @this {WebInspector.AnimationTimeline} | |
| 292 */ | |
| 293 function nodeResolved(node) | |
| 294 { | |
| 295 uiAnimation.setNode(node); | |
| 296 node[this._symbol] = nodeUI; | |
| 297 } | |
| 298 | |
| 299 if (resetTimeline) | 289 if (resetTimeline) |
| 300 this._reset(); | 290 this._reset(); |
| 301 | 291 |
| 302 // Ignore Web Animations custom effects & groups | 292 // Ignore Web Animations custom effects & groups |
| 303 if (animation.type() === "WebAnimation" && animation.source().keyframesR
ule().keyframes().length === 0) | 293 if (animation.type() === "WebAnimation" && animation.source().keyframesR
ule().keyframes().length === 0) |
| 304 return; | 294 return; |
| 305 | 295 |
| 306 if (this._resizeWindow(animation)) | 296 if (this._resizeWindow(animation)) |
| 307 this.scheduleRedraw(); | 297 this.scheduleRedraw(); |
| 308 else | 298 else |
| 309 this._resetTimerAnimation(); | 299 this._resetTimerAnimation(); |
| 310 | 300 |
| 311 var nodeUI = this._nodesMap.get(animation.source().backendNodeId()); | 301 var nodeUI = this._nodesMap.get(animation.source().backendNodeId()); |
| 312 if (!nodeUI) { | 302 if (!nodeUI) { |
| 313 nodeUI = new WebInspector.AnimationTimeline.NodeUI(animation.source(
)); | 303 nodeUI = new WebInspector.AnimationTimeline.NodeUI(this, animation.s
ource()); |
| 314 this._animationsContainer.appendChild(nodeUI.element); | 304 this._animationsContainer.appendChild(nodeUI.element); |
| 315 this._nodesMap.set(animation.source().backendNodeId(), nodeUI); | 305 this._nodesMap.set(animation.source().backendNodeId(), nodeUI); |
| 316 } | 306 } |
| 317 var nodeRow = nodeUI.findRow(animation); | 307 nodeUI.addAnimation(animation); |
| 318 var uiAnimation = new WebInspector.AnimationUI(animation, this, nodeRow.
element); | |
| 319 animation.source().deferredNode().resolve(nodeResolved.bind(this)); | |
| 320 nodeRow.animations.push(uiAnimation); | |
| 321 this._animationsMap.set(animation.id(), animation); | 308 this._animationsMap.set(animation.id(), animation); |
| 322 }, | 309 }, |
| 323 | 310 |
| 324 /** | 311 /** |
| 325 * @param {!WebInspector.Event} event | 312 * @param {!WebInspector.Event} event |
| 326 */ | 313 */ |
| 327 _animationCanceled: function(event) | 314 _animationCanceled: function(event) |
| 328 { | 315 { |
| 329 this._cancelAnimation(/** @type {string} */ (event.data.playerId)); | 316 this._cancelAnimation(/** @type {string} */ (event.data.playerId)); |
| 330 }, | 317 }, |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 bezierEditor: function() | 566 bezierEditor: function() |
| 580 { | 567 { |
| 581 return this._timelineBezierEditor; | 568 return this._timelineBezierEditor; |
| 582 }, | 569 }, |
| 583 | 570 |
| 584 __proto__: WebInspector.VBox.prototype | 571 __proto__: WebInspector.VBox.prototype |
| 585 } | 572 } |
| 586 | 573 |
| 587 /** | 574 /** |
| 588 * @constructor | 575 * @constructor |
| 576 * @param {!WebInspector.AnimationTimeline} timeline |
| 589 * @param {!WebInspector.AnimationModel.AnimationNode} animationNode | 577 * @param {!WebInspector.AnimationModel.AnimationNode} animationNode |
| 590 */ | 578 */ |
| 591 WebInspector.AnimationTimeline.NodeUI = function(animationNode) { | 579 WebInspector.AnimationTimeline.NodeUI = function(timeline, animationNode) { |
| 592 /** | 580 /** |
| 593 * @param {?WebInspector.DOMNode} node | 581 * @param {?WebInspector.DOMNode} node |
| 594 * @this {WebInspector.AnimationTimeline.NodeUI} | 582 * @this {WebInspector.AnimationTimeline.NodeUI} |
| 595 */ | 583 */ |
| 596 function nodeResolved(node) | 584 function nodeResolved(node) |
| 597 { | 585 { |
| 586 this._node = node; |
| 587 this._node[this._timeline._symbol] = this; |
| 598 this._description.appendChild(WebInspector.DOMPresentationUtils.linkifyN
odeReference(node)); | 588 this._description.appendChild(WebInspector.DOMPresentationUtils.linkifyN
odeReference(node)); |
| 589 for (var nodeRow of this._rows) { |
| 590 for (var ui of nodeRow.animations) |
| 591 ui.setNode(this._node); |
| 592 } |
| 599 } | 593 } |
| 600 | 594 |
| 595 this._timeline = timeline; |
| 601 this._rows = []; | 596 this._rows = []; |
| 602 this.element = createElementWithClass("div", "animation-node-row"); | 597 this.element = createElementWithClass("div", "animation-node-row"); |
| 603 this._description = this.element.createChild("div", "animation-node-descript
ion"); | 598 this._description = this.element.createChild("div", "animation-node-descript
ion"); |
| 604 animationNode.deferredNode().resolve(nodeResolved.bind(this)); | 599 animationNode.deferredNode().resolve(nodeResolved.bind(this)); |
| 605 this._timelineElement = this.element.createChild("div", "animation-node-time
line"); | 600 this._timelineElement = this.element.createChild("div", "animation-node-time
line"); |
| 606 } | 601 } |
| 607 | 602 |
| 608 /** @typedef {{element: !Element, animations: !Array<!WebInspector.AnimationUI>}
} */ | 603 /** @typedef {{element: !Element, animations: !Array<!WebInspector.AnimationUI>}
} */ |
| 609 WebInspector.AnimationTimeline.NodeRow; | 604 WebInspector.AnimationTimeline.NodeRow; |
| 610 | 605 |
| 611 WebInspector.AnimationTimeline.NodeUI.prototype = { | 606 WebInspector.AnimationTimeline.NodeUI.prototype = { |
| 612 /** | 607 /** |
| 613 * @param {!WebInspector.AnimationModel.AnimationPlayer} animation | 608 * @param {!WebInspector.AnimationModel.AnimationPlayer} animation |
| 609 */ |
| 610 addAnimation: function(animation) |
| 611 { |
| 612 var nodeRow = this._findRow(animation); |
| 613 var uiAnimation = new WebInspector.AnimationUI(animation, this._timeline
, nodeRow.element); |
| 614 uiAnimation.addEventListener(WebInspector.AnimationUI.Events.TimingChang
ed, this._timingChanged, this); |
| 615 uiAnimation.addEventListener(WebInspector.AnimationUI.Events.EasingChang
ed, this._easingChanged, this); |
| 616 nodeRow.animations.push(uiAnimation); |
| 617 if (this._node) |
| 618 uiAnimation.setNode(this._node); |
| 619 |
| 620 }, |
| 621 |
| 622 /** |
| 623 * @param {!WebInspector.AnimationModel.AnimationPlayer} animation |
| 614 * @return {!WebInspector.AnimationTimeline.NodeRow} | 624 * @return {!WebInspector.AnimationTimeline.NodeRow} |
| 615 */ | 625 */ |
| 616 findRow: function(animation) | 626 _findRow: function(animation) |
| 617 { | 627 { |
| 618 // Check if it can fit into an existing row | 628 // Check if it can fit into an existing row |
| 619 var existingRow = this._collapsibleIntoRow(animation); | 629 var existingRow = this._collapsibleIntoRow(animation); |
| 620 if (existingRow) | 630 if (existingRow) |
| 621 return existingRow; | 631 return existingRow; |
| 622 | 632 |
| 623 // Create new row | 633 // Create new row |
| 624 var container = this._timelineElement.createChild("div", "animation-time
line-row"); | 634 var container = this._timelineElement.createChild("div", "animation-time
line-row"); |
| 625 var nodeRow = {element: container, animations: []}; | 635 var nodeRow = {element: container, animations: []}; |
| 626 this._rows.push(nodeRow); | 636 this._rows.push(nodeRow); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 649 overlap |= animation.overlaps(ui.animation()); | 659 overlap |= animation.overlaps(ui.animation()); |
| 650 if (!overlap) | 660 if (!overlap) |
| 651 return nodeRow; | 661 return nodeRow; |
| 652 } | 662 } |
| 653 return null; | 663 return null; |
| 654 }, | 664 }, |
| 655 | 665 |
| 656 nodeRemoved: function() | 666 nodeRemoved: function() |
| 657 { | 667 { |
| 658 this.element.classList.add("animation-node-removed"); | 668 this.element.classList.add("animation-node-removed"); |
| 669 }, |
| 670 |
| 671 /** |
| 672 * @param {string} id |
| 673 * @param {string} animationType |
| 674 * @param {function(!WebInspector.AnimationUI)} processor |
| 675 */ |
| 676 _applyToFilteredAnimations: function(id, animationType, processor) |
| 677 { |
| 678 for (var nodeRow of this._rows) { |
| 679 for (var ui of nodeRow.animations) { |
| 680 if (id === ui.animation().id() || ui.animation().type() !== anim
ationType || ui.canceled()) |
| 681 continue; |
| 682 processor(ui); |
| 683 ui.redraw(); |
| 684 } |
| 685 } |
| 686 }, |
| 687 |
| 688 /** |
| 689 * @param {!WebInspector.Event} event |
| 690 */ |
| 691 _timingChanged: function(event) |
| 692 { |
| 693 /** |
| 694 * @param {number} delay |
| 695 * @param {number} duration |
| 696 * @param {!WebInspector.AnimationUI} ui |
| 697 */ |
| 698 function updateTiming(delay, duration, ui) |
| 699 { |
| 700 ui.innerSetDelayDuration(delay, duration); |
| 701 } |
| 702 |
| 703 var animationType = /** @type {string} */(event.data.animationType); |
| 704 if (animationType === "WebAnimation") |
| 705 return; |
| 706 var delay = /** @type {number} */(event.data.delay); |
| 707 var duration = /** @type {number} */(event.data.duration); |
| 708 this._applyToFilteredAnimations(/** @type {string} */(event.data.animati
onId), animationType, updateTiming.bind(null, delay, duration)); |
| 709 }, |
| 710 |
| 711 /** |
| 712 * @param {!WebInspector.Event} event |
| 713 */ |
| 714 _easingChanged: function(event) |
| 715 { |
| 716 /** |
| 717 * @param {string} easing |
| 718 * @param {!WebInspector.AnimationUI} ui |
| 719 */ |
| 720 function updateEasing(easing, ui) |
| 721 { |
| 722 ui.innerSetEasing(easing); |
| 723 } |
| 724 |
| 725 var animationType = /** @type {string} */(event.data.animationType); |
| 726 if (animationType === "WebAnimation") |
| 727 return; |
| 728 this._applyToFilteredAnimations(/** @type {string} */(event.data.animati
onId), animationType, updateEasing.bind(null, /** @type {string} */(event.data.e
asing))); |
| 659 } | 729 } |
| 660 } | 730 } |
| 661 | 731 |
| 662 /** | 732 /** |
| 663 * @constructor | 733 * @constructor |
| 664 * @param {number} steps | 734 * @param {number} steps |
| 665 * @param {string} stepAtPosition | 735 * @param {string} stepAtPosition |
| 666 */ | 736 */ |
| 667 WebInspector.AnimationTimeline.StepTimingFunction = function(steps, stepAtPositi
on) | 737 WebInspector.AnimationTimeline.StepTimingFunction = function(steps, stepAtPositi
on) |
| 668 { | 738 { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 679 if (match) | 749 if (match) |
| 680 return new WebInspector.AnimationTimeline.StepTimingFunction(1, match[1]
); | 750 return new WebInspector.AnimationTimeline.StepTimingFunction(1, match[1]
); |
| 681 match = text.match(/^steps\((\d+), (start|middle|end)\)$/); | 751 match = text.match(/^steps\((\d+), (start|middle|end)\)$/); |
| 682 if (match) | 752 if (match) |
| 683 return new WebInspector.AnimationTimeline.StepTimingFunction(parseInt(ma
tch[1], 10), match[2]); | 753 return new WebInspector.AnimationTimeline.StepTimingFunction(parseInt(ma
tch[1], 10), match[2]); |
| 684 return null; | 754 return null; |
| 685 } | 755 } |
| 686 | 756 |
| 687 /** | 757 /** |
| 688 * @constructor | 758 * @constructor |
| 759 * @extends {WebInspector.Object} |
| 689 * @param {!WebInspector.AnimationModel.AnimationPlayer} animation | 760 * @param {!WebInspector.AnimationModel.AnimationPlayer} animation |
| 690 * @param {!WebInspector.AnimationTimeline} timeline | 761 * @param {!WebInspector.AnimationTimeline} timeline |
| 691 * @param {!Element} parentElement | 762 * @param {!Element} parentElement |
| 692 */ | 763 */ |
| 693 WebInspector.AnimationUI = function(animation, timeline, parentElement) { | 764 WebInspector.AnimationUI = function(animation, timeline, parentElement) { |
| 694 this._animation = animation; | 765 this._animation = animation; |
| 695 this._timeline = timeline; | 766 this._timeline = timeline; |
| 696 this._parentElement = parentElement; | 767 this._parentElement = parentElement; |
| 697 | 768 |
| 698 if (this._animation.source().keyframesRule()) | 769 if (this._animation.source().keyframesRule()) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 724 /** | 795 /** |
| 725 * @enum {string} | 796 * @enum {string} |
| 726 */ | 797 */ |
| 727 WebInspector.AnimationUI.MouseEvents = { | 798 WebInspector.AnimationUI.MouseEvents = { |
| 728 AnimationDrag: "AnimationDrag", | 799 AnimationDrag: "AnimationDrag", |
| 729 KeyframeMove: "KeyframeMove", | 800 KeyframeMove: "KeyframeMove", |
| 730 StartEndpointMove: "StartEndpointMove", | 801 StartEndpointMove: "StartEndpointMove", |
| 731 FinishEndpointMove: "FinishEndpointMove" | 802 FinishEndpointMove: "FinishEndpointMove" |
| 732 } | 803 } |
| 733 | 804 |
| 805 /** |
| 806 * @enum {string} |
| 807 */ |
| 808 WebInspector.AnimationUI.Events = { |
| 809 TimingChanged: "TimingChanged", |
| 810 EasingChanged: "EasingChanged" |
| 811 } |
| 812 |
| 734 WebInspector.AnimationUI.prototype = { | 813 WebInspector.AnimationUI.prototype = { |
| 735 /** | 814 /** |
| 736 * @return {!WebInspector.AnimationModel.AnimationPlayer} | 815 * @return {!WebInspector.AnimationModel.AnimationPlayer} |
| 737 */ | 816 */ |
| 738 animation: function() | 817 animation: function() |
| 739 { | 818 { |
| 740 return this._animation; | 819 return this._animation; |
| 741 }, | 820 }, |
| 742 | 821 |
| 743 /** | 822 /** |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 } else { | 945 } else { |
| 867 var stepFunction = WebInspector.AnimationTimeline.StepTimingFunction
.parse(easing); | 946 var stepFunction = WebInspector.AnimationTimeline.StepTimingFunction
.parse(easing); |
| 868 group.removeChildren(); | 947 group.removeChildren(); |
| 869 const offsetMap = {"start": 0, "middle": 0.5, "end": 1}; | 948 const offsetMap = {"start": 0, "middle": 0.5, "end": 1}; |
| 870 const offsetWeight = offsetMap[stepFunction.stepAtPosition]; | 949 const offsetWeight = offsetMap[stepFunction.stepAtPosition]; |
| 871 for (var i = 0; i < stepFunction.steps; i++) | 950 for (var i = 0; i < stepFunction.steps; i++) |
| 872 createStepLine(group, (i + offsetWeight) * width / stepFunction.
steps, this._color()); | 951 createStepLine(group, (i + offsetWeight) * width / stepFunction.
steps, this._color()); |
| 873 } | 952 } |
| 874 }, | 953 }, |
| 875 | 954 |
| 955 /** |
| 956 * @return {boolean} |
| 957 */ |
| 958 canceled: function() |
| 959 { |
| 960 return this._animation.playState() === "idle"; |
| 961 }, |
| 962 |
| 876 redraw: function() | 963 redraw: function() |
| 877 { | 964 { |
| 878 var durationWithDelay = this._delay() + this._duration() * this._animati
on.source().iterations() + this._animation.source().endDelay(); | 965 var durationWithDelay = this._delay() + this._duration() * this._animati
on.source().iterations() + this._animation.source().endDelay(); |
| 879 var leftMargin = ((this._animation.startTime() - this._timeline.startTim
e()) * this._timeline.pixelMsRatio()); | 966 var leftMargin = ((this._animation.startTime() - this._timeline.startTim
e()) * this._timeline.pixelMsRatio()); |
| 880 var maxWidth = this._timeline.width() - WebInspector.AnimationUI.Options
.AnimationMargin - leftMargin; | 967 var maxWidth = this._timeline.width() - WebInspector.AnimationUI.Options
.AnimationMargin - leftMargin; |
| 881 var svgWidth = Math.min(maxWidth, durationWithDelay * this._timeline.pix
elMsRatio()); | 968 var svgWidth = Math.min(maxWidth, durationWithDelay * this._timeline.pix
elMsRatio()); |
| 882 | 969 |
| 883 this._svg.classList.toggle("animation-ui-canceled", this._animation.play
State() === "idle"); | 970 this._svg.classList.toggle("animation-ui-canceled", this.canceled()); |
| 884 this._svg.setAttribute("width", (svgWidth + 2 * WebInspector.AnimationUI
.Options.AnimationMargin).toFixed(2)); | 971 this._svg.setAttribute("width", (svgWidth + 2 * WebInspector.AnimationUI
.Options.AnimationMargin).toFixed(2)); |
| 885 this._svg.style.transform = "translateX(" + leftMargin.toFixed(2) + "px
)"; | 972 this._svg.style.transform = "translateX(" + leftMargin.toFixed(2) + "px
)"; |
| 886 this._activeIntervalGroup.style.transform = "translateX(" + (this._delay
() * this._timeline.pixelMsRatio()).toFixed(2) + "px)"; | 973 this._activeIntervalGroup.style.transform = "translateX(" + (this._delay
() * this._timeline.pixelMsRatio()).toFixed(2) + "px)"; |
| 887 | 974 |
| 888 var leftPosition = (leftMargin + this._delay() * this._timeline.pixelMsR
atio() + WebInspector.AnimationUI.Options.AnimationMargin).toFixed(2); | 975 var leftPosition = (leftMargin + this._delay() * this._timeline.pixelMsR
atio() + WebInspector.AnimationUI.Options.AnimationMargin).toFixed(2); |
| 889 this._nameElement.style.transform = "translateX(" + leftPosition + "px)"
; | 976 this._nameElement.style.transform = "translateX(" + leftPosition + "px)"
; |
| 890 this._bezierIconElement.style.marginLeft = leftPosition + "px"; | 977 this._bezierIconElement.style.marginLeft = leftPosition + "px"; |
| 891 this._nameElement.style.width = (this._duration() * this._timeline.pixel
MsRatio().toFixed(2)) + "px"; | 978 this._nameElement.style.width = (this._duration() * this._timeline.pixel
MsRatio().toFixed(2)) + "px"; |
| 892 this._drawDelayLine(this._svg); | 979 this._drawDelayLine(this._svg); |
| 893 | 980 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 }, | 1101 }, |
| 1015 | 1102 |
| 1016 /** | 1103 /** |
| 1017 * @param {!Event} event | 1104 * @param {!Event} event |
| 1018 */ | 1105 */ |
| 1019 _mouseUp: function(event) | 1106 _mouseUp: function(event) |
| 1020 { | 1107 { |
| 1021 this._movementInMs = (event.clientX - this._downMouseX) / this._timeline
.pixelMsRatio(); | 1108 this._movementInMs = (event.clientX - this._downMouseX) / this._timeline
.pixelMsRatio(); |
| 1022 | 1109 |
| 1023 // Commit changes | 1110 // Commit changes |
| 1024 if (this._mouseEventType === WebInspector.AnimationUI.MouseEvents.Keyfra
meMove) { | 1111 if (this._mouseEventType === WebInspector.AnimationUI.MouseEvents.Keyfra
meMove) |
| 1025 this._keyframes[this._keyframeMoved].setOffset(this._offset(this._ke
yframeMoved)); | 1112 this._keyframes[this._keyframeMoved].setOffset(this._offset(this._ke
yframeMoved)); |
| 1026 } else { | 1113 else |
| 1027 var delay = this._delay(); | 1114 this._setDelayDuration(this._delay(), this._duration()); |
| 1028 var duration = this._duration(); | |
| 1029 this._setDelay(delay); | |
| 1030 this._setDuration(duration); | |
| 1031 if (this._animation.type() !== "CSSAnimation") { | |
| 1032 var target = WebInspector.targetManager.mainTarget(); | |
| 1033 if (target) | |
| 1034 target.animationAgent().setTiming(this._animation.id(), dura
tion, delay); | |
| 1035 } | |
| 1036 } | |
| 1037 | 1115 |
| 1038 this._movementInMs = 0; | 1116 this._movementInMs = 0; |
| 1039 this.redraw(); | 1117 this.redraw(); |
| 1040 | 1118 |
| 1041 this._parentElement.ownerDocument.removeEventListener("mousemove", this.
_mouseMoveHandler); | 1119 this._parentElement.ownerDocument.removeEventListener("mousemove", this.
_mouseMoveHandler); |
| 1042 this._parentElement.ownerDocument.removeEventListener("mouseup", this._m
ouseUpHandler); | 1120 this._parentElement.ownerDocument.removeEventListener("mouseup", this._m
ouseUpHandler); |
| 1043 delete this._mouseMoveHandler; | 1121 delete this._mouseMoveHandler; |
| 1044 delete this._mouseUpHandler; | 1122 delete this._mouseUpHandler; |
| 1045 delete this._mouseEventType; | 1123 delete this._mouseEventType; |
| 1046 delete this._downMouseX; | 1124 delete this._downMouseX; |
| 1047 delete this._keyframeMoved; | 1125 delete this._keyframeMoved; |
| 1048 }, | 1126 }, |
| 1049 | 1127 |
| 1050 /** | 1128 /** |
| 1051 * @param {boolean} show | 1129 * @param {boolean} show |
| 1052 */ | 1130 */ |
| 1053 _toggleBezierIcon: function(show) | 1131 _toggleBezierIcon: function(show) |
| 1054 { | 1132 { |
| 1055 var bezier = WebInspector.Geometry.CubicBezier.parse(this._animation.sou
rce().easing()); | 1133 var bezier = WebInspector.Geometry.CubicBezier.parse(this._animation.sou
rce().easing()); |
| 1056 if (show && (this._animation.playState() === "idle" || !bezier)) | 1134 if (show && (this._animation.playState() === "idle" || !bezier)) |
| 1057 return; | 1135 return; |
| 1058 this._bezierIconElement.classList.toggle("shown", show); | 1136 this._bezierIconElement.classList.toggle("shown", show); |
| 1059 }, | 1137 }, |
| 1060 | 1138 |
| 1061 /** | 1139 /** |
| 1140 * @return {string} |
| 1141 */ |
| 1142 _animationProperty: function() |
| 1143 { |
| 1144 return this._animation.type() === "CSSTransition" ? "transition" : "anim
ation"; |
| 1145 }, |
| 1146 |
| 1147 /** |
| 1062 * @param {string} value | 1148 * @param {string} value |
| 1063 */ | 1149 */ |
| 1064 _setEasing: function(value) | 1150 setEasing: function(value) |
| 1065 { | 1151 { |
| 1066 if (!this._node || this._animation.source().easing() == value) | 1152 if (!this._node) |
| 1067 return; | 1153 return; |
| 1068 | 1154 |
| 1155 this.innerSetEasing(value); |
| 1156 |
| 1157 if (this._animation.type() !== "WebAnimation") { |
| 1158 var style = this._node.getAttribute("style") || ""; |
| 1159 style = style.replace(new RegExp("\\s*(-webkit-)?" + this._animation
Property() + "-timing-function:[^;]*;?\\s*", "g"), ""); |
| 1160 this._node.setAttributeValue("style", String.sprintf("%s %s-timing-f
unction: %s;", style, this._animationProperty(), value)); |
| 1161 } |
| 1162 |
| 1163 this.redraw(); |
| 1164 this.dispatchEventToListeners(WebInspector.AnimationUI.Events.EasingChan
ged, { "animationId": this._animation.id(), "animationType": this._animation.typ
e(), "easing": value }); |
| 1165 }, |
| 1166 |
| 1167 /** |
| 1168 * @param {string} value |
| 1169 */ |
| 1170 innerSetEasing: function(value) |
| 1171 { |
| 1069 this._animation.source().setEasing(value); | 1172 this._animation.source().setEasing(value); |
| 1070 this.redraw(); | |
| 1071 | 1173 |
| 1072 var animationType = this._animation.type(); | 1174 if (this._animation.type() !== "CSSAnimation") { |
| 1073 if (animationType !== "CSSAnimation") { | |
| 1074 var target = WebInspector.targetManager.mainTarget(); | 1175 var target = WebInspector.targetManager.mainTarget(); |
| 1075 if (target) | 1176 if (target) |
| 1076 target.animationAgent().setEasing(this._animation.id(), value); | 1177 target.animationAgent().setEasing(this._animation.id(), value); |
| 1077 } | 1178 } |
| 1078 | |
| 1079 if (animationType !== "WebAnimation") | |
| 1080 this._setNodeStyle(animationType === "CSSTransition" ? "transition-t
iming-function" : "animation-timing-function", value); | |
| 1081 }, | 1179 }, |
| 1082 | 1180 |
| 1083 /** | 1181 /** |
| 1084 * @param {number} value | 1182 * @param {number} delay |
| 1183 * @param {number} duration |
| 1085 */ | 1184 */ |
| 1086 _setDelay: function(value) | 1185 _setDelayDuration: function(delay, duration) |
| 1087 { | 1186 { |
| 1088 if (!this._node || this._animation.source().delay() == this._delay()) | 1187 if (!this._node) |
| 1089 return; | 1188 return; |
| 1090 | 1189 |
| 1091 this._animation.source().setDelay(this._delay()); | 1190 this.innerSetDelayDuration(delay, duration); |
| 1092 var propertyName; | 1191 |
| 1093 if (this._animation.type() == "CSSTransition") | 1192 if (this._animation.type() === "WebAnimation") { |
| 1094 propertyName = "transition-delay"; | 1193 var style = this._node.getAttribute("style") || ""; |
| 1095 else if (this._animation.type() == "CSSAnimation") | 1194 style = style.replace(new RegExp("\\s*(-webkit-)?" + this._animation
Property() + "-(delay|duration):[^;]*;?\\s*", "g"), ""); |
| 1096 propertyName = "animation-delay"; | 1195 this._node.setAttributeValue("style", String.sprintf("%s %s-delay: %
sms; %s-duration: %sms;", style, this._animationProperty(), Math.round(delay), t
his._animationProperty(), Math.round(duration))); |
| 1097 else | 1196 } |
| 1098 return; | 1197 |
| 1099 this._setNodeStyle(propertyName, Math.round(value) + "ms"); | 1198 this.dispatchEventToListeners(WebInspector.AnimationUI.Events.TimingChan
ged, { "animationId": this._animation.id(), "animationType": this._animation.typ
e(), "delay": delay, "duration": duration }); |
| 1100 }, | 1199 }, |
| 1101 | 1200 |
| 1102 /** | 1201 /** |
| 1103 * @param {number} value | 1202 * @param {number} delay |
| 1203 * @param {number} duration |
| 1104 */ | 1204 */ |
| 1105 _setDuration: function(value) | 1205 innerSetDelayDuration: function(delay, duration) |
| 1106 { | 1206 { |
| 1107 if (!this._node || this._animation.source().duration() == value) | 1207 this._animation.source().setDelay(delay); |
| 1108 return; | 1208 this._animation.source().setDuration(duration); |
| 1109 | 1209 |
| 1110 this._animation.source().setDuration(value); | 1210 if (this._animation.type() !== "CSSAnimation") { |
| 1111 var propertyName; | 1211 var target = WebInspector.targetManager.mainTarget(); |
| 1112 if (this._animation.type() == "CSSTransition") | 1212 if (target) |
| 1113 propertyName = "transition-duration"; | 1213 target.animationAgent().setTiming(this._animation.id(), duration
, delay); |
| 1114 else if (this._animation.type() == "CSSAnimation") | 1214 } |
| 1115 propertyName = "animation-duration"; | |
| 1116 else | |
| 1117 return; | |
| 1118 this._setNodeStyle(propertyName, Math.round(value) + "ms"); | |
| 1119 }, | 1215 }, |
| 1120 | 1216 |
| 1121 /** | 1217 /** |
| 1122 * @param {string} name | |
| 1123 * @param {string} value | |
| 1124 */ | |
| 1125 _setNodeStyle: function(name, value) | |
| 1126 { | |
| 1127 var style = this._node.getAttribute("style") || ""; | |
| 1128 if (style) | |
| 1129 style = style.replace(new RegExp("\\s*(-webkit-)?" + name + ":[^;]*;
?\\s*", "g"), ""); | |
| 1130 var valueString = name + ": " + value; | |
| 1131 this._node.setAttributeValue("style", style + " " + valueString + ";"); | |
| 1132 }, | |
| 1133 | |
| 1134 /** | |
| 1135 * @return {string} | 1218 * @return {string} |
| 1136 */ | 1219 */ |
| 1137 _color: function() | 1220 _color: function() |
| 1138 { | 1221 { |
| 1139 /** | 1222 /** |
| 1140 * @param {string} string | 1223 * @param {string} string |
| 1141 * @return {number} | 1224 * @return {number} |
| 1142 */ | 1225 */ |
| 1143 function hash(string) | 1226 function hash(string) |
| 1144 { | 1227 { |
| 1145 var hash = 0; | 1228 var hash = 0; |
| 1146 for (var i = 0; i < string.length; i++) | 1229 for (var i = 0; i < string.length; i++) |
| 1147 hash = (hash << 5) + hash + string.charCodeAt(i); | 1230 hash = (hash << 5) + hash + string.charCodeAt(i); |
| 1148 return Math.abs(hash); | 1231 return Math.abs(hash); |
| 1149 } | 1232 } |
| 1150 | 1233 |
| 1151 if (!this._selectedColor) { | 1234 if (!this._selectedColor) { |
| 1152 var names = Object.keys(WebInspector.AnimationUI.Colors); | 1235 var names = Object.keys(WebInspector.AnimationUI.Colors); |
| 1153 var color = WebInspector.AnimationUI.Colors[names[hash(this._animati
on.name() || this._animation.id()) % names.length]]; | 1236 var color = WebInspector.AnimationUI.Colors[names[hash(this._animati
on.name() || this._animation.id()) % names.length]]; |
| 1154 this._selectedColor = color.asString(WebInspector.Color.Format.RGB); | 1237 this._selectedColor = color.asString(WebInspector.Color.Format.RGB); |
| 1155 } | 1238 } |
| 1156 return this._selectedColor; | 1239 return this._selectedColor; |
| 1157 } | 1240 }, |
| 1241 |
| 1242 __proto__: WebInspector.Object.prototype |
| 1158 } | 1243 } |
| 1159 | 1244 |
| 1160 WebInspector.AnimationUI.Options = { | 1245 WebInspector.AnimationUI.Options = { |
| 1161 AnimationHeight: 32, | 1246 AnimationHeight: 32, |
| 1162 AnimationSVGHeight: 80, | 1247 AnimationSVGHeight: 80, |
| 1163 AnimationMargin: 7, | 1248 AnimationMargin: 7, |
| 1164 EndpointsClickRegionSize: 10, | 1249 EndpointsClickRegionSize: 10, |
| 1165 GridCanvasHeight: 40 | 1250 GridCanvasHeight: 40 |
| 1166 } | 1251 } |
| 1167 | 1252 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 /** | 1318 /** |
| 1234 * @param {boolean=} commitEdit | 1319 * @param {boolean=} commitEdit |
| 1235 */ | 1320 */ |
| 1236 _hide: function(commitEdit) | 1321 _hide: function(commitEdit) |
| 1237 { | 1322 { |
| 1238 if (!this._popover.isShowing()) | 1323 if (!this._popover.isShowing()) |
| 1239 return; | 1324 return; |
| 1240 this._anchorElement.classList.remove("bezier-editor-open"); | 1325 this._anchorElement.classList.remove("bezier-editor-open"); |
| 1241 this._bezierEditor.removeEventListener(WebInspector.BezierEditor.Events.
BezierChanged, this._bezierChanged, this); | 1326 this._bezierEditor.removeEventListener(WebInspector.BezierEditor.Events.
BezierChanged, this._bezierChanged, this); |
| 1242 if (!commitEdit) | 1327 if (!commitEdit) |
| 1243 this._animationUI._setEasing(this._originalEasing); | 1328 this._animationUI.setEasing(this._originalEasing); |
| 1329 |
| 1244 this._popover.hide(); | 1330 this._popover.hide(); |
| 1245 this._bezierEditor.detach(); | 1331 this._bezierEditor.detach(); |
| 1246 this._bezierEditor.contentElement.removeEventListener("keydown", this._b
oundOnKeyDown); | 1332 this._bezierEditor.contentElement.removeEventListener("keydown", this._b
oundOnKeyDown); |
| 1247 this._bezierEditor.contentElement.removeEventListener("focusout", this._
boundOnFocusOut); | 1333 this._bezierEditor.contentElement.removeEventListener("focusout", this._
boundOnFocusOut); |
| 1248 WebInspector.setCurrentFocusElement(this._previousFocusElement); | 1334 WebInspector.setCurrentFocusElement(this._previousFocusElement); |
| 1249 }, | 1335 }, |
| 1250 | 1336 |
| 1251 /** | 1337 /** |
| 1252 * @param {!Event} event | 1338 * @param {!Event} event |
| 1253 */ | 1339 */ |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1270 this._hide(false); | 1356 this._hide(false); |
| 1271 event.consume(true); | 1357 event.consume(true); |
| 1272 } | 1358 } |
| 1273 }, | 1359 }, |
| 1274 | 1360 |
| 1275 /** | 1361 /** |
| 1276 * @param {!WebInspector.Event} event | 1362 * @param {!WebInspector.Event} event |
| 1277 */ | 1363 */ |
| 1278 _bezierChanged: function(event) | 1364 _bezierChanged: function(event) |
| 1279 { | 1365 { |
| 1280 this._animationUI._setEasing(/** @type {string} */ (event.data)); | 1366 this._animationUI.setEasing(/** @type {string} */ (event.data)); |
| 1281 } | 1367 } |
| 1282 } | 1368 } |
| OLD | NEW |