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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sources/ScriptFormatter.js

Issue 2570263002: DevTools: introduce API for the Common.FormatterWorkerPool. (Closed)
Patch Set: rebaseline Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/sources/ScriptFormatter.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sources/ScriptFormatter.js b/third_party/WebKit/Source/devtools/front_end/sources/ScriptFormatter.js
index d3e7433958a2af4beb39fdc7cb4c8daa9887dca3..3bc5ad7fc94dd9668f1bf6a252092f9809cf4362 100644
--- a/third_party/WebKit/Source/devtools/front_end/sources/ScriptFormatter.js
+++ b/third_party/WebKit/Source/devtools/front_end/sources/ScriptFormatter.js
@@ -85,27 +85,20 @@ Sources.ScriptFormatter = class {
this._callback = callback;
this._originalContent = content;
- var parameters = {
- mimeType: mimeType,
- content: content,
- indentString: Common.moduleSetting('textEditorIndent').get()
- };
- Common.formatterWorkerPool.runTask('format', parameters).then(this._didFormatContent.bind(this));
+ Common.formatterWorkerPool.format(mimeType, content, Common.moduleSetting('textEditorIndent').get())
+ .then(this._didFormatContent.bind(this));
}
/**
- * @param {?MessageEvent} event
+ * @param {?{content: string, mapping: !{original: !Array<number>, formatted: !Array<number>}}} data
dgozman 2016/12/14 19:33:00 FormatResult?
lushnikov 2016/12/14 23:36:56 Done.
*/
- _didFormatContent(event) {
- var formattedContent = '';
- var mapping = [];
- if (event) {
- formattedContent = event.data.content;
- mapping = event.data['mapping'];
- }
+ _didFormatContent(data) {
+ if (!data)
+ data = {content: '', mapping: {original: [], formatted: []}};
+
var sourceMapping = new Sources.FormatterSourceMappingImpl(
- this._originalContent.computeLineEndings(), formattedContent.computeLineEndings(), mapping);
- this._callback(formattedContent, sourceMapping);
+ this._originalContent.computeLineEndings(), data.content.computeLineEndings(), data.mapping);
+ this._callback(data.content, sourceMapping);
}
};
@@ -125,11 +118,6 @@ Sources.ScriptIdentityFormatter = class {
};
/**
- * @typedef {{original: !Array.<number>, formatted: !Array.<number>}}
- */
-Sources.FormatterMappingPayload;
-
-/**
* @interface
*/
Sources.FormatterSourceMapping = function() {};
@@ -184,7 +172,7 @@ Sources.FormatterSourceMappingImpl = class {
/**
* @param {!Array.<number>} originalLineEndings
* @param {!Array.<number>} formattedLineEndings
- * @param {!Sources.FormatterMappingPayload} mapping
+ * @param {!Common.FormatterWorkerPool.FormatMapping} mapping
*/
constructor(originalLineEndings, formattedLineEndings, mapping) {
this._originalLineEndings = originalLineEndings;

Powered by Google App Engine
This is Rietveld 408576698