Bug 1634031, lazy load appmenu and extension notification panel by using a template r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D73389
This commit is contained in:
Emma Malysz
2020-05-08 16:53:45 +00:00
parent a8aac1e14b
commit 41fea0b093
7 changed files with 202 additions and 159 deletions

View File

@@ -252,7 +252,7 @@ class ExtensionControlledPopup {
// Find the elements we need.
let doc = win.document;
let panel = doc.getElementById("extension-notification-panel");
let panel = ExtensionControlledPopup._getAndMaybeCreatePanel(doc);
let popupnotification = doc.getElementById(this.popupnotificationId);
let urlBarWasFocused = win.gURLBar.focused;
@@ -323,7 +323,6 @@ class ExtensionControlledPopup {
anchorButton = action || doc.getElementById("PanelUI-menu-button");
}
let anchor = anchorButton.icon;
panel.hidden = false;
popupnotification.show();
panel.openPopup(anchor);
}
@@ -426,4 +425,14 @@ class ExtensionControlledPopup {
}
});
}
static _getAndMaybeCreatePanel(doc) {
// // Lazy load the extension-notification panel the first time we need to display it.
let template = doc.getElementById("extensionNotificationTemplate");
if (template) {
template.replaceWith(template.content);
}
return doc.getElementById("extension-notification-panel");
}
}