Commit 24562423 authored by Donn Denman's avatar Donn Denman Committed by Commit Bot

Revert "[TTS] Fix elippsis overlap with Bar icon mangle."

This reverts commit 0a8ea251.

Reason for revert:
This CL is causing the text in the bar to be drawn smaller,
and is suspected as the cause of issue 1020081.

BUG=1012835, 1020081

Original change's description:
> [TTS] Fix elippsis overlap with Bar icon mangle.
> 
> Fixes a drawing problem where the ellipsis on contracting
> text does not erase when it contracts and the icon is drawn
> over the older version of the text image.
> 
> This only happens on one brand of devices.
> 
> Renames the OverlayPanelRepaddingTextView.java file to
> OverlayPanelAdjustingTextView.java and the actual adjustment
> is done in native code now (which is not ideal -- see bug for
> details).
> 
> BUG=1012835
> 
> Change-Id: I4c1068743a54e7970d12dfa5cce23dd1f1733235
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1883113
> Reviewed-by: Theresa  <twellington@chromium.org>
> Reviewed-by: Matthew Jones <mdjones@chromium.org>
> Auto-Submit: Donn Denman <donnd@chromium.org>
> Commit-Queue: Donn Denman <donnd@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#710559}

TBR=donnd@chromium.org,twellington@chromium.org,mdjones@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1012835
Change-Id: I381b03a4af00e827930529f92a22d8bcbb4fd0cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1894398Reviewed-by: default avatarDonn Denman <donnd@chromium.org>
Commit-Queue: Donn Denman <donnd@chromium.org>
Auto-Submit: Donn Denman <donnd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711518}
parent d620105c
......@@ -208,7 +208,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelContentViewDelegate.java",
"java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelInflater.java",
"java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelManager.java",
"java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelAdjustingTextView.java",
"java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelRepaddingTextView.java",
"java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelTextViewInflater.java",
"java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchBarBannerControl.java",
"java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchBarControl.java",
......
......@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.compositor.bottombar;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import org.chromium.ui.resources.dynamics.DynamicResourceLoader;
......@@ -14,13 +15,18 @@ import org.chromium.ui.resources.dynamics.DynamicResourceLoader;
* This implementation simply does a binary transition when the panel is 50% of the way
* between peek and expanded states.
*/
public abstract class OverlayPanelAdjustingTextView extends OverlayPanelInflater {
private static final float ADJUSTING_THRESHOLD = 0.5f;
public abstract class OverlayPanelRepaddingTextView extends OverlayPanelInflater {
private static final float REPADDING_THRESHOLD = 0.5f;
private final float mPeekedEndButtonsWidth;
private final float mExpandedEndButtonsWidth;
private int mBoundsAdjust;
private int mPaddingStart;
private int mPaddingTop;
private int mPaddingBottom;
private boolean mIsPanelExpandedBeyondHalf;
private boolean mWasPanelExpandedBeyondHalf;
/**
* @param panel The panel.
......@@ -32,7 +38,7 @@ public abstract class OverlayPanelAdjustingTextView extends OverlayPanelInflater
* @param peekedDimension The dimension resource for the padding when the Overlay is Peeked.
* @param expandedDimension The dimension resource for the padding when the Overlay is Expanded.
*/
public OverlayPanelAdjustingTextView(OverlayPanel panel, int layoutResource, int layoutId,
public OverlayPanelRepaddingTextView(OverlayPanel panel, int layoutResource, int layoutId,
Context context, ViewGroup container, DynamicResourceLoader resourceLoader,
int peekedDimension, int expandedDimension) {
super(panel, layoutResource, layoutId, context, container, resourceLoader);
......@@ -40,7 +46,6 @@ public abstract class OverlayPanelAdjustingTextView extends OverlayPanelInflater
peekedDimension == 0 ? 0 : context.getResources().getDimension(peekedDimension);
mExpandedEndButtonsWidth =
expandedDimension == 0 ? 0 : context.getResources().getDimension(expandedDimension);
mBoundsAdjust = 0;
}
/**
......@@ -49,13 +54,41 @@ public abstract class OverlayPanelAdjustingTextView extends OverlayPanelInflater
* been expanded.
*/
public void onUpdateFromPeekToExpand(float percentage) {
int barPaddingWidth = (int) (percentage > ADJUSTING_THRESHOLD ? mExpandedEndButtonsWidth
: mPeekedEndButtonsWidth);
mBoundsAdjust = -barPaddingWidth;
mIsPanelExpandedBeyondHalf = percentage > REPADDING_THRESHOLD;
invalidateIfNeeded(false);
}
@Override
public void invalidate() {
invalidateIfNeeded(true);
}
/**
* Invalidates the view, if needed. Checks the {@code mIsPanelExpandedBeyondHalf} private
* member to see if the panel is beyond a threshold that's part way between peek and expanded
* states.
* @param alwaysInvalidate When {@code true}, makes sure that {@link #invalidate} is called.
*/
protected void invalidateIfNeeded(boolean alwaysInvalidate) {
View view = getView();
if (view == null
|| !alwaysInvalidate && mIsPanelExpandedBeyondHalf == mWasPanelExpandedBeyondHalf) {
return;
}
mWasPanelExpandedBeyondHalf = mIsPanelExpandedBeyondHalf;
int barPaddingWidth = (int) (mIsPanelExpandedBeyondHalf ? mExpandedEndButtonsWidth
: mPeekedEndButtonsWidth);
view.setPaddingRelative(mPaddingStart, mPaddingTop, barPaddingWidth, mPaddingBottom);
super.invalidate();
}
/** @return The signed value of how much to adjust the horizontal bounds for this view. */
public int getBoundsAdjust() {
return mBoundsAdjust;
@Override
protected void onFinishInflate() {
super.onFinishInflate();
View view = getView();
mPaddingStart = view.getPaddingStart();
mPaddingTop = view.getPaddingTop();
mPaddingBottom = view.getPaddingBottom();
}
}
......@@ -21,13 +21,13 @@ import org.chromium.ui.resources.dynamics.DynamicResourceLoader;
* Details in this issue: crbug.com/651389.
*/
public abstract class OverlayPanelTextViewInflater
extends OverlayPanelAdjustingTextView implements OnLayoutChangeListener {
extends OverlayPanelRepaddingTextView implements OnLayoutChangeListener {
private static final float SHORTNESS_FACTOR = 0.5f;
private boolean mDidAdjustViewDirection;
/**
* Constructs an instance similar to an {@link OverlayPanelAdjustingTextView} that can adjust
* Constructs an instance similar to an {@link OverlayPanelRepaddingTextView} that can adjust
* the RTL/LTR ordering of text fragments whose initial values are considered short relative to
* the width of the view.
* @param panel The panel.
......@@ -47,7 +47,7 @@ public abstract class OverlayPanelTextViewInflater
}
/**
* Constructs an instance similar to an {@link OverlayPanelAdjustingTextView} that can adjust
* Constructs an instance similar to an {@link OverlayPanelRepaddingTextView} that can adjust
* the RTL/LTR ordering of text fragments whose initial values are considered short relative to
* the width of the view.
* @param panel The panel.
......
......@@ -355,13 +355,6 @@ public class ContextualSearchBarControl {
return mSearchBarTermOpacity;
}
/**
* @return The bounds adjustment for the SearchBar's search term.
*/
public int getSearchBarTermBoundsAdjust() {
return mSearchTermControl.getBoundsAdjust();
}
/**
* Sets the quick action if one is available.
* @param quickActionUri The URI for the intent associated with the quick action.
......
......@@ -11,13 +11,13 @@ import android.widget.TextView;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel;
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanelAdjustingTextView;
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanelRepaddingTextView;
import org.chromium.ui.resources.dynamics.DynamicResourceLoader;
/**
* Controls the Search Context View that is used as a dynamic resource.
*/
public class ContextualSearchContextControl extends OverlayPanelAdjustingTextView {
public class ContextualSearchContextControl extends OverlayPanelRepaddingTextView {
/**
* The selected text View.
*/
......
......@@ -107,7 +107,6 @@ public class ContextualSearchSceneLayer extends SceneOverlayLayer {
float searchContextOpacity = searchBarControl.getSearchBarContextOpacity();
float searchTermOpacity = searchBarControl.getSearchBarTermOpacity();
int searchTermBoundsAdjust = searchBarControl.getSearchBarTermBoundsAdjust();
float searchCaptionAnimationPercentage = searchBarControl.getCaptionAnimationPercentage();
boolean searchCaptionVisible = searchBarControl.getCaptionVisible();
......@@ -172,7 +171,7 @@ public class ContextualSearchSceneLayer extends SceneOverlayLayer {
searchPanelY * mDpToPx, searchPanelWidth * mDpToPx, searchPanelHeight * mDpToPx,
searchBarMarginSide * mDpToPx, searchBarMarginTop * mDpToPx,
searchBarHeight * mDpToPx, searchContextOpacity,
searchBarControl.getTextLayerMinHeight(), searchTermOpacity, searchTermBoundsAdjust,
searchBarControl.getTextLayerMinHeight(), searchTermOpacity,
searchBarControl.getSearchTermCaptionSpacing(), searchCaptionAnimationPercentage,
searchCaptionVisible, searchBarBorderVisible, searchBarBorderHeight * mDpToPx,
searchBarShadowVisible, quickActionIconVisible, thumbnailVisible, thumbnailUrl,
......@@ -247,7 +246,7 @@ public class ContextualSearchSceneLayer extends SceneOverlayLayer {
float searchBarBannerTextOpacity, float searchPanelX, float searchPanelY,
float searchPanelWidth, float searchPanelHeight, float searchBarMarginSide,
float searchBarMarginTop, float searchBarHeight, float searchContextOpacity,
float searchTextLayerMinHeight, float searchTermOpacity, int searchTermBoundsAdjust,
float searchTextLayerMinHeight, float searchTermOpacity,
float searchTermCaptionSpacing, float searchCaptionAnimationPercentage,
boolean searchCaptionVisible, boolean searchBarBorderVisible,
float searchBarBorderHeight, boolean searchBarShadowVisible,
......
......@@ -72,7 +72,6 @@ void ContextualSearchLayer::SetProperties(
float search_context_opacity,
float search_text_layer_min_height,
float search_term_opacity,
int search_term_bounds_adjust,
float search_term_caption_spacing,
float search_caption_animation_percentage,
bool search_caption_visible,
......@@ -127,10 +126,9 @@ void ContextualSearchLayer::SetProperties(
dp_to_px, content_layer, content_view_top, search_panel_x, search_panel_y,
search_panel_width, search_panel_height, search_bar_background_color,
search_bar_margin_side, search_bar_margin_top, search_bar_height,
search_bar_top, search_term_opacity, search_term_bounds_adjust,
should_render_bar_border, search_bar_border_height,
search_bar_shadow_visible, icon_color, drag_handlebar_color,
close_icon_opacity, separator_line_color);
search_bar_top, search_term_opacity, should_render_bar_border,
search_bar_border_height, search_bar_shadow_visible, icon_color,
drag_handlebar_color, close_icon_opacity, separator_line_color);
// -----------------------------------------------------------------
// Content setup, to center in space below drag handle (when present).
......
......@@ -70,7 +70,6 @@ class ContextualSearchLayer : public OverlayPanelLayer {
float search_context_opacity,
float search_text_layer_min_height,
float search_term_opacity,
int search_term_bounds_adjust,
float search_term_caption_spacing,
float search_caption_animation_percentage,
bool search_caption_visible,
......
......@@ -106,13 +106,12 @@ void EphemeralTabLayer::SetProperties(
float bar_bottom = bar_top + bar_height;
float title_opacity = 0.f;
int no_text_bounds_adjust = 0;
OverlayPanelLayer::SetProperties(
dp_to_px, content_layer, bar_height, panel_x, panel_y, panel_width,
panel_height, bar_background_color, bar_margin_side, bar_margin_top,
bar_height, 0.0f, title_opacity, no_text_bounds_adjust,
bar_border_visible, bar_border_height, bar_shadow_visible, icon_color,
drag_handlebar_color, 1.0f /* icon opacity */, separator_line_color);
bar_height, 0.0f, title_opacity, bar_border_visible, bar_border_height,
bar_shadow_visible, icon_color, drag_handlebar_color,
1.0f /* icon opacity */, separator_line_color);
// Content setup, to center in space below drag handle (when present).
int content_top = bar_top;
......
......@@ -73,7 +73,6 @@ void OverlayPanelLayer::SetProperties(
float bar_height,
float bar_offset_y,
float bar_text_opacity,
int bar_text_bounds_adjust,
bool bar_border_visible,
float bar_border_height,
bool bar_shadow_visible,
......@@ -188,13 +187,7 @@ void OverlayPanelLayer::SetProperties(
float bar_padding_top = content_top_y + content_height / 2 -
bar_text_resource->size().height() / 2;
bar_text_->SetUIResourceId(bar_text_resource->ui_resource()->id());
// TODO(donnd): Find a cleaner way! See https://crbug.com/1012835.
// Adjust bounds to account for the open tab icon.
gfx::Size text_size = bar_text_resource->size();
text_size.set_width(text_size.width() + bar_text_bounds_adjust);
bar_text_->SetBounds(text_size);
bar_text_->SetBounds(bar_text_resource->size());
bar_text_->SetPosition(gfx::PointF(0.f, bar_padding_top));
bar_text_->SetOpacity(bar_text_opacity);
}
......
......@@ -52,7 +52,6 @@ class OverlayPanelLayer : public Layer {
float bar_height,
float bar_offset_y,
float bar_text_opacity,
int bar_text_bounds_adjust,
bool bar_border_visible,
float bar_border_height,
bool bar_shadow_visible,
......
......@@ -110,7 +110,6 @@ void ContextualSearchSceneLayer::UpdateContextualSearchLayer(
jfloat search_context_opacity,
jfloat search_text_layer_min_height,
jfloat search_term_opacity,
jint search_term_bounds_adjust,
jfloat search_term_caption_spacing,
jfloat search_caption_animation_percentage,
jboolean search_caption_visible,
......@@ -185,10 +184,10 @@ void ContextualSearchSceneLayer::UpdateContextualSearchLayer(
search_panel_width, search_panel_height, search_bar_margin_side,
search_bar_margin_top, search_bar_height, search_context_opacity,
search_text_layer_min_height, search_term_opacity,
search_term_bounds_adjust, search_term_caption_spacing,
search_caption_animation_percentage, search_caption_visible,
search_bar_border_visible, search_bar_border_height,
search_bar_shadow_visible, quick_action_icon_visible, thumbnail_visible,
search_term_caption_spacing, search_caption_animation_percentage,
search_caption_visible, search_bar_border_visible,
search_bar_border_height, search_bar_shadow_visible,
quick_action_icon_visible, thumbnail_visible,
custom_image_visibility_percentage, bar_image_size, icon_color,
drag_handlebar_color, arrow_icon_opacity, arrow_icon_rotation,
close_icon_opacity, progress_bar_visible, progress_bar_height,
......
......@@ -82,7 +82,6 @@ class ContextualSearchSceneLayer : public SceneLayer,
jfloat search_context_opacity,
jfloat search_text_layer_min_height,
jfloat search_term_opacity,
jint search_term_bounds_adjust,
jfloat search_term_caption_spacing,
jfloat search_caption_animation_percentage,
jboolean search_caption_visible,
......
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