| 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 * @extends {WebInspector.Object} | 6 * @extends {WebInspector.Object} |
| 7 * @constructor | 7 * @constructor |
| 8 */ | 8 */ |
| 9 WebInspector.SharedSidebarModel = function() | 9 WebInspector.SharedSidebarModel = function() |
| 10 { | 10 { |
| 11 WebInspector.Object.call(this); | 11 WebInspector.Object.call(this); |
| 12 this._node = WebInspector.context.flavor(WebInspector.DOMNode); | 12 this._node = WebInspector.context.flavor(WebInspector.DOMNode); |
| 13 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this._onN
odeChanged, this); | 13 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this._onN
odeChanged, this); |
| 14 } | 14 } |
| 15 | 15 |
| 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 = { | 16 WebInspector.SharedSidebarModel.Events = { |
| 31 ComputedStyleChanged: "ComputedStyleChanged" | 17 ComputedStyleChanged: "ComputedStyleChanged" |
| 32 } | 18 } |
| 33 | 19 |
| 34 WebInspector.SharedSidebarModel.prototype = { | 20 WebInspector.SharedSidebarModel.prototype = { |
| 35 /** | 21 /** |
| 36 * @return {?WebInspector.DOMNode} | 22 * @return {?WebInspector.DOMNode} |
| 37 */ | 23 */ |
| 38 node: function() | 24 node: function() |
| 39 { | 25 { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 domModel.addEventListener(WebInspector.DOMModel.Events.DOMMutate
d, this._onComputedStyleChanged, this) | 73 domModel.addEventListener(WebInspector.DOMModel.Events.DOMMutate
d, this._onComputedStyleChanged, this) |
| 88 ]; | 74 ]; |
| 89 } | 75 } |
| 90 }, | 76 }, |
| 91 | 77 |
| 92 /** | 78 /** |
| 93 * @return {?WebInspector.DOMNode} | 79 * @return {?WebInspector.DOMNode} |
| 94 */ | 80 */ |
| 95 _elementNode: function() | 81 _elementNode: function() |
| 96 { | 82 { |
| 97 return WebInspector.SharedSidebarModel.elementNode(this.node()); | 83 return this.node() ? this.node().enclosingElementOrSelf() : null; |
| 98 }, | 84 }, |
| 99 | 85 |
| 100 /** | 86 /** |
| 101 * @return {!Promise.<?WebInspector.SharedSidebarModel.ComputedStyle>} | 87 * @return {!Promise.<?WebInspector.SharedSidebarModel.ComputedStyle>} |
| 102 */ | 88 */ |
| 103 fetchComputedStyle: function() | 89 fetchComputedStyle: function() |
| 104 { | 90 { |
| 105 var elementNode = this._elementNode(); | 91 var elementNode = this._elementNode(); |
| 106 var cssModel = this.cssModel(); | 92 var cssModel = this.cssModel(); |
| 107 if (!elementNode || !cssModel) | 93 if (!elementNode || !cssModel) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 136 /** | 122 /** |
| 137 * @constructor | 123 * @constructor |
| 138 * @param {!WebInspector.DOMNode} node | 124 * @param {!WebInspector.DOMNode} node |
| 139 * @param {!Map.<string, string>} computedStyle | 125 * @param {!Map.<string, string>} computedStyle |
| 140 */ | 126 */ |
| 141 WebInspector.SharedSidebarModel.ComputedStyle = function(node, computedStyle) | 127 WebInspector.SharedSidebarModel.ComputedStyle = function(node, computedStyle) |
| 142 { | 128 { |
| 143 this.node = node; | 129 this.node = node; |
| 144 this.computedStyle = computedStyle; | 130 this.computedStyle = computedStyle; |
| 145 } | 131 } |
| OLD | NEW |