Changeset 132321 in webkit
- Timestamp:
- Oct 24, 2012, 12:34:24 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r132315 r132321 1 2012-10-24 Alexander Pavlov <[email protected]> 2 3 Web Inspector: Implement CSS reload upon related SASS resource saving 4 https://bugs.webkit.org/show_bug.cgi?id=98024 5 6 Reviewed by Vsevolod Vlasov. 7 8 SASS-generated debug info in CSS is parsed to find out which SASS files contributed to this stylesheet. 9 Upon SASS file save in the Sources panel, all affected external CSS stylesheets are reloaded to update 10 the page styles (presuming that SASS is running in the "watch" mode during the development cycle). 11 12 * English.lproj/localizedStrings.js: 13 * inspector/front-end/SASSSourceMapping.js: 14 (WebInspector.SASSSourceMapping): 15 (WebInspector.SASSSourceMapping.prototype._fileSaveFinished.callback): 16 (WebInspector.SASSSourceMapping.prototype._reloadCSS): 17 (_bindUISourceCode): 18 (_addCSSURLforSASSURL): 19 * inspector/front-end/Settings.js: 20 * inspector/front-end/SettingsScreen.js: 21 (WebInspector.GenericSettingsTab): 22 1 23 2012-10-23 Yury Semikhatsky <[email protected]> 2 24 -
trunk/Source/WebCore/English.lproj/localizedStrings.js
r132199 r132321 79 79 localizedStrings["Audit Present State"] = "Audit Present State"; 80 80 localizedStrings["Audits"] = "Audits"; 81 localizedStrings["Auto-reload CSS upon SASS save"] = "Auto-reload CSS upon SASS save"; 81 82 localizedStrings["Average"] = "Average"; 82 83 localizedStrings["Blocking"] = "Blocking"; … … 412 413 localizedStrings["Timeline"] = "Timeline"; 413 414 localizedStrings["Timeout"] = "Timeout"; 415 localizedStrings["Timeout (ms)"] = "Timeout (ms)"; 414 416 localizedStrings["Timer Fired"] = "Timer Fired"; 415 417 localizedStrings["Timer ID"] = "Timer ID"; -
trunk/Source/WebCore/inspector/front-end/SASSSourceMapping.js
r132234 r132321 38 38 this._workspace = workspace; 39 39 this._uiLocations = {}; 40 this._cssURLsForSASSURL = {}; 41 this._timeoutForURL = {}; 40 42 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, this._resourceAdded, this); 43 WebInspector.fileManager.addEventListener(WebInspector.FileManager.EventTypes.SavedURL, this._fileSaveFinished, this); 41 44 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this); 42 45 } … … 56 59 57 60 populateFrame.call(this, WebInspector.resourceTreeModel.mainFrame); 61 }, 62 63 /** 64 * @param {WebInspector.Event} event 65 */ 66 _fileSaveFinished: function(event) 67 { 68 var sassURL = /** @type {string} */ event.data; 69 function callback() 70 { 71 delete this._timeoutForURL[sassURL]; 72 var cssURLs = this._cssURLsForSASSURL[sassURL]; 73 if (!cssURLs) 74 return; 75 for (var i = 0; i < cssURLs.length; ++i) 76 this._reloadCSS(cssURLs[i]); 77 } 78 79 var timer = this._timeoutForURL[sassURL]; 80 if (timer) { 81 clearTimeout(timer); 82 delete this._timeoutForURL[sassURL]; 83 } 84 if (!WebInspector.settings.cssReloadEnabled.get() || !this._cssURLsForSASSURL[sassURL]) 85 return; 86 var timeout = WebInspector.settings.cssReloadTimeout.get(); 87 if (timeout && isFinite(timeout)) 88 this._timeoutForURL[sassURL] = setTimeout(callback.bind(this), Number(timeout)); 89 }, 90 91 _reloadCSS: function(url) 92 { 93 var uiSourceCode = this._workspace.uiSourceCodeForURL(url); 94 if (!uiSourceCode) 95 return; 96 var newContent = InspectorFrontendHost.loadResourceSynchronously(url); 97 uiSourceCode.addRevision(newContent); 58 98 }, 59 99 … … 122 162 var rawLocationString = rawURL + ":" + (rawLine + 1); // Next line after mapping metainfo 123 163 this._uiLocations[rawLocationString] = new WebInspector.UILocation(uiSourceCode, line - 1, 0); 164 this._addCSSURLforSASSURL(rawURL, url); 165 }, 166 167 /** 168 * @param {string} cssURL 169 * @param {string} sassURL 170 */ 171 _addCSSURLforSASSURL: function(cssURL, sassURL) 172 { 173 var cssURLs; 174 if (this._cssURLsForSASSURL.hasOwnProperty(sassURL)) 175 cssURLs = this._cssURLsForSASSURL[sassURL]; 176 else { 177 cssURLs = []; 178 this._cssURLsForSASSURL[sassURL] = cssURLs; 179 } 180 if (cssURLs.indexOf(cssURL) === -1) 181 cssURLs.push(cssURL); 124 182 }, 125 183 -
trunk/Source/WebCore/inspector/front-end/Settings.js
r131176 r132321 106 106 this.textEditorIndent = this.createSetting("textEditorIndent", " "); 107 107 this.lastDockState = this.createSetting("lastDockState", ""); 108 this.cssReloadEnabled = this.createSetting("cssReloadEnabled", false); 109 this.cssReloadTimeout = this.createSetting("cssReloadTimeout", 1000); 108 110 109 111 // If there are too many breakpoints in a storage, it is likely due to a recent bug that caused -
trunk/Source/WebCore/inspector/front-end/SettingsScreen.js
r131870 r132321 277 277 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Search in content scripts"), WebInspector.settings.searchInContentScripts)); 278 278 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Enable source maps"), WebInspector.settings.sourceMapsEnabled)); 279 if (WebInspector.experimentsSettings.isEnabled("sass")) 280 p.appendChild(this._createCSSAutoReloadControls()); 279 281 p.appendChild(this._createSelectSetting(WebInspector.UIString("Indentation"), [ 280 282 [ WebInspector.UIString("2 spaces"), WebInspector.TextEditorModel.Indent.TwoSpaces ], … … 332 334 // We need to manually update the checkbox state, since enabling JavaScript in the page can actually uncover the "forbidden" state. 333 335 PageAgent.setScriptExecutionDisabled(WebInspector.settings.javaScriptDisabled.get(), this._updateScriptDisabledCheckbox.bind(this)); 336 }, 337 338 _createCSSAutoReloadControls: function() 339 { 340 var fragment = document.createDocumentFragment(); 341 var labelElement = fragment.createChild("label"); 342 var checkboxElement = labelElement.createChild("input"); 343 checkboxElement.type = "checkbox"; 344 checkboxElement.checked = WebInspector.settings.cssReloadEnabled.get(); 345 checkboxElement.addEventListener("click", checkboxClicked, false); 346 labelElement.appendChild(document.createTextNode(WebInspector.UIString("Auto-reload CSS upon SASS save"))); 347 348 var fieldsetElement = fragment.createChild("fieldset"); 349 fieldsetElement.disabled = !checkboxElement.checked; 350 var p = fieldsetElement.createChild("p"); 351 p.appendChild(document.createTextNode(WebInspector.UIString("Timeout (ms)"))); 352 p.appendChild(document.createTextNode(" ")); 353 var timeoutInput = p.createChild("input"); 354 timeoutInput.value = WebInspector.settings.cssReloadTimeout.get(); 355 timeoutInput.style.width = "60px"; 356 timeoutInput.maxLength = 8; 357 timeoutInput.addEventListener("blur", blurListener, false); 358 return fragment; 359 360 function checkboxClicked() 361 { 362 var reloadEnabled = checkboxElement.checked; 363 WebInspector.settings.cssReloadEnabled.set(reloadEnabled); 364 fieldsetElement.disabled = !reloadEnabled; 365 } 366 367 function blurListener() 368 { 369 var value = timeoutInput.value; 370 if (!isFinite(value) || value <= 0) { 371 timeoutInput.value = WebInspector.settings.cssReloadTimeout.get(); 372 return; 373 } 374 WebInspector.settings.cssReloadTimeout.set(Number(value)); 375 } 334 376 }, 335 377
Note:
See TracChangeset
for help on using the changeset viewer.