Bug 715011 - Check the computed style instead of the element style to determine scrollableness. r=Cwiiis
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 04 Jan 2012 13:24:56 -0500
changeset 85063 8e10a9f7ee1bc9e93fb5a52bf2068b921c9c2a26
parent 85062 505df76715456d7047899fa5f15b322a21114f20
child 85064 7ac9a1114c661b2e7860005a786a0d044df382c7
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersCwiiis
bugs715011
milestone12.0a1
Bug 715011 - Check the computed style instead of the element style to determine scrollableness. r=Cwiiis
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -2101,31 +2101,40 @@ var BrowserEventHandler = {
     }
 
     [aX, aY] = ElementTouchHelper.toBrowserCoords(aElement.ownerDocument.defaultView, aX, aY);
     let cwu = aElement.ownerDocument.defaultView.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
     aButton = aButton || 0;
     cwu.sendMouseEventToWindow(aName, Math.round(aX), Math.round(aY), aButton, 1, 0, true);
   },
 
+  _hasScrollableOverflow: function(elem) {
+    var win = elem.ownerDocument.defaultView;
+    if (!win)
+      return false;
+    var computedStyle = win.getComputedStyle(elem);
+    if (!computedStyle)
+      return false;
+    return computedStyle.overflow == 'auto' || computedStyle.overflow == 'scroll';
+  },
+
   _findScrollableElement: function(elem, checkElem) {
     // Walk the DOM tree until we find a scrollable element
     let scrollable = false;
     while (elem) {
       /* Element is scrollable if its scroll-size exceeds its client size, and:
        * - It has overflow 'auto' or 'scroll'
        * - It's a textarea
        * - It's an HTML/BODY node
        * - It's a select element showing multiple rows
        */
       if (checkElem) {
         if (((elem.scrollHeight > elem.clientHeight) ||
              (elem.scrollWidth > elem.clientWidth)) &&
-            (elem.style.overflow == 'auto' ||
-             elem.style.overflow == 'scroll' ||
+            (this._hasScrollableOverflow(elem) ||
              elem.mozMatchesSelector("html, body, textarea")) ||
             (elem instanceof HTMLSelectElement && (elem.size > 1 || elem.multiple))) {
           scrollable = true;
           break;
         }
       } else {
         checkElem = true;
       }