Commit 2db4f032 authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Android: Fix regression on simplified NTP

https://crrev.com/c/1180637 introduced a regression on the simplified
NTP. TextView in native page has a sizing issue when View#layout() is
invoked in unattached state. This CL makes layout not performed
in the corresponding state.

Bug: 876686
Change-Id: I81eff601781ec85e398ccc4d1ce555c441e20ddb
Reviewed-on: https://chromium-review.googlesource.com/1189682Reviewed-by: default avatarTheresa <twellington@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587916}
parent 28a596db
...@@ -210,6 +210,13 @@ public class CompositorViewHolder extends FrameLayout ...@@ -210,6 +210,13 @@ public class CompositorViewHolder extends FrameLayout
@Override @Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) { int oldLeft, int oldTop, int oldRight, int oldBottom) {
Tab tab = getCurrentTab();
// Set the size of NTP if we're in the attached state as it may have not been sized
// properly when initializing tab. See the comment in #initializeTab() for why.
if (tab != null && tab.isNativePage() && isAttachedToWindow(tab.getView())) {
Point viewportSize = getViewportSize();
setSize(tab.getWebContents(), tab.getView(), viewportSize.x, viewportSize.y);
}
onViewportChanged(); onViewportChanged();
// If there's an event that needs to occur after the keyboard is hidden, post // If there's an event that needs to occur after the keyboard is hidden, post
...@@ -1031,6 +1038,11 @@ public class CompositorViewHolder extends FrameLayout ...@@ -1031,6 +1038,11 @@ public class CompositorViewHolder extends FrameLayout
if (tab.getView() == null) return; if (tab.getView() == null) return;
tab.setTopControlsHeight(getTopControlsHeightPixels(), controlsResizeView()); tab.setTopControlsHeight(getTopControlsHeightPixels(), controlsResizeView());
tab.setBottomControlsHeight(getBottomControlsHeightPixels()); tab.setBottomControlsHeight(getBottomControlsHeightPixels());
// TextView with compound drawables in the NTP gets a wrong width when measure/layout is
// performed in the unattached state. Delay the layout till #onLayoutChange().
// See https://crbug.com/876686.
if (tab.isNativePage() && !isAttachedToWindow(tab.getView())) return;
Point viewportSize = getViewportSize(); Point viewportSize = getViewportSize();
setSize(webContents, tab.getView(), viewportSize.x, viewportSize.y); setSize(webContents, tab.getView(), viewportSize.x, viewportSize.y);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment