Bug 898650 - Simplified scroll direction heuristics using scrollMaX/Y then document aspect ratio. r=mbrubeck
authorSam Foster <sfoster@mozilla.com>
Tue, 03 Sep 2013 17:24:47 -0700
changeset 145483 1793358348cfa500eb06e4a5cf8321f8c356a794
parent 145482 7e00c3ed09c1c82f0e7252c8281aaaf0c9ff4fb0
child 145484 7848c8ff7608b8e055660219461341c1821ea584
push id25214
push userkwierso@gmail.com
push dateThu, 05 Sep 2013 00:02:20 +0000
treeherdermozilla-central@99bd249e5a20 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
bugs898650
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 898650 - Simplified scroll direction heuristics using scrollMaX/Y then document aspect ratio. r=mbrubeck
browser/metro/modules/CrossSlide.jsm
--- a/browser/metro/modules/CrossSlide.jsm
+++ b/browser/metro/modules/CrossSlide.jsm
@@ -37,42 +37,38 @@ let CrossSlidingStateNames = [
 // --------------------------------
 // module helpers
 //
 
 function isSelectable(aElement) {
   // placeholder logic
   return aElement.nodeName == 'richgriditem';
 }
-
 function withinCone(aLen, aHeight) {
   // check pt falls within 45deg either side of the cross axis
   return aLen > aHeight;
 }
+function getScrollAxisFromElement(aElement) {
+  // keeping it simple - just return apparent scroll axis for the document
+  let win = aElement.ownerDocument.defaultView;
+  let scrollX = win.scrollMaxX,
+      scrollY = win.scrollMaxY;
+  // determine scroll axis from scrollable content when possible
+  if (scrollX || scrollY)
+    return scrollX >= scrollY ? 'x' : 'y';
 
-function getScrollAxisFromElement(aElement) {
-  let elem = aElement,
-      win = elem.ownerDocument.defaultView;
-  let scrollX, scrollY;
-  for (; elem && 1==elem.nodeType; elem = elem.parentNode) {
-    let cs = win.getComputedStyle(elem);
-    scrollX = (cs.overflowX=='scroll' || cs.overflowX=='auto');
-    scrollY = (cs.overflowX=='scroll' || cs.overflowX=='auto');
-    if (scrollX || scrollY) {
-      break;
-    }
-  }
-  return scrollX ? 'x' : 'y';
+  // fall back to guessing at scroll axis from document aspect ratio
+  let docElem = aElement.ownerDocument.documentElement;
+  return  docElem.clientWidth >= docElem.clientHeight ?
+          'x' : 'y';
 }
-
 function pointFromTouchEvent(aEvent) {
   let touch = aEvent.touches[0];
   return { x: touch.clientX, y: touch.clientY };
 }
-
 // This damping function has these important properties:
 // f(0) = 0
 // f'(0) = 1
 // limit as x -> Infinity of f(x) = 1
 function damp(aX) {
   return 2 / (1 + Math.exp(-2 * aX)) - 1;
 }
 function speedbump(aDelta, aStart, aEnd) {