Bug 1304513 - Get rid of sdk use in devtools/shared/layout/utils.js;r=tromey
MozReview-Commit-ID: 9jWrJrwqSp3
--- 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) {