OLD | NEW |
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 18 matching lines...) Expand all Loading... |
29 */ | 29 */ |
30 | 30 |
31 /** | 31 /** |
32 * @constructor | 32 * @constructor |
33 * @extends {WebInspector.Object} | 33 * @extends {WebInspector.Object} |
34 * @param {!WebInspector.Target} target | 34 * @param {!WebInspector.Target} target |
35 */ | 35 */ |
36 WebInspector.CSSStyleModel = function(target) | 36 WebInspector.CSSStyleModel = function(target) |
37 { | 37 { |
38 this._domModel = target.domModel; | 38 this._domModel = target.domModel; |
| 39 this._agent = target.cssAgent(); |
39 this._pendingCommandsMajorState = []; | 40 this._pendingCommandsMajorState = []; |
40 this._styleLoader = new WebInspector.CSSStyleModel.ComputedStyleLoader(this)
; | 41 this._styleLoader = new WebInspector.CSSStyleModel.ComputedStyleLoader(this)
; |
41 this._domModel.addEventListener(WebInspector.DOMModel.Events.UndoRedoRequest
ed, this._undoRedoRequested, this); | 42 this._domModel.addEventListener(WebInspector.DOMModel.Events.UndoRedoRequest
ed, this._undoRedoRequested, this); |
42 this._domModel.addEventListener(WebInspector.DOMModel.Events.UndoRedoComplet
ed, this._undoRedoCompleted, this); | 43 this._domModel.addEventListener(WebInspector.DOMModel.Events.UndoRedoComplet
ed, this._undoRedoCompleted, this); |
43 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeMod
el.EventTypes.MainFrameCreatedOrNavigated, this._mainFrameCreatedOrNavigated, th
is); | 44 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeMod
el.EventTypes.MainFrameCreatedOrNavigated, this._mainFrameCreatedOrNavigated, th
is); |
44 InspectorBackend.registerCSSDispatcher(new WebInspector.CSSDispatcher(this))
; | 45 InspectorBackend.registerCSSDispatcher(new WebInspector.CSSDispatcher(this))
; |
45 CSSAgent.enable(this._wasEnabled.bind(this)); | 46 this._agent.enable(this._wasEnabled.bind(this)); |
46 this._resetStyleSheets(); | 47 this._resetStyleSheets(); |
47 } | 48 } |
48 | 49 |
| 50 WebInspector.CSSStyleModel.PseudoStatePropertyName = "pseudoState"; |
| 51 |
49 /** | 52 /** |
50 * @param {!WebInspector.CSSStyleModel} cssModel | 53 * @param {!WebInspector.CSSStyleModel} cssModel |
51 * @param {!Array.<!CSSAgent.RuleMatch>|undefined} matchArray | 54 * @param {!Array.<!CSSAgent.RuleMatch>|undefined} matchArray |
52 */ | 55 */ |
53 WebInspector.CSSStyleModel.parseRuleMatchArrayPayload = function(cssModel, match
Array) | 56 WebInspector.CSSStyleModel.parseRuleMatchArrayPayload = function(cssModel, match
Array) |
54 { | 57 { |
55 if (!matchArray) | 58 if (!matchArray) |
56 return []; | 59 return []; |
57 | 60 |
58 var result = []; | 61 var result = []; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 if (entryPayload.matchedCSSRules) | 134 if (entryPayload.matchedCSSRules) |
132 entry.matchedCSSRules = WebInspector.CSSStyleModel.parse
RuleMatchArrayPayload(this, entryPayload.matchedCSSRules); | 135 entry.matchedCSSRules = WebInspector.CSSStyleModel.parse
RuleMatchArrayPayload(this, entryPayload.matchedCSSRules); |
133 result.inherited.push(entry); | 136 result.inherited.push(entry); |
134 } | 137 } |
135 } | 138 } |
136 | 139 |
137 if (userCallback) | 140 if (userCallback) |
138 userCallback(result); | 141 userCallback(result); |
139 } | 142 } |
140 | 143 |
141 CSSAgent.getMatchedStylesForNode(nodeId, needPseudo, needInherited, call
back.bind(this, userCallback)); | 144 this._agent.getMatchedStylesForNode(nodeId, needPseudo, needInherited, c
allback.bind(this, userCallback)); |
142 }, | 145 }, |
143 | 146 |
144 /** | 147 /** |
145 * @param {!DOMAgent.NodeId} nodeId | 148 * @param {!DOMAgent.NodeId} nodeId |
146 * @param {function(?WebInspector.CSSStyleDeclaration)} userCallback | 149 * @param {function(?WebInspector.CSSStyleDeclaration)} userCallback |
147 */ | 150 */ |
148 getComputedStyleAsync: function(nodeId, userCallback) | 151 getComputedStyleAsync: function(nodeId, userCallback) |
149 { | 152 { |
150 this._styleLoader.getComputedStyle(nodeId, userCallback); | 153 this._styleLoader.getComputedStyle(nodeId, userCallback); |
151 }, | 154 }, |
152 | 155 |
153 /** | 156 /** |
154 * @param {number} nodeId | 157 * @param {number} nodeId |
155 * @param {function(?string, ?Array.<!CSSAgent.PlatformFontUsage>)} callback | 158 * @param {function(?string, ?Array.<!CSSAgent.PlatformFontUsage>)} callback |
156 */ | 159 */ |
157 getPlatformFontsForNode: function(nodeId, callback) | 160 getPlatformFontsForNode: function(nodeId, callback) |
158 { | 161 { |
159 function platformFontsCallback(error, cssFamilyName, fonts) | 162 function platformFontsCallback(error, cssFamilyName, fonts) |
160 { | 163 { |
161 if (error) | 164 if (error) |
162 callback(null, null); | 165 callback(null, null); |
163 else | 166 else |
164 callback(cssFamilyName, fonts); | 167 callback(cssFamilyName, fonts); |
165 } | 168 } |
166 CSSAgent.getPlatformFontsForNode(nodeId, platformFontsCallback); | 169 this._agent.getPlatformFontsForNode(nodeId, platformFontsCallback); |
167 }, | 170 }, |
168 | 171 |
169 /** | 172 /** |
170 * @return {!Array.<!WebInspector.CSSStyleSheetHeader>} | 173 * @return {!Array.<!WebInspector.CSSStyleSheetHeader>} |
171 */ | 174 */ |
172 allStyleSheets: function() | 175 allStyleSheets: function() |
173 { | 176 { |
174 var values = Object.values(this._styleSheetIdToHeader); | 177 var values = Object.values(this._styleSheetIdToHeader); |
175 /** | 178 /** |
176 * @param {!WebInspector.CSSStyleSheetHeader} a | 179 * @param {!WebInspector.CSSStyleSheetHeader} a |
(...skipping 27 matching lines...) Expand all Loading... |
204 * @this {WebInspector.CSSStyleModel} | 207 * @this {WebInspector.CSSStyleModel} |
205 */ | 208 */ |
206 function callback(userCallback, error, inlinePayload, attributesStylePay
load) | 209 function callback(userCallback, error, inlinePayload, attributesStylePay
load) |
207 { | 210 { |
208 if (error || !inlinePayload) | 211 if (error || !inlinePayload) |
209 userCallback(null, null); | 212 userCallback(null, null); |
210 else | 213 else |
211 userCallback(WebInspector.CSSStyleDeclaration.parsePayload(this,
inlinePayload), attributesStylePayload ? WebInspector.CSSStyleDeclaration.parse
Payload(this, attributesStylePayload) : null); | 214 userCallback(WebInspector.CSSStyleDeclaration.parsePayload(this,
inlinePayload), attributesStylePayload ? WebInspector.CSSStyleDeclaration.parse
Payload(this, attributesStylePayload) : null); |
212 } | 215 } |
213 | 216 |
214 CSSAgent.getInlineStylesForNode(nodeId, callback.bind(this, userCallback
)); | 217 this._agent.getInlineStylesForNode(nodeId, callback.bind(this, userCallb
ack)); |
215 }, | 218 }, |
216 | 219 |
217 /** | 220 /** |
218 * @param {!DOMAgent.NodeId} nodeId | 221 * @param {!WebInspector.DOMNode} node |
219 * @param {?Array.<string>|undefined} forcedPseudoClasses | 222 * @param {string} pseudoClass |
220 * @param {function()=} userCallback | 223 * @param {boolean} enable |
| 224 * @return {boolean} |
221 */ | 225 */ |
222 forcePseudoState: function(nodeId, forcedPseudoClasses, userCallback) | 226 forcePseudoState: function(node, pseudoClass, enable) |
223 { | 227 { |
224 CSSAgent.forcePseudoState(nodeId, forcedPseudoClasses || [], userCallbac
k); | 228 var pseudoClasses = node.getUserProperty(WebInspector.CSSStyleModel.Pseu
doStatePropertyName) || []; |
| 229 if (enable) { |
| 230 if (pseudoClasses.indexOf(pseudoClass) >= 0) |
| 231 return false; |
| 232 pseudoClasses.push(pseudoClass); |
| 233 node.setUserProperty(WebInspector.CSSStyleModel.PseudoStatePropertyN
ame, pseudoClasses); |
| 234 } else { |
| 235 if (pseudoClasses.indexOf(pseudoClass) < 0) |
| 236 return false; |
| 237 pseudoClasses.remove(pseudoClass); |
| 238 if (!pseudoClasses.length) |
| 239 node.removeUserProperty(WebInspector.CSSStyleModel.PseudoStatePr
opertyName); |
| 240 } |
| 241 |
| 242 this._agent.forcePseudoState(node.id, pseudoClasses); |
| 243 return true; |
225 }, | 244 }, |
226 | 245 |
227 /** | 246 /** |
228 * @param {!CSSAgent.CSSRuleId} ruleId | 247 * @param {!CSSAgent.CSSRuleId} ruleId |
229 * @param {!DOMAgent.NodeId} nodeId | 248 * @param {!DOMAgent.NodeId} nodeId |
230 * @param {string} newSelector | 249 * @param {string} newSelector |
231 * @param {function(!WebInspector.CSSRule)} successCallback | 250 * @param {function(!WebInspector.CSSRule)} successCallback |
232 * @param {function()} failureCallback | 251 * @param {function()} failureCallback |
233 */ | 252 */ |
234 setRuleSelector: function(ruleId, nodeId, newSelector, successCallback, fail
ureCallback) | 253 setRuleSelector: function(ruleId, nodeId, newSelector, successCallback, fail
ureCallback) |
(...skipping 13 matching lines...) Expand all Loading... |
248 if (error) { | 267 if (error) { |
249 failureCallback(); | 268 failureCallback(); |
250 return; | 269 return; |
251 } | 270 } |
252 this._domModel.markUndoableState(); | 271 this._domModel.markUndoableState(); |
253 this._computeMatchingSelectors(rulePayload, nodeId, successCallback,
failureCallback); | 272 this._computeMatchingSelectors(rulePayload, nodeId, successCallback,
failureCallback); |
254 } | 273 } |
255 | 274 |
256 | 275 |
257 this._pendingCommandsMajorState.push(true); | 276 this._pendingCommandsMajorState.push(true); |
258 CSSAgent.setRuleSelector(ruleId, newSelector, callback.bind(this, nodeId
, successCallback, failureCallback, newSelector)); | 277 this._agent.setRuleSelector(ruleId, newSelector, callback.bind(this, nod
eId, successCallback, failureCallback, newSelector)); |
259 }, | 278 }, |
260 | 279 |
261 /** | 280 /** |
262 * @param {!CSSAgent.CSSRule} rulePayload | 281 * @param {!CSSAgent.CSSRule} rulePayload |
263 * @param {!DOMAgent.NodeId} nodeId | 282 * @param {!DOMAgent.NodeId} nodeId |
264 * @param {function(!WebInspector.CSSRule)} successCallback | 283 * @param {function(!WebInspector.CSSRule)} successCallback |
265 * @param {function()} failureCallback | 284 * @param {function()} failureCallback |
266 */ | 285 */ |
267 _computeMatchingSelectors: function(rulePayload, nodeId, successCallback, fa
ilureCallback) | 286 _computeMatchingSelectors: function(rulePayload, nodeId, successCallback, fa
ilureCallback) |
268 { | 287 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 /** | 321 /** |
303 * @param {!CSSAgent.StyleSheetId} styleSheetId | 322 * @param {!CSSAgent.StyleSheetId} styleSheetId |
304 * @param {!WebInspector.DOMNode} node | 323 * @param {!WebInspector.DOMNode} node |
305 * @param {string} selector | 324 * @param {string} selector |
306 * @param {function(!WebInspector.CSSRule)} successCallback | 325 * @param {function(!WebInspector.CSSRule)} successCallback |
307 * @param {function()} failureCallback | 326 * @param {function()} failureCallback |
308 */ | 327 */ |
309 addRule: function(styleSheetId, node, selector, successCallback, failureCall
back) | 328 addRule: function(styleSheetId, node, selector, successCallback, failureCall
back) |
310 { | 329 { |
311 this._pendingCommandsMajorState.push(true); | 330 this._pendingCommandsMajorState.push(true); |
312 CSSAgent.addRule(styleSheetId, selector, callback.bind(this)); | 331 this._agent.addRule(styleSheetId, selector, callback.bind(this)); |
313 | 332 |
314 /** | 333 /** |
315 * @param {?Protocol.Error} error | 334 * @param {?Protocol.Error} error |
316 * @param {!CSSAgent.CSSRule} rulePayload | 335 * @param {!CSSAgent.CSSRule} rulePayload |
317 * @this {WebInspector.CSSStyleModel} | 336 * @this {WebInspector.CSSStyleModel} |
318 */ | 337 */ |
319 function callback(error, rulePayload) | 338 function callback(error, rulePayload) |
320 { | 339 { |
321 this._pendingCommandsMajorState.pop(); | 340 this._pendingCommandsMajorState.pop(); |
322 if (error) { | 341 if (error) { |
(...skipping 29 matching lines...) Expand all Loading... |
352 function innerCallback(error, styleSheetId) | 371 function innerCallback(error, styleSheetId) |
353 { | 372 { |
354 if (error) { | 373 if (error) { |
355 console.error(error); | 374 console.error(error); |
356 callback(null); | 375 callback(null); |
357 } | 376 } |
358 | 377 |
359 callback(this._styleSheetIdToHeader[styleSheetId]); | 378 callback(this._styleSheetIdToHeader[styleSheetId]); |
360 } | 379 } |
361 | 380 |
362 CSSAgent.createStyleSheet(frameId, innerCallback.bind(this)); | 381 this._agent.createStyleSheet(frameId, innerCallback.bind(this)); |
363 }, | 382 }, |
364 | 383 |
365 mediaQueryResultChanged: function() | 384 mediaQueryResultChanged: function() |
366 { | 385 { |
367 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.MediaQue
ryResultChanged); | 386 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.MediaQue
ryResultChanged); |
368 }, | 387 }, |
369 | 388 |
370 /** | 389 /** |
371 * @param {!CSSAgent.StyleSheetId} id | 390 * @param {!CSSAgent.StyleSheetId} id |
372 * @return {!WebInspector.CSSStyleSheetHeader} | 391 * @return {!WebInspector.CSSStyleSheetHeader} |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 | 430 |
412 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.StyleShe
etChanged, { styleSheetId: styleSheetId, majorChange: majorChange }); | 431 this.dispatchEventToListeners(WebInspector.CSSStyleModel.Events.StyleShe
etChanged, { styleSheetId: styleSheetId, majorChange: majorChange }); |
413 }, | 432 }, |
414 | 433 |
415 /** | 434 /** |
416 * @param {!CSSAgent.CSSStyleSheetHeader} header | 435 * @param {!CSSAgent.CSSStyleSheetHeader} header |
417 */ | 436 */ |
418 _styleSheetAdded: function(header) | 437 _styleSheetAdded: function(header) |
419 { | 438 { |
420 console.assert(!this._styleSheetIdToHeader[header.styleSheetId]); | 439 console.assert(!this._styleSheetIdToHeader[header.styleSheetId]); |
421 var styleSheetHeader = new WebInspector.CSSStyleSheetHeader(header); | 440 var styleSheetHeader = new WebInspector.CSSStyleSheetHeader(this, header
); |
422 this._styleSheetIdToHeader[header.styleSheetId] = styleSheetHeader; | 441 this._styleSheetIdToHeader[header.styleSheetId] = styleSheetHeader; |
423 var url = styleSheetHeader.resourceURL(); | 442 var url = styleSheetHeader.resourceURL(); |
424 if (!this._styleSheetIdsForURL[url]) | 443 if (!this._styleSheetIdsForURL[url]) |
425 this._styleSheetIdsForURL[url] = {}; | 444 this._styleSheetIdsForURL[url] = {}; |
426 var frameIdToStyleSheetIds = this._styleSheetIdsForURL[url]; | 445 var frameIdToStyleSheetIds = this._styleSheetIdsForURL[url]; |
427 var styleSheetIds = frameIdToStyleSheetIds[styleSheetHeader.frameId]; | 446 var styleSheetIds = frameIdToStyleSheetIds[styleSheetHeader.frameId]; |
428 if (!styleSheetIds) { | 447 if (!styleSheetIds) { |
429 styleSheetIds = []; | 448 styleSheetIds = []; |
430 frameIdToStyleSheetIds[styleSheetHeader.frameId] = styleSheetIds; | 449 frameIdToStyleSheetIds[styleSheetHeader.frameId] = styleSheetIds; |
431 } | 450 } |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 console.error(error); | 910 console.error(error); |
892 userCallback(null); | 911 userCallback(null); |
893 } else | 912 } else |
894 userCallback(WebInspector.CSSStyleDeclaration.parsePayload(this.
_cssModel, payload)); | 913 userCallback(WebInspector.CSSStyleDeclaration.parsePayload(this.
_cssModel, payload)); |
895 } | 914 } |
896 | 915 |
897 if (!this.id) | 916 if (!this.id) |
898 throw "No style id"; | 917 throw "No style id"; |
899 | 918 |
900 this._cssModel._pendingCommandsMajorState.push(true); | 919 this._cssModel._pendingCommandsMajorState.push(true); |
901 CSSAgent.setPropertyText(this.id, index, name + ": " + value + ";", fals
e, callback.bind(this)); | 920 this._cssModel._agent.setPropertyText(this.id, index, name + ": " + valu
e + ";", false, callback.bind(this)); |
902 }, | 921 }, |
903 | 922 |
904 /** | 923 /** |
905 * @param {string} name | 924 * @param {string} name |
906 * @param {string} value | 925 * @param {string} value |
907 * @param {function(?WebInspector.CSSStyleDeclaration)=} userCallback | 926 * @param {function(?WebInspector.CSSStyleDeclaration)=} userCallback |
908 */ | 927 */ |
909 appendProperty: function(name, value, userCallback) | 928 appendProperty: function(name, value, userCallback) |
910 { | 929 { |
911 this.insertPropertyAt(this.allProperties.length, name, value, userCallba
ck); | 930 this.insertPropertyAt(this.allProperties.length, name, value, userCallba
ck); |
912 }, | 931 } |
913 } | 932 } |
914 | 933 |
915 /** | 934 /** |
916 * @constructor | 935 * @constructor |
917 * @param {!WebInspector.CSSStyleModel} cssModel | 936 * @param {!WebInspector.CSSStyleModel} cssModel |
918 * @param {!CSSAgent.CSSRule} payload | 937 * @param {!CSSAgent.CSSRule} payload |
919 * @param {!Array.<number>=} matchingSelectors | 938 * @param {!Array.<number>=} matchingSelectors |
920 */ | 939 */ |
921 WebInspector.CSSRule = function(cssModel, payload, matchingSelectors) | 940 WebInspector.CSSRule = function(cssModel, payload, matchingSelectors) |
922 { | 941 { |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 } | 1170 } |
1152 } | 1171 } |
1153 | 1172 |
1154 if (!this.ownerStyle) | 1173 if (!this.ownerStyle) |
1155 throw "No ownerStyle for property"; | 1174 throw "No ownerStyle for property"; |
1156 | 1175 |
1157 if (!this.ownerStyle.id) | 1176 if (!this.ownerStyle.id) |
1158 throw "No owner style id"; | 1177 throw "No owner style id"; |
1159 | 1178 |
1160 // An index past all the properties adds a new property to the style. | 1179 // An index past all the properties adds a new property to the style. |
1161 this.ownerStyle._cssModel._pendingCommandsMajorState.push(majorChange); | 1180 var cssModel = this.ownerStyle._cssModel; |
1162 CSSAgent.setPropertyText(this.ownerStyle.id, this.index, propertyText, o
verwrite, callback.bind(this)); | 1181 cssModel._pendingCommandsMajorState.push(majorChange); |
| 1182 cssModel._agent.setPropertyText(this.ownerStyle.id, this.index, property
Text, overwrite, callback.bind(this)); |
1163 }, | 1183 }, |
1164 | 1184 |
1165 /** | 1185 /** |
1166 * @param {string} newValue | 1186 * @param {string} newValue |
1167 * @param {boolean} majorChange | 1187 * @param {boolean} majorChange |
1168 * @param {boolean} overwrite | 1188 * @param {boolean} overwrite |
1169 * @param {function(?WebInspector.CSSStyleDeclaration)=} userCallback | 1189 * @param {function(?WebInspector.CSSStyleDeclaration)=} userCallback |
1170 */ | 1190 */ |
1171 setValue: function(newValue, majorChange, overwrite, userCallback) | 1191 setValue: function(newValue, majorChange, overwrite, userCallback) |
1172 { | 1192 { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 */ | 1312 */ |
1293 header: function() | 1313 header: function() |
1294 { | 1314 { |
1295 return this.parentStyleSheetId ? this._cssModel.styleSheetHeaderForId(th
is.parentStyleSheetId) : null; | 1315 return this.parentStyleSheetId ? this._cssModel.styleSheetHeaderForId(th
is.parentStyleSheetId) : null; |
1296 } | 1316 } |
1297 } | 1317 } |
1298 | 1318 |
1299 /** | 1319 /** |
1300 * @constructor | 1320 * @constructor |
1301 * @implements {WebInspector.ContentProvider} | 1321 * @implements {WebInspector.ContentProvider} |
| 1322 * @param {!WebInspector.CSSStyleModel} cssModel |
1302 * @param {!CSSAgent.CSSStyleSheetHeader} payload | 1323 * @param {!CSSAgent.CSSStyleSheetHeader} payload |
1303 */ | 1324 */ |
1304 WebInspector.CSSStyleSheetHeader = function(payload) | 1325 WebInspector.CSSStyleSheetHeader = function(cssModel, payload) |
1305 { | 1326 { |
| 1327 this._cssModel = cssModel; |
1306 this.id = payload.styleSheetId; | 1328 this.id = payload.styleSheetId; |
1307 this.frameId = payload.frameId; | 1329 this.frameId = payload.frameId; |
1308 this.sourceURL = payload.sourceURL; | 1330 this.sourceURL = payload.sourceURL; |
1309 this.hasSourceURL = !!payload.hasSourceURL; | 1331 this.hasSourceURL = !!payload.hasSourceURL; |
1310 this.sourceMapURL = payload.sourceMapURL; | 1332 this.sourceMapURL = payload.sourceMapURL; |
1311 this.origin = payload.origin; | 1333 this.origin = payload.origin; |
1312 this.title = payload.title; | 1334 this.title = payload.title; |
1313 this.disabled = payload.disabled; | 1335 this.disabled = payload.disabled; |
1314 this.isInline = payload.isInline; | 1336 this.isInline = payload.isInline; |
1315 this.startLine = payload.startLine; | 1337 this.startLine = payload.startLine; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 var sourceURLRegex = /\n[\040\t]*\/\*[#@][\040\t]sourceURL=[\040\t]*([^\
s]*)[\040\t]*\*\/[\040\t]*$/mg; | 1459 var sourceURLRegex = /\n[\040\t]*\/\*[#@][\040\t]sourceURL=[\040\t]*([^\
s]*)[\040\t]*\*\/[\040\t]*$/mg; |
1438 return text.replace(sourceURLRegex, ""); | 1460 return text.replace(sourceURLRegex, ""); |
1439 }, | 1461 }, |
1440 | 1462 |
1441 /** | 1463 /** |
1442 * @override | 1464 * @override |
1443 * @param {function(?string)} callback | 1465 * @param {function(?string)} callback |
1444 */ | 1466 */ |
1445 requestContent: function(callback) | 1467 requestContent: function(callback) |
1446 { | 1468 { |
1447 CSSAgent.getStyleSheetText(this.id, textCallback.bind(this)); | 1469 this._cssModel._agent.getStyleSheetText(this.id, textCallback.bind(this)
); |
1448 | 1470 |
1449 /** | 1471 /** |
1450 * @this {WebInspector.CSSStyleSheetHeader} | 1472 * @this {WebInspector.CSSStyleSheetHeader} |
1451 */ | 1473 */ |
1452 function textCallback(error, text) | 1474 function textCallback(error, text) |
1453 { | 1475 { |
1454 if (error) { | 1476 if (error) { |
1455 WebInspector.console.log("Failed to get text for stylesheet " +
this.id + ": " + error); | 1477 WebInspector.console.log("Failed to get text for stylesheet " +
this.id + ": " + error); |
1456 text = ""; | 1478 text = ""; |
1457 // Fall through. | 1479 // Fall through. |
(...skipping 19 matching lines...) Expand all Loading... |
1477 | 1499 |
1478 /** | 1500 /** |
1479 * @param {string} newText | 1501 * @param {string} newText |
1480 * @param {function(?Protocol.Error)} callback | 1502 * @param {function(?Protocol.Error)} callback |
1481 */ | 1503 */ |
1482 setContent: function(newText, callback) | 1504 setContent: function(newText, callback) |
1483 { | 1505 { |
1484 newText = this._trimSourceURL(newText); | 1506 newText = this._trimSourceURL(newText); |
1485 if (this.hasSourceURL) | 1507 if (this.hasSourceURL) |
1486 newText += "\n/*# sourceURL=" + this.sourceURL + " */"; | 1508 newText += "\n/*# sourceURL=" + this.sourceURL + " */"; |
1487 CSSAgent.setStyleSheetText(this.id, newText, callback); | 1509 this._cssModel._agent.setStyleSheetText(this.id, newText, callback); |
1488 }, | 1510 }, |
1489 | 1511 |
1490 /** | 1512 /** |
1491 * @return {boolean} | 1513 * @return {boolean} |
1492 */ | 1514 */ |
1493 isViaInspector: function() | 1515 isViaInspector: function() |
1494 { | 1516 { |
1495 return this.origin === "inspector"; | 1517 return this.origin === "inspector"; |
1496 }, | 1518 }, |
1497 | 1519 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1556 */ | 1578 */ |
1557 getComputedStyle: function(nodeId, userCallback) | 1579 getComputedStyle: function(nodeId, userCallback) |
1558 { | 1580 { |
1559 if (this._nodeIdToCallbackData[nodeId]) { | 1581 if (this._nodeIdToCallbackData[nodeId]) { |
1560 this._nodeIdToCallbackData[nodeId].push(userCallback); | 1582 this._nodeIdToCallbackData[nodeId].push(userCallback); |
1561 return; | 1583 return; |
1562 } | 1584 } |
1563 | 1585 |
1564 this._nodeIdToCallbackData[nodeId] = [userCallback]; | 1586 this._nodeIdToCallbackData[nodeId] = [userCallback]; |
1565 | 1587 |
1566 CSSAgent.getComputedStyleForNode(nodeId, resultCallback.bind(this, nodeI
d)); | 1588 this._cssModel._agent.getComputedStyleForNode(nodeId, resultCallback.bin
d(this, nodeId)); |
1567 | 1589 |
1568 /** | 1590 /** |
1569 * @param {!DOMAgent.NodeId} nodeId | 1591 * @param {!DOMAgent.NodeId} nodeId |
1570 * @param {?Protocol.Error} error | 1592 * @param {?Protocol.Error} error |
1571 * @param {!Array.<!CSSAgent.CSSComputedStyleProperty>} computedPayload | 1593 * @param {!Array.<!CSSAgent.CSSComputedStyleProperty>} computedPayload |
1572 * @this {WebInspector.CSSStyleModel.ComputedStyleLoader} | 1594 * @this {WebInspector.CSSStyleModel.ComputedStyleLoader} |
1573 */ | 1595 */ |
1574 function resultCallback(nodeId, error, computedPayload) | 1596 function resultCallback(nodeId, error, computedPayload) |
1575 { | 1597 { |
1576 var computedStyle = (error || !computedPayload) ? null : WebInspecto
r.CSSStyleDeclaration.parseComputedStylePayload(this._cssModel, computedPayload)
; | 1598 var computedStyle = (error || !computedPayload) ? null : WebInspecto
r.CSSStyleDeclaration.parseComputedStylePayload(this._cssModel, computedPayload)
; |
1577 var callbacks = this._nodeIdToCallbackData[nodeId]; | 1599 var callbacks = this._nodeIdToCallbackData[nodeId]; |
1578 | 1600 |
1579 // The loader has been reset. | 1601 // The loader has been reset. |
1580 if (!callbacks) | 1602 if (!callbacks) |
1581 return; | 1603 return; |
1582 | 1604 |
1583 delete this._nodeIdToCallbackData[nodeId]; | 1605 delete this._nodeIdToCallbackData[nodeId]; |
1584 for (var i = 0; i < callbacks.length; ++i) | 1606 for (var i = 0; i < callbacks.length; ++i) |
1585 callbacks[i](computedStyle); | 1607 callbacks[i](computedStyle); |
1586 } | 1608 } |
1587 } | 1609 } |
1588 } | 1610 } |
1589 | 1611 |
1590 /** | 1612 /** |
1591 * @type {!WebInspector.CSSStyleModel} | 1613 * @type {!WebInspector.CSSStyleModel} |
1592 */ | 1614 */ |
1593 WebInspector.cssModel; | 1615 WebInspector.cssModel; |
OLD | NEW |