Bug 1459027 - Lazy load the AutocompletePopup in the rule view. r=pbro

This commit is contained in:
Gabriel Luong 2018-05-21 10:14:40 -04:00
Родитель b29b040b36
Коммит 6888ec6426
2 изменённых файлов: 20 добавлений и 10 удалений

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

@ -31,10 +31,10 @@ const TooltipsOverlay = require("devtools/client/inspector/shared/tooltips-overl
const {createChild, promiseWarn} = require("devtools/client/inspector/shared/utils"); const {createChild, promiseWarn} = require("devtools/client/inspector/shared/utils");
const {debounce} = require("devtools/shared/debounce"); const {debounce} = require("devtools/shared/debounce");
const EventEmitter = require("devtools/shared/event-emitter"); const EventEmitter = require("devtools/shared/event-emitter");
const AutocompletePopup = require("devtools/client/shared/autocomplete-popup");
loader.lazyRequireGetter(this, "ClassListPreviewer", "devtools/client/inspector/rules/views/class-list-previewer"); loader.lazyRequireGetter(this, "ClassListPreviewer", "devtools/client/inspector/rules/views/class-list-previewer");
loader.lazyRequireGetter(this, "StyleInspectorMenu", "devtools/client/inspector/shared/style-inspector-menu"); loader.lazyRequireGetter(this, "StyleInspectorMenu", "devtools/client/inspector/shared/style-inspector-menu");
loader.lazyRequireGetter(this, "AutocompletePopup", "devtools/client/shared/autocomplete-popup");
loader.lazyRequireGetter(this, "KeyShortcuts", "devtools/client/shared/key-shortcuts"); loader.lazyRequireGetter(this, "KeyShortcuts", "devtools/client/shared/key-shortcuts");
loader.lazyRequireGetter(this, "clipboardHelper", "devtools/shared/platform/clipboard"); loader.lazyRequireGetter(this, "clipboardHelper", "devtools/shared/platform/clipboard");
@ -176,12 +176,6 @@ function CssRuleView(inspector, document, store, pageStyle) {
this.showUserAgentStyles = Services.prefs.getBoolPref(PREF_UA_STYLES); this.showUserAgentStyles = Services.prefs.getBoolPref(PREF_UA_STYLES);
this.showFontEditor = Services.prefs.getBoolPref(PREF_FONT_EDITOR); this.showFontEditor = Services.prefs.getBoolPref(PREF_FONT_EDITOR);
// The popup will be attached to the toolbox document.
this.popup = new AutocompletePopup(inspector._toolbox.doc, {
autoSelect: true,
theme: "auto"
});
this._showEmpty(); this._showEmpty();
// Add the tooltips and highlighters to the view // Add the tooltips and highlighters to the view
@ -201,6 +195,18 @@ CssRuleView.prototype = {
// to figure out how shorthand properties will be parsed. // to figure out how shorthand properties will be parsed.
_dummyElement: null, _dummyElement: null,
get popup() {
if (!this._popup) {
// The popup will be attached to the toolbox document.
this._popup = new AutocompletePopup(this.inspector.toolbox.doc, {
autoSelect: true,
theme: "auto",
});
}
return this._popup;
},
get classListPreviewer() { get classListPreviewer() {
if (!this._classListPreviewer) { if (!this._classListPreviewer) {
this._classListPreviewer = new ClassListPreviewer(this.inspector, this.classPanel); this._classListPreviewer = new ClassListPreviewer(this.inspector, this.classPanel);
@ -784,7 +790,10 @@ CssRuleView.prototype = {
this._elementStyle.destroy(); this._elementStyle.destroy();
} }
this.popup.destroy(); if (this._popup) {
this._popup.destroy();
this._popup = null;
}
}, },
/** /**

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

@ -5,14 +5,15 @@
"use strict"; "use strict";
const HTML_NS = "http://www.w3.org/1999/xhtml";
const Services = require("Services"); const Services = require("Services");
const {HTMLTooltip} = require("devtools/client/shared/widgets/tooltip/HTMLTooltip");
const EventEmitter = require("devtools/shared/event-emitter"); const EventEmitter = require("devtools/shared/event-emitter");
const {HTMLTooltip} = require("devtools/client/shared/widgets/tooltip/HTMLTooltip");
const {PrefObserver} = require("devtools/client/shared/prefs"); const {PrefObserver} = require("devtools/client/shared/prefs");
const {colorUtils} = require("devtools/shared/css/color"); const {colorUtils} = require("devtools/shared/css/color");
const HTML_NS = "http://www.w3.org/1999/xhtml";
let itemIdCounter = 0; let itemIdCounter = 0;
/** /**
* Autocomplete popup UI implementation. * Autocomplete popup UI implementation.
* *