Commit 1800888c authored by Theresa's avatar Theresa Committed by Commit Bot

Capture a new toolbar texture after exiting tab switcher

Request an update to the toolbar texture after exiting the tab switcher
to ensure a new texture is captured before the user re-enters the tab
switcher. This used to be handled in
ToolbarPhone#updateVisualsForLocationBarState due to the visual state
for the toolbar changing from TAB_SWITCHER_* to one of the other states.

Also update the location bar bounds logic and shadow drawing logic to
ensure that the location bar is properly clipped and the shadow has the
proper visibility when capturing textures.


BUG=916561

Change-Id: I8ab5116d087866c7aa6e56865dc160c7a5f729c3
Reviewed-on: https://chromium-review.googlesource.com/c/1384374Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Theresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619440}
parent 0ed70f71
......@@ -654,7 +654,7 @@ public class ToolbarPhone extends ToolbarLayout implements Invalidator.Client, O
private int getViewBoundsLeftOfLocationBar(@VisualState int visualState) {
// Uses getMeasuredWidth()s instead of getLeft() because this is called in onMeasure
// and the layout values have not yet been set.
if (visualState == VisualState.NEW_TAB_NORMAL) {
if (visualState == VisualState.NEW_TAB_NORMAL && mTabSwitcherState == STATIC_TAB) {
return mToolbarSidePadding;
} else if (ApiCompatibilityUtils.isLayoutRtl(this)) {
return getBoundsAfterAccountingForRightButtons();
......@@ -682,7 +682,7 @@ public class ToolbarPhone extends ToolbarLayout implements Invalidator.Client, O
private int getViewBoundsRightOfLocationBar(@VisualState int visualState) {
// Uses getMeasuredWidth()s instead of getRight() because this is called in onMeasure
// and the layout values have not yet been set.
if (visualState == VisualState.NEW_TAB_NORMAL) {
if (visualState == VisualState.NEW_TAB_NORMAL && mTabSwitcherState == STATIC_TAB) {
return getMeasuredWidth() - mToolbarSidePadding;
} else if (ApiCompatibilityUtils.isLayoutRtl(this)) {
return getMeasuredWidth() - getBoundsAfterAccountingForLeftButton();
......@@ -1420,6 +1420,7 @@ public class ToolbarPhone extends ToolbarLayout implements Invalidator.Client, O
int rightDelta = getViewBoundsRightOfLocationBar(mVisualState)
- mUnfocusedLocationBarLayoutLeft - mUnfocusedLocationBarLayoutWidth;
float inversePercent = 1f - mUrlExpansionPercent;
locationBarClipLeft += leftDelta * inversePercent;
locationBarClipRight -= rightDelta * inversePercent;
......@@ -1620,7 +1621,7 @@ public class ToolbarPhone extends ToolbarLayout implements Invalidator.Client, O
exitAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
updateViewsForTabSwitcherMode();
onExitTabSwitcherAnimationEnd();
}
});
......@@ -1646,19 +1647,28 @@ public class ToolbarPhone extends ToolbarLayout implements Invalidator.Client, O
@Override
public void onAnimationEnd(Animator animation) {
mDelayedTabSwitcherModeAnimation = null;
updateViewsForTabSwitcherMode();
onExitTabSwitcherAnimationEnd();
}
});
return exitAnimation;
}
private void onExitTabSwitcherAnimationEnd() {
updateViewsForTabSwitcherMode();
// Request a texture update to ensure a texture is captured before the user
// re-enters the tab switcher.
mLayoutUpdateHost.requestUpdate();
}
@Override
public void setTextureCaptureMode(boolean textureMode) {
assert mTextureCaptureMode != textureMode;
mTextureCaptureMode = textureMode;
if (mTextureCaptureMode) {
if (!hideShadowForIncognitoNtp() && !hideShadowForInterstitial()) {
if (!hideShadowForIncognitoNtp() && !hideShadowForInterstitial()
&& !hideShadowForRegularNtpTextureCapture()) {
mToolbarShadow.setVisibility(VISIBLE);
}
mPreTextureCaptureAlpha = getAlpha();
......@@ -1673,6 +1683,11 @@ public class ToolbarPhone extends ToolbarLayout implements Invalidator.Client, O
}
}
private boolean hideShadowForRegularNtpTextureCapture() {
return !isIncognito() && NewTabPage.isNTPUrl(getToolbarDataProvider().getCurrentUrl())
&& mNtpSearchBoxScrollPercent < 1.f;
}
// TODO(dtrainor): This is always true when in the tab switcher (crbug.com/710750).
private boolean isTabSwitcherAnimationRunning() {
return mTabSwitcherState == ENTERING_TAB_SWITCHER
......@@ -2267,7 +2282,6 @@ public class ToolbarPhone extends ToolbarLayout implements Invalidator.Client, O
// These are used to skip setting state unnecessarily while in the tab switcher.
boolean inOrEnteringStaticTab =
mTabSwitcherState == STATIC_TAB || mTabSwitcherState == EXITING_TAB_SWITCHER;
boolean inOrEnteringTabSwitcher = !inOrEnteringStaticTab;
@VisualState
int newVisualState = computeVisualState();
......
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