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

Commit 8116da5f authored by Michael Kolb's avatar Michael Kolb
Browse files

Remove embedded titlebar rendering

    Bug: 5032345

During the zoom, the embedded titlebar doesn't get rendered
in the correct spot. Browser renders the titlebar differently
now, so the old code can be removed

Change-Id: I6affc9e6119dc17e89d15dad77e14e1cdf139662
parent 04247163
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -1912,13 +1912,6 @@ public class WebView extends AbsoluteLayout
        mProvider.getViewDelegate().onWindowVisibilityChanged(visibility);
    }

    @Override
    protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
        // Not using short-circuit OR: provider does suppress base-class call.
        return mProvider.getViewDelegate().drawChild(canvas, child, drawingTime) |
                super.drawChild(canvas, child, drawingTime);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        mProvider.getViewDelegate().onDraw(canvas);
+4 −67
Original line number Diff line number Diff line
@@ -2014,7 +2014,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
        if (mWebView instanceof TitleBarDelegate) {
            return ((TitleBarDelegate) mWebView).getTitleHeight();
        }
        return mTitleBar != null ? mTitleBar.getHeight() : 0;
        return 0;
    }

    /**
@@ -2945,50 +2945,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
                      computeRealVerticalScrollRange() + getTitleHeight());
    }

    /**
     * A title bar which is embedded in this WebView, and scrolls along with it
     * vertically, but not horizontally.
     */
    private View mTitleBar;

    /**
     * the title bar rendering gravity
     */
    private int mTitleGravity;

    /**
     * Add or remove a title bar to be embedded into the WebView, and scroll
     * along with it vertically, while remaining in view horizontally. Pass
     * null to remove the title bar from the WebView, and return to drawing
     * the WebView normally without translating to account for the title bar.
     */
    public void setEmbeddedTitleBar(View v) {
        if (mWebView instanceof TitleBarDelegate) {
            ((TitleBarDelegate) mWebView).onSetEmbeddedTitleBar(v);
        }
        if (mTitleBar == v) return;
        if (mTitleBar != null) {
            mWebView.removeView(mTitleBar);
        }
        if (null != v) {
            mWebView.addView(v, new AbsoluteLayout.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0));
        }
        mTitleBar = v;
    }

    /**
     * Set where to render the embedded title bar
     * NO_GRAVITY at the top of the page
     * TOP        at the top of the screen
     */
    public void setTitleBarGravity(int gravity) {
        mTitleGravity = gravity;
        // force refresh
        invalidate();
    }

    /**
     * Given a distance in view space, convert it to content space. Note: this
     * does not reflect translation, just scaling, so this should not be called
@@ -4187,7 +4143,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
        // animate the title bar off screen slowly enough that the user can see
        // it.
        if (cx == 0 && cy == 1 && getScrollX() == 0 && getScrollY() == 0
                && mTitleBar != null) {
                && getTitleHeight() > 0) {
            // FIXME: 100 should be defined somewhere as our max progress.
            if (getProgress() < 100) {
                // Wait to scroll the title bar off screen until the page has
@@ -4404,24 +4360,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
        }
    }

    @Override
    public boolean drawChild(Canvas canvas, View child, long drawingTime) {
        if (child == mTitleBar) {
            // When drawing the title bar, move it horizontally to always show
            // at the top of the WebView.
            mTitleBar.offsetLeftAndRight(getScrollX() - mTitleBar.getLeft());
            int newTop = 0;
            if (mTitleGravity == Gravity.NO_GRAVITY) {
                newTop = Math.min(0, getScrollY());
            } else if (mTitleGravity == Gravity.TOP) {
                newTop = getScrollY();
            }
            mTitleBar.setBottom(newTop + mTitleBar.getHeight());
            mTitleBar.setTop(newTop);
        }
        return false;  // We never call invalidate(), so unconditionally returning false.
    }

    private void drawContent(Canvas canvas) {
        if (mDrawHistory) {
            canvas.scale(mZoomManager.getScale(), mZoomManager.getScale());
@@ -4586,9 +4524,8 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
                .getUseWebViewBackgroundForOverscrollBackground()) {
            drawOverScrollBackground(canvas);
        }
        if (mTitleBar != null) {

        canvas.translate(0, getTitleHeight());
        }
        drawContent(canvas);
        canvas.restoreToCount(saveCount);

+0 −2
Original line number Diff line number Diff line
@@ -287,8 +287,6 @@ public interface WebViewProvider {

        public void onWindowVisibilityChanged(int visibility);

        public boolean drawChild(Canvas canvas, View child, long drawingTime);

        public void onDraw(Canvas canvas);

        public void setLayoutParams(LayoutParams layoutParams);