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

Side by Side Diff: Source/devtools/front_end/StylesSourceMapping.js

Issue 18347003: DevTools: Implement CSS pretty-printing (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Comments addressed Created 7 years, 2 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
OLDNEW
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 200 }
201 } 201 }
202 202
203 /** 203 /**
204 * @constructor 204 * @constructor
205 * @param {WebInspector.UISourceCode} uiSourceCode 205 * @param {WebInspector.UISourceCode} uiSourceCode
206 */ 206 */
207 WebInspector.StyleFile = function(uiSourceCode) 207 WebInspector.StyleFile = function(uiSourceCode)
208 { 208 {
209 this._uiSourceCode = uiSourceCode; 209 this._uiSourceCode = uiSourceCode;
210 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Formatt edChanged, this._formattedChanged, this);
vsevik 2013/09/30 16:12:13 You don't need this because this should work out o
210 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyChanged, this._workingCopyChanged, this); 211 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyChanged, this._workingCopyChanged, this);
211 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyCommitted, this._workingCopyCommitted, this); 212 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyCommitted, this._workingCopyCommitted, this);
212 } 213 }
213 214
214 WebInspector.StyleFile.updateTimeout = 200; 215 WebInspector.StyleFile.updateTimeout = 200;
215 216
216 WebInspector.StyleFile.sourceURLRegex = /\n[\040\t]*\/\*#[\040\t]sourceURL=[\040 \t]*([^\s]*)[\040\t]*\*\/[\040\t]*$/m; 217 WebInspector.StyleFile.sourceURLRegex = /\n[\040\t]*\/\*#[\040\t]sourceURL=[\040 \t]*([^\s]*)[\040\t]*\*\/[\040\t]*$/m;
217 218
218 WebInspector.StyleFile.prototype = { 219 WebInspector.StyleFile.prototype = {
220 _formattedChanged: function()
221 {
222 WebInspector.styleContentBinding.styleContentFormattingChanged(this._uiS ourceCode);
223 },
224
219 _workingCopyCommitted: function(event) 225 _workingCopyCommitted: function(event)
220 { 226 {
221 if (this._isAddingRevision) 227 if (this._isAddingRevision)
222 return; 228 return;
223 229
224 this._commitIncrementalEdit(true); 230 this._commitIncrementalEdit(true);
225 }, 231 },
226 232
227 _workingCopyChanged: function(event) 233 _workingCopyChanged: function(event)
228 { 234 {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 if (this._uiSourceCode.project().type() === WebInspector.projectTypes.Fi leSystem) 277 if (this._uiSourceCode.project().type() === WebInspector.projectTypes.Fi leSystem)
272 content = content.replace(WebInspector.StyleFile.sourceURLRegex, "") ; 278 content = content.replace(WebInspector.StyleFile.sourceURLRegex, "") ;
273 this._uiSourceCode.addRevision(content); 279 this._uiSourceCode.addRevision(content);
274 delete this._isAddingRevision; 280 delete this._isAddingRevision;
275 }, 281 },
276 282
277 dispose: function() 283 dispose: function()
278 { 284 {
279 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyCommitted, this._workingCopyCommitted, this); 285 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyCommitted, this._workingCopyCommitted, this);
280 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyChanged, this._workingCopyChanged, this); 286 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyChanged, this._workingCopyChanged, this);
287 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. FormattedChanged, this._formattedChanged, this);
281 } 288 }
282 } 289 }
283 290
284 /** 291 /**
285 * @constructor 292 * @constructor
286 * @param {WebInspector.CSSStyleModel} cssModel 293 * @param {WebInspector.CSSStyleModel} cssModel
287 */ 294 */
288 WebInspector.StyleContentBinding = function(cssModel, workspace) 295 WebInspector.StyleContentBinding = function(cssModel, workspace)
289 { 296 {
290 this._cssModel = cssModel; 297 this._cssModel = cssModel;
291 this._workspace = workspace; 298 this._workspace = workspace;
292 this._cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheet Changed, this._styleSheetChanged, this); 299 this._cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheet Changed, this._styleSheetChanged, this);
293 } 300 }
294 301
295 WebInspector.StyleContentBinding.prototype = { 302 WebInspector.StyleContentBinding.prototype = {
296 /** 303 /**
297 * @param {WebInspector.UISourceCode} uiSourceCode 304 * @param {WebInspector.UISourceCode} uiSourceCode
305 */
306 styleContentFormattingChanged: function(uiSourceCode)
307 {
308 var styleSheetIds = this._cssModel.styleSheetIdsForURL(uiSourceCode.url) ;
309 for (var i = 0; i < styleSheetIds.length; ++i)
310 this._cssModel.styleSheetHeaderForId(styleSheetIds[i]).updateLocatio ns();
311 },
312
313 /**
314 * @param {WebInspector.UISourceCode} uiSourceCode
298 * @param {string} content 315 * @param {string} content
299 * @param {boolean} majorChange 316 * @param {boolean} majorChange
300 * @param {function(?string)} userCallback 317 * @param {function(?string)} userCallback
301 */ 318 */
302 setStyleContent: function(uiSourceCode, content, majorChange, userCallback) 319 setStyleContent: function(uiSourceCode, content, majorChange, userCallback)
303 { 320 {
304 var styleSheetIds = this._cssModel.styleSheetIdsForURL(uiSourceCode.url) ; 321 var styleSheetIds = this._cssModel.styleSheetIdsForURL(uiSourceCode.url) ;
305 if (!styleSheetIds.length) { 322 if (!styleSheetIds.length) {
306 userCallback("No stylesheet found: " + uiSourceCode.url); 323 userCallback("No stylesheet found: " + uiSourceCode.url);
307 return; 324 return;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 375
359 if (uiSourceCode.styleFile()) 376 if (uiSourceCode.styleFile())
360 uiSourceCode.styleFile().addRevision(content); 377 uiSourceCode.styleFile().addRevision(content);
361 } 378 }
362 } 379 }
363 380
364 /** 381 /**
365 * @type {?WebInspector.StyleContentBinding} 382 * @type {?WebInspector.StyleContentBinding}
366 */ 383 */
367 WebInspector.styleContentBinding = null; 384 WebInspector.styleContentBinding = null;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698