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 cb60db70713415b2311dda7a3a95b44de7c1db7c..426fcf5d998e873576e78dab923ea0e0adcb4550 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 |
@@ -113,6 +113,8 @@ |
private float mUrlFocusChangePercent; |
private boolean mDisableUrlFocusChangeAnimations; |
+ /** Flag used to request some layout changes after the next layout pass is completed. */ |
+ private boolean mTileCountChanged; |
private boolean mSnapshotMostVisitedChanged; |
private int mSnapshotWidth; |
private int mSnapshotHeight; |
@@ -368,7 +370,7 @@ public void onClick(View v) { |
params.bottomMargin = 0; |
} |
- addOnLayoutChangeListener(this); |
+ mNewTabPageLayout.addOnLayoutChangeListener(this); |
setSearchProviderHasLogo(searchProviderHasLogo); |
mPendingLoadTasks++; |
@@ -807,9 +809,11 @@ void captureThumbnail(Canvas canvas) { |
@Override |
public void onLayoutChange(View v, int left, int top, int right, int bottom, |
int oldLeft, int oldTop, int oldRight, int oldBottom) { |
- int oldWidth = oldRight - oldLeft; |
- int newWidth = right - left; |
- if (oldWidth == newWidth) return; |
+ int oldHeight = oldBottom - oldTop; |
dgn
2016/07/08 23:45:36
Using height should achieve the same effect as wid
|
+ int newHeight = bottom - top; |
+ |
+ if (oldHeight == newHeight && !mTileCountChanged) return; |
+ mTileCountChanged = false; |
// Re-apply the url focus change amount after a rotation to ensure the views are correctly |
// placed with their new layout configurations. |
@@ -892,6 +896,12 @@ private void onOfflineUrlsAvailable(final String[] titles, final String[] urls, |
mHasReceivedMostVisitedSites = true; |
updateMostVisitedPlaceholderVisibility(); |
+ if (mUrlFocusChangePercent == 1f && oldItemCount != mMostVisitedItems.length) { |
+ // If the number of NTP Tile rows change while the URL bar is focused, the icons' |
+ // position will be wrong. Schedule the translation to be updated. |
+ mTileCountChanged = true; |
+ } |
+ |
if (isInitialLoad) { |
loadTaskCompleted(); |
// The page contents are initially hidden; otherwise they'll be drawn centered on the |