From 951162464984c26f56a5e13b56299239d1bee5db Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Tue, 21 Dec 2010 14:03:09 -0500 Subject: [PATCH] Deal with some Buffer.findScrollable corner cases. --HG-- extra : rebase_source : 6acbaac21f3098ab357ceddcd796e6566a61a6d9 --- common/content/buffer.js | 2 ++ common/content/io.js | 2 +- common/modules/util.jsm | 11 +++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/common/content/buffer.js b/common/content/buffer.js index d42691ca..ef1c2a82 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -1144,6 +1144,8 @@ const Buffer = Module("buffer", { findScrollable: function findScrollable(dir, horizontal) { function find(elem) { + while (!(elem instanceof Element) && elem.parentNode) + elem = elem.parentNode; for (; elem && elem.parentNode instanceof Element; elem = elem.parentNode) if (Buffer.isScrollable(elem, dir, horizontal)) break; diff --git a/common/content/io.js b/common/content/io.js index 0836e63c..e6d09e07 100644 --- a/common/content/io.js +++ b/common/content/io.js @@ -675,7 +675,7 @@ unlet s:cpo_save lines.__defineGetter__("last", function () this[this.length - 1]); for (let item in (isArray(items) ? array.iterValues : iter)(items)) { - if (item.length > width && (!lines.length || lines.last.length)) { + if (item.length > width && (!lines.length || lines.last.length > 1)) { lines.push([prefix]); width = WIDTH - prefix.length; prefix = " \\ "; diff --git a/common/modules/util.jsm b/common/modules/util.jsm index cc9b6448..da30fdeb 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -318,9 +318,16 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]) * @returns {Object} */ computedStyle: function computedStyle(node) { - while (node instanceof Ci.nsIDOMText && node.parentNode) + while (!(node instanceof Ci.nsIDOMElement) && node.parentNode) node = node.parentNode; - return node.ownerDocument.defaultView.getComputedStyle(node, null); + try { + return node.ownerDocument.defaultView.getComputedStyle(node, null); + } + catch (e) { + util.reportError(e); + util.dump(String(node)); + return {}; + } }, /**