diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-08-18 10:51:49 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-08-18 10:51:49 -0700 |
commit | db33d4bbaeedf2095968ec7795b488038cdcd015 (patch) | |
tree | b6d1ce478c55872d51a1e24fd75bf57c8deeda4e /core | |
parent | 014849570c80ce2c7081f8477ac97dcebabc4f5c (diff) | |
parent | 7a02d6e457073bd7f00546ff4b5b442937724651 (diff) | |
download | frameworks_base-db33d4bbaeedf2095968ec7795b488038cdcd015.zip frameworks_base-db33d4bbaeedf2095968ec7795b488038cdcd015.tar.gz frameworks_base-db33d4bbaeedf2095968ec7795b488038cdcd015.tar.bz2 |
Merge change 21468 into eclair
* changes:
Couple of fixes for viewport.
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/webkit/WebViewCore.java | 66 |
1 files changed, 44 insertions, 22 deletions
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index 0720beb..dee62b4 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -1778,12 +1778,27 @@ final class WebViewCore { mBrowserFrame.didFirstLayout(); - // reset the scroll position as it is a new page now - mWebkitScrollX = mWebkitScrollY = 0; + if (mWebView == null) return; + + setupViewport(standardLoad || mRestoredScale > 0); + + // reset the scroll position, the restored offset and scales + mWebkitScrollX = mWebkitScrollY = mRestoredX = mRestoredY + = mRestoredScale = mRestoredScreenWidthScale = 0; + } - // for non-standard load, we only adjust scale if mRestoredScale > 0 - if (mWebView == null || (mRestoredScale == 0 && !standardLoad)) return; + // called by JNI + private void updateViewport() { + // if updateViewport is called before first layout, wait until first + // layout to update the viewport. In the rare case, this is called after + // first layout, force an update as we have just parsed the viewport + // meta tag. + if (mBrowserFrame.firstLayoutDone()) { + setupViewport(true); + } + } + private void setupViewport(boolean updateRestoreState) { // set the viewport settings from WebKit setViewportSettingsFromNative(); @@ -1834,6 +1849,9 @@ final class WebViewCore { mViewportWidth = 0; } + // if mViewportWidth is 0, it means device-width, always update. + if (mViewportWidth != 0 && !updateRestoreState) return; + // now notify webview int webViewWidth = Math.round(mCurrentViewWidth * mCurrentViewScale); mRestoreState = new RestoreState(); @@ -1884,25 +1902,29 @@ final class WebViewCore { data.mScale = -1.0f; mEventHub.sendMessageAtFrontOfQueue(Message.obtain(null, EventHub.VIEW_SIZE_CHANGED, data)); - } else if (mSettings.getUseWideViewPort() && mCurrentViewWidth > 0) { - WebView.ViewSizeData data = new WebView.ViewSizeData(); - // mViewScale as 0 means it is in zoom overview mode. So we don't - // know the exact scale. If mRestoredScale is non-zero, use it; - // otherwise just use mTextWrapScale as the initial scale. - data.mScale = mRestoreState.mViewScale == 0 - ? (mRestoredScale > 0 ? mRestoredScale - : mRestoreState.mTextWrapScale) - : mRestoreState.mViewScale; - data.mWidth = Math.round(webViewWidth / data.mScale); - data.mHeight = mCurrentViewHeight * data.mWidth - / mCurrentViewWidth; - data.mTextWrapWidth = Math.round(webViewWidth - / mRestoreState.mTextWrapScale); - mEventHub.sendMessageAtFrontOfQueue(Message.obtain(null, - EventHub.VIEW_SIZE_CHANGED, data)); + } else if (mSettings.getUseWideViewPort()) { + if (mCurrentViewWidth == 0) { + // Trick to ensure VIEW_SIZE_CHANGED will be sent from WebView + // to WebViewCore + mWebView.mLastWidthSent = 0; + } else { + WebView.ViewSizeData data = new WebView.ViewSizeData(); + // mViewScale as 0 means it is in zoom overview mode. So we don't + // know the exact scale. If mRestoredScale is non-zero, use it; + // otherwise just use mTextWrapScale as the initial scale. + data.mScale = mRestoreState.mViewScale == 0 + ? (mRestoredScale > 0 ? mRestoredScale + : mRestoreState.mTextWrapScale) + : mRestoreState.mViewScale; + data.mWidth = Math.round(webViewWidth / data.mScale); + data.mHeight = mCurrentViewHeight * data.mWidth + / mCurrentViewWidth; + data.mTextWrapWidth = Math.round(webViewWidth + / mRestoreState.mTextWrapScale); + mEventHub.sendMessageAtFrontOfQueue(Message.obtain(null, + EventHub.VIEW_SIZE_CHANGED, data)); + } } - // reset restored offset, scale - mRestoredX = mRestoredY = mRestoredScale = mRestoredScreenWidthScale = 0; } // called by JNI |