Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1414)

Unified Diff: Source/devtools/front_end/elements/StylesSidebarPane.js

Issue 1149373004: Devtools: Extensible toolbar in SSP (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix naming Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/elements/StylesSidebarPane.js
diff --git a/Source/devtools/front_end/elements/StylesSidebarPane.js b/Source/devtools/front_end/elements/StylesSidebarPane.js
index 6c2a2b7098697c3266d12d34e92e3d175c7d1c90..b46f93c2f336ef4477c33efc6aa11855895a554a 100644
--- a/Source/devtools/front_end/elements/StylesSidebarPane.js
+++ b/Source/devtools/front_end/elements/StylesSidebarPane.js
@@ -40,30 +40,11 @@ WebInspector.StylesSidebarPane = function(requestShowCallback)
WebInspector.moduleSetting("colorFormat").addChangeListener(this.update.bind(this));
WebInspector.moduleSetting("textEditorIndent").addChangeListener(this.update.bind(this));
- var toolbar = new WebInspector.Toolbar(this.titleElement);
+ var toolbar = new WebInspector.ExtensibleToolbar("styles-sidebarpane-toolbar", this.titleElement);
toolbar.element.classList.add("styles-pane-toolbar");
toolbar.makeNarrow();
- var addNewStyleRuleButton = new WebInspector.ToolbarButton(WebInspector.UIString("New Style Rule"), "add-toolbar-item");
- addNewStyleRuleButton.makeLongClickEnabled();
- addNewStyleRuleButton.addEventListener("click", this._createNewRuleInViaInspectorStyleSheet, this);
- addNewStyleRuleButton.addEventListener("longClickDown", this._onAddButtonLongClick, this);
- toolbar.appendToolbarItem(addNewStyleRuleButton);
-
- this._elementStateButton = new WebInspector.ToolbarButton(WebInspector.UIString("Toggle Element State"), "element-state-toolbar-item");
- this._elementStateButton.addEventListener("click", this._toggleElementStatePane, this);
- toolbar.appendToolbarItem(this._elementStateButton);
-
- this._animationsControlButton = new WebInspector.ToolbarButton(WebInspector.UIString("Animations Controls"), "animation-toolbar-item");
- this._animationsControlButton.addEventListener("click", this._toggleAnimationsControlPane, this);
- toolbar.appendToolbarItem(this._animationsControlButton);
-
this._requestShowCallback = requestShowCallback;
-
- this._createElementStatePane();
- this.bodyElement.appendChild(this._elementStatePane);
- this._animationsControlPane = new WebInspector.AnimationControlPane();
- this.bodyElement.appendChild(this._animationsControlPane.element);
this._sectionsContainer = createElement("div");
this.bodyElement.appendChild(this._sectionsContainer);
@@ -306,34 +287,6 @@ WebInspector.StylesSidebarPane.prototype = {
},
/**
- * @return {?T}
- * @template T
- */
- _forcedPseudoClasses: function()
- {
- return this.node() ? (this.node().getUserProperty(WebInspector.CSSStyleModel.PseudoStatePropertyName) || undefined) : undefined;
- },
-
- _updateForcedPseudoStateInputs: function()
- {
- var node = this.node();
- if (!node || !WebInspector.CSSStyleModel.fromNode(node).isEnabled())
- return;
-
- var hasPseudoType = !!node.pseudoType();
- this._elementStateButton.setEnabled(!hasPseudoType);
- this._elementStatePane.classList.toggle("expanded", !hasPseudoType && this._elementStateButton.toggled());
-
- var nodePseudoState = this._forcedPseudoClasses();
- if (!nodePseudoState)
- nodePseudoState = [];
-
- var inputs = this._elementStatePane.inputs;
- for (var i = 0; i < inputs.length; ++i)
- inputs[i].checked = nodePseudoState.indexOf(inputs[i].state) >= 0;
- },
-
- /**
* @override
* @param {?WebInspector.DOMNode} node
*/
@@ -353,9 +306,6 @@ WebInspector.StylesSidebarPane.prototype = {
node = WebInspector.SharedSidebarModel.elementNode(node);
this._resetCache();
- this._animationsControlPane.setNode(node);
- if (this._animationTimeline)
- this._animationTimeline.setNode(node);
WebInspector.ElementsSidebarPane.prototype.setNode.call(this, node);
},
@@ -387,7 +337,6 @@ WebInspector.StylesSidebarPane.prototype = {
*/
doUpdate: function(finishedCallback)
{
- this._updateForcedPseudoStateInputs();
this._discardElementUnderMouse();
this.fetchMatchedCascade()
@@ -776,85 +725,6 @@ WebInspector.StylesSidebarPane.prototype = {
}
},
- _toggleElementStatePane: function()
- {
- var buttonToggled = !this._elementStateButton.toggled();
- if (buttonToggled)
- this.expand();
- this._elementStateButton.setToggled(buttonToggled);
- this._elementStatePane.classList.toggle("expanded", buttonToggled);
- if (!Runtime.experiments.isEnabled("animationInspection"))
- this._animationsControlButton.setToggled(false);
- this._animationsControlPane.element.classList.remove("expanded");
- },
-
- _createElementStatePane: function()
- {
- this._elementStatePane = createElement("div");
- this._elementStatePane.className = "styles-element-state-pane source-code";
- var table = createElement("table");
-
- var inputs = [];
- this._elementStatePane.inputs = inputs;
-
- /**
- * @param {!Event} event
- * @this {WebInspector.StylesSidebarPane}
- */
- function clickListener(event)
- {
- var node = this.node();
- if (!node)
- return;
- WebInspector.CSSStyleModel.fromNode(node).forcePseudoState(node, event.target.state, event.target.checked);
- }
-
- /**
- * @param {string} state
- * @return {!Element}
- * @this {WebInspector.StylesSidebarPane}
- */
- function createCheckbox(state)
- {
- var td = createElement("td");
- var label = createCheckboxLabel(":" + state);
- var input = label.checkboxElement;
- input.state = state;
- input.addEventListener("click", clickListener.bind(this), false);
- inputs.push(input);
- td.appendChild(label);
- return td;
- }
-
- var tr = table.createChild("tr");
- tr.appendChild(createCheckbox.call(this, "active"));
- tr.appendChild(createCheckbox.call(this, "hover"));
-
- tr = table.createChild("tr");
- tr.appendChild(createCheckbox.call(this, "focus"));
- tr.appendChild(createCheckbox.call(this, "visited"));
-
- this._elementStatePane.appendChild(table);
- },
-
- _toggleAnimationsControlPane: function()
- {
- var buttonToggled = !this._animationsControlButton.toggled();
- if (buttonToggled)
- this.expand();
- this._animationsControlButton.setToggled(buttonToggled);
- if (Runtime.experiments.isEnabled("animationInspection")) {
- if (!this._animationTimeline)
- this._animationTimeline = new WebInspector.AnimationTimeline();
- var elementsPanel = WebInspector.ElementsPanel.instance();
- elementsPanel.setWidgetBelowDOM(buttonToggled ? this._animationTimeline : null);
- } else {
- this._animationsControlPane.element.classList.toggle("expanded", buttonToggled);
- this._elementStateButton.setToggled(false);
- this._elementStatePane.classList.remove("expanded");
- }
- },
-
/**
* @return {?RegExp}
*/
@@ -933,6 +803,21 @@ WebInspector.StylesSidebarPane.prototype = {
}
},
+ /**
+ * @param {?WebInspector.Widget} widget
+ */
+ showToolbarPane: function(widget)
+ {
+ if (this._currentToolbarPane) {
+ this._currentToolbarPane.detach();
+ this._currentToolbarPane = null;
+ }
+ if (widget) {
+ this._currentToolbarPane = widget;
+ this._currentToolbarPane.show(this.bodyElement, this._sectionsContainer);
+ }
+ },
+
__proto__: WebInspector.ElementsSidebarPane.prototype
}
@@ -3248,3 +3133,80 @@ WebInspector.StylesSidebarPane.MatchedRulesPayload.prototype = {
return !!(this.matchedCSSRules && this.pseudoElements && this.inherited);
}
}
+
+/**
+ * @constructor
+ * @extends {WebInspector.Widget}
+ * @param {!WebInspector.ToolbarItem} toolbarItem
+ */
+WebInspector.StylesSidebarPane.BaseToolbarPaneWidget = function(toolbarItem)
+{
+ WebInspector.Widget.call(this);
+ this._toolbarItem = toolbarItem;
+ WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this._nodeChanged, this);
+}
+
+WebInspector.StylesSidebarPane.BaseToolbarPaneWidget.prototype = {
+ _nodeChanged: function()
+ {
+ if (!this.isShowing())
+ return;
+
+ var elementNode = WebInspector.SharedSidebarModel.elementNode(WebInspector.context.flavor(WebInspector.DOMNode));
+ this.onNodeChanged(elementNode);
+ },
+
+ /**
+ * @param {?WebInspector.DOMNode} newNode
+ * @protected
+ */
+ onNodeChanged: function(newNode)
+ {
+ },
+
+ willHide: function()
lushnikov 2015/05/29 13:38:47 @override?
sergeyv 2015/05/29 13:43:18 Done.
+ {
+ this._toolbarItem.setToggled(false);
+ },
+
+ wasShown: function()
lushnikov 2015/05/29 13:38:47 ditto
sergeyv 2015/05/29 13:43:18 Done.
+ {
+ this._toolbarItem.setToggled(true);
+ var elementNode = WebInspector.SharedSidebarModel.elementNode(WebInspector.context.flavor(WebInspector.DOMNode));
lushnikov 2015/05/29 13:38:47 this._nodeChanged() ?
sergeyv 2015/05/29 13:43:18 Done.
+ this.onNodeChanged(elementNode);
+ },
+
+ __proto__: WebInspector.Widget.prototype
+}
+
+/**
+ * @constructor
+ * @implements {WebInspector.ToolbarItem.Provider}
+ */
+WebInspector.StylesSidebarPane.AddNewRuleButtonProvider = function()
+{
+ this._button = new WebInspector.ToolbarButton(WebInspector.UIString("New Style Rule"), "add-toolbar-item");
+ this._button.makeLongClickEnabled();
+ var stylesSidebarPane = WebInspector.ElementsPanel.instance().sidebarPanes.styles;
+ this._button.addEventListener("click", stylesSidebarPane._createNewRuleInViaInspectorStyleSheet, stylesSidebarPane);
+ this._button.addEventListener("longClickDown", stylesSidebarPane._onAddButtonLongClick, stylesSidebarPane);
+ WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this._onNodeChanged, this);
+ this._onNodeChanged()
+}
+
+WebInspector.StylesSidebarPane.AddNewRuleButtonProvider.prototype = {
+ _onNodeChanged: function()
+ {
+ var node = WebInspector.context.flavor(WebInspector.DOMNode);
+ this.item().setEnabled(!!node);
+ },
+
+ /**
+ * @override
+ * @return {?WebInspector.ToolbarItem}
+ */
+ item: function()
+ {
+ return this._button;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698