SASSSourceMapping.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. /*
  2. * Copyright (C) 2012 Google Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are
  6. * met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above
  11. * copyright notice, this list of conditions and the following disclaimer
  12. * in the documentation and/or other materials provided with the
  13. * distribution.
  14. * * Neither the name of Google Inc. nor the names of its
  15. * contributors may be used to endorse or promote products derived from
  16. * this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. /**
  31. * @constructor
  32. * @implements {WebInspector.SourceMapping}
  33. * @param {WebInspector.CSSStyleModel} cssModel
  34. * @param {WebInspector.Workspace} workspace
  35. * @param {WebInspector.SimpleWorkspaceProvider} networkWorkspaceProvider
  36. */
  37. WebInspector.SASSSourceMapping = function(cssModel, workspace, networkWorkspaceProvider)
  38. {
  39. this.pollPeriodMs = 5000;
  40. this.pollIntervalMs = 200;
  41. this._cssModel = cssModel;
  42. this._workspace = workspace;
  43. this._networkWorkspaceProvider = networkWorkspaceProvider;
  44. this._addingRevisionCounter = 0;
  45. this._reset();
  46. WebInspector.fileManager.addEventListener(WebInspector.FileManager.EventTypes.SavedURL, this._fileSaveFinished, this);
  47. WebInspector.settings.cssSourceMapsEnabled.addChangeListener(this._toggleSourceMapSupport, this)
  48. this._cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetChanged, this._styleSheetChanged, this);
  49. this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeAdded, this._uiSourceCodeAdded, this);
  50. this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeContentCommitted, this._uiSourceCodeContentCommitted, this);
  51. this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this);
  52. }
  53. WebInspector.SASSSourceMapping.prototype = {
  54. /**
  55. * @param {WebInspector.Event} event
  56. */
  57. _styleSheetChanged: function(event)
  58. {
  59. var id = /** @type {!CSSAgent.StyleSheetId} */ (event.data.styleSheetId);
  60. if (this._addingRevisionCounter) {
  61. --this._addingRevisionCounter;
  62. return;
  63. }
  64. var header = this._cssModel.styleSheetHeaderForId(id);
  65. if (!header)
  66. return;
  67. this.removeHeader(header);
  68. },
  69. /**
  70. * @param {WebInspector.Event} event
  71. */
  72. _toggleSourceMapSupport: function(event)
  73. {
  74. var enabled = /** @type {boolean} */ (event.data);
  75. var headers = this._cssModel.styleSheetHeaders();
  76. for (var i = 0; i < headers.length; ++i) {
  77. if (enabled)
  78. this.addHeader(headers[i]);
  79. else
  80. this.removeHeader(headers[i]);
  81. }
  82. },
  83. /**
  84. * @param {WebInspector.Event} event
  85. */
  86. _fileSaveFinished: function(event)
  87. {
  88. var sassURL = /** @type {string} */ (event.data);
  89. this._sassFileSaved(sassURL, false);
  90. },
  91. /**
  92. * @param {string} headerName
  93. * @param {NetworkAgent.Headers} headers
  94. * @return {?string}
  95. */
  96. _headerValue: function(headerName, headers)
  97. {
  98. headerName = headerName.toLowerCase();
  99. var value = null;
  100. for (var name in headers) {
  101. if (name.toLowerCase() === headerName) {
  102. value = headers[name];
  103. break;
  104. }
  105. }
  106. return value;
  107. },
  108. /**
  109. * @param {NetworkAgent.Headers} headers
  110. * @return {?Date}
  111. */
  112. _lastModified: function(headers)
  113. {
  114. var lastModifiedHeader = this._headerValue("last-modified", headers);
  115. if (!lastModifiedHeader)
  116. return null;
  117. var lastModified = new Date(lastModifiedHeader);
  118. if (isNaN(lastModified.getTime()))
  119. return null;
  120. return lastModified;
  121. },
  122. /**
  123. * @param {NetworkAgent.Headers} headers
  124. * @param {string} url
  125. * @return {?Date}
  126. */
  127. _checkLastModified: function(headers, url)
  128. {
  129. var lastModified = this._lastModified(headers);
  130. if (lastModified)
  131. return lastModified;
  132. var etagMessage = this._headerValue("etag", headers) ? ", \"ETag\" response header found instead" : "";
  133. var message = String.sprintf("The \"Last-Modified\" response header is missing or invalid for %s%s. The CSS auto-reload functionality will not work correctly.", url, etagMessage);
  134. WebInspector.log(message);
  135. return null;
  136. },
  137. /**
  138. * @param {string} sassURL
  139. * @param {boolean} wasLoadedFromFileSystem
  140. */
  141. _sassFileSaved: function(sassURL, wasLoadedFromFileSystem)
  142. {
  143. var cssURLs = this._cssURLsForSASSURL[sassURL];
  144. if (!cssURLs)
  145. return;
  146. if (!WebInspector.settings.cssReloadEnabled.get())
  147. return;
  148. var sassFile = this._workspace.uiSourceCodeForURL(sassURL);
  149. console.assert(sassFile);
  150. if (wasLoadedFromFileSystem)
  151. sassFile.requestMetadata(metadataReceived.bind(this));
  152. else
  153. NetworkAgent.loadResourceForFrontend(WebInspector.resourceTreeModel.mainFrame.id, sassURL, undefined, sassLoadedViaNetwork.bind(this));
  154. /**
  155. * @param {?Protocol.Error} error
  156. * @param {number} statusCode
  157. * @param {NetworkAgent.Headers} headers
  158. * @param {string} content
  159. */
  160. function sassLoadedViaNetwork(error, statusCode, headers, content)
  161. {
  162. if (error || statusCode >= 400) {
  163. console.error("Could not load content for " + sassURL + " : " + (error || ("HTTP status code: " + statusCode)));
  164. return;
  165. }
  166. var lastModified = this._checkLastModified(headers, sassURL);
  167. if (!lastModified)
  168. return;
  169. metadataReceived.call(this, lastModified);
  170. }
  171. /**
  172. * @param {?Date} timestamp
  173. */
  174. function metadataReceived(timestamp)
  175. {
  176. if (!timestamp)
  177. return;
  178. var now = Date.now();
  179. var deadlineMs = now + this.pollPeriodMs;
  180. var pollData = this._pollDataForSASSURL[sassURL];
  181. if (pollData) {
  182. var dataByURL = pollData.dataByURL;
  183. for (var url in dataByURL)
  184. clearTimeout(dataByURL[url].timer);
  185. }
  186. pollData = { dataByURL: {}, deadlineMs: deadlineMs, sassTimestamp: timestamp };
  187. this._pollDataForSASSURL[sassURL] = pollData;
  188. for (var i = 0; i < cssURLs.length; ++i) {
  189. pollData.dataByURL[cssURLs[i]] = { previousPoll: now };
  190. this._pollCallback(cssURLs[i], sassURL, false);
  191. }
  192. }
  193. },
  194. /**
  195. * @param {string} cssURL
  196. * @param {string} sassURL
  197. * @param {boolean} stopPolling
  198. */
  199. _pollCallback: function(cssURL, sassURL, stopPolling)
  200. {
  201. var now;
  202. var pollData = this._pollDataForSASSURL[sassURL];
  203. if (!pollData)
  204. return;
  205. if (stopPolling || (now = new Date().getTime()) > pollData.deadlineMs) {
  206. delete pollData.dataByURL[cssURL];
  207. if (!Object.keys(pollData.dataByURL).length)
  208. delete this._pollDataForSASSURL[sassURL];
  209. return;
  210. }
  211. var nextPoll = this.pollIntervalMs + pollData.dataByURL[cssURL].previousPoll;
  212. var remainingTimeoutMs = Math.max(0, nextPoll - now);
  213. pollData.dataByURL[cssURL].previousPoll = now + remainingTimeoutMs;
  214. pollData.dataByURL[cssURL].timer = setTimeout(this._reloadCSS.bind(this, cssURL, sassURL, this._pollCallback.bind(this)), remainingTimeoutMs);
  215. },
  216. /**
  217. * @param {string} cssURL
  218. * @param {string} sassURL
  219. * @param {function(string, string, boolean)} callback
  220. */
  221. _reloadCSS: function(cssURL, sassURL, callback)
  222. {
  223. var cssUISourceCode = this._workspace.uiSourceCodeForURL(cssURL);
  224. if (!cssUISourceCode) {
  225. WebInspector.log(cssURL + " resource missing. Please reload the page.");
  226. callback(cssURL, sassURL, true);
  227. return;
  228. }
  229. if (this._workspace.hasMappingForURL(sassURL))
  230. this._reloadCSSFromFileSystem(cssUISourceCode, sassURL, callback);
  231. else
  232. this._reloadCSSFromNetwork(cssUISourceCode, sassURL, callback);
  233. },
  234. /**
  235. * @param {WebInspector.UISourceCode} cssUISourceCode
  236. * @param {string} sassURL
  237. * @param {function(string, string, boolean)} callback
  238. */
  239. _reloadCSSFromNetwork: function(cssUISourceCode, sassURL, callback)
  240. {
  241. var cssURL = cssUISourceCode.url;
  242. var data = this._pollDataForSASSURL[sassURL];
  243. if (!data) {
  244. callback(cssURL, sassURL, true);
  245. return;
  246. }
  247. var headers = { "if-modified-since": new Date(data.sassTimestamp.getTime() - 1000).toUTCString() };
  248. NetworkAgent.loadResourceForFrontend(WebInspector.resourceTreeModel.mainFrame.id, cssURL, headers, contentLoaded.bind(this));
  249. /**
  250. * @param {?Protocol.Error} error
  251. * @param {number} statusCode
  252. * @param {NetworkAgent.Headers} headers
  253. * @param {string} content
  254. */
  255. function contentLoaded(error, statusCode, headers, content)
  256. {
  257. if (error || statusCode >= 400) {
  258. console.error("Could not load content for " + cssURL + " : " + (error || ("HTTP status code: " + statusCode)));
  259. callback(cssURL, sassURL, true);
  260. return;
  261. }
  262. if (!this._pollDataForSASSURL[sassURL]) {
  263. callback(cssURL, sassURL, true);
  264. return;
  265. }
  266. if (statusCode === 304) {
  267. callback(cssURL, sassURL, false);
  268. return;
  269. }
  270. var lastModified = this._checkLastModified(headers, cssURL);
  271. if (!lastModified) {
  272. callback(cssURL, sassURL, true);
  273. return;
  274. }
  275. if (lastModified.getTime() < data.sassTimestamp.getTime()) {
  276. callback(cssURL, sassURL, false);
  277. return;
  278. }
  279. this._updateCSSRevision(cssUISourceCode, content, sassURL, callback);
  280. }
  281. },
  282. /**
  283. * @param {WebInspector.UISourceCode} cssUISourceCode
  284. * @param {string} content
  285. * @param {string} sassURL
  286. * @param {function(string, string, boolean)} callback
  287. */
  288. _updateCSSRevision: function(cssUISourceCode, content, sassURL, callback)
  289. {
  290. ++this._addingRevisionCounter;
  291. cssUISourceCode.addRevision(content);
  292. this._cssUISourceCodeUpdated(cssUISourceCode.url, sassURL, callback);
  293. },
  294. /**
  295. * @param {WebInspector.UISourceCode} cssUISourceCode
  296. * @param {string} sassURL
  297. * @param {function(string, string, boolean)} callback
  298. */
  299. _reloadCSSFromFileSystem: function(cssUISourceCode, sassURL, callback)
  300. {
  301. cssUISourceCode.requestMetadata(metadataCallback.bind(this));
  302. /**
  303. * @param {?Date} timestamp
  304. */
  305. function metadataCallback(timestamp)
  306. {
  307. var cssURL = cssUISourceCode.url;
  308. if (!timestamp) {
  309. callback(cssURL, sassURL, false);
  310. return;
  311. }
  312. var cssTimestamp = timestamp.getTime();
  313. var pollData = this._pollDataForSASSURL[sassURL];
  314. if (!pollData) {
  315. callback(cssURL, sassURL, true);
  316. return;
  317. }
  318. if (cssTimestamp < pollData.sassTimestamp.getTime()) {
  319. callback(cssURL, sassURL, false);
  320. return;
  321. }
  322. cssUISourceCode.requestOriginalContent(contentCallback.bind(this));
  323. function contentCallback(content)
  324. {
  325. // Empty string is a valid value, null means error.
  326. if (content === null)
  327. return;
  328. this._updateCSSRevision(cssUISourceCode, content, sassURL, callback);
  329. }
  330. }
  331. },
  332. /**
  333. * @param {string} cssURL
  334. * @param {string} sassURL
  335. * @param {function(string, string, boolean)} callback
  336. */
  337. _cssUISourceCodeUpdated: function(cssURL, sassURL, callback)
  338. {
  339. var completeSourceMapURL = this._completeSourceMapURLForCSSURL[cssURL];
  340. if (!completeSourceMapURL)
  341. return;
  342. var ids = this._cssModel.styleSheetIdsForURL(cssURL);
  343. if (!ids)
  344. return;
  345. var headers = [];
  346. for (var i = 0; i < ids.length; ++i)
  347. headers.push(this._cssModel.styleSheetHeaderForId(ids[i]));
  348. for (var i = 0; i < ids.length; ++i)
  349. this._loadSourceMapAndBindUISourceCode(headers, true, completeSourceMapURL);
  350. callback(cssURL, sassURL, true);
  351. },
  352. /**
  353. * @param {WebInspector.CSSStyleSheetHeader} header
  354. */
  355. addHeader: function(header)
  356. {
  357. if (!header.sourceMapURL || !header.sourceURL || header.isInline || !WebInspector.settings.cssSourceMapsEnabled.get())
  358. return;
  359. var completeSourceMapURL = WebInspector.ParsedURL.completeURL(header.sourceURL, header.sourceMapURL);
  360. if (!completeSourceMapURL)
  361. return;
  362. this._completeSourceMapURLForCSSURL[header.sourceURL] = completeSourceMapURL;
  363. this._loadSourceMapAndBindUISourceCode([header], false, completeSourceMapURL);
  364. },
  365. /**
  366. * @param {WebInspector.CSSStyleSheetHeader} header
  367. */
  368. removeHeader: function(header)
  369. {
  370. var sourceURL = header.sourceURL;
  371. if (!sourceURL || !header.sourceMapURL || header.isInline || !this._completeSourceMapURLForCSSURL[sourceURL])
  372. return;
  373. delete this._sourceMapByStyleSheetURL[sourceURL];
  374. delete this._completeSourceMapURLForCSSURL[sourceURL];
  375. for (var sassURL in this._cssURLsForSASSURL) {
  376. var urls = this._cssURLsForSASSURL[sassURL];
  377. urls.remove(sourceURL);
  378. if (!urls.length)
  379. delete this._cssURLsForSASSURL[sassURL];
  380. }
  381. var completeSourceMapURL = WebInspector.ParsedURL.completeURL(sourceURL, header.sourceMapURL);
  382. if (completeSourceMapURL)
  383. delete this._sourceMapByURL[completeSourceMapURL];
  384. header.updateLocations();
  385. },
  386. /**
  387. * @param {Array.<WebInspector.CSSStyleSheetHeader>} headersWithSameSourceURL
  388. * @param {boolean} forceRebind
  389. * @param {string} completeSourceMapURL
  390. */
  391. _loadSourceMapAndBindUISourceCode: function(headersWithSameSourceURL, forceRebind, completeSourceMapURL)
  392. {
  393. console.assert(headersWithSameSourceURL.length);
  394. var sourceURL = headersWithSameSourceURL[0].sourceURL;
  395. this._loadSourceMapForStyleSheet(completeSourceMapURL, sourceURL, forceRebind, sourceMapLoaded.bind(this));
  396. /**
  397. * @param {?WebInspector.SourceMap} sourceMap
  398. */
  399. function sourceMapLoaded(sourceMap)
  400. {
  401. if (!sourceMap)
  402. return;
  403. this._sourceMapByStyleSheetURL[sourceURL] = sourceMap;
  404. for (var i = 0; i < headersWithSameSourceURL.length; ++i) {
  405. if (forceRebind)
  406. headersWithSameSourceURL[i].updateLocations();
  407. else
  408. this._bindUISourceCode(headersWithSameSourceURL[i], sourceMap);
  409. }
  410. }
  411. },
  412. /**
  413. * @param {string} cssURL
  414. * @param {string} sassURL
  415. */
  416. _addCSSURLforSASSURL: function(cssURL, sassURL)
  417. {
  418. var cssURLs;
  419. if (this._cssURLsForSASSURL.hasOwnProperty(sassURL))
  420. cssURLs = this._cssURLsForSASSURL[sassURL];
  421. else {
  422. cssURLs = [];
  423. this._cssURLsForSASSURL[sassURL] = cssURLs;
  424. }
  425. if (cssURLs.indexOf(cssURL) === -1)
  426. cssURLs.push(cssURL);
  427. },
  428. /**
  429. * @param {string} completeSourceMapURL
  430. * @param {string} completeStyleSheetURL
  431. * @param {boolean} forceReload
  432. * @param {function(?WebInspector.SourceMap)} callback
  433. */
  434. _loadSourceMapForStyleSheet: function(completeSourceMapURL, completeStyleSheetURL, forceReload, callback)
  435. {
  436. var sourceMap = this._sourceMapByURL[completeSourceMapURL];
  437. if (sourceMap && !forceReload) {
  438. callback(sourceMap);
  439. return;
  440. }
  441. var pendingCallbacks = this._pendingSourceMapLoadingCallbacks[completeSourceMapURL];
  442. if (pendingCallbacks) {
  443. pendingCallbacks.push(callback);
  444. return;
  445. }
  446. pendingCallbacks = [callback];
  447. this._pendingSourceMapLoadingCallbacks[completeSourceMapURL] = pendingCallbacks;
  448. WebInspector.SourceMap.load(completeSourceMapURL, completeStyleSheetURL, sourceMapLoaded.bind(this));
  449. /**
  450. * @param {?WebInspector.SourceMap} sourceMap
  451. */
  452. function sourceMapLoaded(sourceMap)
  453. {
  454. var callbacks = this._pendingSourceMapLoadingCallbacks[completeSourceMapURL];
  455. delete this._pendingSourceMapLoadingCallbacks[completeSourceMapURL];
  456. if (!callbacks)
  457. return;
  458. if (sourceMap)
  459. this._sourceMapByURL[completeSourceMapURL] = sourceMap;
  460. else
  461. delete this._sourceMapByURL[completeSourceMapURL];
  462. for (var i = 0; i < callbacks.length; ++i)
  463. callbacks[i](sourceMap);
  464. }
  465. },
  466. /**
  467. * @param {WebInspector.CSSStyleSheetHeader} header
  468. * @param {WebInspector.SourceMap} sourceMap
  469. */
  470. _bindUISourceCode: function(header, sourceMap)
  471. {
  472. header.pushSourceMapping(this);
  473. var rawURL = header.sourceURL;
  474. var sources = sourceMap.sources();
  475. for (var i = 0; i < sources.length; ++i) {
  476. var url = sources[i];
  477. this._addCSSURLforSASSURL(rawURL, url);
  478. if (!this._workspace.hasMappingForURL(url) && !this._workspace.uiSourceCodeForURL(url)) {
  479. var contentProvider = sourceMap.sourceContentProvider(url, WebInspector.resourceTypes.Stylesheet);
  480. var uiSourceCode = this._networkWorkspaceProvider.addFileForURL(url, contentProvider, true);
  481. uiSourceCode.setSourceMapping(this);
  482. }
  483. }
  484. },
  485. /**
  486. * @param {WebInspector.RawLocation} rawLocation
  487. * @return {WebInspector.UILocation}
  488. */
  489. rawLocationToUILocation: function(rawLocation)
  490. {
  491. var location = /** @type WebInspector.CSSLocation */ (rawLocation);
  492. var entry;
  493. var sourceMap = this._sourceMapByStyleSheetURL[location.url];
  494. if (!sourceMap)
  495. return null;
  496. entry = sourceMap.findEntry(location.lineNumber, location.columnNumber);
  497. if (!entry || entry.length === 2)
  498. return null;
  499. var uiSourceCode = this._workspace.uiSourceCodeForURL(entry[2]);
  500. if (!uiSourceCode)
  501. return null;
  502. return new WebInspector.UILocation(uiSourceCode, entry[3], entry[4]);
  503. },
  504. /**
  505. * @param {WebInspector.UISourceCode} uiSourceCode
  506. * @param {number} lineNumber
  507. * @param {number} columnNumber
  508. * @return {WebInspector.RawLocation}
  509. */
  510. uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber)
  511. {
  512. // FIXME: Implement this when ui -> raw mapping has clients.
  513. return new WebInspector.CSSLocation(uiSourceCode.url || "", lineNumber, columnNumber);
  514. },
  515. /**
  516. * @return {boolean}
  517. */
  518. isIdentity: function()
  519. {
  520. return false;
  521. },
  522. /**
  523. * @param {WebInspector.Event} event
  524. */
  525. _uiSourceCodeAdded: function(event)
  526. {
  527. var uiSourceCode = /** @type {WebInspector.UISourceCode} */ (event.data);
  528. var cssURLs = this._cssURLsForSASSURL[uiSourceCode.url];
  529. if (!cssURLs)
  530. return;
  531. uiSourceCode.setSourceMapping(this);
  532. for (var i = 0; i < cssURLs.length; ++i) {
  533. var ids = this._cssModel.styleSheetIdsForURL(cssURLs[i]);
  534. for (var j = 0; j < ids.length; ++j) {
  535. var header = this._cssModel.styleSheetHeaderForId(ids[j]);
  536. console.assert(header);
  537. header.updateLocations();
  538. }
  539. }
  540. },
  541. /**
  542. * @param {WebInspector.Event} event
  543. */
  544. _uiSourceCodeContentCommitted: function(event)
  545. {
  546. var uiSourceCode = /** @type {WebInspector.UISourceCode} */ (event.data.uiSourceCode);
  547. if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSystem)
  548. this._sassFileSaved(uiSourceCode.url, true);
  549. },
  550. _reset: function()
  551. {
  552. this._addingRevisionCounter = 0;
  553. this._completeSourceMapURLForCSSURL = {};
  554. this._cssURLsForSASSURL = {};
  555. /** @type {Object.<string, Array.<function(?WebInspector.SourceMap)>>} */
  556. this._pendingSourceMapLoadingCallbacks = {};
  557. /** @type {Object.<string, {deadlineMs: number, dataByURL: Object.<string, {timer: number, previousPoll: number}>}>} */
  558. this._pollDataForSASSURL = {};
  559. /** @type {Object.<string, WebInspector.SourceMap>} */
  560. this._sourceMapByURL = {};
  561. this._sourceMapByStyleSheetURL = {};
  562. }
  563. }