Bug 1573158 - Share one fragment across all consumers of places-popup r=surkov
authorBrian Grinstead <bgrinstead@mozilla.com>
Fri, 30 Aug 2019 21:23:34 +0000
changeset 491215 c90add9d9f7f36b023f240e9b2b7771b64c386d0
parent 491214 3f54e52c52eb5c4c9a0ff7ba8de2e21ed3fa1afa
child 491216 f6703db1f55296ef3bdfc360af3b3b957385a785
push id114017
push userdluca@mozilla.com
push dateMon, 02 Sep 2019 21:47:39 +0000
treeherdermozilla-inbound@4cd56624e723 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs1573158
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1573158 - Share one fragment across all consumers of places-popup r=surkov This will avoid parsing the markup strings into fragments for every consumer. Differential Revision: https://phabricator.services.mozilla.com/D43846
browser/components/places/content/places-menupopup.js
--- a/browser/components/places/content/places-menupopup.js
+++ b/browser/components/places/content/places-menupopup.js
@@ -29,16 +29,25 @@
       ];
       for (let event_name of event_names) {
         this.addEventListener(event_name, ev => this[`on_${event_name}`](ev));
       }
 
       this.attachShadow({ mode: "open" });
     }
 
+    get fragment() {
+      if (!this.constructor.hasOwnProperty("_fragment")) {
+        this.constructor._fragment = MozXULElement.parseXULToFragment(
+          this.markup
+        );
+      }
+      return document.importNode(this.constructor._fragment, true);
+    }
+
     get markup() {
       return `
       <html:link rel="stylesheet" href="chrome://global/skin/global.css" />
       <hbox flex="1" part="innerbox">
         <vbox part="drop-indicator-bar" hidden="true">
           <image part="drop-indicator" mousethrough="always"></image>
         </vbox>
         <arrowscrollbox class="popup-internal-box" flex="1" orient="vertical"
@@ -50,19 +59,17 @@
     }
 
     connectedCallback() {
       if (this.delayConnectedCallback()) {
         return;
       }
 
       this.shadowRoot.textContent = "";
-      this.shadowRoot.appendChild(
-        MozXULElement.parseXULToFragment(this.markup)
-      );
+      this.shadowRoot.appendChild(this.fragment);
 
       this._indicatorBar = this.shadowRoot.querySelector(
         "[part=drop-indicator-bar]"
       );
       this._scrollBox = this.shadowRoot.querySelector(".popup-internal-box");
 
       /**
        * Sub-menus should be opened when the mouse drags over them, and closed