Commit 467eb198 authored by Brandon Wylie's avatar Brandon Wylie Committed by Commit Bot

Prevent the URL bar from overlapping with the actions container

Replacing a workaround with a less hacky solution.

Bug: 1122212,1012436,1121577
Change-Id: I7d3cb641a695d4c8f4a70b982316f38957941cc0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2386344Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarPatrick Noland <pnoland@chromium.org>
Commit-Queue: Brandon Wylie <wylieb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804444}
parent 0e869531
...@@ -11,10 +11,6 @@ ...@@ -11,10 +11,6 @@
<include layout="@layout/location_status" /> <include layout="@layout/location_status" />
<!--
Padding for this view is adjusted in LocationBarPhone when the search engine logo is active.
This is to prevent the url clipping described in crbug.com/1012436.
-->
<include <include
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
......
...@@ -685,6 +685,12 @@ public class LocationBarLayout extends FrameLayout ...@@ -685,6 +685,12 @@ public class LocationBarLayout extends FrameLayout
int urlContainerMarginEnd = getUrlContainerMarginEnd(); int urlContainerMarginEnd = getUrlContainerMarginEnd();
LayoutParams urlLayoutParams = (LayoutParams) mUrlBar.getLayoutParams(); LayoutParams urlLayoutParams = (LayoutParams) mUrlBar.getLayoutParams();
if (MarginLayoutParamsCompat.getMarginEnd(urlLayoutParams) != urlContainerMarginEnd) { if (MarginLayoutParamsCompat.getMarginEnd(urlLayoutParams) != urlContainerMarginEnd) {
// Include the space which the URL bar will be translated post-layout into the
// end-margin so the URL bar doesn't overlap with the URL actions container.
if (SearchEngineLogoUtils.shouldShowSearchEngineLogo(
mToolbarDataProvider.isIncognito())) {
urlContainerMarginEnd += mStatusCoordinator.getEndPaddingPixelSizeOnFocusDelta();
}
MarginLayoutParamsCompat.setMarginEnd(urlLayoutParams, urlContainerMarginEnd); MarginLayoutParamsCompat.setMarginEnd(urlLayoutParams, urlContainerMarginEnd);
mUrlBar.setLayoutParams(urlLayoutParams); mUrlBar.setLayoutParams(urlLayoutParams);
} }
......
...@@ -44,7 +44,6 @@ public class LocationBarPhone extends LocationBarLayout { ...@@ -44,7 +44,6 @@ public class LocationBarPhone extends LocationBarLayout {
super.onFinishInflate(); super.onFinishInflate();
mUrlBar = findViewById(R.id.url_bar); mUrlBar = findViewById(R.id.url_bar);
updateUrlBarPaddingForSearchEngineIcon();
mStatusView = findViewById(R.id.location_bar_status); mStatusView = findViewById(R.id.location_bar_status);
// Assign the first visible view here only if it hasn't been set by the DSE icon experiment. // Assign the first visible view here only if it hasn't been set by the DSE icon experiment.
// See onNativeLibrary ready for when this variable is set for the DSE icon case. // See onNativeLibrary ready for when this variable is set for the DSE icon case.
...@@ -81,7 +80,6 @@ public class LocationBarPhone extends LocationBarLayout { ...@@ -81,7 +80,6 @@ public class LocationBarPhone extends LocationBarLayout {
int lateralPadding = getResources().getDimensionPixelOffset( int lateralPadding = getResources().getDimensionPixelOffset(
R.dimen.sei_location_bar_lateral_padding); R.dimen.sei_location_bar_lateral_padding);
setPaddingRelative(lateralPadding, getPaddingTop(), lateralPadding, getPaddingBottom()); setPaddingRelative(lateralPadding, getPaddingTop(), lateralPadding, getPaddingBottom());
updateUrlBarPaddingForSearchEngineIcon();
} }
// This branch will be hit if the search engine logo experiment is enabled and we should // This branch will be hit if the search engine logo experiment is enabled and we should
...@@ -90,7 +88,6 @@ public class LocationBarPhone extends LocationBarLayout { ...@@ -90,7 +88,6 @@ public class LocationBarPhone extends LocationBarLayout {
mStatusView.updateSearchEngineStatusIcon( mStatusView.updateSearchEngineStatusIcon(
shouldShowSearchEngineLogo, isSearchEngineGoogle, searchEngineUrl); shouldShowSearchEngineLogo, isSearchEngineGoogle, searchEngineUrl);
mFirstVisibleFocusedView = mStatusView; mFirstVisibleFocusedView = mStatusView;
updateUrlBarPaddingForSearchEngineIcon();
// When the search engine icon is enabled, icons are translations into the parent view's // When the search engine icon is enabled, icons are translations into the parent view's
// padding area. Set clip padding to false to prevent them from getting clipped. // padding area. Set clip padding to false to prevent them from getting clipped.
...@@ -99,27 +96,6 @@ public class LocationBarPhone extends LocationBarLayout { ...@@ -99,27 +96,6 @@ public class LocationBarPhone extends LocationBarLayout {
setShowIconsWhenUrlFocused(shouldShowSearchEngineLogo); setShowIconsWhenUrlFocused(shouldShowSearchEngineLogo);
} }
/**
* Factor in extra padding added for the focused state when the search engine icon is active.
*/
private void updateUrlBarPaddingForSearchEngineIcon() {
if (mUrlBar == null || mStatusCoordinator == null) return;
mUrlBar.post(() -> {
// TODO(crbug.com/1019019): Come up with a better solution for M80 or M81.
// This padding prevents the UrlBar's content from extending past the available space
// and into the next view while focused.
final int endPadding = SearchEngineLogoUtils.shouldShowSearchEngineLogo(
mToolbarDataProvider.isIncognito())
&& hasFocus()
? mStatusCoordinator.getEndPaddingPixelSizeOnFocusDelta()
: 0;
mUrlBar.setPaddingRelative(mUrlBar.getPaddingStart(), mUrlBar.getPaddingTop(),
endPadding, mUrlBar.getPaddingBottom());
});
}
/** /**
* @return Width of child views before the first view that would be visible when location bar is * @return Width of child views before the first view that would be visible when location bar is
* focused. The first visible, focused view should be either url bar or status icon. * focused. The first visible, focused view should be either url bar or status icon.
...@@ -267,7 +243,6 @@ public class LocationBarPhone extends LocationBarLayout { ...@@ -267,7 +243,6 @@ public class LocationBarPhone extends LocationBarLayout {
setFocusable(false); setFocusable(false);
setFocusableInTouchMode(false); setFocusableInTouchMode(false);
} }
updateUrlBarPaddingForSearchEngineIcon();
setUrlFocusChangeInProgress(true); setUrlFocusChangeInProgress(true);
updateShouldAnimateIconChanges(); updateShouldAnimateIconChanges();
super.onUrlFocusChange(hasFocus); super.onUrlFocusChange(hasFocus);
...@@ -303,7 +278,6 @@ public class LocationBarPhone extends LocationBarLayout { ...@@ -303,7 +278,6 @@ public class LocationBarPhone extends LocationBarLayout {
if (!hasFocus) { if (!hasFocus) {
mUrlActionContainer.setVisibility(GONE); mUrlActionContainer.setVisibility(GONE);
} }
updateUrlBarPaddingForSearchEngineIcon();
mStatusCoordinator.onUrlAnimationFinished(hasFocus); mStatusCoordinator.onUrlAnimationFinished(hasFocus);
} }
...@@ -339,7 +313,6 @@ public class LocationBarPhone extends LocationBarLayout { ...@@ -339,7 +313,6 @@ public class LocationBarPhone extends LocationBarLayout {
mFirstVisibleFocusedView = shouldShowSearchEngineLogo ? mStatusView : mUrlBar; mFirstVisibleFocusedView = shouldShowSearchEngineLogo ? mStatusView : mUrlBar;
updateStatusVisibility(); updateStatusVisibility();
updateUrlBarPaddingForSearchEngineIcon();
} }
@Override @Override
......
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