Bug 1468138 - Throttle box model update call. r=pbro draft
authorGabriel Luong <gabriel.luong@gmail.com>
Sun, 10 Jun 2018 22:48:14 -0400
changeset 806703 fdb50ea92070ab2f9227f53eea2688733001b15e
parent 806702 29598a3b4cc09aef566178a33b3c5d7dbd36da17
push id112908
push userbmo:gl@mozilla.com
push dateMon, 11 Jun 2018 02:53:29 +0000
reviewerspbro
bugs1468138
milestone62.0a1
Bug 1468138 - Throttle box model update call. r=pbro MozReview-Commit-ID: 25ExMknjhCM
devtools/client/inspector/boxmodel/box-model.js
--- a/devtools/client/inspector/boxmodel/box-model.js
+++ b/devtools/client/inspector/boxmodel/box-model.js
@@ -1,14 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
+const { throttle } = require("devtools/client/inspector/shared/utils");
+
 const {
   updateGeometryEditorEnabled,
   updateLayout,
   updateOffsetParent,
 } = require("./actions/box-model");
 
 loader.lazyRequireGetter(this, "EditingSession", "devtools/client/inspector/boxmodel/utils/editing-session");
 loader.lazyRequireGetter(this, "InplaceEditor", "devtools/client/shared/inplace-editor", true);
@@ -24,17 +26,17 @@ const NUMERIC = /^-?[\d\.]+$/;
  * @param  {Window} window
  *         The document window of the toolbox.
  */
 function BoxModel(inspector, window) {
   this.document = window.document;
   this.inspector = inspector;
   this.store = inspector.store;
 
-  this.updateBoxModel = this.updateBoxModel.bind(this);
+  this.updateBoxModel = throttle(this.updateBoxModel, 500, this);
 
   this.onHideBoxModelHighlighter = this.onHideBoxModelHighlighter.bind(this);
   this.onHideGeometryEditor = this.onHideGeometryEditor.bind(this);
   this.onMarkupViewLeave = this.onMarkupViewLeave.bind(this);
   this.onMarkupViewNodeHover = this.onMarkupViewNodeHover.bind(this);
   this.onNewSelection = this.onNewSelection.bind(this);
   this.onShowBoxModelEditor = this.onShowBoxModelEditor.bind(this);
   this.onShowBoxModelHighlighter = this.onShowBoxModelHighlighter.bind(this);