Changeset 246178 in webkit
- Timestamp:
- Jun 6, 2019 4:35:12 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 16 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r246175 r246178 1 2019-06-06 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Formatter: pretty-print CSS using a Worker 4 https://bugs.webkit.org/show_bug.cgi?id=197829 5 <rdar://problem/36891532> 6 7 Reviewed by Timothy Hatcher. 8 9 * inspector/formatting/formatting-css.html: Added. 10 * inspector/formatting/formatting-css-expected.txt: Added. 11 * inspector/formatting/resources/css-tests/basic-expected.css: Added. 12 * inspector/formatting/resources/css-tests/basic.css: Added. 13 * inspector/formatting/resources/css-tests/gradient-expected.css: Added. 14 * inspector/formatting/resources/css-tests/gradient.css: Added. 15 * inspector/formatting/resources/css-tests/keyframes-expected.css: Added. 16 * inspector/formatting/resources/css-tests/keyframes.css: Added. 17 * inspector/formatting/resources/css-tests/media-query-expected.css: Added. 18 * inspector/formatting/resources/css-tests/media-query.css: Added. 19 * inspector/formatting/resources/css-tests/selectors-expected.css: Added. 20 * inspector/formatting/resources/css-tests/selectors.css: Added. 21 * inspector/formatting/resources/css-tests/wrapping-expected.css: Added. 22 * inspector/formatting/resources/css-tests/wrapping.css: Added. 23 * inspector/formatting/resources/utilities.js: 24 (TestPage.registerInitializer.runFormattingTest): 25 1 26 2019-06-06 Youenn Fablet <youenn@apple.com> 2 27 -
trunk/LayoutTests/inspector/formatting/resources/utilities.js
r243953 r246178 14 14 let {testText, expectedText} = results; 15 15 return new Promise(function(resolve, reject) { 16 let workerProxy = WI.FormatterWorkerProxy.singleton(); 16 17 const indentString = " "; 17 let workerProxy = WI.FormatterWorkerProxy.singleton(); 18 let isModule = /^module/.test(testName); 19 workerProxy.formatJavaScript(testText, isModule, indentString, ({formattedText, sourceMapData}) => { 18 19 function callback({formattedText, sourceMapData}) { 20 20 let pass = formattedText === expectedText; 21 21 InspectorTest.log(pass ? "PASS" : "FAIL"); … … 37 37 38 38 resolve(pass); 39 }); 39 } 40 41 switch (mode) { 42 case "text/javascript": { 43 let isModule = /^module/.test(testName); 44 workerProxy.formatJavaScript(testText, isModule, indentString, callback); 45 break; 46 } 47 48 case "text/css": 49 workerProxy.formatCSS(testText, indentString, callback); 50 break; 51 } 40 52 }); 41 53 }); -
trunk/Source/WebInspectorUI/.eslintrc
r242743 r246178 91 91 92 92 // Formatters 93 "CSSFormatter": true, 93 94 "ESTreeWalker": true, 94 95 "EsprimaFormatter": true, -
trunk/Source/WebInspectorUI/ChangeLog
r246176 r246178 1 2019-06-06 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Formatter: pretty-print CSS using a Worker 4 https://bugs.webkit.org/show_bug.cgi?id=197829 5 <rdar://problem/36891532> 6 7 Reviewed by Timothy Hatcher. 8 9 * UserInterface/Proxies/FormatterWorkerProxy.js: 10 (WI.FormatterWorkerProxy.prototype.formatCSS): Added. 11 * UserInterface/Workers/Formatter/FormatterWorker.js: 12 (FormatterWorker.prototype.formatCSS): Added. 13 * UserInterface/Workers/Formatter/CSSFormatter.js: Added. 14 (CSSFormatter): 15 (CSSFormatter.prototype.get success): 16 (CSSFormatter.prototype.get formattedText): 17 (CSSFormatter.prototype.get sourceMapData): 18 (CSSFormatter.prototype._format): 19 20 * UserInterface/Workers/Formatter/FormatterContentBuilder.js: 21 (FormatterContentBuilder.prototype.get currentLine): Added. 22 23 * UserInterface/Views/TextEditor.js: 24 (WI.TextEditor.prototype._canUseFormatterWorker): 25 (WI.TextEditor.prototype._startWorkerPrettyPrint): 26 27 * .eslintrc: 28 1 29 2019-06-06 Devin Rousso <drousso@apple.com> 2 30 -
trunk/Source/WebInspectorUI/UserInterface/Proxies/FormatterWorkerProxy.js
r220119 r246178 51 51 } 52 52 53 formatCSS(sourceText, indentString, includeSourceMapData) 54 { 55 this.performAction("formatCSS", ...arguments); 56 } 57 53 58 // Public 54 59 -
trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js
r243826 r246178 897 897 _canUseFormatterWorker() 898 898 { 899 return this._codeMirror.getMode().name === "javascript"; 899 let mode = this._codeMirror.getMode().name; 900 return mode === "javascript" || mode === "css"; 900 901 } 901 902 … … 920 921 _startWorkerPrettyPrint(beforePrettyPrintState, callback) 921 922 { 923 let workerProxy = WI.FormatterWorkerProxy.singleton(); 922 924 let sourceText = this._codeMirror.getValue(); 923 925 let indentString = WI.indentString(); 924 926 const includeSourceMapData = true; 925 927 926 let sourceType = this._delegate ? this._delegate.textEditorScriptSourceType(this) : WI.Script.SourceType.Program; 927 const isModule = sourceType === WI.Script.SourceType.Module; 928 929 let workerProxy = WI.FormatterWorkerProxy.singleton(); 930 workerProxy.formatJavaScript(sourceText, isModule, indentString, includeSourceMapData, ({formattedText, sourceMapData}) => { 928 let formatCallback = ({formattedText, sourceMapData}) => { 931 929 // Handle if formatting failed, which is possible for invalid programs. 932 930 if (formattedText === null) { … … 935 933 } 936 934 this._finishPrettyPrint(beforePrettyPrintState, formattedText, sourceMapData, callback); 937 }); 935 }; 936 937 let mode = this._codeMirror.getMode().name; 938 if (mode === "javascript") { 939 let sourceType = this._delegate ? this._delegate.textEditorScriptSourceType(this) : WI.Script.SourceType.Program; 940 const isModule = sourceType === WI.Script.SourceType.Module; 941 workerProxy.formatJavaScript(sourceText, isModule, indentString, includeSourceMapData, formatCallback); 942 } else if (mode === "css") 943 workerProxy.formatCSS(sourceText, indentString, includeSourceMapData, formatCallback); 938 944 } 939 945 -
trunk/Source/WebInspectorUI/UserInterface/Workers/Formatter/FormatterContentBuilder.js
r199168 r246178 75 75 } 76 76 77 get currentLine() 78 { 79 return this._formattedContent.slice(this._formattedContent.lastIndexOf("\n") + 1).join(""); 80 } 81 77 82 setOriginalContent(originalContent) 78 83 { -
trunk/Source/WebInspectorUI/UserInterface/Workers/Formatter/FormatterWorker.js
r223308 r246178 30 30 "ESTreeWalker.js", 31 31 "EsprimaFormatter.js", 32 "CSSFormatter.js", 32 33 ]); 33 34 … … 89 90 } 90 91 92 formatCSS(sourceText, indentString, includeSourceMapData) 93 { 94 let result = {formattedText: null}; 95 let formatter = new CSSFormatter(sourceText, indentString); 96 if (formatter.success) { 97 result.formattedText = formatter.formattedText; 98 if (includeSourceMapData) 99 result.sourceMapData = formatter.sourceMapData; 100 } 101 return result; 102 } 103 91 104 // Private 92 105
Note: See TracChangeset
for help on using the changeset viewer.