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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabObserver.java

Issue 2741993004: Fix Android tab navigation "stretch" regression. (Closed)
Patch Set: Created 3 years, 9 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/customtabs/CustomTabObserver.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabObserver.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabObserver.java
index 931341626efa08c8857e515bdc88dd02c1f64272..3268dafec54df4e56c41b8f043f76f8948a6a1c7 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabObserver.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabObserver.java
@@ -32,7 +32,8 @@ class CustomTabObserver extends EmptyTabObserver {
private final CustomTabsConnection mCustomTabsConnection;
private final CustomTabsSessionToken mSession;
private final boolean mOpenedByChrome;
- private float mScaleForNavigationInfo = 1f;
+ private int mContentBitmapWidth;
+ private int mContentBitmapHeight;
private long mIntentReceivedTimestamp;
private long mPageLoadStartedTimestamp;
@@ -58,8 +59,17 @@ class CustomTabObserver extends EmptyTabObserver {
float desiredHeight = application.getResources().getDimensionPixelSize(
R.dimen.custom_tabs_screenshot_height);
Rect bounds = ExternalPrerenderHandler.estimateContentSize(application, false);
- mScaleForNavigationInfo = (bounds.width() == 0 || bounds.height() == 0) ? 1f :
- Math.min(desiredWidth / bounds.width(), desiredHeight / bounds.height());
+ if (bounds.width() == 0 || bounds.height() == 0) {
+ mContentBitmapWidth = (int) Math.round(desiredWidth);
+ mContentBitmapHeight = (int) Math.round(desiredHeight);
+ } else {
+ // Compute a size that scales the content bitmap to fit one (or both) dimensions,
+ // but also preserves aspect ratio.
+ float scale =
+ Math.min(desiredWidth / bounds.width(), desiredHeight / bounds.height());
+ mContentBitmapWidth = (int) Math.round(bounds.width() * scale);
+ mContentBitmapHeight = (int) Math.round(bounds.height() * scale);
+ }
}
mOpenedByChrome = openedByChrome;
resetPageLoadTracking();
@@ -191,7 +201,7 @@ class CustomTabObserver extends EmptyTabObserver {
if (!tab.isHidden() && mCurrentState != STATE_RESET) return;
if (tab.getWebContents() == null) return;
tab.getWebContents().getContentBitmapAsync(
- Bitmap.Config.ARGB_8888, mScaleForNavigationInfo, new Rect(), callback);
+ mContentBitmapWidth, mContentBitmapHeight, callback);
mScreenshotTakenForCurrentNavigation = true;
}
}, 1000);

Powered by Google App Engine
This is Rietveld 408576698