Address the multiple resizing during initializing
problem adobe run into.
When a child view is created, we first hide it if
the webview is not ready to draw yet. This will avoid
the multiple resizing notification.
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java
index b36fa8d..1337bed 100644
--- a/core/java/android/webkit/BrowserFrame.java
+++ b/core/java/android/webkit/BrowserFrame.java
@@ -339,6 +339,7 @@
// loadType is not used yet
if (isMainFrame) {
mCommitted = true;
+ mWebViewCore.getWebView().mViewManager.postResetStateAll();
}
}
diff --git a/core/java/android/webkit/ViewManager.java b/core/java/android/webkit/ViewManager.java
index 6a838c3..75db0a0 100644
--- a/core/java/android/webkit/ViewManager.java
+++ b/core/java/android/webkit/ViewManager.java
@@ -16,7 +16,6 @@
package android.webkit;
-import android.content.Context;
import android.view.View;
import android.widget.AbsoluteLayout;
@@ -26,6 +25,7 @@
private final WebView mWebView;
private final ArrayList<ChildView> mChildren = new ArrayList<ChildView>();
private boolean mHidden;
+ private boolean mReadyToDraw;
class ChildView {
int x;
@@ -70,6 +70,9 @@
void attachViewOnUIThread(AbsoluteLayout.LayoutParams lp) {
mWebView.addView(mView, lp);
mChildren.add(this);
+ if (!mReadyToDraw) {
+ mView.setVisibility(View.GONE);
+ }
}
void removeView() {
@@ -154,4 +157,23 @@
}
mHidden = false;
}
+
+ void postResetStateAll() {
+ mWebView.mPrivateHandler.post(new Runnable() {
+ public void run() {
+ mReadyToDraw = false;
+ }
+ });
+ }
+
+ void postReadyToDrawAll() {
+ mWebView.mPrivateHandler.post(new Runnable() {
+ public void run() {
+ mReadyToDraw = true;
+ for (ChildView v : mChildren) {
+ v.mView.setVisibility(View.VISIBLE);
+ }
+ }
+ });
+ }
}
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 9ca7adc..bfe5b41 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -773,12 +773,11 @@
init();
mCallbackProxy = new CallbackProxy(context, this);
+ mViewManager = new ViewManager(this);
mWebViewCore = new WebViewCore(context, this, mCallbackProxy, javascriptInterfaces);
mDatabase = WebViewDatabase.getInstance(context);
mScroller = new Scroller(context);
- mViewManager = new ViewManager(this);
-
mZoomButtonsController = new ZoomButtonsController(this);
mZoomButtonsController.setOnZoomListener(mZoomListener);
// ZoomButtonsController positions the buttons at the bottom, but in
@@ -5410,7 +5409,8 @@
final Point viewSize = draw.mViewPoint;
boolean useWideViewport = settings.getUseWideViewPort();
WebViewCore.RestoreState restoreState = draw.mRestoreState;
- if (restoreState != null) {
+ boolean hasRestoreState = restoreState != null;
+ if (hasRestoreState) {
mInZoomOverview = false;
mLastScale = mInitialScaleInPercent > 0
? mInitialScaleInPercent / 100.0f
@@ -5500,6 +5500,9 @@
if (draw.mFocusSizeChanged && inEditingMode()) {
mFocusSizeChanged = true;
}
+ if (hasRestoreState) {
+ mViewManager.postReadyToDrawAll();
+ }
break;
}
case WEBCORE_INITIALIZED_MSG_ID:
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index ce2637b..fc22f37 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -1924,7 +1924,14 @@
if (mWebView == null) return;
- setupViewport(standardLoad || mRestoredScale > 0);
+ boolean updateRestoreState = standardLoad || mRestoredScale > 0;
+ setupViewport(updateRestoreState);
+ // if updateRestoreState is true, ViewManager.postReadyToDrawAll() will
+ // be called after the WebView restore the state. If updateRestoreState
+ // is false, start to draw now as it is ready.
+ if (!updateRestoreState) {
+ mWebView.mViewManager.postReadyToDrawAll();
+ }
// reset the scroll position, the restored offset and scales
mWebkitScrollX = mWebkitScrollY = mRestoredX = mRestoredY