Bug 1304513 - Get rid of sdk use in devtools/shared/layout/utils.js;r=tromey draft
authorBrian Grinstead <bgrinstead@mozilla.com>
Wed, 21 Sep 2016 16:12:46 -0700
changeset 416364 5e95a5c992997e30baf121fcfde7615a9fd36c83
parent 416363 69a451ac94605fe68efa3780fd20a66ccdcb0b35
child 531829 d492256f638e9af6d32800da9a009db56868038c
push id30115
push userbgrinstead@mozilla.com
push dateWed, 21 Sep 2016 23:13:27 +0000
reviewerstromey
bugs1304513
milestone52.0a1
Bug 1304513 - Get rid of sdk use in devtools/shared/layout/utils.js;r=tromey MozReview-Commit-ID: 9jWrJrwqSp3
devtools/shared/layout/utils.js
--- a/devtools/shared/layout/utils.js
+++ b/devtools/shared/layout/utils.js
@@ -1,32 +1,35 @@
 /* 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 { Ci, Cc } = require("chrome");
-const { memoize } = require("sdk/lang/functional");
 const nodeFilterConstants = require("devtools/shared/dom-node-filter-constants");
 
 loader.lazyRequireGetter(this, "setIgnoreLayoutChanges", "devtools/server/actors/layout", true);
 exports.setIgnoreLayoutChanges = (...args) =>
   this.setIgnoreLayoutChanges(...args);
 
 /**
  * Returns the `DOMWindowUtils` for the window given.
  *
  * @param {DOMWindow} win
  * @returns {DOMWindowUtils}
  */
-const utilsFor = memoize(
-  win => win.QueryInterface(Ci.nsIInterfaceRequestor)
-            .getInterface(Ci.nsIDOMWindowUtils)
-);
+const utilsCache = new WeakMap();
+function utilsFor(win) {
+  if (!utilsCache.has(win)) {
+    utilsCache.set(win, win.QueryInterface(Ci.nsIInterfaceRequestor)
+                           .getInterface(Ci.nsIDOMWindowUtils));
+  }
+  return utilsCache.get(win);
+}
 
 /**
  * like win.top, but goes through mozbrowsers and mozapps iframes.
  *
  * @param {DOMWindow} win
  * @return {DOMWindow}
  */
 function getTopWindow(win) {