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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/elements/ComputedStyleModel.js

Issue 2144923002: DevTools: remove the ComputedStyles -> Styles pane dependency. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaselined 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 unified diff | Download patch
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 * @extends {WebInspector.Object} 6 * @extends {WebInspector.Object}
7 * @constructor 7 * @constructor
8 */ 8 */
9 WebInspector.SharedSidebarModel = function() 9 WebInspector.ComputedStyleModel = 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 WebInspector.SharedSidebarModel.Events = { 16 WebInspector.ComputedStyleModel.Events = {
17 ComputedStyleChanged: "ComputedStyleChanged" 17 ComputedStyleChanged: "ComputedStyleChanged"
18 } 18 }
19 19
20 WebInspector.SharedSidebarModel.prototype = { 20 WebInspector.ComputedStyleModel.prototype = {
21 /** 21 /**
22 * @return {?WebInspector.DOMNode} 22 * @return {?WebInspector.DOMNode}
23 */ 23 */
24 node: function() 24 node: function()
25 { 25 {
26 return this._node; 26 return this._node;
27 }, 27 },
28 28
29 /** 29 /**
30 * @return {?WebInspector.CSSModel} 30 * @return {?WebInspector.CSSModel}
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 /** 78 /**
79 * @return {?WebInspector.DOMNode} 79 * @return {?WebInspector.DOMNode}
80 */ 80 */
81 _elementNode: function() 81 _elementNode: function()
82 { 82 {
83 return this.node() ? this.node().enclosingElementOrSelf() : null; 83 return this.node() ? this.node().enclosingElementOrSelf() : null;
84 }, 84 },
85 85
86 /** 86 /**
87 * @return {!Promise.<?WebInspector.SharedSidebarModel.ComputedStyle>} 87 * @return {!Promise.<?WebInspector.ComputedStyleModel.ComputedStyle>}
88 */ 88 */
89 fetchComputedStyle: function() 89 fetchComputedStyle: function()
90 { 90 {
91 var elementNode = this._elementNode(); 91 var elementNode = this._elementNode();
92 var cssModel = this.cssModel(); 92 var cssModel = this.cssModel();
93 if (!elementNode || !cssModel) 93 if (!elementNode || !cssModel)
94 return Promise.resolve(/** @type {?WebInspector.SharedSidebarModel.C omputedStyle} */(null)); 94 return Promise.resolve(/** @type {?WebInspector.ComputedStyleModel.C omputedStyle} */(null));
95 95
96 if (!this._computedStylePromise) 96 if (!this._computedStylePromise)
97 this._computedStylePromise = cssModel.computedStylePromise(elementNo de.id).then(verifyOutdated.bind(this, elementNode)); 97 this._computedStylePromise = cssModel.computedStylePromise(elementNo de.id).then(verifyOutdated.bind(this, elementNode));
98 98
99 return this._computedStylePromise; 99 return this._computedStylePromise;
100 100
101 /** 101 /**
102 * @param {!WebInspector.DOMNode} elementNode 102 * @param {!WebInspector.DOMNode} elementNode
103 * @param {?Map.<string, string>} style 103 * @param {?Map.<string, string>} style
104 * @return {?WebInspector.SharedSidebarModel.ComputedStyle} 104 * @return {?WebInspector.ComputedStyleModel.ComputedStyle}
105 * @this {WebInspector.SharedSidebarModel} 105 * @this {WebInspector.ComputedStyleModel}
106 */ 106 */
107 function verifyOutdated(elementNode, style) 107 function verifyOutdated(elementNode, style)
108 { 108 {
109 return elementNode === this._elementNode() && style ? new WebInspect or.SharedSidebarModel.ComputedStyle(elementNode, style) : /** @type {?WebInspect or.SharedSidebarModel.ComputedStyle} */(null); 109 return elementNode === this._elementNode() && style ? new WebInspect or.ComputedStyleModel.ComputedStyle(elementNode, style) : /** @type {?WebInspect or.ComputedStyleModel.ComputedStyle} */(null);
110 } 110 }
111 }, 111 },
112 112
113 _onComputedStyleChanged: function() 113 _onComputedStyleChanged: function()
114 { 114 {
115 delete this._computedStylePromise; 115 delete this._computedStylePromise;
116 this.dispatchEventToListeners(WebInspector.SharedSidebarModel.Events.Com putedStyleChanged); 116 this.dispatchEventToListeners(WebInspector.ComputedStyleModel.Events.Com putedStyleChanged);
117 }, 117 },
118 118
119 __proto__: WebInspector.Object.prototype 119 __proto__: WebInspector.Object.prototype
120 } 120 }
121 121
122 /** 122 /**
123 * @constructor 123 * @constructor
124 * @param {!WebInspector.DOMNode} node 124 * @param {!WebInspector.DOMNode} node
125 * @param {!Map.<string, string>} computedStyle 125 * @param {!Map.<string, string>} computedStyle
126 */ 126 */
127 WebInspector.SharedSidebarModel.ComputedStyle = function(node, computedStyle) 127 WebInspector.ComputedStyleModel.ComputedStyle = function(node, computedStyle)
128 { 128 {
129 this.node = node; 129 this.node = node;
130 this.computedStyle = computedStyle; 130 this.computedStyle = computedStyle;
131 } 131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698