Bug 1408085 - resizeWaterfall via requestIdleCallback;r=honza draft
authorgasolin <gasolin@gmail.com>
Mon, 16 Oct 2017 10:05:59 +0800
changeset 681166 0fe43bfe3df6bba029843646c5a7dc9c93a9fe7c
parent 680630 2ba9ba4fa63b942d8d9401f6ff6e40f5730adcd1
child 736109 69464e286704a4d10c7156053eb920a2972d19b1
push id84784
push userbmo:gasolin@mozilla.com
push dateTue, 17 Oct 2017 04:05:15 +0000
reviewershonza
bugs1408085
milestone58.0a1
Bug 1408085 - resizeWaterfall via requestIdleCallback;r=honza MozReview-Commit-ID: Fws5LrQGhlv
devtools/client/netmonitor/src/components/request-list-header.js
--- a/devtools/client/netmonitor/src/components/request-list-header.js
+++ b/devtools/client/netmonitor/src/components/request-list-header.js
@@ -82,19 +82,19 @@ const RequestListHeader = createClass({
     this.background.draw(props);
   },
 
   resizeWaterfall() {
     let waterfallHeader = this.refs.waterfallHeader;
     if (waterfallHeader) {
       // Measure its width and update the 'waterfallWidth' property in the store.
       // The 'waterfallWidth' will be further updated on every window resize.
-      setTimeout(() => {
-        this.props.resizeWaterfall(waterfallHeader.getBoundingClientRect().width);
-      }, 500);
+      window.cancelIdleCallback(this._resizeTimerId);
+      this._resizeTimerId = window.requestIdleCallback(() =>
+        this.props.resizeWaterfall(waterfallHeader.getBoundingClientRect().width));
     }
   },
 
   render() {
     let { columns, scale, sort, sortBy, waterfallWidth } = this.props;
 
     return (
       div({ className: "devtools-toolbar requests-list-headers" },