Index: chrome/android/java/src/org/chromium/chrome/browser/util/ViewUtils.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/util/ViewUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/util/ViewUtils.java |
index 79d4f02e925c1d7b078945ff4810c104ced222e0..afd81ad14e7c279c2051070e8289337d3bb077a5 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/util/ViewUtils.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/util/ViewUtils.java |
@@ -68,9 +68,11 @@ public class ViewUtils { |
assert outPosition.length == 2; |
outPosition[0] = 0; |
outPosition[1] = 0; |
- while (childView != null && childView != rootView) { |
+ if (rootView == null || childView == rootView) return; |
+ while (childView != null) { |
outPosition[0] += childView.getLeft(); |
outPosition[1] += childView.getTop(); |
+ if (childView.getParent() == rootView) break; |
childView = (View) childView.getParent(); |
} |
} |
@@ -87,9 +89,11 @@ public class ViewUtils { |
assert outPosition.length == 2; |
outPosition[0] = 0; |
outPosition[1] = 0; |
- while (childView != null && childView != rootView) { |
+ if (rootView == null || childView == rootView) return; |
+ while (childView != null) { |
outPosition[0] += childView.getX(); |
outPosition[1] += childView.getY(); |
+ if (childView.getParent() == rootView) break; |
childView = (View) childView.getParent(); |
} |
} |