Index: Source/devtools/front_end/elements/AnimationsSidebarPane.js |
diff --git a/Source/devtools/front_end/elements/AnimationsSidebarPane.js b/Source/devtools/front_end/elements/AnimationsSidebarPane.js |
index 417854d28df64e9577976ff0ef8612e26c97e033..bc0a14a93278327444128bcec7dfafb0c340524d 100644 |
--- a/Source/devtools/front_end/elements/AnimationsSidebarPane.js |
+++ b/Source/devtools/front_end/elements/AnimationsSidebarPane.js |
@@ -11,16 +11,42 @@ WebInspector.AnimationsSidebarPane = function(stylesPane) |
WebInspector.ElementsSidebarPane.call(this, WebInspector.UIString("Animations")); |
this._stylesPane = stylesPane; |
+ this.headerElement = createElementWithClass("div", "animationsSettings"); |
+ this._showSubtreeSetting = WebInspector.settings.createSetting("showSubtreeAnimations", true); |
+ this.headerElement.appendChild(WebInspector.AnimationsSidebarPane._showSubtreeAnimationsCheckbox(this._showSubtreeSetting)); |
+ this._showSubtreeSetting.addChangeListener(this._showSubtreeSettingChanged.bind(this)); |
this._emptyElement = createElement("div"); |
this._emptyElement.className = "info"; |
this._emptyElement.textContent = WebInspector.UIString("No Animations"); |
+ this.animationsElement = createElement("div"); |
+ this.animationsElement.appendChild(this._emptyElement); |
this._animationSections = []; |
- this.bodyElement.appendChild(this._emptyElement); |
+ this.bodyElement.appendChild(this.headerElement); |
+ this.bodyElement.appendChild(this.animationsElement); |
+} |
+ |
+/** |
+ * @param {!WebInspector.Setting} setting |
+ * @return {!Element} |
+ */ |
+WebInspector.AnimationsSidebarPane._showSubtreeAnimationsCheckbox = function(setting) |
+{ |
+ if (!WebInspector.AnimationsSidebarPane._showSubtreeAnimationsCheckboxElement) { |
+ WebInspector.AnimationsSidebarPane._showSubtreeAnimationsCheckboxElement = WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Show subtree animations"), setting, true); |
+ WebInspector.AnimationsSidebarPane._showSubtreeAnimationsCheckboxElement.classList.add("checkbox-with-label"); |
+ } |
+ return WebInspector.AnimationsSidebarPane._showSubtreeAnimationsCheckboxElement; |
} |
WebInspector.AnimationsSidebarPane.prototype = { |
+ _showSubtreeSettingChanged: function() |
+ { |
+ this._forceUpdate = true; |
+ this.update(); |
+ }, |
+ |
/** |
* @param {!WebInspector.Throttler.FinishCallback} finishCallback |
* @protected |
@@ -33,37 +59,38 @@ WebInspector.AnimationsSidebarPane.prototype = { |
*/ |
function animationPlayersCallback(animationPlayers) |
{ |
- this.bodyElement.removeChildren(); |
+ this.animationsElement.removeChildren(); |
this._animationSections = []; |
if (!animationPlayers || !animationPlayers.length) { |
- this.bodyElement.appendChild(this._emptyElement); |
+ this.animationsElement.appendChild(this._emptyElement); |
finishCallback(); |
return; |
} |
- |
for (var i = 0; i < animationPlayers.length; ++i) { |
var player = animationPlayers[i]; |
- this._animationSections[i] = new WebInspector.AnimationSection(this, player); |
- var separatorElement = this.bodyElement.createChild("div", "sidebar-separator"); |
- separatorElement.createTextChild(WebInspector.UIString("Animation") + " " + player.name()); |
- this.bodyElement.appendChild(this._animationSections[i].element); |
- |
- if (player.source().keyframesRule()) { |
- var keyframes = player.source().keyframesRule().keyframes(); |
- for (var j = 0; j < keyframes.length; j++) { |
- var style = { selectorText: keyframes[j].offset(), style: keyframes[j].style(), isAttribute: true }; |
- var section = new WebInspector.StylePropertiesSection(this._stylesPane, style, true, false); |
- section.expanded = true; |
- this.bodyElement.appendChild(section.element); |
- } |
- } |
+ this._animationSections[i] = new WebInspector.AnimationSection(this, this._stylesPane, player); |
+ if (animationPlayers.length < 5) |
+ this._animationSections[i].expand(true); |
+ this.animationsElement.appendChild(this._animationSections[i].element); |
} |
finishCallback(); |
} |
- if (!this.node()) |
+ if (!this.node()) { |
+ finishCallback(); |
+ return; |
+ } |
+ |
+ if (!this._forceUpdate && this._selectedNode === this.node()) { |
+ for (var i = 0; i < this._animationSections.length; ++i) |
+ this._animationSections[i].updateCurrentTime(); |
+ finishCallback(); |
return; |
- this.node().target().animationModel.getAnimationPlayers(this.node().id, animationPlayersCallback.bind(this)); |
+ } |
+ |
+ this._forceUpdate = false; |
+ this._selectedNode = this.node(); |
+ this.node().target().animationModel.getAnimationPlayers(this.node().id, this._showSubtreeSetting.get(), animationPlayersCallback.bind(this)); |
}, |
__proto__: WebInspector.ElementsSidebarPane.prototype |
@@ -72,28 +99,57 @@ WebInspector.AnimationsSidebarPane.prototype = { |
/** |
* @constructor |
* @param {!WebInspector.AnimationsSidebarPane} parentPane |
+ * @param {!WebInspector.StylesSidebarPane} stylesPane |
* @param {?WebInspector.AnimationModel.AnimationPlayer} animationPlayer |
*/ |
-WebInspector.AnimationSection = function(parentPane, animationPlayer) |
+WebInspector.AnimationSection = function(parentPane, stylesPane, animationPlayer) |
{ |
this._parentPane = parentPane; |
- this.propertiesSection = createElement("div"); |
+ this._stylesPane = stylesPane; |
+ this._propertiesElement = createElement("div"); |
+ this._keyframesElement = createElement("div"); |
this._setAnimationPlayer(animationPlayer); |
- this.element = createElement("div"); |
- this.element.className = "styles-section"; |
- |
this._updateThrottler = new WebInspector.Throttler(WebInspector.AnimationSection.updateTimeout); |
- this.element.appendChild(this._createAnimationControls()); |
- this.element.appendChild(this.propertiesSection); |
+ |
+ this.element = createElement("div"); |
+ this.element.appendChild(this._createHeader()); |
+ this.bodyElement = this.element.createChild("div", "animationSectionBody"); |
+ this.bodyElement.appendChild(this._createAnimationControls()); |
+ this.bodyElement.appendChild(this._propertiesElement); |
+ this.bodyElement.appendChild(this._keyframesElement); |
} |
WebInspector.AnimationSection.updateTimeout = 100; |
WebInspector.AnimationSection.prototype = { |
+ /** |
+ * @return {boolean} |
+ */ |
+ _expanded: function() |
+ { |
+ return this.bodyElement.classList.contains("expanded"); |
+ }, |
+ |
+ _toggle: function() |
+ { |
+ this.bodyElement.classList.toggle("expanded"); |
+ this.updateCurrentTime(); |
+ }, |
+ |
+ /** |
+ * @param {boolean} expanded |
+ */ |
+ expand: function(expanded) |
+ { |
+ this.bodyElement.classList.toggle("expanded", expanded); |
+ this.updateCurrentTime(); |
+ }, |
+ |
updateCurrentTime: function() |
{ |
- this._updateThrottler.schedule(this._updateCurrentTime.bind(this), false); |
+ if (this._expanded()) |
+ this._updateThrottler.schedule(this._updateCurrentTime.bind(this), false); |
}, |
/** |
@@ -154,6 +210,28 @@ WebInspector.AnimationSection.prototype = { |
/** |
* @return {!Element} |
*/ |
+ _createHeader: function() |
+ { |
+ /** |
+ * @param {?WebInspector.DOMNode} node |
+ */ |
+ function nodeResolved(node) |
+ { |
+ headerElement.addEventListener("mouseover", node.highlight.bind(node, undefined, undefined), false); |
+ headerElement.addEventListener("mouseleave", node.domModel().hideDOMNodeHighlight.bind(node.domModel()), false); |
+ } |
+ |
+ var headerElement = createElementWithClass("div", "sidebar-separator"); |
+ var id = this.player.source().name() ? this.player.source().name() : this.player.id(); |
+ headerElement.createTextChild(WebInspector.UIString("Animation") + " " + id); |
+ headerElement.addEventListener("click", this._toggle.bind(this), false); |
+ this.player.source().getNode(nodeResolved); |
+ return headerElement; |
+ }, |
+ |
+ /** |
+ * @return {!Element} |
+ */ |
_createAnimationControls: function() |
{ |
/** |
@@ -202,7 +280,7 @@ WebInspector.AnimationSection.prototype = { |
if (!p || p === this.player) |
return; |
this.player = p; |
- this.propertiesSection.removeChildren(); |
+ this._propertiesElement.removeChildren(); |
var animationObject = { |
"playState": p.playState(), |
"start-time": p.startTime(), |
@@ -218,7 +296,17 @@ WebInspector.AnimationSection.prototype = { |
"time-fraction": p.source().timeFraction() |
}; |
var obj = WebInspector.RemoteObject.fromLocalObject(animationObject); |
- var section = new WebInspector.ObjectPropertiesSection(obj, WebInspector.UIString("Animation Properties")); |
- this.propertiesSection.appendChild(section.element); |
+ var objSection = new WebInspector.ObjectPropertiesSection(obj, WebInspector.UIString("Animation Properties")); |
+ this._propertiesElement.appendChild(objSection.element); |
+ |
+ if (this.player.source().keyframesRule()) { |
+ var keyframes = this.player.source().keyframesRule().keyframes(); |
+ for (var j = 0; j < keyframes.length; j++) { |
+ var inlineStyle = { selectorText: keyframes[j].offset(), style: keyframes[j].style(), isAttribute: true }; |
+ var styleSection = new WebInspector.StylePropertiesSection(this._stylesPane, inlineStyle, true, false); |
+ styleSection.expanded = true; |
+ this._keyframesElement.appendChild(styleSection.element); |
+ } |
+ } |
} |
} |