Index: chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java |
index c140d73cb2a9f7669eda6b0998fd3fb0f03e8866..6e5653ba9ee52c910b8e0a286aded81333a8ad64 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java |
@@ -462,9 +462,9 @@ public class ToolbarPhone extends ToolbarLayout |
} |
} |
- int leftViewBounds = getViewBoundsLeftOfLocationBar(); |
+ int leftViewBounds = getViewBoundsLeftOfLocationBar(mVisualState); |
if (!hasVisibleViewPriorToUrlBar) leftViewBounds += mToolbarSidePadding; |
- int rightViewBounds = getViewBoundsRightOfLocationBar(); |
+ int rightViewBounds = getViewBoundsRightOfLocationBar(mVisualState); |
if (!mPhoneLocationBar.hasVisibleViewsAfterUrlBarWhenUnfocused()) { |
// Add spacing between the end of the URL and the edge of the omnibox drawable. |
@@ -545,10 +545,10 @@ public class ToolbarPhone extends ToolbarLayout |
return changed; |
} |
- private int getViewBoundsLeftOfLocationBar() { |
+ private int getViewBoundsLeftOfLocationBar(VisualState visualState) { |
// Uses getMeasuredWidth()s instead of getLeft() because this is called in onMeasure |
// and the layout values have not yet been set. |
- if (mVisualState == VisualState.NEW_TAB_NORMAL) { |
+ if (visualState == VisualState.NEW_TAB_NORMAL) { |
return 0; |
} else if (ApiCompatibilityUtils.isLayoutRtl(this)) { |
return Math.max( |
@@ -559,10 +559,10 @@ public class ToolbarPhone extends ToolbarLayout |
} |
} |
- private int getViewBoundsRightOfLocationBar() { |
+ private int getViewBoundsRightOfLocationBar(VisualState visualState) { |
// Uses getMeasuredWidth()s instead of getRight() because this is called in onMeasure |
// and the layout values have not yet been set. |
- if (mVisualState == VisualState.NEW_TAB_NORMAL) { |
+ if (visualState == VisualState.NEW_TAB_NORMAL) { |
return getMeasuredWidth(); |
} else if (ApiCompatibilityUtils.isLayoutRtl(this)) { |
return getMeasuredWidth() - (mHomeButton.getVisibility() != GONE |
@@ -613,39 +613,7 @@ public class ToolbarPhone extends ToolbarLayout |
if (mLocationBarBackground != null |
&& (mPhoneLocationBar.getVisibility() == VISIBLE || mTextureCaptureMode)) { |
- // Calculate the visible boundaries of the left and right most child views |
- // of the location bar. |
- int leftViewPosition = getViewBoundsLeftOfLocationBar(); |
- int rightViewPosition = getViewBoundsRightOfLocationBar(); |
- |
- leftViewPosition -= mUrlBackgroundPadding.left; |
- if (mUrlExpansionPercent != 0f) { |
- leftViewPosition *= (1f - mUrlExpansionPercent); |
- leftViewPosition -= mUrlBackgroundPadding.left * mUrlExpansionPercent; |
- } |
- |
- rightViewPosition += mUrlBackgroundPadding.right; |
- if (mUrlExpansionPercent != 0f) { |
- rightViewPosition += ((getWidth() - rightViewPosition) * mUrlExpansionPercent); |
- rightViewPosition += mUrlBackgroundPadding.right * mUrlExpansionPercent; |
- } |
- |
- // The bounds are set by the following: |
- // - The left most visible location bar child view. |
- // - The top of the viewport is aligned with the top of the location bar. |
- // - The right most visible location bar child view. |
- // - The bottom of the viewport is aligned with the bottom of the location bar. |
- // Additional padding can be applied for use during animations. |
- mUrlViewportBounds.set( |
- leftViewPosition, |
- 0, |
- rightViewPosition, |
- (int) (mPhoneLocationBar.getMeasuredHeight() |
- + (getHeight() - mPhoneLocationBar.getMeasuredHeight() |
- + mUrlBackgroundPadding.bottom + mUrlBackgroundPadding.top) |
- * mUrlExpansionPercent)); |
- mUrlViewportBounds.offset(0, (int) (mPhoneLocationBar.getY() |
- - (mUrlBackgroundPadding.top * mUrlExpansionPercent))); |
+ updateUrlViewportBounds(mUrlViewportBounds, mVisualState, false); |
} |
if (mTextureCaptureMode) { |
@@ -688,6 +656,45 @@ public class ToolbarPhone extends ToolbarLayout |
updateUrlExpansionAnimation(); |
} |
+ private void updateUrlViewportBounds(Rect urlViewPortBounds, VisualState visualState, |
David Trainor- moved to gerrit
2015/11/02 16:25:08
I might add a javadoc to this or rename urlViewPor
aurimas (slooooooooow)
2015/11/02 19:31:46
Done
|
+ boolean ignoreTranslationY) { |
+ // Calculate the visible boundaries of the left and right most child views |
+ // of the location bar. |
+ int leftViewPosition = getViewBoundsLeftOfLocationBar(visualState); |
+ int rightViewPosition = getViewBoundsRightOfLocationBar(visualState); |
+ |
+ leftViewPosition -= mUrlBackgroundPadding.left; |
+ if (mUrlExpansionPercent != 0f) { |
+ leftViewPosition *= (1f - mUrlExpansionPercent); |
+ leftViewPosition -= mUrlBackgroundPadding.left * mUrlExpansionPercent; |
+ } |
+ |
+ rightViewPosition += mUrlBackgroundPadding.right; |
+ if (mUrlExpansionPercent != 0f) { |
+ rightViewPosition += ((getWidth() - rightViewPosition) * mUrlExpansionPercent); |
+ rightViewPosition += mUrlBackgroundPadding.right * mUrlExpansionPercent; |
+ } |
+ |
+ // The bounds are set by the following: |
+ // - The left most visible location bar child view. |
+ // - The top of the viewport is aligned with the top of the location bar. |
+ // - The right most visible location bar child view. |
+ // - The bottom of the viewport is aligned with the bottom of the location bar. |
+ // Additional padding can be applied for use during animations. |
+ urlViewPortBounds.set( |
+ leftViewPosition, |
+ 0, |
+ rightViewPosition, |
+ (int) (mPhoneLocationBar.getMeasuredHeight() |
+ + (getHeight() - mPhoneLocationBar.getMeasuredHeight() |
+ + mUrlBackgroundPadding.bottom + mUrlBackgroundPadding.top) |
+ * mUrlExpansionPercent)); |
+ float yOffset = ignoreTranslationY ? mPhoneLocationBar.getTop() : mPhoneLocationBar.getY(); |
+ |
+ urlViewPortBounds.offset(0, (int) (yOffset |
+ - (mUrlBackgroundPadding.top * mUrlExpansionPercent))); |
+ } |
+ |
/** |
* Updates percentage of current the URL focus change animation. |
* @param percent 1.0 is 100% focused, 0 is completely unfocused. |
@@ -1043,7 +1050,8 @@ public class ToolbarPhone extends ToolbarLayout |
} |
mLocationBarBackground.setAlpha(backgroundAlpha); |
- if (mPhoneLocationBar.getAlpha() > 0 || mForceDrawLocationBarBackground) { |
+ if ((mPhoneLocationBar.getAlpha() > 0 || mForceDrawLocationBarBackground) |
+ && !mTextureCaptureMode) { |
mLocationBarBackground.setBounds( |
mUrlViewportBounds.left + mLocationBarBackgroundOffset.left, |
mUrlViewportBounds.top + mLocationBarBackgroundOffset.top, |
@@ -1062,8 +1070,9 @@ public class ToolbarPhone extends ToolbarLayout |
// is applied to increase the clip regions such that when the location bar converts |
// to the narrower collapsed layout that the visible content is the same. |
if (mUrlExpansionPercent != 1f) { |
- int leftDelta = mUnfocusedLocationBarLayoutLeft - getViewBoundsLeftOfLocationBar(); |
- int rightDelta = getViewBoundsRightOfLocationBar() |
+ int leftDelta = mUnfocusedLocationBarLayoutLeft |
+ - getViewBoundsLeftOfLocationBar(mVisualState); |
+ int rightDelta = getViewBoundsRightOfLocationBar(mVisualState) |
- mUnfocusedLocationBarLayoutLeft |
- mUnfocusedLocationBarLayoutWidth; |
float inversePercent = 1f - mUrlExpansionPercent; |
@@ -1166,12 +1175,18 @@ public class ToolbarPhone extends ToolbarLayout |
@Override |
public void getLocationBarContentRect(Rect outRect) { |
- if (isLocationBarShownInNTP() && !isFocused()) { |
- outRect.setEmpty(); |
- return; |
- } |
- |
- super.getLocationBarContentRect(outRect); |
+ mLocationBarBackground.getPadding(outRect); |
+ int paddingLeft = outRect.left; |
+ int paddingTop = outRect.top; |
+ int paddingRight = outRect.right; |
+ int paddingBottom = outRect.bottom; |
+ |
+ updateUrlViewportBounds(outRect, VisualState.NORMAL, true); |
+ |
+ outRect.set(outRect.left + paddingLeft, |
+ outRect.top + paddingTop, |
+ outRect.right - paddingRight, |
+ outRect.bottom - paddingBottom); |
} |
@Override |