From 5249447d5e68ae41647996f5ae013a688f19d63b Mon Sep 17 00:00:00 2001 From: Jinho Hwang Date: Fri, 26 Apr 2013 16:50:12 -0400 Subject: [PATCH] Bug 864684 - Prevent two way scrolling if it is not neccessary. r=vingtetun --- dom/browser-element/BrowserElementPanning.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/dom/browser-element/BrowserElementPanning.js b/dom/browser-element/BrowserElementPanning.js index 8ed3d59a1d0..b15e5defb2c 100644 --- a/dom/browser-element/BrowserElementPanning.js +++ b/dom/browser-element/BrowserElementPanning.js @@ -371,13 +371,20 @@ const ContentPanning = { let isScrolling = false; let oldX, oldY, newX, newY; let win, doc, htmlNode, bodyNode; + let xScrollable = content.scrollWidth > content.clientWidth; + let yScrollable = content.scrollHeight > content.clientHeight; function doScroll(node, delta) { if (node instanceof Ci.nsIDOMHTMLElement) { - oldX = node.scrollLeft, oldY = node.scrollTop; - node.scrollLeft += delta.x; - node.scrollTop += delta.y; - newX = node.scrollLeft, newY = node.scrollTop; + newX = oldX = node.scrollLeft, newY = oldY = node.scrollTop; + if (xScrollable) { + node.scrollLeft += delta.x; + newX = node.scrollLeft; + } + if (yScrollable) { + node.scrollTop += delta.y; + newY = node.scrollTop; + } return (newX != oldX || newY != oldY); } else if (node instanceof Ci.nsIDOMWindow) { win = node;