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

Commit fec22c6b 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.

Change-Id: If2a5349555ec9e86e4295e819d5d9086f0adcdbd
parent 53b5d17d
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -9484,8 +9484,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 &&
@@ -9496,7 +9496,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() {
@@ -10643,7 +10644,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();