| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 * @param {boolean} majorChange | 237 * @param {boolean} majorChange |
| 238 * @param {function(?string)} userCallback | 238 * @param {function(?string)} userCallback |
| 239 */ | 239 */ |
| 240 setStyleContent: function(uiSourceCode, content, majorChange, userCallback) | 240 setStyleContent: function(uiSourceCode, content, majorChange, userCallback) |
| 241 { | 241 { |
| 242 var resource = WebInspector.resourceForURL(uiSourceCode.url); | 242 var resource = WebInspector.resourceForURL(uiSourceCode.url); |
| 243 if (!resource) { | 243 if (!resource) { |
| 244 userCallback("No resource found: " + uiSourceCode.url); | 244 userCallback("No resource found: " + uiSourceCode.url); |
| 245 return; | 245 return; |
| 246 } | 246 } |
| 247 | |
| 248 this._cssModel.resourceBinding().requestStyleSheetIdForResource(resource
, callback.bind(this)); | |
| 249 | 247 |
| 250 /** | 248 var styleSheetId = this._cssModel.resourceBinding().styleSheetIdForResou
rce(resource); |
| 251 * @param {?CSSAgent.StyleSheetId} styleSheetId | 249 if (!styleSheetId) { |
| 252 */ | 250 userCallback("No stylesheet found: " + resource.frameId + ":" + reso
urce.url); |
| 253 function callback(styleSheetId) | 251 return; |
| 254 { | 252 } |
| 255 if (!styleSheetId) { | |
| 256 userCallback("No stylesheet found: " + resource.frameId + ":" +
resource.url); | |
| 257 return; | |
| 258 } | |
| 259 | 253 |
| 260 this._innerSetContent(styleSheetId, content, majorChange, userCallba
ck, null); | |
| 261 } | |
| 262 }, | |
| 263 | |
| 264 /** | |
| 265 * @param {CSSAgent.StyleSheetId} styleSheetId | |
| 266 * @param {string} content | |
| 267 * @param {boolean} majorChange | |
| 268 * @param {function(?string)} userCallback | |
| 269 */ | |
| 270 _innerSetContent: function(styleSheetId, content, majorChange, userCallback) | |
| 271 { | |
| 272 this._isSettingContent = true; | 254 this._isSettingContent = true; |
| 273 function callback(error) | 255 function callback(error) |
| 274 { | 256 { |
| 275 userCallback(error); | 257 userCallback(error); |
| 276 delete this._isSettingContent; | 258 delete this._isSettingContent; |
| 277 } | 259 } |
| 278 this._cssModel.setStyleSheetText(styleSheetId, content, majorChange, cal
lback.bind(this)); | 260 this._cssModel.setStyleSheetText(styleSheetId, content, majorChange, cal
lback.bind(this)); |
| 279 }, | 261 }, |
| 280 | 262 |
| 281 /** | 263 /** |
| (...skipping 18 matching lines...) Expand all Loading... |
| 300 } | 282 } |
| 301 CSSAgent.getStyleSheetText(event.data.styleSheetId, callback.bind(this))
; | 283 CSSAgent.getStyleSheetText(event.data.styleSheetId, callback.bind(this))
; |
| 302 }, | 284 }, |
| 303 | 285 |
| 304 /** | 286 /** |
| 305 * @param {CSSAgent.StyleSheetId} styleSheetId | 287 * @param {CSSAgent.StyleSheetId} styleSheetId |
| 306 * @param {string} content | 288 * @param {string} content |
| 307 */ | 289 */ |
| 308 _innerStyleSheetChanged: function(styleSheetId, content) | 290 _innerStyleSheetChanged: function(styleSheetId, content) |
| 309 { | 291 { |
| 310 /** | 292 var styleSheetURL = this._cssModel.resourceBinding().resourceURLForStyle
SheetId(styleSheetId); |
| 311 * @param {?string} styleSheetURL | 293 if (typeof styleSheetURL !== "string") |
| 312 */ | 294 return; |
| 313 function callback(styleSheetURL) | |
| 314 { | |
| 315 if (typeof styleSheetURL !== "string") | |
| 316 return; | |
| 317 | 295 |
| 318 var uiSourceCode = this._workspace.uiSourceCodeForURL(styleSheetURL)
; | 296 var uiSourceCode = this._workspace.uiSourceCodeForURL(styleSheetURL) |
| 319 if (!uiSourceCode) | 297 if (!uiSourceCode) |
| 320 return; | 298 return; |
| 321 | 299 |
| 322 if (uiSourceCode.styleFile()) | 300 if (uiSourceCode.styleFile()) |
| 323 uiSourceCode.styleFile().addRevision(content); | 301 uiSourceCode.styleFile().addRevision(content); |
| 324 } | 302 } |
| 325 | |
| 326 this._cssModel.resourceBinding().requestResourceURLForStyleSheetId(style
SheetId, callback.bind(this)); | |
| 327 }, | |
| 328 } | 303 } |
| 329 | 304 |
| 330 /** | 305 /** |
| 331 * @type {?WebInspector.StyleContentBinding} | 306 * @type {?WebInspector.StyleContentBinding} |
| 332 */ | 307 */ |
| 333 WebInspector.styleContentBinding = null; | 308 WebInspector.styleContentBinding = null; |
| OLD | NEW |