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

Side by Side Diff: Source/devtools/front_end/elements/ElementStatePaneWidget.js

Issue 1164123002: Devtools: Synchronization state in ElementStatePaneWidget with contextMenu (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/devtools/front_end/elements/SharedSidebarModel.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/elements/SharedSidebarModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698