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

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

Issue 13845021: DevTools: Bring Sass support from behind the experiment (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Comments addressed Created 7 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 | 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 28 matching lines...) Expand all
39 { 39 {
40 this.pollPeriodMs = 5000; 40 this.pollPeriodMs = 5000;
41 this.pollIntervalMs = 200; 41 this.pollIntervalMs = 200;
42 42
43 this._cssModel = cssModel; 43 this._cssModel = cssModel;
44 this._workspace = workspace; 44 this._workspace = workspace;
45 this._networkWorkspaceProvider = networkWorkspaceProvider; 45 this._networkWorkspaceProvider = networkWorkspaceProvider;
46 this._addingRevisionCounter = 0; 46 this._addingRevisionCounter = 0;
47 this._reset(); 47 this._reset();
48 WebInspector.fileManager.addEventListener(WebInspector.FileManager.EventType s.SavedURL, this._fileSaveFinished, this); 48 WebInspector.fileManager.addEventListener(WebInspector.FileManager.EventType s.SavedURL, this._fileSaveFinished, this);
49 WebInspector.settings.cssSourceMapsEnabled.addChangeListener(this._toggleSou rceMapSupport, this)
49 this._cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheet Changed, this._styleSheetChanged, this); 50 this._cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheet Changed, this._styleSheetChanged, this);
50 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA dded, this._uiSourceCodeAdded, this); 51 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA dded, this._uiSourceCodeAdded, this);
51 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeC ontentCommitted, this._uiSourceCodeContentCommitted, this); 52 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeC ontentCommitted, this._uiSourceCodeContentCommitted, this);
52 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillRe set, this._reset, this); 53 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillRe set, this._reset, this);
53 } 54 }
54 55
55 WebInspector.SASSSourceMapping.prototype = { 56 WebInspector.SASSSourceMapping.prototype = {
56 /** 57 /**
57 * @param {WebInspector.Event} event 58 * @param {WebInspector.Event} event
58 */ 59 */
59 _styleSheetChanged: function(event) 60 _styleSheetChanged: function(event)
60 { 61 {
61 var id = /** @type {!CSSAgent.StyleSheetId} */ (event.data.styleSheetId) ; 62 var id = /** @type {!CSSAgent.StyleSheetId} */ (event.data.styleSheetId) ;
62 if (this._addingRevisionCounter) { 63 if (this._addingRevisionCounter) {
63 --this._addingRevisionCounter; 64 --this._addingRevisionCounter;
64 return; 65 return;
65 } 66 }
66 var header = this._cssModel.styleSheetHeaderForId(id); 67 var header = this._cssModel.styleSheetHeaderForId(id);
67 if (!header || !WebInspector.experimentsSettings.sass.isEnabled()) 68 if (!header)
68 return; 69 return;
69 70
70 var wasHeaderKnown = header.sourceURL && !!this._completeSourceMapURLFor CSSURL[header.sourceURL];
71 this.removeHeader(header); 71 this.removeHeader(header);
72 if (wasHeaderKnown)
73 header.updateLocations();
74 }, 72 },
75 73
76 /** 74 /**
75 * @param {WebInspector.Event} event
76 */
77 _toggleSourceMapSupport: function(event)
78 {
79 var enabled = /** @type {boolean} */ (event.data);
80 var headers = this._cssModel.styleSheetHeaders();
81 for (var i = 0; i < headers.length; ++i) {
82 if (enabled)
83 this.addHeader(headers[i]);
84 else
85 this.removeHeader(headers[i]);
86 }
87 },
88
89 /**
77 * @param {WebInspector.Event} event 90 * @param {WebInspector.Event} event
78 */ 91 */
79 _fileSaveFinished: function(event) 92 _fileSaveFinished: function(event)
80 { 93 {
81 var sassURL = /** @type {string} */ (event.data); 94 var sassURL = /** @type {string} */ (event.data);
82 this._sassFileSaved(sassURL, false); 95 this._sassFileSaved(sassURL, false);
83 }, 96 },
84 97
85 /** 98 /**
86 * @param {string} headerName 99 * @param {string} headerName
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 for (var i = 0; i < ids.length; ++i) 375 for (var i = 0; i < ids.length; ++i)
363 this._loadSourceMapAndBindUISourceCode(headers, true, completeSource MapURL); 376 this._loadSourceMapAndBindUISourceCode(headers, true, completeSource MapURL);
364 callback(cssURL, sassURL, true); 377 callback(cssURL, sassURL, true);
365 }, 378 },
366 379
367 /** 380 /**
368 * @param {WebInspector.CSSStyleSheetHeader} header 381 * @param {WebInspector.CSSStyleSheetHeader} header
369 */ 382 */
370 addHeader: function(header) 383 addHeader: function(header)
371 { 384 {
372 if (!header.sourceMapURL || !header.sourceURL || header.isInline || !Web Inspector.experimentsSettings.sass.isEnabled()) 385 if (!header.sourceMapURL || !header.sourceURL || header.isInline || !Web Inspector.settings.cssSourceMapsEnabled.get())
373 return; 386 return;
374 var completeSourceMapURL = WebInspector.ParsedURL.completeURL(header.sou rceURL, header.sourceMapURL); 387 var completeSourceMapURL = WebInspector.ParsedURL.completeURL(header.sou rceURL, header.sourceMapURL);
375 if (!completeSourceMapURL) 388 if (!completeSourceMapURL)
376 return; 389 return;
377 this._completeSourceMapURLForCSSURL[header.sourceURL] = completeSourceMa pURL; 390 this._completeSourceMapURLForCSSURL[header.sourceURL] = completeSourceMa pURL;
378 this._loadSourceMapAndBindUISourceCode([header], false, completeSourceMa pURL); 391 this._loadSourceMapAndBindUISourceCode([header], false, completeSourceMa pURL);
379 }, 392 },
380 393
381 /** 394 /**
382 * @param {WebInspector.CSSStyleSheetHeader} header 395 * @param {WebInspector.CSSStyleSheetHeader} header
383 */ 396 */
384 removeHeader: function(header) 397 removeHeader: function(header)
385 { 398 {
386 var sourceURL = header.sourceURL; 399 var sourceURL = header.sourceURL;
387 if (!sourceURL || !header.sourceMapURL || header.isInline || !this._comp leteSourceMapURLForCSSURL[sourceURL]) 400 if (!sourceURL || !header.sourceMapURL || header.isInline || !this._comp leteSourceMapURLForCSSURL[sourceURL])
388 return; 401 return;
389 delete this._sourceMapByStyleSheetURL[sourceURL]; 402 delete this._sourceMapByStyleSheetURL[sourceURL];
390 delete this._completeSourceMapURLForCSSURL[sourceURL]; 403 delete this._completeSourceMapURLForCSSURL[sourceURL];
391 for (var sassURL in this._cssURLsForSASSURL) { 404 for (var sassURL in this._cssURLsForSASSURL) {
392 var urls = this._cssURLsForSASSURL[sassURL]; 405 var urls = this._cssURLsForSASSURL[sassURL];
393 urls.remove(sourceURL); 406 urls.remove(sourceURL);
394 if (!urls.length) 407 if (!urls.length)
395 delete this._cssURLsForSASSURL[sassURL]; 408 delete this._cssURLsForSASSURL[sassURL];
396 } 409 }
397 var completeSourceMapURL = WebInspector.ParsedURL.completeURL(sourceURL, header.sourceMapURL); 410 var completeSourceMapURL = WebInspector.ParsedURL.completeURL(sourceURL, header.sourceMapURL);
398 if (completeSourceMapURL) 411 if (completeSourceMapURL)
399 delete this._sourceMapByURL[completeSourceMapURL]; 412 delete this._sourceMapByURL[completeSourceMapURL];
413 header.updateLocations();
400 }, 414 },
401 415
402 /** 416 /**
403 * @param {Array.<WebInspector.CSSStyleSheetHeader>} headersWithSameSourceUR L 417 * @param {Array.<WebInspector.CSSStyleSheetHeader>} headersWithSameSourceUR L
404 * @param {boolean} forceRebind 418 * @param {boolean} forceRebind
405 * @param {string} completeSourceMapURL 419 * @param {string} completeSourceMapURL
406 */ 420 */
407 _loadSourceMapAndBindUISourceCode: function(headersWithSameSourceURL, forceR ebind, completeSourceMapURL) 421 _loadSourceMapAndBindUISourceCode: function(headersWithSameSourceURL, forceR ebind, completeSourceMapURL)
408 { 422 {
409 console.assert(headersWithSameSourceURL.length); 423 console.assert(headersWithSameSourceURL.length);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 this._cssURLsForSASSURL = {}; 599 this._cssURLsForSASSURL = {};
586 /** @type {Object.<string, Array.<function(?WebInspector.SourceMap)>>} * / 600 /** @type {Object.<string, Array.<function(?WebInspector.SourceMap)>>} * /
587 this._pendingSourceMapLoadingCallbacks = {}; 601 this._pendingSourceMapLoadingCallbacks = {};
588 /** @type {Object.<string, {deadlineMs: number, dataByURL: Object.<strin g, {timer: number, previousPoll: number}>}>} */ 602 /** @type {Object.<string, {deadlineMs: number, dataByURL: Object.<strin g, {timer: number, previousPoll: number}>}>} */
589 this._pollDataForSASSURL = {}; 603 this._pollDataForSASSURL = {};
590 /** @type {Object.<string, WebInspector.SourceMap>} */ 604 /** @type {Object.<string, WebInspector.SourceMap>} */
591 this._sourceMapByURL = {}; 605 this._sourceMapByURL = {};
592 this._sourceMapByStyleSheetURL = {}; 606 this._sourceMapByStyleSheetURL = {};
593 } 607 }
594 } 608 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/DebuggerScriptMapping.js ('k') | Source/devtools/front_end/Settings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698