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.
This commit is contained in:
Grace Kloba
2009-12-20 11:33:58 -08:00
parent 4d0e827d0b
commit 9a67c82089
4 changed files with 38 additions and 5 deletions

View File

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

View File

@@ -16,7 +16,6 @@
package android.webkit;
import android.content.Context;
import android.view.View;
import android.widget.AbsoluteLayout;
@@ -26,6 +25,7 @@ class ViewManager {
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 @@ class ViewManager {
void attachViewOnUIThread(AbsoluteLayout.LayoutParams lp) {
mWebView.addView(mView, lp);
mChildren.add(this);
if (!mReadyToDraw) {
mView.setVisibility(View.GONE);
}
}
void removeView() {
@@ -154,4 +157,23 @@ class ViewManager {
}
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();
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 @@ public class WebView extends AbsoluteLayout
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 @@ public class WebView extends AbsoluteLayout
if (draw.mFocusSizeChanged && inEditingMode()) {
mFocusSizeChanged = true;
}
if (hasRestoreState) {
mViewManager.postReadyToDrawAll();
}
break;
}
case WEBCORE_INITIALIZED_MSG_ID:

View File

@@ -1924,7 +1924,14 @@ final class WebViewCore {
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