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

Commit 93347c24 authored by Gilles Debunne's avatar Gilles Debunne
Browse files

Text handles do not handle scroll correctly

A recent patch taking scroll into account was applied at the wrong
level. isVisible() expects positions that already take scroll into
account. isOffsetVisible() is where the initial bug was.

Cherry pick of 144415 from master.

Change-Id: I06ceebfb3d7b24aa4adba886c24fcf9d8dd39d2e
parent b44038fd
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -9409,8 +9409,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                return false;
            }

            int posX = mPositionX + positionX - getScrollX();
            int posY = mPositionY + positionY - getScrollY();
            int posX = mPositionX + positionX;
            int posY = mPositionY + positionY;

            // Offset by 1 to take into account 0.5 and int rounding around getPrimaryHorizontal.
            return posX >= clip.left - 1 && posX <= clip.right + 1 &&
@@ -9421,7 +9421,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            final int line = mLayout.getLineForOffset(offset);
            final int lineBottom = mLayout.getLineBottom(line);
            final int primaryHorizontal = (int) mLayout.getPrimaryHorizontal(offset);
            return isVisible(primaryHorizontal, lineBottom);
            return isVisible(primaryHorizontal + viewportToContentHorizontalOffset(),
                    lineBottom + viewportToContentVerticalOffset());
        }

        public void onScrollChanged() {
@@ -10561,7 +10562,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                mPositionX = (int) (mLayout.getPrimaryHorizontal(offset) - 0.5f - mHotspotX);
                mPositionY = mLayout.getLineBottom(line);

                // Take TextView's padding into account.
                // Take TextView's padding and scroll into account.
                mPositionX += viewportToContentHorizontalOffset();
                mPositionY += viewportToContentVerticalOffset();