From 3f9faf473712be7d6471913b921bf8a63ab3205d Mon Sep 17 00:00:00 2001 From: Grace Kloba Date: Tue, 13 Oct 2009 14:13:54 -0700 Subject: [PATCH] When WebView has wrap_content, we are sending WebKit 0 height to get the exact height. But if the View system doesn't think the WebView dimension changed, even we call requestLayout, we won't get onSizeChanged. So we never notify the WebKit about the final view size. If updateLayout is true, which is probable because that we set the height to be 0 to WebKit, just call requestLayout() even the meansured height / width is matching the content height / width. Fix http://b/issue?id=2162991 --- core/java/android/webkit/WebView.java | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 47b12cb880ee3..87cc49237e2ea 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -2619,12 +2619,12 @@ public class WebView extends AbsoluteLayout if (mHeightCanMeasure) { if (getMeasuredHeight() != contentToViewDimension(mContentHeight) - && updateLayout) { + || updateLayout) { requestLayout(); } } else if (mWidthCanMeasure) { if (getMeasuredWidth() != contentToViewDimension(mContentWidth) - && updateLayout) { + || updateLayout) { requestLayout(); } } else { @@ -3664,6 +3664,24 @@ public class WebView extends AbsoluteLayout super.onFocusChanged(focused, direction, previouslyFocusedRect); } + /** + * @hide + */ + @Override + protected boolean setFrame(int left, int top, int right, int bottom) { + boolean changed = super.setFrame(left, top, right, bottom); + if (!changed && mHeightCanMeasure) { + // When mHeightCanMeasure is true, we will set mLastHeightSent to 0 + // in WebViewCore after we get the first layout. We do call + // requestLayout() when we get contentSizeChanged(). But the View + // system won't call onSizeChanged if the dimension is not changed. + // In this case, we need to call sendViewSizeZoom() explicitly to + // notify the WebKit about the new dimensions. + sendViewSizeZoom(); + } + return changed; + } + @Override protected void onSizeChanged(int w, int h, int ow, int oh) { super.onSizeChanged(w, h, ow, oh);