am 9a67c820: Address the multiple resizing during initializing problem adobe run into.

Merge commit '9a67c82089e43d37f5038c74b0e1dca8edc4ac8a' into eclair-mr2-plus-aosp

* commit '9a67c82089e43d37f5038c74b0e1dca8edc4ac8a':
  Address the multiple resizing during initializing
This commit is contained in:
Grace Kloba
2009-12-20 11:34:57 -08:00
committed by Android Git Automerger
4 changed files with 38 additions and 5 deletions

View File

@@ -339,6 +339,7 @@ class BrowserFrame extends Handler {
// loadType is not used yet // loadType is not used yet
if (isMainFrame) { if (isMainFrame) {
mCommitted = true; mCommitted = true;
mWebViewCore.getWebView().mViewManager.postResetStateAll();
} }
} }

View File

@@ -16,7 +16,6 @@
package android.webkit; package android.webkit;
import android.content.Context;
import android.view.View; import android.view.View;
import android.widget.AbsoluteLayout; import android.widget.AbsoluteLayout;
@@ -26,6 +25,7 @@ class ViewManager {
private final WebView mWebView; private final WebView mWebView;
private final ArrayList<ChildView> mChildren = new ArrayList<ChildView>(); private final ArrayList<ChildView> mChildren = new ArrayList<ChildView>();
private boolean mHidden; private boolean mHidden;
private boolean mReadyToDraw;
class ChildView { class ChildView {
int x; int x;
@@ -70,6 +70,9 @@ class ViewManager {
void attachViewOnUIThread(AbsoluteLayout.LayoutParams lp) { void attachViewOnUIThread(AbsoluteLayout.LayoutParams lp) {
mWebView.addView(mView, lp); mWebView.addView(mView, lp);
mChildren.add(this); mChildren.add(this);
if (!mReadyToDraw) {
mView.setVisibility(View.GONE);
}
} }
void removeView() { void removeView() {
@@ -154,4 +157,23 @@ class ViewManager {
} }
mHidden = false; 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);
}
}
});
}
} }

View File

@@ -773,12 +773,11 @@ public class WebView extends AbsoluteLayout
init(); init();
mCallbackProxy = new CallbackProxy(context, this); mCallbackProxy = new CallbackProxy(context, this);
mViewManager = new ViewManager(this);
mWebViewCore = new WebViewCore(context, this, mCallbackProxy, javascriptInterfaces); mWebViewCore = new WebViewCore(context, this, mCallbackProxy, javascriptInterfaces);
mDatabase = WebViewDatabase.getInstance(context); mDatabase = WebViewDatabase.getInstance(context);
mScroller = new Scroller(context); mScroller = new Scroller(context);
mViewManager = new ViewManager(this);
mZoomButtonsController = new ZoomButtonsController(this); mZoomButtonsController = new ZoomButtonsController(this);
mZoomButtonsController.setOnZoomListener(mZoomListener); mZoomButtonsController.setOnZoomListener(mZoomListener);
// ZoomButtonsController positions the buttons at the bottom, but in // ZoomButtonsController positions the buttons at the bottom, but in
@@ -5410,7 +5409,8 @@ public class WebView extends AbsoluteLayout
final Point viewSize = draw.mViewPoint; final Point viewSize = draw.mViewPoint;
boolean useWideViewport = settings.getUseWideViewPort(); boolean useWideViewport = settings.getUseWideViewPort();
WebViewCore.RestoreState restoreState = draw.mRestoreState; WebViewCore.RestoreState restoreState = draw.mRestoreState;
if (restoreState != null) { boolean hasRestoreState = restoreState != null;
if (hasRestoreState) {
mInZoomOverview = false; mInZoomOverview = false;
mLastScale = mInitialScaleInPercent > 0 mLastScale = mInitialScaleInPercent > 0
? mInitialScaleInPercent / 100.0f ? mInitialScaleInPercent / 100.0f
@@ -5500,6 +5500,9 @@ public class WebView extends AbsoluteLayout
if (draw.mFocusSizeChanged && inEditingMode()) { if (draw.mFocusSizeChanged && inEditingMode()) {
mFocusSizeChanged = true; mFocusSizeChanged = true;
} }
if (hasRestoreState) {
mViewManager.postReadyToDrawAll();
}
break; break;
} }
case WEBCORE_INITIALIZED_MSG_ID: case WEBCORE_INITIALIZED_MSG_ID:

View File

@@ -1924,7 +1924,14 @@ final class WebViewCore {
if (mWebView == null) return; 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 // reset the scroll position, the restored offset and scales
mWebkitScrollX = mWebkitScrollY = mRestoredX = mRestoredY mWebkitScrollX = mWebkitScrollY = mRestoredX = mRestoredY