Commit 1463abf9 authored by Ted Choc's avatar Ted Choc Committed by Commit Bot

Fix the scroll state for RTL hint text (again).

The issue was that when transitioning from a LTR URL to
an empty textview the call to ApiCompatibilityUtils.isLayoutRtl(this)
would return false in the initial scroll calculation and then true in
the subsequent one.  To work around this, we need to track the RTL-ness
of the previous scroll to ensure it remains the same before we reuse
the previous scroll offset.

BUG=871147

Change-Id: I2440ffdd56c4ec9f95b01194e2e4f81f2f8bb572
Reviewed-on: https://chromium-review.googlesource.com/1169526Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Ted Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582001}
parent ef2fe058
......@@ -95,6 +95,7 @@ public class UrlBar extends AutocompleteEditText {
private int mPreviousScrollViewWidth;
private int mPreviousScrollResultXPosition;
private float mPreviousScrollFontSize;
private boolean mPreviousScrollWasRtl;
// Used as a hint to indicate the text may contain an ellipsize span. This will be true if an
// ellispize span was applied the last time the text changed. A true value here does not
......@@ -629,12 +630,16 @@ public class UrlBar extends AutocompleteEditText {
// Ensure any selection from the focus state is cleared.
setSelection(0);
float currentTextSize = getTextSize();
boolean currentIsRtl = ApiCompatibilityUtils.isLayoutRtl(this);
int measuredWidth = getMeasuredWidth() - (getPaddingLeft() + getPaddingRight());
if (scrollType == mPreviousScrollType && TextUtils.equals(text, mPreviousScrollText)
&& measuredWidth == mPreviousScrollViewWidth
// Font size is float but it changes in discrete range (eg small font, big font),
// therefore false negative using regular equality is unlikely.
&& getTextSize() == mPreviousScrollFontSize) {
&& currentTextSize == mPreviousScrollFontSize
&& currentIsRtl == mPreviousScrollWasRtl) {
scrollTo(mPreviousScrollResultXPosition, getScrollY());
return;
}
......@@ -654,8 +659,9 @@ public class UrlBar extends AutocompleteEditText {
mPreviousScrollType = scrollType;
mPreviousScrollText = text.toString();
mPreviousScrollViewWidth = measuredWidth;
mPreviousScrollFontSize = getTextSize();
mPreviousScrollFontSize = currentTextSize;
mPreviousScrollResultXPosition = getScrollX();
mPreviousScrollWasRtl = currentIsRtl;
}
/**
......
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