Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | |
|
lushnikov
2016/07/12 00:42:19
nit: stray line
pfeldman
2016/07/12 01:09:41
Done.
| |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 2 // 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 | 3 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 4 // found in the LICENSE file. |
| 4 | 5 |
| 5 /** | 6 /** |
| 6 * @extends {WebInspector.Object} | 7 * @extends {WebInspector.Object} |
| 7 * @constructor | 8 * @constructor |
| 8 */ | 9 */ |
| 9 WebInspector.SharedSidebarModel = function() | 10 WebInspector.SharedSidebarModel = function() |
| 10 { | 11 { |
| 11 WebInspector.Object.call(this); | 12 WebInspector.Object.call(this); |
| 12 this._node = WebInspector.context.flavor(WebInspector.DOMNode); | 13 this._node = WebInspector.context.flavor(WebInspector.DOMNode); |
| 13 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this._onN odeChanged, this); | 14 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this._onN odeChanged, this); |
| 14 } | 15 } |
| 15 | 16 |
| 16 /** | |
| 17 * @param {?WebInspector.DOMNode} node | |
| 18 * @return {?WebInspector.DOMNode} | |
| 19 */ | |
| 20 WebInspector.SharedSidebarModel.elementNode = function(node) | |
| 21 { | |
| 22 if (node && node.nodeType() === Node.TEXT_NODE && node.parentNode) | |
| 23 node = node.parentNode; | |
| 24 | |
| 25 if (node && node.nodeType() !== Node.ELEMENT_NODE) | |
| 26 node = null; | |
| 27 return node; | |
| 28 } | |
| 29 | |
| 30 WebInspector.SharedSidebarModel.Events = { | 17 WebInspector.SharedSidebarModel.Events = { |
| 31 ComputedStyleChanged: "ComputedStyleChanged" | 18 ComputedStyleChanged: "ComputedStyleChanged" |
| 32 } | 19 } |
| 33 | 20 |
| 34 WebInspector.SharedSidebarModel.prototype = { | 21 WebInspector.SharedSidebarModel.prototype = { |
| 35 /** | 22 /** |
| 36 * @return {?WebInspector.DOMNode} | 23 * @return {?WebInspector.DOMNode} |
| 37 */ | 24 */ |
| 38 node: function() | 25 node: function() |
| 39 { | 26 { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 domModel.addEventListener(WebInspector.DOMModel.Events.DOMMutate d, this._onComputedStyleChanged, this) | 74 domModel.addEventListener(WebInspector.DOMModel.Events.DOMMutate d, this._onComputedStyleChanged, this) |
| 88 ]; | 75 ]; |
| 89 } | 76 } |
| 90 }, | 77 }, |
| 91 | 78 |
| 92 /** | 79 /** |
| 93 * @return {?WebInspector.DOMNode} | 80 * @return {?WebInspector.DOMNode} |
| 94 */ | 81 */ |
| 95 _elementNode: function() | 82 _elementNode: function() |
| 96 { | 83 { |
| 97 return WebInspector.SharedSidebarModel.elementNode(this.node()); | 84 return this.node() ? this.node().enclosingElementOrSelf() : null; |
| 98 }, | 85 }, |
| 99 | 86 |
| 100 /** | 87 /** |
| 101 * @return {!Promise.<?WebInspector.SharedSidebarModel.ComputedStyle>} | 88 * @return {!Promise.<?WebInspector.SharedSidebarModel.ComputedStyle>} |
| 102 */ | 89 */ |
| 103 fetchComputedStyle: function() | 90 fetchComputedStyle: function() |
| 104 { | 91 { |
| 105 var elementNode = this._elementNode(); | 92 var elementNode = this._elementNode(); |
| 106 var cssModel = this.cssModel(); | 93 var cssModel = this.cssModel(); |
| 107 if (!elementNode || !cssModel) | 94 if (!elementNode || !cssModel) |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 136 /** | 123 /** |
| 137 * @constructor | 124 * @constructor |
| 138 * @param {!WebInspector.DOMNode} node | 125 * @param {!WebInspector.DOMNode} node |
| 139 * @param {!Map.<string, string>} computedStyle | 126 * @param {!Map.<string, string>} computedStyle |
| 140 */ | 127 */ |
| 141 WebInspector.SharedSidebarModel.ComputedStyle = function(node, computedStyle) | 128 WebInspector.SharedSidebarModel.ComputedStyle = function(node, computedStyle) |
| 142 { | 129 { |
| 143 this.node = node; | 130 this.node = node; |
| 144 this.computedStyle = computedStyle; | 131 this.computedStyle = computedStyle; |
| 145 } | 132 } |
| OLD | NEW |