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

Unified Diff: third_party/WebKit/Source/devtools/front_end/elements/ElementStatePaneWidget.js

Issue 2140753003: DevTools: remove BaseToolbarPaneWidget. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lcean Created 4 years, 5 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: third_party/WebKit/Source/devtools/front_end/elements/ElementStatePaneWidget.js
diff --git a/third_party/WebKit/Source/devtools/front_end/elements/ElementStatePaneWidget.js b/third_party/WebKit/Source/devtools/front_end/elements/ElementStatePaneWidget.js
index 17da5aba62ae1eedcb24cc9d254e446065d38c73..b008343bf8eace6eaf26b0af4393adeee6cf903c 100644
--- a/third_party/WebKit/Source/devtools/front_end/elements/ElementStatePaneWidget.js
+++ b/third_party/WebKit/Source/devtools/front_end/elements/ElementStatePaneWidget.js
@@ -4,12 +4,11 @@
/**
* @constructor
- * @extends {WebInspector.ElementsPanel.BaseToolbarPaneWidget}
- * @param {!WebInspector.ToolbarItem} toolbarItem
+ * @extends {WebInspector.Widget}
*/
-WebInspector.ElementStatePaneWidget = function(toolbarItem)
+WebInspector.ElementStatePaneWidget = function()
{
- WebInspector.ElementsPanel.BaseToolbarPaneWidget.call(this, toolbarItem);
+ WebInspector.Widget.call(this);
this.element.className = "styles-element-state-pane";
this.element.createChild("div").createTextChild(WebInspector.UIString("Force element state"));
var table = createElementWithClass("table", "source-code");
@@ -53,6 +52,7 @@ WebInspector.ElementStatePaneWidget = function(toolbarItem)
tr.appendChild(createCheckbox.call(null, "visited"));
this.element.appendChild(table);
+ WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this._update, this);
}
WebInspector.ElementStatePaneWidget.prototype = {
@@ -66,40 +66,33 @@ WebInspector.ElementStatePaneWidget.prototype = {
if (this._target) {
var cssModel = WebInspector.CSSModel.fromTarget(this._target);
- cssModel.removeEventListener(WebInspector.CSSModel.Events.PseudoStateForced, this._pseudoStateForced, this)
+ cssModel.removeEventListener(WebInspector.CSSModel.Events.PseudoStateForced, this._update, this)
}
this._target = target;
if (target) {
var cssModel = WebInspector.CSSModel.fromTarget(target);
- cssModel.addEventListener(WebInspector.CSSModel.Events.PseudoStateForced, this._pseudoStateForced, this)
+ cssModel.addEventListener(WebInspector.CSSModel.Events.PseudoStateForced, this._update, this)
}
},
/**
- * @param {!WebInspector.Event} event
- */
- _pseudoStateForced: function(event)
- {
- this.update();
- },
-
- /**
* @override
- * @param {?WebInspector.DOMNode} newNode
*/
- onNodeChanged: function(newNode)
+ wasShown: function()
{
- this._updateTarget(newNode ? newNode.target() : null);
- this.update();
+ this._update();
},
- /**
- * @override
- * @return {!Promise.<?>}
- */
- doUpdate: function()
+ _update: function()
{
+ if (!this.isShowing())
+ return;
+
var node = WebInspector.context.flavor(WebInspector.DOMNode);
+ if (node)
+ node = node.enclosingElementOrSelf();
+
+ this._updateTarget(node ? node.target() : null);
if (node) {
var nodePseudoState = WebInspector.CSSModel.fromNode(node).pseudoState(node);
for (var input of this._inputs) {
@@ -112,10 +105,9 @@ WebInspector.ElementStatePaneWidget.prototype = {
input.checked = false;
}
}
- return Promise.resolve();
},
- __proto__: WebInspector.ElementsPanel.BaseToolbarPaneWidget.prototype
+ __proto__: WebInspector.Widget.prototype
}
/**
@@ -127,15 +119,13 @@ WebInspector.ElementStatePaneWidget.ButtonProvider = function()
this._button = new WebInspector.ToolbarToggle(WebInspector.UIString("Toggle Element State"), "", WebInspector.UIString(":hov"));
this._button.addEventListener("click", this._clicked, this);
this._button.element.classList.add("monospace");
- this._view = new WebInspector.ElementStatePaneWidget(this.item());
- WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this._nodeChanged, this);
- this._nodeChanged();
+ this._view = new WebInspector.ElementStatePaneWidget();
}
WebInspector.ElementStatePaneWidget.ButtonProvider.prototype = {
_clicked: function()
{
- WebInspector.ElementsPanel.instance().showToolbarPane(!this._view.isShowing() ? this._view : null);
+ WebInspector.ElementsPanel.instance().showToolbarPane(!this._view.isShowing() ? this._view : null, this._button);
},
/**
@@ -145,13 +135,5 @@ WebInspector.ElementStatePaneWidget.ButtonProvider.prototype = {
item: function()
{
return this._button;
- },
-
- _nodeChanged: function()
- {
- var enabled = !!WebInspector.context.flavor(WebInspector.DOMNode);
- this._button.setEnabled(enabled);
- if (!enabled && this._button.toggled())
- WebInspector.ElementsPanel.instance().showToolbarPane(null);
}
}

Powered by Google App Engine
This is Rietveld 408576698