Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9a67c820 authored by Grace Kloba's avatar Grace Kloba
Browse files

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. 
parent 4d0e827d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -339,6 +339,7 @@ class BrowserFrame extends Handler {
        // loadType is not used yet
        if (isMainFrame) {
            mCommitted = true;
            mWebViewCore.getWebView().mViewManager.postResetStateAll();
        }
    }

+23 −1
Original line number Diff line number Diff line
@@ -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);
                }
            }
        });
    }
}
+6 −3
Original line number Diff line number Diff line
@@ -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:
+8 −1
Original line number Diff line number Diff line
@@ -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