DevTools: fix CSS parser to property report last parsed chunk

This patch fixes CSSParser which failed to properly report last
parsed chunk.

BUG=329825

Review URL: https://codereview.chromium.org/208593002

git-svn-id: svn://svn.chromium.org/blink/trunk@169836 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0903d84b
......@@ -88,7 +88,7 @@ WebInspector.CSSParser.prototype = {
for (var i = 0; i < chunk.length; ++i)
this._rules.push(chunk[i]);
if (data.index === data.total - 1)
if (data.isLastChunk)
this._onFinishedParsing();
this.dispatchEventToListeners(WebInspector.CSSParser.Events.RulesParsed);
},
......@@ -104,7 +104,7 @@ WebInspector.CSSParser.prototype = {
}
/**
* @typedef {{index: number, total: number, chunk: !Array.<!WebInspector.CSSParser.Rule>}}
* @typedef {{isLastChunk: boolean, chunk: !Array.<!WebInspector.CSSParser.Rule>}}
*/
WebInspector.CSSParser.DataChunk;
......
......@@ -212,12 +212,9 @@ FormatterWorker.CSSParserStates = {
FormatterWorker.parseCSS = function(params)
{
var chunkSize = 100000; // characters per data chunk
var totalLength = params.content.length;
var lines = params.content.split("\n");
var chunkCount = FormatterWorker._chunkCount(totalLength, chunkSize);
var rules = [];
var processedChunkCharacters = 0;
var currentChunk = 0;
var state = FormatterWorker.CSSParserStates.Initial;
var rule;
......@@ -308,7 +305,7 @@ FormatterWorker.parseCSS = function(params)
}
processedChunkCharacters += newColumn - column;
if (processedChunkCharacters > chunkSize) {
postMessage({ chunk: rules, total: chunkCount, index: currentChunk++ });
postMessage({ chunk: rules, isLastChunk: false });
rules = [];
processedChunkCharacters = 0;
}
......@@ -319,7 +316,7 @@ FormatterWorker.parseCSS = function(params)
var line = lines[lineNumber];
tokenizer(line, processToken);
}
postMessage({ chunk: rules, total: chunkCount, index: currentChunk++ });
postMessage({ chunk: rules, isLastChunk: true });
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment