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
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user