From 6d45accc7166c84f94fdb5ca35602463ec4a32a4 Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Thu, 27 Aug 2009 15:42:57 -0400 Subject: [PATCH] don't layout when setting size from zoom if only height changed (companion change in external/webkit) Add a boolean parameter to WebViewCore.java nativeSizeSize(). If set, only layout if the width has also changed. If clear, layout if the height alone has changed. Layout is clear when called from zoom setup, and set otherwise. --- core/java/android/webkit/WebView.java | 2 ++ core/java/android/webkit/WebViewCore.java | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 196c66bf5f5f0..e39e3f1eddd77 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -1935,6 +1935,7 @@ public class WebView extends AbsoluteLayout int mHeight; int mTextWrapWidth; float mScale; + boolean mIgnoreHeight; } /** @@ -1969,6 +1970,7 @@ public class WebView extends AbsoluteLayout data.mTextWrapWidth = mInZoomOverview ? Math.round(viewWidth / mLastScale) : newWidth; data.mScale = mActualScale; + data.mIgnoreHeight = mZoomScale != 0 && !mHeightCanMeasure; mWebViewCore.sendMessage(EventHub.VIEW_SIZE_CHANGED, data); mLastWidthSent = newWidth; mLastHeightSent = newHeight; diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index 25cb249cfaf03..f474f15ac4794 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -418,7 +418,8 @@ final class WebViewCore { should this be called nativeSetViewPortSize? */ private native void nativeSetSize(int width, int height, int screenWidth, - float scale, int realScreenWidth, int screenHeight); + float scale, int realScreenWidth, int screenHeight, + boolean ignoreHeight); private native int nativeGetContentMinPrefWidth(); @@ -918,7 +919,8 @@ final class WebViewCore { WebView.ViewSizeData data = (WebView.ViewSizeData) msg.obj; viewSizeChanged(data.mWidth, data.mHeight, - data.mTextWrapWidth, data.mScale); + data.mTextWrapWidth, data.mScale, + data.mIgnoreHeight); break; } case SET_SCROLL_OFFSET: @@ -1411,7 +1413,8 @@ final class WebViewCore { private float mCurrentViewScale = 1.0f; // notify webkit that our virtual view size changed size (after inv-zoom) - private void viewSizeChanged(int w, int h, int textwrapWidth, float scale) { + private void viewSizeChanged(int w, int h, int textwrapWidth, float scale, + boolean ignoreHeight) { if (DebugFlags.WEB_VIEW_CORE) { Log.v(LOGTAG, "viewSizeChanged w=" + w + "; h=" + h + "; textwrapWidth=" + textwrapWidth + "; scale=" + scale); @@ -1447,7 +1450,7 @@ final class WebViewCore { } } nativeSetSize(width, width == w ? h : Math.round((float) width * h / w), - textwrapWidth, scale, w, h); + textwrapWidth, scale, w, h, ignoreHeight); // Remember the current width and height boolean needInvalidate = (mCurrentViewWidth == 0); mCurrentViewWidth = w; @@ -1905,6 +1908,7 @@ final class WebViewCore { // true. It is safe to use mWidth for mTextWrapWidth. data.mTextWrapWidth = data.mWidth; data.mScale = -1.0f; + data.mIgnoreHeight = false; mEventHub.sendMessageAtFrontOfQueue(Message.obtain(null, EventHub.VIEW_SIZE_CHANGED, data)); } else if (mSettings.getUseWideViewPort()) { @@ -1926,6 +1930,7 @@ final class WebViewCore { / mCurrentViewWidth; data.mTextWrapWidth = Math.round(webViewWidth / mRestoreState.mTextWrapScale); + data.mIgnoreHeight = false; mEventHub.sendMessageAtFrontOfQueue(Message.obtain(null, EventHub.VIEW_SIZE_CHANGED, data)); }