From d1bee05d6494cc2dd2751a17b60e34994f925c59 Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Fri, 5 Mar 2010 11:30:07 +0000 Subject: [PATCH] It is possible that we may get a call from WebCore that the first layout has completed before we've successfully syncd the webview dimensions from Java to native and in this case, we end up syncing a height of 0 to WebKit. This causes hit detection to fail, as WebKit thinks we have a 0-height visible area. This patch fixes this scenario by syncing the height of the webview back to WebKit in the case that the first layout comes back before we've sent our dimensions. Fix for b/2449863 Change-Id: Id72c37b17411f3409edc7104d83ca5ffd17ab09b --- core/java/android/webkit/WebViewCore.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index 71f69feeb19d2..b339015e2646b 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -2191,7 +2191,14 @@ final class WebViewCore { ); } data.mWidth = Math.round(webViewWidth / data.mScale); - data.mHeight = mCurrentViewHeight * data.mWidth / viewportWidth; + // We may get a call here when mCurrentViewHeight == 0 if webcore completes the + // first layout before we sync our webview dimensions to it. In that case, we + // request the real height of the webview. This is not a perfect solution as we + // are calling a WebView method from the WebCore thread. But this is preferable + // to syncing an incorrect height. + data.mHeight = mCurrentViewHeight == 0 ? + Math.round(mWebView.getViewHeight() / data.mScale) + : mCurrentViewHeight * data.mWidth / viewportWidth; data.mTextWrapWidth = Math.round(webViewWidth / mRestoreState.mTextWrapScale); data.mIgnoreHeight = false;