Bug 1187584 - Don't use the hidden window for creating value nodes in the rule view. r=mratcliffe

This commit is contained in:
Simon Lindholm 2015-07-28 09:36:00 -04:00
Родитель 4f6c514820
Коммит 0eebe6337a
5 изменённых файлов: 12 добавлений и 15 удалений

Просмотреть файл

@ -18,7 +18,7 @@ function* performTest() {
let [host, , doc] = yield createHost("bottom", "data:text/html," +
"<h1>browser_outputParser.js</h1><div></div>");
let parser = new OutputParser();
let parser = new OutputParser(doc);
testParseCssProperty(doc, parser);
testParseCssVar(doc, parser);

Просмотреть файл

@ -137,7 +137,7 @@ function CssComputedView(inspector, document, pageStyle) {
this.propertyViews = [];
this._outputParser = new OutputParser();
this._outputParser = new OutputParser(document);
let chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry);

Просмотреть файл

@ -1161,7 +1161,7 @@ function CssRuleView(inspector, document, aStore, aPageStyle) {
this.store = aStore || {};
this.pageStyle = aPageStyle;
this._outputParser = new OutputParser();
this._outputParser = new OutputParser(document);
this._onKeypress = this._onKeypress.bind(this);
this._onAddRule = this._onAddRule.bind(this);

Просмотреть файл

@ -310,7 +310,7 @@ function test() {
}
];
let parser = new OutputParser();
let parser = new OutputParser(document);
for (let i = 0; i < testData.length; i ++) {
let data = testData[i];
info("Output-parser test data " + i + ". {" + data.name + " : " + data.value + ";}");

Просмотреть файл

@ -44,12 +44,13 @@ loader.lazyGetter(this, "DOMUtils", function() {
* Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
* const {OutputParser} = devtools.require("devtools/output-parser");
*
* let parser = new OutputParser();
* let parser = new OutputParser(document);
*
* parser.parseCssProperty("color", "red"); // Returns document fragment.
*/
function OutputParser() {
function OutputParser(document) {
this.parsed = [];
this.doc = document;
this.colorSwatches = new WeakMap();
this._onSwatchMouseDown = this._onSwatchMouseDown.bind(this);
}
@ -442,12 +443,10 @@ OutputParser.prototype = {
* @param {String} [value]
* If a value is included it will be appended as a text node inside
* the tag. This is useful e.g. for span tags.
* @return {Node} Newly created Node.
* @return {Node} Newly created Node.
*/
_createNode: function(tagName, attributes, value="") {
let win = Services.appShell.hiddenDOMWindow;
let doc = win.document;
let node = doc.createElementNS(HTML_NS, tagName);
let node = this.doc.createElementNS(HTML_NS, tagName);
let attrs = Object.getOwnPropertyNames(attributes);
for (let attr of attrs) {
@ -457,7 +456,7 @@ OutputParser.prototype = {
}
if (value) {
let textNode = doc.createTextNode(value);
let textNode = this.doc.createTextNode(value);
node.appendChild(textNode);
}
@ -503,13 +502,11 @@ OutputParser.prototype = {
* Document Fragment
*/
_toDOM: function() {
let win = Services.appShell.hiddenDOMWindow;
let doc = win.document;
let frag = doc.createDocumentFragment();
let frag = this.doc.createDocumentFragment();
for (let item of this.parsed) {
if (typeof item === "string") {
frag.appendChild(doc.createTextNode(item));
frag.appendChild(this.doc.createTextNode(item));
} else {
frag.appendChild(item);
}