Skip to content

Commit

Permalink
Android: Fix regression on simplified NTP
Browse files Browse the repository at this point in the history
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.

[email protected], [email protected]

Bug: 876686
Change-Id: I81eff601781ec85e398ccc4d1ce555c441e20ddb
Reviewed-on: https://chromium-review.googlesource.com/1189682
Reviewed-by: Theresa <[email protected]>
Reviewed-by: Ted Choc <[email protected]>
Commit-Queue: Jinsuk Kim <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#587916}(cherry picked from commit 2db4f03)
Reviewed-on: https://chromium-review.googlesource.com/1203470
Reviewed-by: Jinsuk Kim <[email protected]>
Cr-Commit-Position: refs/branch-heads/3538@{#14}
Cr-Branched-From: 79f7c91-refs/heads/master@{#587811}
  • Loading branch information
JinsukKim committed Sep 3, 2018
1 parent 03ff085 commit fcd9723
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ public void onContentChanged(Tab tab) {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
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();

// If there's an event that needs to occur after the keyboard is hidden, post
Expand Down Expand Up @@ -1031,6 +1038,11 @@ private void initializeTab(Tab tab) {
if (tab.getView() == null) return;
tab.setTopControlsHeight(getTopControlsHeightPixels(), controlsResizeView());
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();
setSize(webContents, tab.getView(), viewportSize.x, viewportSize.y);
}
Expand Down

0 comments on commit fcd9723

Please sign in to comment.