| Index: content/public/android/java/src/org/chromium/content/browser/ContentView.java
|
| diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentView.java b/content/public/android/java/src/org/chromium/content/browser/ContentView.java
|
| index 0886e4cb4effd1259e3271a72fd30b71bcebb808..9e775afc34ad10076953a3c641499882c148593b 100644
|
| --- a/content/public/android/java/src/org/chromium/content/browser/ContentView.java
|
| +++ b/content/public/android/java/src/org/chromium/content/browser/ContentView.java
|
| @@ -15,6 +15,7 @@ import android.view.DragEvent;
|
| import android.view.KeyEvent;
|
| import android.view.MotionEvent;
|
| import android.view.View;
|
| +import android.view.View.MeasureSpec;
|
| import android.view.ViewStructure;
|
| import android.view.accessibility.AccessibilityNodeProvider;
|
| import android.view.inputmethod.EditorInfo;
|
| @@ -33,9 +34,20 @@ public class ContentView extends FrameLayout
|
|
|
| private static final String TAG = "cr.ContentView";
|
|
|
| + // Default value to signal that the ContentView's size need not be overridden.
|
| + public static final int DEFAULT_MEASURE_SPEC =
|
| + MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
|
| +
|
| protected final ContentViewCore mContentViewCore;
|
|
|
| /**
|
| + * The desired size of this view in {@link MeasureSpec}. Set by the host
|
| + * when it should be different from that of the parent.
|
| + */
|
| + private int mDesiredWidthMeasureSpec = DEFAULT_MEASURE_SPEC;
|
| + private int mDesiredHeightMeasureSpec = DEFAULT_MEASURE_SPEC;
|
| +
|
| + /**
|
| * Constructs a new ContentView for the appropriate Android version.
|
| * @param context The Context the view is running in, through which it can
|
| * access the current theme, resources, etc.
|
| @@ -78,6 +90,27 @@ public class ContentView extends FrameLayout
|
| return super.performAccessibilityAction(action, arguments);
|
| }
|
|
|
| + /**
|
| + * Set the desired size of the view. The values are in {@link MeasureSpec}.
|
| + * @param width The width of the content view.
|
| + * @param height The height of the content view.
|
| + */
|
| + public void setDesiredMeasureSpec(int width, int height) {
|
| + mDesiredWidthMeasureSpec = width;
|
| + mDesiredHeightMeasureSpec = height;
|
| + }
|
| +
|
| + @Override
|
| + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
| + if (mDesiredWidthMeasureSpec != DEFAULT_MEASURE_SPEC) {
|
| + widthMeasureSpec = mDesiredWidthMeasureSpec;
|
| + }
|
| + if (mDesiredHeightMeasureSpec != DEFAULT_MEASURE_SPEC) {
|
| + heightMeasureSpec = mDesiredHeightMeasureSpec;
|
| + }
|
| + super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
| + }
|
| +
|
| @Override
|
| public AccessibilityNodeProvider getAccessibilityNodeProvider() {
|
| AccessibilityNodeProvider provider = mContentViewCore.getAccessibilityNodeProvider();
|
| @@ -231,25 +264,6 @@ public class ContentView extends FrameLayout
|
| return mContentViewCore.computeVerticalScrollRange();
|
| }
|
|
|
| - @Override
|
| - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
| - ContentViewClient client = mContentViewCore.getContentViewClient();
|
| -
|
| - // Allow the ContentViewClient to override the ContentView's width.
|
| - int desiredWidthMeasureSpec = client.getDesiredWidthMeasureSpec();
|
| - if (MeasureSpec.getMode(desiredWidthMeasureSpec) != MeasureSpec.UNSPECIFIED) {
|
| - widthMeasureSpec = desiredWidthMeasureSpec;
|
| - }
|
| -
|
| - // Allow the ContentViewClient to override the ContentView's height.
|
| - int desiredHeightMeasureSpec = client.getDesiredHeightMeasureSpec();
|
| - if (MeasureSpec.getMode(desiredHeightMeasureSpec) != MeasureSpec.UNSPECIFIED) {
|
| - heightMeasureSpec = desiredHeightMeasureSpec;
|
| - }
|
| -
|
| - super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
| - }
|
| -
|
| // End FrameLayout overrides.
|
|
|
| @Override
|
|
|