зеркало из https://github.com/mozilla/gecko-dev.git
Last Comment Bug 931191 - Inspector janks for seconds at a time looking at chat.meatspac.es; r=mratcliffe
This commit is contained in:
Родитель
a0bd27f087
Коммит
ed56f0b1b3
|
@ -8,6 +8,7 @@ const {Cc, Ci, Cu} = require("chrome");
|
||||||
const {colorUtils} = require("devtools/css-color");
|
const {colorUtils} = require("devtools/css-color");
|
||||||
const {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
|
const {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
|
||||||
|
|
||||||
|
const MAX_ITERATIONS = 100;
|
||||||
const REGEX_QUOTES = /^".*?"|^".*/;
|
const REGEX_QUOTES = /^".*?"|^".*/;
|
||||||
const REGEX_URL = /^url\(["']?(.+?)(?::(\d+))?["']?\)/;
|
const REGEX_URL = /^url\(["']?(.+?)(?::(\d+))?["']?\)/;
|
||||||
const REGEX_WHITESPACE = /^\s+/;
|
const REGEX_WHITESPACE = /^\s+/;
|
||||||
|
@ -135,6 +136,7 @@ OutputParser.prototype = {
|
||||||
let dirty = false;
|
let dirty = false;
|
||||||
let matched = null;
|
let matched = null;
|
||||||
let nameValueSupported = false;
|
let nameValueSupported = false;
|
||||||
|
let i = 0;
|
||||||
|
|
||||||
let trimMatchFromStart = function(match) {
|
let trimMatchFromStart = function(match) {
|
||||||
text = text.substr(match.length);
|
text = text.substr(match.length);
|
||||||
|
@ -207,6 +209,14 @@ OutputParser.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
dirty = false;
|
dirty = false;
|
||||||
|
|
||||||
|
// Prevent this loop from slowing down the browser with too
|
||||||
|
// many nodes being appended into output.
|
||||||
|
i++;
|
||||||
|
if (i > MAX_ITERATIONS) {
|
||||||
|
trimMatchFromStart(text);
|
||||||
|
this._appendTextNode(text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._toDOM();
|
return this._toDOM();
|
||||||
|
@ -312,14 +322,10 @@ OutputParser.prototype = {
|
||||||
*/
|
*/
|
||||||
_appendTextNode: function(text) {
|
_appendTextNode: function(text) {
|
||||||
let lastItem = this.parsed[this.parsed.length - 1];
|
let lastItem = this.parsed[this.parsed.length - 1];
|
||||||
|
if (typeof lastItem === "string") {
|
||||||
if (typeof lastItem !== "undefined" && lastItem.nodeName === "#text") {
|
this.parsed[this.parsed.length - 1] = lastItem + text
|
||||||
lastItem.nodeValue += text;
|
|
||||||
} else {
|
} else {
|
||||||
let win = Services.appShell.hiddenDOMWindow;
|
this.parsed.push(text);
|
||||||
let doc = win.document;
|
|
||||||
let textNode = doc.createTextNode(text);
|
|
||||||
this.parsed.push(textNode);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -335,7 +341,11 @@ OutputParser.prototype = {
|
||||||
let frag = doc.createDocumentFragment();
|
let frag = doc.createDocumentFragment();
|
||||||
|
|
||||||
for (let item of this.parsed) {
|
for (let item of this.parsed) {
|
||||||
frag.appendChild(item);
|
if (typeof item === "string") {
|
||||||
|
frag.appendChild(doc.createTextNode(item));
|
||||||
|
} else {
|
||||||
|
frag.appendChild(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.parsed.length = 0;
|
this.parsed.length = 0;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче