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

Commit 1e65d9e5 authored by Grace Kloba's avatar Grace Kloba
Browse files

Use float instead of cast to int when calculating

the new zoom center. This should avoid the rounding
difference which caused the video in nytimes.com
not fully fit in the current view.

Fix http://b/issue?id=2512510
parent 43bde929
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -5761,11 +5761,11 @@ public class WebView extends AbsoluteLayout
                    contentToViewY(docY + docHeight / 2) - viewHeight / 2,
                    true, 0);
        } else {
            int oldScreenX = contentToViewX(docX) - mScrollX;
            int rectViewX = (int) (docX * scale);
            int rectViewWidth = (int) (docWidth * scale);
            int newMaxWidth = (int) (mContentWidth * scale);
            int newScreenX = (viewWidth - rectViewWidth) / 2;
            float oldScreenX = docX * mActualScale - mScrollX;
            float rectViewX = docX * scale;
            float rectViewWidth = docWidth * scale;
            float newMaxWidth = mContentWidth * scale;
            float newScreenX = (viewWidth - rectViewWidth) / 2;
            // pin the newX to the WebView
            if (newScreenX > rectViewX) {
                newScreenX = rectViewX;
@@ -5774,12 +5774,12 @@ public class WebView extends AbsoluteLayout
            }
            mZoomCenterX = (oldScreenX * scale - newScreenX * mActualScale)
                    / (scale - mActualScale);
            int oldScreenY = contentToViewY(docY) - mScrollY;
            int rectViewY = (int) (docY * scale) + getTitleHeight();
            int rectViewHeight = (int) (docHeight * scale);
            int newMaxHeight = (int) (mContentHeight * scale)
                    + getTitleHeight();
            int newScreenY = (viewHeight - rectViewHeight) / 2;
            float oldScreenY = docY * mActualScale + getTitleHeight()
                    - mScrollY;
            float rectViewY = docY * scale + getTitleHeight();
            float rectViewHeight = docHeight * scale;
            float newMaxHeight = mContentHeight * scale + getTitleHeight();
            float newScreenY = (viewHeight - rectViewHeight) / 2;
            // pin the newY to the WebView
            if (newScreenY > rectViewY) {
                newScreenY = rectViewY;