Bug 1448096 - Throttle the inspector window resize handler with requestIdleCallback. r=bgrins draft
authorGabriel Luong <gabriel.luong@gmail.com>
Thu, 05 Apr 2018 18:29:35 -0400
changeset 778183 c18064e6687161eae0cf9c0d6a916091c05cc04c
parent 778182 c5788ecf518b9269c504057bd99ed4a3e354f45a
push id105414
push userbmo:gl@mozilla.com
push dateThu, 05 Apr 2018 22:30:11 +0000
reviewersbgrins
bugs1448096
milestone61.0a1
Bug 1448096 - Throttle the inspector window resize handler with requestIdleCallback. r=bgrins MozReview-Commit-ID: 7UwTDAR0JDs
devtools/client/inspector/inspector.js
--- a/devtools/client/inspector/inspector.js
+++ b/devtools/client/inspector/inspector.js
@@ -521,18 +521,21 @@ Inspector.prototype = {
     this.sidebar.off("destroy", this.onSidebarHidden);
   },
 
   /**
    * If Toolbox width is less than 600 px, the splitter changes its mode
    * to `horizontal` to support portrait view.
    */
   onPanelWindowResize: function() {
-    this.splitBox.setState({
-      vert: this.useLandscapeMode(),
+    this.panelWin.cancelIdleCallback(this._resizeTimerId);
+    this._resizeTimerId = this.panelWin.requestIdleCallback(() => {
+      this.splitBox.setState({
+        vert: this.useLandscapeMode(),
+      });
     });
   },
 
   getSidebarSize: function() {
     let width;
     let height;
     let splitSidebarWidth;