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

Side by Side Diff: Source/devtools/front_end/sdk/CSSStyleModel.js

Issue 1350183004: DevTools: CSS.getMatchedStylesForNode protocol command to return inline styles (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix tests Created 5 years, 3 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 | « Source/devtools/front_end/elements/StylesSidebarPane.js ('k') | Source/devtools/protocol.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 }, 120 },
121 121
122 /** 122 /**
123 * @param {!DOMAgent.NodeId} nodeId 123 * @param {!DOMAgent.NodeId} nodeId
124 * @return {!Promise.<?WebInspector.CSSStyleModel.MatchedStyleResult>} 124 * @return {!Promise.<?WebInspector.CSSStyleModel.MatchedStyleResult>}
125 */ 125 */
126 matchedStylesPromise: function(nodeId) 126 matchedStylesPromise: function(nodeId)
127 { 127 {
128 /** 128 /**
129 * @param {?Protocol.Error} error 129 * @param {?Protocol.Error} error
130 * @param {?CSSAgent.CSSStyle=} inlinePayload
131 * @param {?CSSAgent.CSSStyle=} attributesPayload
130 * @param {!Array.<!CSSAgent.RuleMatch>=} matchedPayload 132 * @param {!Array.<!CSSAgent.RuleMatch>=} matchedPayload
131 * @param {!Array.<!CSSAgent.PseudoIdMatches>=} pseudoPayload 133 * @param {!Array.<!CSSAgent.PseudoIdMatches>=} pseudoPayload
132 * @param {!Array.<!CSSAgent.InheritedStyleEntry>=} inheritedPayload 134 * @param {!Array.<!CSSAgent.InheritedStyleEntry>=} inheritedPayload
133 * @return {?WebInspector.CSSStyleModel.MatchedStyleResult} 135 * @return {?WebInspector.CSSStyleModel.MatchedStyleResult}
134 * @this {WebInspector.CSSStyleModel} 136 * @this {WebInspector.CSSStyleModel}
135 */ 137 */
136 function callback(error, matchedPayload, pseudoPayload, inheritedPayload ) 138 function callback(error, inlinePayload, attributesPayload, matchedPayloa d, pseudoPayload, inheritedPayload)
137 { 139 {
138 if (error) 140 if (error)
139 return null; 141 return null;
140 142
143 var inlineStyle = inlinePayload ? WebInspector.CSSStyleDeclaration.p arsePayload(this, inlinePayload) : null;
144 var attributesStyle = attributesPayload ? WebInspector.CSSStyleDecla ration.parsePayload(this, attributesPayload) : null;
145
141 var matchedRules = WebInspector.CSSStyleModel.parseRuleMatchArrayPay load(this, matchedPayload); 146 var matchedRules = WebInspector.CSSStyleModel.parseRuleMatchArrayPay load(this, matchedPayload);
142 147
143 var pseudoElements = []; 148 var pseudoElements = [];
144 if (pseudoPayload) { 149 if (pseudoPayload) {
145 for (var i = 0; i < pseudoPayload.length; ++i) { 150 for (var i = 0; i < pseudoPayload.length; ++i) {
146 var entryPayload = pseudoPayload[i]; 151 var entryPayload = pseudoPayload[i];
147 pseudoElements.push(new WebInspector.CSSStyleModel.PseudoEle mentMatches(entryPayload.pseudoId, WebInspector.CSSStyleModel.parseRuleMatchArra yPayload(this, entryPayload.matches))); 152 pseudoElements.push(new WebInspector.CSSStyleModel.PseudoEle mentMatches(entryPayload.pseudoId, WebInspector.CSSStyleModel.parseRuleMatchArra yPayload(this, entryPayload.matches)));
148 } 153 }
149 } 154 }
150 155
151 var inherited = []; 156 var inherited = [];
152 if (inheritedPayload) { 157 if (inheritedPayload) {
153 for (var i = 0; i < inheritedPayload.length; ++i) { 158 for (var i = 0; i < inheritedPayload.length; ++i) {
154 var entryPayload = inheritedPayload[i]; 159 var entryPayload = inheritedPayload[i];
155 var inlineStyle = entryPayload.inlineStyle ? WebInspector.CS SStyleDeclaration.parsePayload(this, entryPayload.inlineStyle) : null; 160 var inheritedInlineStyle = entryPayload.inlineStyle ? WebIns pector.CSSStyleDeclaration.parsePayload(this, entryPayload.inlineStyle) : null;
156 var matchedCSSRules = entryPayload.matchedCSSRules ? WebInsp ector.CSSStyleModel.parseRuleMatchArrayPayload(this, entryPayload.matchedCSSRule s) : null; 161 var inheritedMatchedCSSRules = entryPayload.matchedCSSRules ? WebInspector.CSSStyleModel.parseRuleMatchArrayPayload(this, entryPayload.match edCSSRules) : null;
157 inherited.push(new WebInspector.CSSStyleModel.InheritedMatch es(inlineStyle, matchedCSSRules)); 162 inherited.push(new WebInspector.CSSStyleModel.InheritedMatch es(inheritedInlineStyle, inheritedMatchedCSSRules));
158 } 163 }
159 } 164 }
160 return new WebInspector.CSSStyleModel.MatchedStyleResult(matchedRule s, inherited, pseudoElements); 165 return new WebInspector.CSSStyleModel.MatchedStyleResult(inlineStyle , attributesStyle, matchedRules, inherited, pseudoElements);
161 } 166 }
162 167
163 return this._agent.getMatchedStylesForNode(nodeId, callback.bind(this)); 168 return this._agent.getMatchedStylesForNode(nodeId, callback.bind(this));
164 }, 169 },
165 170
166 /** 171 /**
167 * @param {!DOMAgent.NodeId} nodeId 172 * @param {!DOMAgent.NodeId} nodeId
168 * @return {!Promise.<?Map.<string, string>>} 173 * @return {!Promise.<?Map.<string, string>>}
169 */ 174 */
170 computedStylePromise: function(nodeId) 175 computedStylePromise: function(nodeId)
(...skipping 1794 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 * @param {!WebInspector.DOMNode} node 1970 * @param {!WebInspector.DOMNode} node
1966 * @return {!WebInspector.CSSStyleModel} 1971 * @return {!WebInspector.CSSStyleModel}
1967 */ 1972 */
1968 WebInspector.CSSStyleModel.fromNode = function(node) 1973 WebInspector.CSSStyleModel.fromNode = function(node)
1969 { 1974 {
1970 return /** @type {!WebInspector.CSSStyleModel} */ (WebInspector.CSSStyleMode l.fromTarget(node.target())); 1975 return /** @type {!WebInspector.CSSStyleModel} */ (WebInspector.CSSStyleMode l.fromTarget(node.target()));
1971 } 1976 }
1972 1977
1973 /** 1978 /**
1974 * @constructor 1979 * @constructor
1980 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle
1981 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle
1975 * @param {?Array.<!WebInspector.CSSRule>} matchedRules 1982 * @param {?Array.<!WebInspector.CSSRule>} matchedRules
1976 * @param {?Array.<!WebInspector.CSSStyleModel.InheritedMatches>} inherited 1983 * @param {?Array.<!WebInspector.CSSStyleModel.InheritedMatches>} inherited
1977 * @param {?Array.<!WebInspector.CSSStyleModel.PseudoElementMatches>} pseudoElem ents 1984 * @param {?Array.<!WebInspector.CSSStyleModel.PseudoElementMatches>} pseudoElem ents
1978 */ 1985 */
1979 WebInspector.CSSStyleModel.MatchedStyleResult = function(matchedRules, inherited , pseudoElements) 1986 WebInspector.CSSStyleModel.MatchedStyleResult = function(inlineStyle, attributes Style, matchedRules, inherited, pseudoElements)
1980 { 1987 {
1988 this.inlineStyle = inlineStyle;
1989 this.attributesStyle = attributesStyle;
1981 this.matchedCSSRules = matchedRules; 1990 this.matchedCSSRules = matchedRules;
1982 this.inherited = inherited; 1991 this.inherited = inherited;
1983 this.pseudoElements = pseudoElements; 1992 this.pseudoElements = pseudoElements;
1984 } 1993 }
1985 1994
1986 /** 1995 /**
1987 * @constructor 1996 * @constructor
1988 * @param {number} pseudoId 1997 * @param {number} pseudoId
1989 * @param {?Array.<!WebInspector.CSSRule>} rules 1998 * @param {?Array.<!WebInspector.CSSRule>} rules
1990 */ 1999 */
(...skipping 18 matching lines...) Expand all
2009 * @constructor 2018 * @constructor
2010 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle 2019 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle
2011 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle 2020 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle
2012 */ 2021 */
2013 WebInspector.CSSStyleModel.InlineStyleResult = function(inlineStyle, attributesS tyle) 2022 WebInspector.CSSStyleModel.InlineStyleResult = function(inlineStyle, attributesS tyle)
2014 { 2023 {
2015 this.inlineStyle = inlineStyle; 2024 this.inlineStyle = inlineStyle;
2016 this.attributesStyle = attributesStyle; 2025 this.attributesStyle = attributesStyle;
2017 } 2026 }
2018 2027
OLDNEW
« no previous file with comments | « Source/devtools/front_end/elements/StylesSidebarPane.js ('k') | Source/devtools/protocol.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698