Bug 862053 - Use getBoundingClientRect instead of offsetParents, r=mdas, a=test-only
authorJonathan Griffin <jgriffin@mozilla.com>
Wed, 17 Apr 2013 00:42:10 -0700
changeset 119083 b81fce68ef67f2c354cd3a27aea678b2f1c03837
parent 119082 30dea6c6bedfa89a3dc8a5a9d3d45c1ed985b645
child 119084 a5a89b7510cc8ddfd0597e86debaae7cd8021ae5
push id678
push userdhunt@mozilla.com
push dateWed, 17 Apr 2013 17:27:28 +0000
reviewersmdas, test-only
bugs862053
milestone18.0
Bug 862053 - Use getBoundingClientRect instead of offsetParents, r=mdas, a=test-only
testing/marionette/marionette-listener.js
--- a/testing/marionette/marionette-listener.js
+++ b/testing/marionette/marionette-listener.js
@@ -706,29 +706,21 @@ function coordinates(target, x0, y0, x1,
   }
   return coords;
 }
 
 /**
  * This function returns if the element is in viewport 
  */
 function elementInViewport(el) {
-  let top = el.offsetTop;
-  let left = el.offsetLeft;
-  let width = el.offsetWidth;
-  let height = el.offsetHeight;
-  while(el.offsetParent) {
-    el = el.offsetParent;
-    top += el.offsetTop;
-    left += el.offsetLeft;
-  }
-  return (top >= curWindow.pageYOffset &&
-          left >= curWindow.pageXOffset &&
-          (top + height) <= (curWindow.pageYOffset + curWindow.innerHeight) &&
-          (left + width) <= (curWindow.pageXOffset + curWindow.innerWidth)
+  let rect = el.getBoundingClientRect();
+  return (rect.top >= curWindow.pageYOffset &&
+          rect.left >= curWindow.pageXOffset &&
+          rect.bottom <= (curWindow.pageYOffset + curWindow.innerHeight) &&
+          rect.right <= (curWindow.pageXOffset + curWindow.innerWidth)
          );
 }
 
 /**
  * This function throws the visibility of the element error
  */
 function checkVisible(el, command_id) {
   //check if the element is visible