From 299ff0ecb36165a65339f315fbff9136e63bb20a Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Mon, 27 Dec 2010 01:51:33 -0500 Subject: [PATCH] Make it impossible for util.computedStyle to return null. Closes issue #180. --- common/modules/util.jsm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 4c769000..9885a1e8 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -353,13 +353,15 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), while (!(node instanceof Ci.nsIDOMElement) && node.parentNode) node = node.parentNode; try { - return node.ownerDocument.defaultView.getComputedStyle(node, null); + var res = node.ownerDocument.defaultView.getComputedStyle(node, null); } - catch (e) { - util.reportError(e); - util.dump(String(node)); + catch (e) {} + if (res == null) { + util.dumpStack("Computed style is null: " + node); + Cu.reportError(Error("Computed style is null: " + node)); return {}; } + return res; }, /**