Bug 1420291 - instanciate RequestListContextMenu lazily r=Honza
authorTom Glowka <glowka.tom@gmail.com>
Fri, 16 Mar 2018 16:19:36 +0100
changeset 408974 e63bab1349dd
parent 408973 d5f031bf5d27
child 408975 79b72c904600
push id61379
push usernerli@mozilla.com
push dateTue, 20 Mar 2018 10:43:16 +0000
treeherderautoland@e63bab1349dd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1420291
milestone61.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 1420291 - instanciate RequestListContextMenu lazily r=Honza MozReview-Commit-ID: Db6fgkHJD1v
devtools/client/netmonitor/src/components/RequestListContent.js
--- a/devtools/client/netmonitor/src/components/RequestListContent.js
+++ b/devtools/client/netmonitor/src/components/RequestListContent.js
@@ -75,22 +75,16 @@ class RequestListContent extends Compone
     this.onScroll = this.onScroll.bind(this);
     this.onResize = this.onResize.bind(this);
     this.onKeyDown = this.onKeyDown.bind(this);
     this.onContextMenu = this.onContextMenu.bind(this);
     this.onFocusedNodeChange = this.onFocusedNodeChange.bind(this);
   }
 
   componentWillMount() {
-    const { connector, cloneSelectedRequest, openStatistics } = this.props;
-    this.contextMenu = new RequestListContextMenu({
-      connector,
-      cloneSelectedRequest,
-      openStatistics,
-    });
     this.tooltip = new HTMLTooltip(window.parent.document, { type: "arrow" });
     window.addEventListener("resize", this.onResize);
   }
 
   componentDidMount() {
     // Install event handler for displaying a tooltip
     this.tooltip.startTogglingOnHover(this.refs.contentEl, this.onHover, {
       toggleDelay: REQUESTS_TOOLTIP_TOGGLE_DELAY,
@@ -239,16 +233,26 @@ class RequestListContent extends Compone
       evt.stopPropagation();
       this.props.onSelectDelta(delta);
     }
   }
 
   onContextMenu(evt) {
     evt.preventDefault();
     let { selectedRequest, displayedRequests } = this.props;
+
+    if (!this.contextMenu) {
+      const { connector, cloneSelectedRequest, openStatistics } = this.props;
+      this.contextMenu = new RequestListContextMenu({
+        connector,
+        cloneSelectedRequest,
+        openStatistics,
+      });
+    }
+
     this.contextMenu.open(evt, selectedRequest, displayedRequests);
   }
 
   /**
    * If selection has just changed (by keyboard navigation), don't keep the list
    * scrolled to bottom, but allow scrolling up with the selection.
    */
   onFocusedNodeChange() {