Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/sources/StyleSheetOutlineDialog.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/sources/StyleSheetOutlineDialog.js b/third_party/WebKit/Source/devtools/front_end/sources/StyleSheetOutlineDialog.js |
| index 83dc4bac8ccd750bb682482411f8c30176dfacd0..c560f15754e68bb803761a8eea8fd3ccd586d859 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/sources/StyleSheetOutlineDialog.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/sources/StyleSheetOutlineDialog.js |
| @@ -37,9 +37,11 @@ Sources.StyleSheetOutlineDialog = class extends UI.FilteredListWidget.Delegate { |
| constructor(uiSourceCode, selectItemCallback) { |
| super([]); |
| this._selectItemCallback = selectItemCallback; |
| - this._cssParser = new SDK.CSSParser(); |
| - this._cssParser.addEventListener(SDK.CSSParser.Events.RulesParsed, this.refresh.bind(this)); |
| - this._cssParser.parse(uiSourceCode.workingCopy()); |
| + this._rules = []; |
|
dgozman
2016/12/14 19:05:02
Let's @type this for compiler to kick-in.
lushnikov
2016/12/15 00:28:46
Done.
|
| + Common.formatterWorkerPool.parseCSS(uiSourceCode.workingCopy(), (isLastChunk, rules) => { |
| + this._rules.push(...rules); |
|
dgozman
2016/12/14 19:05:02
Are you sure this is safe to do?
lushnikov
2016/12/15 00:28:46
The feature has hit stable and looks simple. Shoul
|
| + this.refresh(); |
| + }); |
| } |
| /** |
| @@ -57,7 +59,7 @@ Sources.StyleSheetOutlineDialog = class extends UI.FilteredListWidget.Delegate { |
| * @return {number} |
| */ |
| itemCount() { |
| - return this._cssParser.rules().length; |
| + return this._rules.length; |
| } |
| /** |
| @@ -66,7 +68,7 @@ Sources.StyleSheetOutlineDialog = class extends UI.FilteredListWidget.Delegate { |
| * @return {string} |
| */ |
| itemKeyAt(itemIndex) { |
| - var rule = this._cssParser.rules()[itemIndex]; |
| + var rule = this._rules[itemIndex]; |
| return rule.selectorText || rule.atRule; |
| } |
| @@ -77,7 +79,7 @@ Sources.StyleSheetOutlineDialog = class extends UI.FilteredListWidget.Delegate { |
| * @return {number} |
| */ |
| itemScoreAt(itemIndex, query) { |
| - var rule = this._cssParser.rules()[itemIndex]; |
| + var rule = this._rules[itemIndex]; |
| return -rule.lineNumber; |
| } |
| @@ -89,7 +91,7 @@ Sources.StyleSheetOutlineDialog = class extends UI.FilteredListWidget.Delegate { |
| * @param {!Element} subtitleElement |
| */ |
| renderItem(itemIndex, query, titleElement, subtitleElement) { |
| - var rule = this._cssParser.rules()[itemIndex]; |
| + var rule = this._rules[itemIndex]; |
| titleElement.textContent = rule.selectorText || rule.atRule; |
| this.highlightRanges(titleElement, query); |
| subtitleElement.textContent = ':' + (rule.lineNumber + 1); |
| @@ -101,16 +103,9 @@ Sources.StyleSheetOutlineDialog = class extends UI.FilteredListWidget.Delegate { |
| * @param {string} promptValue |
| */ |
| selectItem(itemIndex, promptValue) { |
| - var rule = this._cssParser.rules()[itemIndex]; |
| + var rule = this._rules[itemIndex]; |
| var lineNumber = rule.lineNumber; |
| if (!isNaN(lineNumber) && lineNumber >= 0) |
| this._selectItemCallback(lineNumber, rule.columnNumber); |
| } |
| - |
| - /** |
| - * @override |
| - */ |
| - dispose() { |
| - this._cssParser.dispose(); |
| - } |
| }; |