Commit 1daccaee authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Android: Delete Tab's TitleRtl property

The RTL property can be obtained dynamically from Tab's title. This
CL updates a single callsite so that Tab doesn't have to manage
the property.

Bug: 925242
Change-Id: Ia9e55818b1f07e320337da4c7991a344c88b1b21
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1501894Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638346}
parent 33853039
...@@ -23,6 +23,7 @@ import org.chromium.chrome.browser.tab.Tab; ...@@ -23,6 +23,7 @@ import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabFavicon; import org.chromium.chrome.browser.tab.TabFavicon;
import org.chromium.chrome.browser.tabmodel.TabModelSelector; import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.ui.base.DeviceFormFactor; import org.chromium.ui.base.DeviceFormFactor;
import org.chromium.ui.base.LocalizationUtils;
import org.chromium.ui.resources.ResourceManager; import org.chromium.ui.resources.ResourceManager;
import org.chromium.ui.resources.dynamics.BitmapDynamicResource; import org.chromium.ui.resources.dynamics.BitmapDynamicResource;
import org.chromium.ui.resources.dynamics.DynamicResourceLoader; import org.chromium.ui.resources.dynamics.DynamicResourceLoader;
...@@ -132,7 +133,6 @@ public class LayerTitleCache implements TitleCache { ...@@ -132,7 +133,6 @@ public class LayerTitleCache implements TitleCache {
mContext, tab.getUrl(), !isDarkTheme); mContext, tab.getUrl(), !isDarkTheme);
} }
boolean isRtl = tab.isTitleDirectionRtl();
TitleBitmapFactory titleBitmapFactory = TitleBitmapFactory titleBitmapFactory =
isDarkTheme ? mDarkTitleBitmapFactory : mStandardTitleBitmapFactory; isDarkTheme ? mDarkTitleBitmapFactory : mStandardTitleBitmapFactory;
...@@ -147,6 +147,10 @@ public class LayerTitleCache implements TitleCache { ...@@ -147,6 +147,10 @@ public class LayerTitleCache implements TitleCache {
titleBitmapFactory.getFaviconBitmap(originalFavicon), fetchFaviconFromHistory); titleBitmapFactory.getFaviconBitmap(originalFavicon), fetchFaviconFromHistory);
if (mNativeLayerTitleCache != 0) { if (mNativeLayerTitleCache != 0) {
String tabTitle = tab.getTitle();
boolean isRtl = tabTitle != null
&& LocalizationUtils.getFirstStrongCharacterDirection(tabTitle)
== LocalizationUtils.RIGHT_TO_LEFT;
nativeUpdateLayer(mNativeLayerTitleCache, tabId, title.getTitleResId(), nativeUpdateLayer(mNativeLayerTitleCache, tabId, title.getTitleResId(),
title.getFaviconResId(), isDarkTheme, isRtl); title.getFaviconResId(), isDarkTheme, isRtl);
} }
......
...@@ -88,7 +88,6 @@ import org.chromium.content_public.browser.WebContentsAccessibility; ...@@ -88,7 +88,6 @@ import org.chromium.content_public.browser.WebContentsAccessibility;
import org.chromium.content_public.common.BrowserControlsState; import org.chromium.content_public.common.BrowserControlsState;
import org.chromium.content_public.common.Referrer; import org.chromium.content_public.common.Referrer;
import org.chromium.content_public.common.ResourceRequestBody; import org.chromium.content_public.common.ResourceRequestBody;
import org.chromium.ui.base.LocalizationUtils;
import org.chromium.ui.base.PageTransition; import org.chromium.ui.base.PageTransition;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.mojom.WindowOpenDisposition; import org.chromium.ui.mojom.WindowOpenDisposition;
...@@ -264,16 +263,10 @@ public class Tab ...@@ -264,16 +263,10 @@ public class Tab
private long mTimestampMillis = INVALID_TIMESTAMP; private long mTimestampMillis = INVALID_TIMESTAMP;
/** /**
* Title of the ContentViews webpage.Always update mTitle through updateTitle() so that it also * Title of the ContentViews webpage.
* updates mIsTitleDirectionRtl correctly.
*/ */
private String mTitle; private String mTitle;
/**
* Indicates if mTitle should be displayed from right to left.
*/
private boolean mIsTitleDirectionRtl;
/** /**
* The mInterceptNavigationDelegate will be consulted for top-level frame navigations. This * The mInterceptNavigationDelegate will be consulted for top-level frame navigations. This
* allows presenting the intent picker to the user so that a native Android application can be * allows presenting the intent picker to the user so that a native Android application can be
...@@ -441,9 +434,6 @@ public class Tab ...@@ -441,9 +434,6 @@ public class Tab
TabThemeColorHelper.get(this).updateFromTabState(state); TabThemeColorHelper.get(this).updateFromTabState(state);
mTitle = state.getDisplayTitleFromState(); mTitle = state.getDisplayTitleFromState();
mIsTitleDirectionRtl = mTitle != null
&& LocalizationUtils.getFirstStrongCharacterDirection(mTitle)
== LocalizationUtils.RIGHT_TO_LEFT;
mLaunchTypeAtCreation = state.tabLaunchTypeAtCreation; mLaunchTypeAtCreation = state.tabLaunchTypeAtCreation;
mRootId = state.rootId == Tab.INVALID_TAB_ID ? mId : state.rootId; mRootId = state.rootId == Tab.INVALID_TAB_ID ? mId : state.rootId;
} }
...@@ -1610,8 +1600,6 @@ public class Tab ...@@ -1610,8 +1600,6 @@ public class Tab
mIsTabStateDirty = true; mIsTabStateDirty = true;
mTitle = title; mTitle = title;
mIsTitleDirectionRtl = LocalizationUtils.getFirstStrongCharacterDirection(title)
== LocalizationUtils.RIGHT_TO_LEFT;
notifyPageTitleChanged(); notifyPageTitleChanged();
} }
...@@ -1637,13 +1625,6 @@ public class Tab ...@@ -1637,13 +1625,6 @@ public class Tab
} }
} }
/**
* @return True if the tab title should be displayed from right to left.
*/
public boolean isTitleDirectionRtl() {
return mIsTitleDirectionRtl;
}
/** /**
* Loads the tab if it's not loaded (e.g. because it was killed in background). * Loads the tab if it's not loaded (e.g. because it was killed in background).
* This will trigger a regular load for tabs with pending lazy first load (tabs opened in * This will trigger a regular load for tabs with pending lazy first load (tabs opened in
......
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