| 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.StylesSidebarPane.BaseToolbarPaneWidget} | 7 * @extends {WebInspector.StylesSidebarPane.BaseToolbarPaneWidget} |
| 8 * @param {!WebInspector.ToolbarItem} toolbarItem | 8 * @param {!WebInspector.ToolbarItem} toolbarItem |
| 9 */ | 9 */ |
| 10 WebInspector.ElementStatePaneWidget = function(toolbarItem) | 10 WebInspector.ElementStatePaneWidget = function(toolbarItem) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 tr = table.createChild("tr"); | 50 tr = table.createChild("tr"); |
| 51 tr.appendChild(createCheckbox.call(null, "focus")); | 51 tr.appendChild(createCheckbox.call(null, "focus")); |
| 52 tr.appendChild(createCheckbox.call(null, "visited")); | 52 tr.appendChild(createCheckbox.call(null, "visited")); |
| 53 | 53 |
| 54 this.element.appendChild(table); | 54 this.element.appendChild(table); |
| 55 } | 55 } |
| 56 | 56 |
| 57 WebInspector.ElementStatePaneWidget.prototype = { | 57 WebInspector.ElementStatePaneWidget.prototype = { |
| 58 /** | 58 /** |
| 59 * @param {?WebInspector.Target} target |
| 60 */ |
| 61 _updateTarget: function(target) |
| 62 { |
| 63 if (this._target === target) |
| 64 return; |
| 65 |
| 66 if (this._target) { |
| 67 var cssModel = WebInspector.CSSStyleModel.fromTarget(this._target); |
| 68 cssModel.removeEventListener(WebInspector.CSSStyleModel.Events.Pseud
oStateForced, this._pseudoStateForced, this) |
| 69 } |
| 70 this._target = target; |
| 71 if (target) { |
| 72 var cssModel = WebInspector.CSSStyleModel.fromTarget(target); |
| 73 cssModel.addEventListener(WebInspector.CSSStyleModel.Events.PseudoSt
ateForced, this._pseudoStateForced, this) |
| 74 } |
| 75 }, |
| 76 |
| 77 /** |
| 78 * @param {!WebInspector.Event} event |
| 79 */ |
| 80 _pseudoStateForced: function(event) |
| 81 { |
| 82 var node = /** @type{!WebInspector.DOMNode} */(event.data.node); |
| 83 if (node === WebInspector.context.flavor(WebInspector.DOMNode)) |
| 84 this._updateInputs(node); |
| 85 }, |
| 86 |
| 87 /** |
| 59 * @override | 88 * @override |
| 60 * @param {?WebInspector.DOMNode} newNode | 89 * @param {?WebInspector.DOMNode} newNode |
| 61 */ | 90 */ |
| 62 onNodeChanged: function(newNode) | 91 onNodeChanged: function(newNode) |
| 63 { | 92 { |
| 93 this._updateTarget(newNode? newNode.target() : null); |
| 64 this.toolbarItem().setEnabled(!!newNode); | 94 this.toolbarItem().setEnabled(!!newNode); |
| 65 if (!newNode && this.isShowing()) { | 95 if (!newNode) { |
| 66 this.detach(); | 96 if (this.isShowing()) |
| 97 this.detach(); |
| 67 return; | 98 return; |
| 68 } | 99 } |
| 100 this._updateInputs(newNode); |
| 101 }, |
| 69 | 102 |
| 70 var nodePseudoState = newNode.getUserProperty(WebInspector.CSSStyleModel
.PseudoStatePropertyName) || []; | 103 /** |
| 104 * @param {!WebInspector.DOMNode} node |
| 105 */ |
| 106 _updateInputs: function(node) |
| 107 { |
| 108 var nodePseudoState = node.getUserProperty(WebInspector.CSSStyleModel.Ps
eudoStatePropertyName) || []; |
| 71 var inputs = this._inputs; | 109 var inputs = this._inputs; |
| 72 for (var i = 0; i < inputs.length; ++i) { | 110 for (var i = 0; i < inputs.length; ++i) { |
| 73 inputs[i].disabled = !!newNode.pseudoType(); | 111 inputs[i].disabled = !!node.pseudoType(); |
| 74 inputs[i].checked = nodePseudoState.indexOf(inputs[i].state) >= 0; | 112 inputs[i].checked = nodePseudoState.indexOf(inputs[i].state) >= 0; |
| 75 } | 113 } |
| 76 }, | 114 }, |
| 77 | 115 |
| 78 __proto__: WebInspector.StylesSidebarPane.BaseToolbarPaneWidget.prototype | 116 __proto__: WebInspector.StylesSidebarPane.BaseToolbarPaneWidget.prototype |
| 79 } | 117 } |
| 80 | 118 |
| 81 /** | 119 /** |
| 82 * @constructor | 120 * @constructor |
| 83 * @implements {WebInspector.ToolbarItem.Provider} | 121 * @implements {WebInspector.ToolbarItem.Provider} |
| (...skipping 14 matching lines...) Expand all Loading... |
| 98 | 136 |
| 99 /** | 137 /** |
| 100 * @override | 138 * @override |
| 101 * @return {!WebInspector.ToolbarItem} | 139 * @return {!WebInspector.ToolbarItem} |
| 102 */ | 140 */ |
| 103 item: function() | 141 item: function() |
| 104 { | 142 { |
| 105 return this._button; | 143 return this._button; |
| 106 } | 144 } |
| 107 } | 145 } |
| OLD | NEW |