Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3976)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java

Issue 2203823002: Handle the search box being detached from the NewTabPageView when calculating its offset. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
index def6af76d2f301b16b4b86b0aa1e5f3b56876541..86ebfd460ca68c1a686a7b7db1e5ee432c506dcb 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
@@ -724,12 +724,19 @@ public class NewTabPageView extends FrameLayout
translation.set(0, 0);
- View view = (View) mSearchBoxView.getParent();
- while (view != null) {
+ View view = mSearchBoxView;
+ while (true) {
+ view = (View) view.getParent();
+ if (view == null) {
+ // The |mSearchBoxView| is not a child of this view. This can happen if the
+ // RecyclerView detaches the NewTabPageLayout after it has been scrolled out of
+ // view. Set the translation to the minimum Y value as an approximation.
+ translation.y = Integer.MIN_VALUE;
+ break;
+ }
translation.offset(-view.getScrollX(), -view.getScrollY());
if (view == this) break;
translation.offset((int) view.getX(), (int) view.getY());
- view = (View) view.getParent();
}
bounds.offset(translation.x, translation.y);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698