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

Unified Diff: third_party/WebKit/Source/devtools/front_end/audits/AuditRules.js

Issue 2572053002: DevTools: kill SDK.CSSParser (Closed)
Patch Set: address comments 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/audits/AuditRules.js
diff --git a/third_party/WebKit/Source/devtools/front_end/audits/AuditRules.js b/third_party/WebKit/Source/devtools/front_end/audits/AuditRules.js
index 8aec3f3b5f758fd3258efc3915611b1663090d9f..9c2143569f302bb4a75c4febc1f04e5accd49911 100644
--- a/third_party/WebKit/Source/devtools/front_end/audits/AuditRules.js
+++ b/third_party/WebKit/Source/devtools/front_end/audits/AuditRules.js
@@ -510,29 +510,30 @@ Audits.AuditRules.StyleSheetProcessor = class {
}
run() {
- this._parser = new SDK.CSSParser();
this._processNextStyleSheet();
}
- _terminateWorker() {
- if (this._parser) {
- this._parser.dispose();
- delete this._parser;
- }
- }
-
- _finish() {
- this._terminateWorker();
- this._styleSheetsParsedCallback(this._styleSheets);
- }
-
_processNextStyleSheet() {
if (!this._styleSheetHeaders.length) {
- this._finish();
+ this._styleSheetsParsedCallback(this._styleSheets);
return;
}
this._currentStyleSheetHeader = this._styleSheetHeaders.shift();
- this._parser.fetchAndParse(this._currentStyleSheetHeader, this._onStyleSheetParsed.bind(this));
+
+ var allRules = [];
+ this._currentStyleSheetHeader.requestContent().then(
+ content => Common.formatterWorkerPool.parseCSS(content || '', onRulesParsed.bind(this)));
+
+ /**
+ * @param {boolean} isLastChunk
+ * @param {!Array<!Common.FormatterWorkerPool.CSSRule>} rules
+ * @this {Audits.AuditRules.StyleSheetProcessor}
+ */
+ function onRulesParsed(isLastChunk, rules) {
+ allRules.push(...rules);
+ if (isLastChunk)
+ this._onStyleSheetParsed(allRules);
+ }
}
/**
@@ -540,7 +541,7 @@ Audits.AuditRules.StyleSheetProcessor = class {
*/
_onStyleSheetParsed(rules) {
if (this._progress.isCanceled()) {
- this._finish();
+ this._styleSheetsParsedCallback(this._styleSheets);
return;
}
« no previous file with comments | « third_party/WebKit/Source/devtools/BUILD.gn ('k') | third_party/WebKit/Source/devtools/front_end/sdk/CSSParser.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698