Bug 1463652 - Lazy load the sourceMapURLService from the rule editor. r=pbro
MozReview-Commit-ID: Ei9g4zLO7KI
--- a/devtools/client/inspector/rules/views/rule-editor.js
+++ b/devtools/client/inspector/rules/views/rule-editor.js
@@ -49,19 +49,16 @@ const STYLE_INSPECTOR_L10N = new Localiz
* The Rule object we're editing.
*/
function RuleEditor(ruleView, rule) {
EventEmitter.decorate(this);
this.ruleView = ruleView;
this.doc = this.ruleView.styleDocument;
this.toolbox = this.ruleView.inspector.toolbox;
- // We stash this locally so that we can refer to it from |destroy|
- // without accidentally reinstantiating the service during shutdown.
- this.sourceMapURLService = this.toolbox.sourceMapURLService;
this.rule = rule;
this.isEditable = !rule.isSystem;
// Flag that blocks updates of the selector and properties when it is
// being edited
this.isEditing = false;
this._onNewProperty = this._onNewProperty.bind(this);
@@ -90,21 +87,32 @@ RuleEditor.prototype = {
if (this.rule.sheet) {
url = this.rule.sheet.href || this.rule.sheet.nodeHref;
}
if (url && !this.rule.isSystem && this.rule.domRule.type !== ELEMENT_STYLE) {
// Only get the original source link if the rule isn't a system
// rule and if it isn't an inline rule.
let sourceLine = this.rule.ruleLine;
let sourceColumn = this.rule.ruleColumn;
- this.sourceMapURLService.unsubscribe(url, sourceLine, sourceColumn,
- this._updateLocation);
+
+ if (this._sourceMapURLService) {
+ this.sourceMapURLService.unsubscribe(url, sourceLine, sourceColumn,
+ this._updateLocation);
+ }
}
},
+ get sourceMapURLService() {
+ if (!this._sourceMapURLService) {
+ this._sourceMapURLService = this.toolbox.sourceMapURLService;
+ }
+
+ return this._sourceMapURLService;
+ },
+
get isSelectorEditable() {
let trait = this.isEditable &&
this.ruleView.inspector.target.client.traits.selectorEditable &&
this.rule.domRule.type !== ELEMENT_STYLE &&
this.rule.domRule.type !== CSSRule.KEYFRAME_RULE;
// Do not allow editing anonymousselectors until we can
// detect mutations on pseudo elements in Bug 1034110.