From a53ce209be45615f2f3acebcd54b9f80a830b8b3 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Tue, 3 Jan 2012 16:10:25 -0500 Subject: [PATCH] Fix bug. --HG-- extra : rebase_source : 001c7dc9fde0e4e43d9d611b46fa9f6cb30328ff --- common/modules/dom.jsm | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/common/modules/dom.jsm b/common/modules/dom.jsm index ba65502b..6b0434c3 100644 --- a/common/modules/dom.jsm +++ b/common/modules/dom.jsm @@ -321,22 +321,26 @@ var DOM = Class("DOM", { this[0] ? this[0].getBoundingClientRect() : {}, get viewport() { - if (this[0] instanceof Ci.nsIDOMWindow) + let node = this[0]; + if (node instanceof Ci.nsIDOMDocument) + node = node.defaultView; + + if (node instanceof Ci.nsIDOMWindow) return { get width() this.right - this.left, get height() this.bottom - this.top, - bottom: this[0].innerHeight, - right: this[0].innerWidth, + bottom: node.innerHeight, + right: node.innerWidth, top: 0, left: 0 }; let r = this.rect; return { - width: this[0].clientWidth, - height: this[0].clientHeight, - top: r.top + this[0].clientTop, + width: node.clientWidth, + height: node.clientHeight, + top: r.top + node.clientTop, get bottom() this.top + this.height, - left: r.left + this[0].clientLeft, + left: r.left + node.clientLeft, get right() this.left + this.width } },