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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/prerender/ExternalPrerenderHandler.java

Issue 2268323003: Initialize RWHV with default bounds rather than only size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 years, 4 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/prerender/ExternalPrerenderHandler.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/prerender/ExternalPrerenderHandler.java b/chrome/android/java/src/org/chromium/chrome/browser/prerender/ExternalPrerenderHandler.java
index 2f99358aa05efe588e7f0a39893528ab47c1d9b3..5e7305d81be403aa1646f4f62da0ca6e6f8aec6b 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/prerender/ExternalPrerenderHandler.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/prerender/ExternalPrerenderHandler.java
@@ -119,29 +119,34 @@ public class ExternalPrerenderHandler {
* @param convertToDp Whether the value should be converted to dp from pixels.
* @return The estimated prerender size in pixels or dp.
*/
- public static Point estimateContentSize(Application application, boolean convertToDp) {
+ public static Rect estimateContentSize(Application application, boolean convertToDp) {
// The size is estimated as:
// X = screenSizeX
// Y = screenSizeY - top bar - bottom bar - custom tabs bar
+ // The bounds rectangle includes the bottom bar and the custom tabs bar as well.
+ Rect screenBounds = new Rect();
Point screenSize = new Point();
WindowManager wm = (WindowManager) application.getSystemService(Context.WINDOW_SERVICE);
wm.getDefaultDisplay().getSize(screenSize);
Resources resources = application.getResources();
int statusBarId = resources.getIdentifier("status_bar_height", "dimen", "android");
try {
- screenSize.y -=
- resources.getDimensionPixelSize(R.dimen.custom_tabs_control_container_height);
screenSize.y -= resources.getDimensionPixelSize(statusBarId);
} catch (Resources.NotFoundException e) {
// Nothing, this is just a best effort estimate.
}
+ screenBounds.set(0,
+ resources.getDimensionPixelSize(R.dimen.custom_tabs_control_container_height),
+ screenSize.x, screenSize.y);
if (convertToDp) {
float density = resources.getDisplayMetrics().density;
- screenSize.x = (int) Math.ceil(screenSize.x / density);
- screenSize.y = (int) Math.ceil(screenSize.y / density);
+ screenBounds.top = (int) Math.ceil(screenBounds.top / density);
+ screenBounds.left = (int) Math.ceil(screenBounds.left / density);
+ screenBounds.right = (int) Math.ceil(screenBounds.right / density);
+ screenBounds.bottom = (int) Math.ceil(screenBounds.bottom / density);
}
- return screenSize;
+ return screenBounds;
}
private static native long nativeInit();

Powered by Google App Engine
This is Rietveld 408576698