| Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/Layout.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/Layout.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/Layout.java
|
| index aadea2eb82133c46e06958ca3427763199c8f6f6..dbb833a701db1f83ccec02972ec7927a34d5a280 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/Layout.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/Layout.java
|
| @@ -7,8 +7,7 @@ package org.chromium.chrome.browser.compositor.layouts;
|
| import static org.chromium.chrome.browser.compositor.layouts.ChromeAnimation.AnimatableAnimation.createAnimation;
|
|
|
| import android.content.Context;
|
| -import android.graphics.Point;
|
| -import android.graphics.Rect;
|
| +import android.graphics.PointF;
|
| import android.graphics.RectF;
|
| import android.view.MotionEvent;
|
| import android.view.View;
|
| @@ -115,9 +114,9 @@ public abstract class Layout implements TabContentManager.ThumbnailChangeListene
|
| public static final long UNSTALLED_ANIMATION_DURATION_MS = 500;
|
|
|
| // Drawing area properties.
|
| - private float mWidth;
|
| - private float mHeight;
|
| - private float mHeightMinusBrowserControls;
|
| + private float mWidthDp;
|
| + private float mHeightDp;
|
| + private float mHeightMinusBrowserControlsDp;
|
|
|
| /** A {@link Context} instance. */
|
| private Context mContext;
|
| @@ -149,6 +148,9 @@ public abstract class Layout implements TabContentManager.ThumbnailChangeListene
|
| // The next id to show when the layout is hidden, or TabBase#INVALID_TAB_ID if no change.
|
| private int mNextTabId = Tab.INVALID_TAB_ID;
|
|
|
| + // The ratio of dp to px.
|
| + private final float mDpToPx;
|
| +
|
| /**
|
| * The {@link Layout} is not usable until sizeChanged is called.
|
| * This is convenient this way so we can pre-create the layout before the host is fully defined.
|
| @@ -165,11 +167,12 @@ public abstract class Layout implements TabContentManager.ThumbnailChangeListene
|
| mEventFilter = eventFilter;
|
|
|
| // Invalid sizes
|
| - mWidth = -1;
|
| - mHeight = -1;
|
| - mHeightMinusBrowserControls = -1;
|
| + mWidthDp = -1;
|
| + mHeightDp = -1;
|
| + mHeightMinusBrowserControlsDp = -1;
|
|
|
| mCurrentOrientation = Orientation.UNSET;
|
| + mDpToPx = context.getResources().getDisplayMetrics().density;
|
| }
|
|
|
| /**
|
| @@ -326,30 +329,32 @@ public abstract class Layout implements TabContentManager.ThumbnailChangeListene
|
| /**
|
| * Called when the size of the viewport has changed.
|
| * @param visibleViewport The visible viewport that represents the area on the screen
|
| - * this {@link Layout} gets to draw to (potentially takes into
|
| - * account browser controls).
|
| - * @param screenViewport The viewport of the screen.
|
| + * this {@link Layout} gets to draw to in px (potentially takes
|
| + * into account browser controls).
|
| + * @param screenViewport The viewport of the screen in px.
|
| * @param heightMinusBrowserControls The height the {@link Layout} gets excluding the height of
|
| - * the
|
| - * browser controls. TODO(dtrainor): Look at getting rid of this.
|
| + * the browser controls in px. TODO(dtrainor): Look at getting rid
|
| + * of this.
|
| * @param orientation The new orientation. Valid values are defined by
|
| * {@link Orientation}.
|
| */
|
| - public final void sizeChanged(RectF visibleViewport, RectF screenViewport,
|
| - float heightMinusBrowserControls, int orientation) {
|
| + public final void sizeChanged(RectF visibleViewportPx, RectF screenViewportPx,
|
| + float heightMinusBrowserControlsPx, int orientation) {
|
| // 1. Pull out this Layout's width and height properties based on the viewport.
|
| - float width = screenViewport.width();
|
| - float height = screenViewport.height();
|
| + float width = screenViewportPx.width() / mDpToPx;
|
| + float height = screenViewportPx.height() / mDpToPx;
|
| + float heightMinusBrowserControlsDp = heightMinusBrowserControlsPx / mDpToPx;
|
|
|
| // 2. Check if any Layout-specific properties have changed.
|
| - boolean layoutPropertiesChanged = mWidth != width || mHeight != height
|
| - || mHeightMinusBrowserControls != heightMinusBrowserControls
|
| + boolean layoutPropertiesChanged = Float.compare(mWidthDp, width) != 0
|
| + || Float.compare(mHeightDp, height) != 0
|
| + || Float.compare(mHeightMinusBrowserControlsDp, heightMinusBrowserControlsDp) != 0
|
| || mCurrentOrientation != orientation;
|
|
|
| // 3. Update the internal sizing properties.
|
| - mWidth = width;
|
| - mHeight = height;
|
| - mHeightMinusBrowserControls = heightMinusBrowserControls;
|
| + mWidthDp = width;
|
| + mHeightDp = height;
|
| + mHeightMinusBrowserControlsDp = heightMinusBrowserControlsDp;
|
| mCurrentOrientation = orientation;
|
|
|
| // 4. Notify the actual Layout if necessary.
|
| @@ -359,7 +364,7 @@ public abstract class Layout implements TabContentManager.ThumbnailChangeListene
|
|
|
| // 5. TODO(dtrainor): Notify the overlay objects.
|
| for (int i = 0; i < mSceneOverlays.size(); i++) {
|
| - mSceneOverlays.get(i).onSizeChanged(width, height, visibleViewport.top, orientation);
|
| + mSceneOverlays.get(i).onSizeChanged(width, height, visibleViewportPx.top, orientation);
|
| }
|
| }
|
|
|
| @@ -560,24 +565,24 @@ public abstract class Layout implements TabContentManager.ThumbnailChangeListene
|
| }
|
|
|
| /**
|
| - * @return The width of the drawing area.
|
| + * @return The width of the drawing area in dp.
|
| */
|
| public float getWidth() {
|
| - return mWidth;
|
| + return mWidthDp;
|
| }
|
|
|
| /**
|
| - * @return The height of the drawing area.
|
| + * @return The height of the drawing area in dp.
|
| */
|
| public float getHeight() {
|
| - return mHeight;
|
| + return mHeightDp;
|
| }
|
|
|
| /**
|
| - * @return The height of the drawing area minus the browser controls.
|
| + * @return The height of the drawing area minus the browser controls in dp.
|
| */
|
| public float getHeightMinusBrowserControls() {
|
| - return mHeightMinusBrowserControls;
|
| + return mHeightMinusBrowserControlsDp;
|
| }
|
|
|
| /**
|
| @@ -1104,7 +1109,7 @@ public abstract class Layout implements TabContentManager.ThumbnailChangeListene
|
| * @return The {@link EventFilter} the {@link Layout} is listening to.
|
| */
|
| public EventFilter findInterceptingEventFilter(
|
| - MotionEvent e, Point offsets, boolean isKeyboardShowing) {
|
| + MotionEvent e, PointF offsets, boolean isKeyboardShowing) {
|
| // The last added overlay will be drawn on top of everything else, therefore the last
|
| // filter added should have the first chance to intercept any touch events.
|
| for (int i = mSceneOverlays.size() - 1; i >= 0; i--) {
|
| @@ -1124,8 +1129,8 @@ public abstract class Layout implements TabContentManager.ThumbnailChangeListene
|
| /**
|
| * Build a {@link SceneLayer} if it hasn't already been built, and update it and return it.
|
| *
|
| - * @param viewport A viewport in which to display content.
|
| - * @param contentViewport The visible section of the viewport.
|
| + * @param viewport A viewport in which to display content in px.
|
| + * @param visibleViewport The visible section of the viewport in px.
|
| * @param layerTitleCache A layer title cache.
|
| * @param tabContentManager A tab content manager.
|
| * @param resourceManager A resource manager.
|
| @@ -1133,10 +1138,10 @@ public abstract class Layout implements TabContentManager.ThumbnailChangeListene
|
| * @return A {@link SceneLayer} that represents the content for this
|
| * {@link Layout}.
|
| */
|
| - public final SceneLayer getUpdatedSceneLayer(Rect viewport, Rect contentViewport,
|
| + public final SceneLayer getUpdatedSceneLayer(RectF viewport, RectF visibleViewport,
|
| LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
|
| ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
|
| - updateSceneLayer(viewport, contentViewport, layerTitleCache, tabContentManager,
|
| + updateSceneLayer(viewport, visibleViewport, layerTitleCache, tabContentManager,
|
| resourceManager, fullscreenManager);
|
|
|
| float offsetPx = fullscreenManager != null ? fullscreenManager.getTopControlOffset() : 0.f;
|
| @@ -1188,7 +1193,7 @@ public abstract class Layout implements TabContentManager.ThumbnailChangeListene
|
| * Update {@link SceneLayer} instance this layout holds. Any class inheriting {@link Layout}
|
| * should override this function in order for other functions to work.
|
| */
|
| - protected void updateSceneLayer(Rect viewport, Rect contentViewport,
|
| + protected void updateSceneLayer(RectF viewport, RectF contentViewport,
|
| LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
|
| ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
|
| }
|
|
|