Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1626)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java

Issue 2694273002: Revert of Refactor ContentViewClient (4/6) (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
index d47e06c8c9edabe79cb02de6a744f18a7babc4e3..7f233424c2afc89b6c132a8976506f041b36f0e8 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
@@ -105,6 +105,7 @@
import org.chromium.printing.PrintingControllerImpl;
import org.chromium.ui.base.LocalizationUtils;
import org.chromium.ui.base.PageTransition;
+import org.chromium.ui.base.ViewAndroidDelegate;
import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.mojom.WindowOpenDisposition;
@@ -374,6 +375,26 @@
private class TabContentViewClient extends ContentViewClient {
@Override
+ public void onBackgroundColorChanged(int color) {
+ Tab.this.onBackgroundColorChanged(color);
+ }
+
+ @Override
+ public void onTopControlsChanged(float topControlsOffsetY, float topContentOffsetY) {
+ super.onTopControlsChanged(topControlsOffsetY, topContentOffsetY);
+ onOffsetsChanged(topControlsOffsetY, mPreviousBottomControlsOffsetY,
+ topContentOffsetY, isShowingSadTab());
+ }
+
+ @Override
+ public void onBottomControlsChanged(float bottomControlsOffsetY,
+ float bottomContentOffsetY) {
+ super.onBottomControlsChanged(bottomControlsOffsetY, bottomContentOffsetY);
+ onOffsetsChanged(mPreviousTopControlsOffsetY, bottomControlsOffsetY,
+ mPreviousContentOffsetY, isShowingSadTab());
+ }
+
+ @Override
public void onImeEvent() {
// Some text was set in the page. Don't reuse it if a tab is
// open from the same external application, we might lose some
@@ -385,6 +406,33 @@
public void onFocusedNodeEditabilityChanged(boolean editable) {
if (getFullscreenManager() == null) return;
updateFullscreenEnabledState();
+ }
+
+ @Override
+ public int getSystemWindowInsetLeft() {
+ ChromeActivity activity = getActivity();
+ if (activity != null && activity.getInsetObserverView() != null) {
+ return activity.getInsetObserverView().getSystemWindowInsetsLeft();
+ }
+ return 0;
+ }
+
+ @Override
+ public int getSystemWindowInsetTop() {
+ ChromeActivity activity = getActivity();
+ if (activity != null && activity.getInsetObserverView() != null) {
+ return activity.getInsetObserverView().getSystemWindowInsetsTop();
+ }
+ return 0;
+ }
+
+ @Override
+ public int getSystemWindowInsetRight() {
+ ChromeActivity activity = getActivity();
+ if (activity != null && activity.getInsetObserverView() != null) {
+ return activity.getInsetObserverView().getSystemWindowInsetsRight();
+ }
+ return 0;
}
@Override
@@ -1594,7 +1642,7 @@
ContentView cv = ContentView.createContentView(mThemedApplicationContext, cvc);
cv.setContentDescription(mThemedApplicationContext.getResources().getString(
R.string.accessibility_content_view));
- cvc.initialize(new TabViewAndroidDelegate(this, cv), cv, webContents,
+ cvc.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv, webContents,
getWindowAndroid());
ChromeActionModeCallback actionModeCallback = new ChromeActionModeCallback(
mThemedApplicationContext, this, cvc.getActionModeCallbackHelper());
@@ -2178,7 +2226,7 @@
* Called when the background color for the content changes.
* @param color The current for the background.
*/
- void onBackgroundColorChanged(int color) {
+ protected void onBackgroundColorChanged(int color) {
for (TabObserver observer : mObservers) observer.onBackgroundColorChanged(this, color);
}
@@ -2478,21 +2526,19 @@
* Called when offset values related with fullscreen functionality has been changed by the
* compositor.
* @param topControlsOffsetY The Y offset of the top controls in physical pixels.
- * {@code Float.NaN} if the value is invalid and the cached value should be used.
* @param bottomControlsOffsetY The Y offset of the bottom controls in physical pixels.
- * {@code Float.NaN} if the value is invalid and the cached value should be used.
* @param contentOffsetY The Y offset of the content in physical pixels.
- */
- void onOffsetsChanged(
- float topControlsOffsetY, float bottomControlsOffsetY, float contentOffsetY) {
- if (!Float.isNaN(topControlsOffsetY)) mPreviousTopControlsOffsetY = topControlsOffsetY;
- if (!Float.isNaN(bottomControlsOffsetY)) {
- mPreviousBottomControlsOffsetY = bottomControlsOffsetY;
- }
+ * @param isNonFullscreenPage Whether a current page is non-fullscreen page or not.
+ */
+ private void onOffsetsChanged(
+ float topControlsOffsetY, float bottomControlsOffsetY, float contentOffsetY,
+ boolean isNonFullscreenPage) {
+ mPreviousTopControlsOffsetY = topControlsOffsetY;
+ mPreviousBottomControlsOffsetY = bottomControlsOffsetY;
mPreviousContentOffsetY = contentOffsetY;
if (mFullscreenManager == null) return;
- if (isShowingSadTab() || isNativePage()) {
+ if (isNonFullscreenPage || isNativePage()) {
mFullscreenManager.setPositionsForTabToNonFullscreen();
} else {
mFullscreenManager.setPositionsForTab(topControlsOffsetY, bottomControlsOffsetY,

Powered by Google App Engine
This is Rietveld 408576698