Bug 1468138 - Throttle box model update call. r=pbro
MozReview-Commit-ID: 25ExMknjhCM
--- 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);