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

Commit cdc74590 authored by Phil Weaver's avatar Phil Weaver
Browse files

Fix a11y text location in clipped views

Bug: 37482849
Test: Run Select to Speak, open apps, scroll so top row is
partially visible, have it read the screen.

Change-Id: Ibbd51221f8e93372ccff6d5fb57cdc2a09f2c19f
parent f9f8120e
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -10268,16 +10268,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                    positionInfoStartIndex + positionInfoLength,
                    viewportToContentHorizontalOffset(), viewportToContentVerticalOffset());
            CursorAnchorInfo cursorAnchorInfo = builder.setMatrix(null).build();
            if (mTempRect == null) mTempRect = new Rect();
            Rect viewBoundsInScreen = mTempRect;
            info.getBoundsInScreen(viewBoundsInScreen);
            int[] locationOnScreen = getLocationOnScreen();
            for (int i = 0; i < positionInfoLength; i++) {
                int flags = cursorAnchorInfo.getCharacterBoundsFlags(positionInfoStartIndex + i);
                if ((flags & FLAG_HAS_VISIBLE_REGION) == FLAG_HAS_VISIBLE_REGION) {
                    RectF bounds = cursorAnchorInfo
                            .getCharacterBounds(positionInfoStartIndex + i);
                    if (bounds != null) {
                        bounds.offset(viewBoundsInScreen.left, viewBoundsInScreen.top);
                        bounds.offset(locationOnScreen[0], locationOnScreen[1]);
                        boundingRects[i] = bounds;
                    }
                }