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

Unified Diff: third_party/WebKit/Source/devtools/front_end/common/FormatterWorkerPool.js

Issue 2783233005: DevTools: Move JavaScript and CSS outline into QuickOpen (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/common/FormatterWorkerPool.js
diff --git a/third_party/WebKit/Source/devtools/front_end/common/FormatterWorkerPool.js b/third_party/WebKit/Source/devtools/front_end/common/FormatterWorkerPool.js
index da21e10c4b8677bcb430bab0b0e477d5bc027b11..1898857053578405713964982260540360a23c36 100644
--- a/third_party/WebKit/Source/devtools/front_end/common/FormatterWorkerPool.js
+++ b/third_party/WebKit/Source/devtools/front_end/common/FormatterWorkerPool.js
@@ -182,6 +182,46 @@ Common.FormatterWorkerPool = class {
callback(isLastChunk, items);
}
}
+
+ /**
+ * @param {string} content
+ * @param {string} mimeType
+ * @param {function(boolean, !Array<!Common.FormatterWorkerPool.OutlineItem>)} callback
+ * @return {boolean}
+ */
+ outlineForMimetype(content, mimeType, callback) {
+ switch (mimeType) {
+ case 'text/html':
+ case 'text/javascript':
+ this.javaScriptOutline(content, javaScriptCallback);
+ return true;
+ case 'text/css':
+ this.parseCSS(content, cssCallback);
+ return true;
+ }
+ return false;
+
+ /**
+ * @param {boolean} isLastChunk
+ * @param {!Array<!Common.FormatterWorkerPool.JSOutlineItem>} items
+ */
+ function javaScriptCallback(isLastChunk, items) {
+ callback(
+ isLastChunk,
+ items.map(item => ({line: item.line, column: item.column, title: item.name, subtitle: item.arguments})));
+ }
+
+ /**
+ * @param {boolean} isLastChunk
+ * @param {!Array<!Common.FormatterWorkerPool.CSSRule>} rules
+ */
+ function cssCallback(isLastChunk, rules) {
+ callback(
+ isLastChunk,
+ rules.map(
+ rule => ({line: rule.lineNumber, column: rule.columnNumber, title: rule.selectorText || rule.atRule})));
+ }
+ }
};
Common.FormatterWorkerPool.MaxWorkers = 2;
@@ -216,6 +256,9 @@ Common.FormatterWorkerPool.FormatResult = class {
/** @typedef {{original: !Array<number>, formatted: !Array<number>}} */
Common.FormatterWorkerPool.FormatMapping;
+/** @typedef {{line: number, column: number, title: string, subtitle: (string|undefined) }} */
+Common.FormatterWorkerPool.OutlineItem;
+
Common.FormatterWorkerPool.JSOutlineItem = class {
constructor() {
/** @type {string} */

Powered by Google App Engine
This is Rietveld 408576698