mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1331802 - Fix remaining ESLint issues in devtools/server/actors/ r=tromey
MozReview-Commit-ID: 3dqvmCywg3s --HG-- extra : rebase_source : 222ff49f275bc0eb86c3b7d099a2255ea8c8776d
This commit is contained in:
parent
dec0a5e74d
commit
fe92e878e9
@ -127,11 +127,6 @@ devtools/client/webconsole/webconsole-connection-proxy.js
|
||||
devtools/client/webconsole/webconsole.js
|
||||
devtools/client/webide/**
|
||||
!devtools/client/webide/components/webideCli.js
|
||||
devtools/server/actors/webconsole.js
|
||||
devtools/server/actors/object.js
|
||||
devtools/server/actors/script.js
|
||||
devtools/server/actors/styleeditor.js
|
||||
devtools/server/actors/stylesheets.js
|
||||
devtools/server/tests/browser/storage-*.html
|
||||
!devtools/server/tests/browser/storage-unsecured-iframe.html
|
||||
devtools/server/tests/browser/stylesheets-nested-iframes.html
|
||||
|
@ -15,8 +15,8 @@ const { assert, dumpn } = DevToolsUtils;
|
||||
loader.lazyRequireGetter(this, "ThreadSafeChromeUtils");
|
||||
|
||||
const TYPED_ARRAY_CLASSES = ["Uint8Array", "Uint8ClampedArray", "Uint16Array",
|
||||
"Uint32Array", "Int8Array", "Int16Array", "Int32Array", "Float32Array",
|
||||
"Float64Array"];
|
||||
"Uint32Array", "Int8Array", "Int16Array", "Int32Array",
|
||||
"Float32Array", "Float64Array"];
|
||||
|
||||
// Number of items to preview in objects, arrays, maps, sets, lists,
|
||||
// collections, etc.
|
||||
@ -47,7 +47,7 @@ const OBJECT_PREVIEW_MAX_ITEMS = 10;
|
||||
* The Debuggee Global Object as given by the ThreadActor
|
||||
*/
|
||||
function ObjectActor(obj, {
|
||||
createValueGrip,
|
||||
createValueGrip: createValueGripHook,
|
||||
sources,
|
||||
createEnvironmentActor,
|
||||
getGripDepth,
|
||||
@ -59,7 +59,7 @@ function ObjectActor(obj, {
|
||||
"Should not create object actors for optimized out values!");
|
||||
this.obj = obj;
|
||||
this.hooks = {
|
||||
createValueGrip,
|
||||
createValueGrip: createValueGripHook,
|
||||
sources,
|
||||
createEnvironmentActor,
|
||||
getGripDepth,
|
||||
@ -86,7 +86,7 @@ ObjectActor.prototype = {
|
||||
|
||||
// If it's a proxy, lie and tell that it belongs to an invented
|
||||
// "Proxy" class, and avoid calling the [[IsExtensible]] trap
|
||||
if(this.obj.isProxy) {
|
||||
if (this.obj.isProxy) {
|
||||
g.class = "Proxy";
|
||||
g.proxyTarget = this.hooks.createValueGrip(this.obj.proxyTarget);
|
||||
g.proxyHandler = this.hooks.createValueGrip(this.obj.proxyHandler);
|
||||
@ -114,7 +114,9 @@ ObjectActor.prototype = {
|
||||
// Bug 1163520: Assert on internal functions
|
||||
g.ownPropertyLength = this.obj.getOwnPropertyNames().length;
|
||||
}
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
let raw = this.obj.unsafeDereference();
|
||||
|
||||
@ -570,7 +572,8 @@ ObjectActor.prototype = {
|
||||
"object grips with a 'Promise' class." };
|
||||
}
|
||||
|
||||
let promises = this.obj.promiseDependentPromises.map(p => this.hooks.createValueGrip(p));
|
||||
let promises = this.obj.promiseDependentPromises
|
||||
.map(p => this.hooks.createValueGrip(p));
|
||||
|
||||
return { promises };
|
||||
},
|
||||
@ -677,7 +680,9 @@ ObjectActor.prototype = {
|
||||
// Catch any errors if the source actor cannot be found
|
||||
try {
|
||||
source = this.hooks.sources().getSourceActorByURL(stack.source);
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
if (!source) {
|
||||
return null;
|
||||
@ -1363,8 +1368,8 @@ DebuggerServer.ObjectActorPreviewers = {
|
||||
return true;
|
||||
}
|
||||
|
||||
grip.preview.ownProperties['<target>'] = {value: grip.proxyTarget};
|
||||
grip.preview.ownProperties['<handler>'] = {value: grip.proxyHandler};
|
||||
grip.preview.ownProperties["<target>"] = {value: grip.proxyTarget};
|
||||
grip.preview.ownProperties["<handler>"] = {value: grip.proxyHandler};
|
||||
|
||||
return true;
|
||||
}],
|
||||
@ -1680,7 +1685,6 @@ DebuggerServer.ObjectActorPreviewers.Object = [
|
||||
preview.nodeName = preview.nodeName.toLowerCase();
|
||||
}
|
||||
|
||||
let i = 0;
|
||||
preview.attributes = {};
|
||||
preview.attributesLength = rawObj.attributes.length;
|
||||
for (let attr of rawObj.attributes) {
|
||||
@ -1808,21 +1812,21 @@ DebuggerServer.ObjectActorPreviewers.Object = [
|
||||
|
||||
// If no item is going to be displayed in preview, better display as sparse object.
|
||||
// The first key should contain the smallest integer index (if any).
|
||||
if(keys[0] >= OBJECT_PREVIEW_MAX_ITEMS) {
|
||||
if (keys[0] >= OBJECT_PREVIEW_MAX_ITEMS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Pseudo-arrays should only have array indices and, optionally, a "length" property.
|
||||
// Since integer indices are sorted first, check if the last property is "length".
|
||||
if(keys[keys.length-1] === "length") {
|
||||
if (keys[keys.length - 1] === "length") {
|
||||
keys.pop();
|
||||
length = DevToolsUtils.getProperty(obj, "length");
|
||||
} else {
|
||||
// Otherwise, let length be the (presumably) greatest array index plus 1.
|
||||
length = +keys[keys.length-1] + 1;
|
||||
length = +keys[keys.length - 1] + 1;
|
||||
}
|
||||
// Check if length is a valid array length, i.e. is a Uint32 number.
|
||||
if(typeof length !== "number" || length >>> 0 !== length) {
|
||||
if (typeof length !== "number" || length >>> 0 !== length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1831,10 +1835,10 @@ DebuggerServer.ObjectActorPreviewers.Object = [
|
||||
// which are not integer indices should be at the end. Then, iterating backwards
|
||||
// allows us to return earlier when the object is not completely a pseudo-array.
|
||||
let prev = length;
|
||||
for(let i = keys.length - 1; i >= 0; --i) {
|
||||
for (let i = keys.length - 1; i >= 0; --i) {
|
||||
let key = keys[i];
|
||||
let numKey = key >>> 0; // ToUint32(key)
|
||||
if (numKey + '' !== key || numKey >= prev) {
|
||||
if (numKey + "" !== key || numKey >= prev) {
|
||||
return false;
|
||||
}
|
||||
prev = numKey;
|
||||
@ -1855,7 +1859,7 @@ DebuggerServer.ObjectActorPreviewers.Object = [
|
||||
|
||||
for (let i = 0; i < numItems; ++i) {
|
||||
let desc = obj.getOwnPropertyDescriptor(i);
|
||||
if (desc && 'value' in desc) {
|
||||
if (desc && "value" in desc) {
|
||||
items.push(hooks.createValueGrip(desc.value));
|
||||
} else {
|
||||
items.push(null);
|
||||
@ -2178,8 +2182,7 @@ function createValueGrip(value, pool, makeObjectGrip) {
|
||||
case "object":
|
||||
if (value === null) {
|
||||
return { type: "null" };
|
||||
}
|
||||
else if (value.optimizedOut ||
|
||||
} else if (value.optimizedOut ||
|
||||
value.uninitialized ||
|
||||
value.missingArguments) {
|
||||
// The slot is optimized out, an uninitialized binding, or
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -5,12 +5,10 @@
|
||||
"use strict";
|
||||
|
||||
const {Cc, Ci} = require("chrome");
|
||||
const Services = require("Services");
|
||||
const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
|
||||
const promise = require("promise");
|
||||
const events = require("sdk/event/core");
|
||||
const protocol = require("devtools/shared/protocol");
|
||||
const {Arg, method, RetVal} = protocol;
|
||||
const {fetch} = require("devtools/shared/DevToolsUtils");
|
||||
const {oldStyleSheetSpec, styleEditorSpec} = require("devtools/shared/specs/styleeditor");
|
||||
|
||||
@ -18,18 +16,17 @@ loader.lazyGetter(this, "CssLogic", () => require("devtools/shared/inspector/css
|
||||
|
||||
var TRANSITION_CLASS = "moz-styleeditor-transitioning";
|
||||
var TRANSITION_DURATION_MS = 500;
|
||||
var TRANSITION_RULE = "\
|
||||
:root.moz-styleeditor-transitioning, :root.moz-styleeditor-transitioning * {\
|
||||
transition-duration: " + TRANSITION_DURATION_MS + "ms !important; \
|
||||
transition-delay: 0ms !important;\
|
||||
transition-timing-function: ease-out !important;\
|
||||
transition-property: all !important;\
|
||||
}";
|
||||
|
||||
var LOAD_ERROR = "error-load";
|
||||
var TRANSITION_RULE = ":root.moz-styleeditor-transitioning, " +
|
||||
":root.moz-styleeditor-transitioning * {\n" +
|
||||
"transition-duration: " + TRANSITION_DURATION_MS +
|
||||
"ms !important;\n" +
|
||||
"transition-delay: 0ms !important;\n" +
|
||||
"transition-timing-function: ease-out !important;\n" +
|
||||
"transition-property: all !important;\n" +
|
||||
"}";
|
||||
|
||||
var OldStyleSheetActor = protocol.ActorClassWithSpec(oldStyleSheetSpec, {
|
||||
toString: function() {
|
||||
toString: function () {
|
||||
return "[OldStyleSheetActor " + this.actorID + "]";
|
||||
},
|
||||
|
||||
@ -59,8 +56,7 @@ var OldStyleSheetActor = protocol.ActorClassWithSpec(oldStyleSheetSpec, {
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
get styleSheetIndex()
|
||||
{
|
||||
get styleSheetIndex() {
|
||||
if (this._styleSheetIndex == -1) {
|
||||
for (let i = 0; i < this.document.styleSheets.length; i++) {
|
||||
if (this.document.styleSheets[i] == this.rawSheet) {
|
||||
@ -72,14 +68,14 @@ var OldStyleSheetActor = protocol.ActorClassWithSpec(oldStyleSheetSpec, {
|
||||
return this._styleSheetIndex;
|
||||
},
|
||||
|
||||
initialize: function (aStyleSheet, aParentActor, aWindow) {
|
||||
initialize: function (styleSheet, parentActor, window) {
|
||||
protocol.Actor.prototype.initialize.call(this, null);
|
||||
|
||||
this.rawSheet = aStyleSheet;
|
||||
this.parentActor = aParentActor;
|
||||
this.rawSheet = styleSheet;
|
||||
this.parentActor = parentActor;
|
||||
this.conn = this.parentActor.conn;
|
||||
|
||||
this._window = aWindow;
|
||||
this._window = window;
|
||||
|
||||
// text and index are unknown until source load
|
||||
this.text = null;
|
||||
@ -133,8 +129,7 @@ var OldStyleSheetActor = protocol.ActorClassWithSpec(oldStyleSheetSpec, {
|
||||
|
||||
try {
|
||||
form.ruleCount = this.rawSheet.cssRules.length;
|
||||
}
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
// stylesheet had an @import rule that wasn't loaded yet
|
||||
}
|
||||
return form;
|
||||
@ -210,8 +205,7 @@ var OldStyleSheetActor = protocol.ActorClassWithSpec(oldStyleSheetSpec, {
|
||||
* defined in <http://www.w3.org/TR/CSS2/syndata.html#charset>.
|
||||
* Note that some of the algorithm is implemented in DevToolsUtils.fetch.
|
||||
*/
|
||||
_getCSSCharset: function ()
|
||||
{
|
||||
_getCSSCharset: function () {
|
||||
let sheet = this.rawSheet;
|
||||
if (sheet) {
|
||||
// Do we have a @charset rule in the stylesheet?
|
||||
@ -265,8 +259,7 @@ var OldStyleSheetActor = protocol.ActorClassWithSpec(oldStyleSheetSpec, {
|
||||
|
||||
if (transition) {
|
||||
this._insertTransistionRule();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this._notifyStyleApplied();
|
||||
}
|
||||
},
|
||||
@ -296,8 +289,7 @@ var OldStyleSheetActor = protocol.ActorClassWithSpec(oldStyleSheetSpec, {
|
||||
* This cleans up class and rule added for transition effect and then
|
||||
* notifies that the style has been applied.
|
||||
*/
|
||||
_onTransitionEnd: function ()
|
||||
{
|
||||
_onTransitionEnd: function () {
|
||||
if (--this._transitionRefCount == 0) {
|
||||
this.document.documentElement.classList.remove(TRANSITION_CLASS);
|
||||
this.rawSheet.deleteRule(this.rawSheet.cssRules.length - 1);
|
||||
@ -313,7 +305,7 @@ exports.OldStyleSheetActor = OldStyleSheetActor;
|
||||
* Creates a StyleEditorActor. StyleEditorActor provides remote access to the
|
||||
* stylesheets of a document.
|
||||
*/
|
||||
var StyleEditorActor = exports.StyleEditorActor = protocol.ActorClassWithSpec(styleEditorSpec, {
|
||||
var StyleEditorActor = protocol.ActorClassWithSpec(styleEditorSpec, {
|
||||
/**
|
||||
* The window we work with, taken from the parent actor.
|
||||
*/
|
||||
@ -328,8 +320,7 @@ var StyleEditorActor = exports.StyleEditorActor = protocol.ActorClassWithSpec(st
|
||||
return this.window.document;
|
||||
},
|
||||
|
||||
form: function ()
|
||||
{
|
||||
form: function () {
|
||||
return { actor: this.actorID };
|
||||
},
|
||||
|
||||
@ -345,8 +336,7 @@ var StyleEditorActor = exports.StyleEditorActor = protocol.ActorClassWithSpec(st
|
||||
/**
|
||||
* Destroy the current StyleEditorActor instance.
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
destroy: function () {
|
||||
this._sheets.clear();
|
||||
},
|
||||
|
||||
@ -362,8 +352,7 @@ var StyleEditorActor = exports.StyleEditorActor = protocol.ActorClassWithSpec(st
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=839103 is fixed
|
||||
if (this.document.readyState == "complete") {
|
||||
this._onDocumentLoaded();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.window.addEventListener("load", this._onDocumentLoaded);
|
||||
}
|
||||
return {};
|
||||
@ -379,7 +368,7 @@ var StyleEditorActor = exports.StyleEditorActor = protocol.ActorClassWithSpec(st
|
||||
}
|
||||
|
||||
let documents = [this.document];
|
||||
var forms = [];
|
||||
let forms = [];
|
||||
for (let doc of documents) {
|
||||
let sheetForms = this._addStyleSheets(doc.styleSheets);
|
||||
forms = forms.concat(sheetForms);
|
||||
@ -401,8 +390,7 @@ var StyleEditorActor = exports.StyleEditorActor = protocol.ActorClassWithSpec(st
|
||||
* @return {[object]}
|
||||
* Array of actors for each StyleSheetActor created
|
||||
*/
|
||||
_addStyleSheets: function (styleSheets)
|
||||
{
|
||||
_addStyleSheets: function (styleSheets) {
|
||||
let sheets = [];
|
||||
for (let i = 0; i < styleSheets.length; i++) {
|
||||
let styleSheet = styleSheets[i];
|
||||
@ -425,8 +413,7 @@ var StyleEditorActor = exports.StyleEditorActor = protocol.ActorClassWithSpec(st
|
||||
* @return {StyleSheetActor}
|
||||
* The actor for this style sheet
|
||||
*/
|
||||
_createStyleSheetActor: function (styleSheet)
|
||||
{
|
||||
_createStyleSheetActor: function (styleSheet) {
|
||||
if (this._sheets.has(styleSheet)) {
|
||||
return this._sheets.get(styleSheet);
|
||||
}
|
||||
@ -447,9 +434,9 @@ var StyleEditorActor = exports.StyleEditorActor = protocol.ActorClassWithSpec(st
|
||||
* All the imported stylesheets
|
||||
*/
|
||||
_getImported: function (styleSheet) {
|
||||
let imported = [];
|
||||
let imported = [];
|
||||
|
||||
for (let i = 0; i < styleSheet.cssRules.length; i++) {
|
||||
for (let i = 0; i < styleSheet.cssRules.length; i++) {
|
||||
let rule = styleSheet.cssRules[i];
|
||||
if (rule.type == Ci.nsIDOMCSSRule.IMPORT_RULE) {
|
||||
// Associated styleSheet may be null if it has already been seen due to
|
||||
@ -461,8 +448,7 @@ var StyleEditorActor = exports.StyleEditorActor = protocol.ActorClassWithSpec(st
|
||||
|
||||
// recurse imports in this stylesheet as well
|
||||
imported = imported.concat(this._getImported(rule.styleSheet));
|
||||
}
|
||||
else if (rule.type != Ci.nsIDOMCSSRule.CHARSET_RULE) {
|
||||
} else if (rule.type != Ci.nsIDOMCSSRule.CHARSET_RULE) {
|
||||
// @import rules must precede all others except @charset
|
||||
break;
|
||||
}
|
||||
@ -510,19 +496,3 @@ XPCOMUtils.defineLazyGetter(this, "DOMUtils", function () {
|
||||
|
||||
exports.StyleEditorActor = StyleEditorActor;
|
||||
|
||||
/**
|
||||
* Normalize multiple relative paths towards the base paths on the right.
|
||||
*/
|
||||
function normalize(...aURLs) {
|
||||
let base = Services.io.newURI(aURLs.pop());
|
||||
let url;
|
||||
while ((url = aURLs.pop())) {
|
||||
base = Services.io.newURI(url, null, base);
|
||||
}
|
||||
return base.spec;
|
||||
}
|
||||
|
||||
function dirname(aPath) {
|
||||
return Services.io.newURI(
|
||||
".", null, Services.io.newURI(aPath)).spec;
|
||||
}
|
||||
|
@ -38,8 +38,6 @@ var TRANSITION_RULE = `${TRANSITION_RULE_SELECTOR} {
|
||||
transition-property: all !important;
|
||||
}`;
|
||||
|
||||
var LOAD_ERROR = "error-load";
|
||||
|
||||
// The possible kinds of style-applied events.
|
||||
// UPDATE_PRESERVING_RULES means that the update is guaranteed to
|
||||
// preserve the number and order of rules on the style sheet.
|
||||
@ -61,12 +59,12 @@ let modifiedStyleSheets = new WeakMap();
|
||||
* in a source map.
|
||||
*/
|
||||
var OriginalSourceActor = protocol.ActorClassWithSpec(originalSourceSpec, {
|
||||
initialize: function (aUrl, aSourceMap, aParentActor) {
|
||||
initialize: function (url, sourceMap, parentActor) {
|
||||
protocol.Actor.prototype.initialize.call(this, null);
|
||||
|
||||
this.url = aUrl;
|
||||
this.sourceMap = aSourceMap;
|
||||
this.parentActor = aParentActor;
|
||||
this.url = url;
|
||||
this.sourceMap = sourceMap;
|
||||
this.parentActor = parentActor;
|
||||
this.conn = this.parentActor.conn;
|
||||
|
||||
this.text = null;
|
||||
@ -93,9 +91,9 @@ var OriginalSourceActor = protocol.ActorClassWithSpec(originalSourceSpec, {
|
||||
policy: Ci.nsIContentPolicy.TYPE_INTERNAL_STYLESHEET,
|
||||
window: this.window
|
||||
};
|
||||
return fetch(this.url, options).then(({content}) => {
|
||||
this.text = content;
|
||||
return content;
|
||||
return fetch(this.url, options).then(({content: text}) => {
|
||||
this.text = text;
|
||||
return text;
|
||||
});
|
||||
},
|
||||
|
||||
@ -126,21 +124,22 @@ var MediaRuleActor = protocol.ActorClassWithSpec(mediaRuleSpec, {
|
||||
return this.mql ? this.mql.matches : null;
|
||||
},
|
||||
|
||||
initialize: function (aMediaRule, aParentActor) {
|
||||
initialize: function (mediaRule, parentActor) {
|
||||
protocol.Actor.prototype.initialize.call(this, null);
|
||||
|
||||
this.rawRule = aMediaRule;
|
||||
this.parentActor = aParentActor;
|
||||
this.rawRule = mediaRule;
|
||||
this.parentActor = parentActor;
|
||||
this.conn = this.parentActor.conn;
|
||||
|
||||
this._matchesChange = this._matchesChange.bind(this);
|
||||
|
||||
this.line = DOMUtils.getRuleLine(aMediaRule);
|
||||
this.column = DOMUtils.getRuleColumn(aMediaRule);
|
||||
this.line = DOMUtils.getRuleLine(mediaRule);
|
||||
this.column = DOMUtils.getRuleColumn(mediaRule);
|
||||
|
||||
try {
|
||||
this.mql = this.window.matchMedia(aMediaRule.media.mediaText);
|
||||
this.mql = this.window.matchMedia(mediaRule.media.mediaText);
|
||||
} catch (e) {
|
||||
// Ignored
|
||||
}
|
||||
|
||||
if (this.mql) {
|
||||
@ -148,8 +147,7 @@ var MediaRuleActor = protocol.ActorClassWithSpec(mediaRuleSpec, {
|
||||
}
|
||||
},
|
||||
|
||||
destroy: function ()
|
||||
{
|
||||
destroy: function () {
|
||||
if (this.mql) {
|
||||
this.mql.removeListener(this._matchesChange);
|
||||
}
|
||||
@ -237,8 +235,7 @@ var StyleSheetActor = protocol.ActorClassWithSpec(styleSheetSpec, {
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
get styleSheetIndex()
|
||||
{
|
||||
get styleSheetIndex() {
|
||||
if (this._styleSheetIndex == -1) {
|
||||
for (let i = 0; i < this.document.styleSheets.length; i++) {
|
||||
if (this.document.styleSheets[i] == this.rawSheet) {
|
||||
@ -258,14 +255,14 @@ var StyleSheetActor = protocol.ActorClassWithSpec(styleSheetSpec, {
|
||||
}
|
||||
},
|
||||
|
||||
initialize: function (aStyleSheet, aParentActor, aWindow) {
|
||||
initialize: function (styleSheet, parentActor, window) {
|
||||
protocol.Actor.prototype.initialize.call(this, null);
|
||||
|
||||
this.rawSheet = aStyleSheet;
|
||||
this.parentActor = aParentActor;
|
||||
this.rawSheet = styleSheet;
|
||||
this.parentActor = parentActor;
|
||||
this.conn = this.parentActor.conn;
|
||||
|
||||
this._window = aWindow;
|
||||
this._window = window;
|
||||
|
||||
// text and index are unknown until source load
|
||||
this.text = null;
|
||||
@ -306,8 +303,7 @@ var StyleSheetActor = protocol.ActorClassWithSpec(styleSheetSpec, {
|
||||
let rules;
|
||||
try {
|
||||
rules = this.rawSheet.cssRules;
|
||||
}
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
// sheet isn't loaded yet
|
||||
}
|
||||
|
||||
@ -355,8 +351,7 @@ var StyleSheetActor = protocol.ActorClassWithSpec(styleSheetSpec, {
|
||||
if (this.ownerNode) {
|
||||
if (this.ownerNode instanceof Ci.nsIDOMHTMLDocument) {
|
||||
docHref = this.ownerNode.location.href;
|
||||
}
|
||||
else if (this.ownerNode.ownerDocument && this.ownerNode.ownerDocument.location) {
|
||||
} else if (this.ownerNode.ownerDocument && this.ownerNode.ownerDocument.location) {
|
||||
docHref = this.ownerNode.ownerDocument.location.href;
|
||||
}
|
||||
}
|
||||
@ -373,8 +368,7 @@ var StyleSheetActor = protocol.ActorClassWithSpec(styleSheetSpec, {
|
||||
|
||||
try {
|
||||
form.ruleCount = this.rawSheet.cssRules.length;
|
||||
}
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
// stylesheet had an @import rule that wasn't loaded yet
|
||||
this.getCSSRules().then(() => {
|
||||
this._notifyPropertyChanged("ruleCount");
|
||||
@ -597,7 +591,7 @@ var StyleSheetActor = protocol.ActorClassWithSpec(styleSheetSpec, {
|
||||
* Clear and unmanage the original source actors for this stylesheet.
|
||||
*/
|
||||
_clearOriginalSources: function () {
|
||||
for (actor in this._originalSources) {
|
||||
for (let actor in this._originalSources) {
|
||||
this.unmanage(actor);
|
||||
}
|
||||
this._originalSources = null;
|
||||
@ -606,16 +600,16 @@ var StyleSheetActor = protocol.ActorClassWithSpec(styleSheetSpec, {
|
||||
/**
|
||||
* Sets the source map's sourceRoot to be relative to the source map url.
|
||||
*/
|
||||
_setSourceMapRoot: function (aSourceMap, aAbsSourceMapURL, aScriptURL) {
|
||||
if (aScriptURL.startsWith("blob:")) {
|
||||
aScriptURL = aScriptURL.replace("blob:", "");
|
||||
_setSourceMapRoot: function (sourceMap, absSourceMapURL, scriptURL) {
|
||||
if (scriptURL.startsWith("blob:")) {
|
||||
scriptURL = scriptURL.replace("blob:", "");
|
||||
}
|
||||
const base = dirname(
|
||||
aAbsSourceMapURL.startsWith("data:")
|
||||
? aScriptURL
|
||||
: aAbsSourceMapURL);
|
||||
aSourceMap.sourceRoot = aSourceMap.sourceRoot
|
||||
? normalize(aSourceMap.sourceRoot, base)
|
||||
absSourceMapURL.startsWith("data:")
|
||||
? scriptURL
|
||||
: absSourceMapURL);
|
||||
sourceMap.sourceRoot = sourceMap.sourceRoot
|
||||
? normalize(sourceMap.sourceRoot, base)
|
||||
: base;
|
||||
},
|
||||
|
||||
@ -628,7 +622,7 @@ var StyleSheetActor = protocol.ActorClassWithSpec(styleSheetSpec, {
|
||||
* Url of source map.
|
||||
*/
|
||||
_extractSourceMapUrl: function (content) {
|
||||
var matches = /sourceMappingURL\=([^\s\*]*)/.exec(content);
|
||||
let matches = /sourceMappingURL\=([^\s\*]*)/.exec(content);
|
||||
if (matches) {
|
||||
return matches[1];
|
||||
}
|
||||
@ -689,8 +683,7 @@ var StyleSheetActor = protocol.ActorClassWithSpec(styleSheetSpec, {
|
||||
* defined in <http://www.w3.org/TR/CSS2/syndata.html#charset>.
|
||||
* Note that some of the algorithm is implemented in DevToolsUtils.fetch.
|
||||
*/
|
||||
_getCSSCharset: function ()
|
||||
{
|
||||
_getCSSCharset: function () {
|
||||
let sheet = this.rawSheet;
|
||||
if (sheet) {
|
||||
// Do we have a @charset rule in the stylesheet?
|
||||
@ -747,8 +740,7 @@ var StyleSheetActor = protocol.ActorClassWithSpec(styleSheetSpec, {
|
||||
|
||||
if (transition) {
|
||||
this._insertTransistionRule(kind);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
events.emit(this, "style-applied", kind, this);
|
||||
}
|
||||
|
||||
@ -770,16 +762,16 @@ var StyleSheetActor = protocol.ActorClassWithSpec(styleSheetSpec, {
|
||||
// Set up clean up and commit after transition duration (+buffer)
|
||||
// @see _onTransitionEnd
|
||||
this.window.clearTimeout(this._transitionTimeout);
|
||||
this._transitionTimeout = this.window.setTimeout(this._onTransitionEnd.bind(this, kind),
|
||||
TRANSITION_DURATION_MS + TRANSITION_BUFFER_MS);
|
||||
this._transitionTimeout = this.window.setTimeout(
|
||||
this._onTransitionEnd.bind(this, kind),
|
||||
TRANSITION_DURATION_MS + TRANSITION_BUFFER_MS);
|
||||
},
|
||||
|
||||
/**
|
||||
* This cleans up class and rule added for transition effect and then
|
||||
* notifies that the style has been applied.
|
||||
*/
|
||||
_onTransitionEnd: function (kind)
|
||||
{
|
||||
_onTransitionEnd: function (kind) {
|
||||
this._transitionTimeout = null;
|
||||
removePseudoClassLock(this.document.documentElement, TRANSITION_PSEUDO_CLASS);
|
||||
|
||||
@ -814,8 +806,7 @@ var StyleSheetsActor = protocol.ActorClassWithSpec(styleSheetsSpec, {
|
||||
return this.window.document;
|
||||
},
|
||||
|
||||
form: function ()
|
||||
{
|
||||
form: function () {
|
||||
return { actor: this.actorID };
|
||||
},
|
||||
|
||||
@ -883,8 +874,7 @@ var StyleSheetsActor = protocol.ActorClassWithSpec(styleSheetsSpec, {
|
||||
* @return {Promise}
|
||||
* Promise that resolves to an array of StyleSheetActors
|
||||
*/
|
||||
_addStyleSheets: function (win)
|
||||
{
|
||||
_addStyleSheets: function (win) {
|
||||
return Task.spawn(function* () {
|
||||
let doc = win.document;
|
||||
// readyState can be uninitialized if an iframe has just been created but
|
||||
@ -948,8 +938,7 @@ var StyleSheetsActor = protocol.ActorClassWithSpec(styleSheetsSpec, {
|
||||
// recurse imports in this stylesheet as well
|
||||
let children = yield this._getImported(doc, actor);
|
||||
imported = imported.concat(children);
|
||||
}
|
||||
else if (rule.type != Ci.nsIDOMCSSRule.CHARSET_RULE) {
|
||||
} else if (rule.type != Ci.nsIDOMCSSRule.CHARSET_RULE) {
|
||||
// @import rules must precede all others except @charset
|
||||
break;
|
||||
}
|
||||
@ -959,7 +948,6 @@ var StyleSheetsActor = protocol.ActorClassWithSpec(styleSheetsSpec, {
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Create a new style sheet in the document with the given text.
|
||||
* Return an actor for it.
|
||||
@ -989,16 +977,16 @@ exports.StyleSheetsActor = StyleSheetsActor;
|
||||
/**
|
||||
* Normalize multiple relative paths towards the base paths on the right.
|
||||
*/
|
||||
function normalize(...aURLs) {
|
||||
let base = Services.io.newURI(aURLs.pop());
|
||||
function normalize(...urls) {
|
||||
let base = Services.io.newURI(urls.pop());
|
||||
let url;
|
||||
while ((url = aURLs.pop())) {
|
||||
while ((url = urls.pop())) {
|
||||
base = Services.io.newURI(url, null, base);
|
||||
}
|
||||
return base.spec;
|
||||
}
|
||||
|
||||
function dirname(aPath) {
|
||||
function dirname(path) {
|
||||
return Services.io.newURI(
|
||||
".", null, Services.io.newURI(aPath)).spec;
|
||||
".", null, Services.io.newURI(path)).spec;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user