diff options
| author | 2024-09-04 06:20:58 +0000 | |
|---|---|---|
| committer | 2024-09-04 06:20:58 +0000 | |
| commit | 52db2456046aa6aa04138f7c8cb71e711fb41a7c (patch) | |
| tree | bab8d7c1e5e8da70deff6aa956b94d9d936c325f | |
| parent | 18a7d247bb4f891d4a36754ad7c268fd8720d6a0 (diff) | |
| parent | 97cc132fdd17195e57c017deb61a5bce60637bd8 (diff) | |
Merge "Fix TextView#getEditorAndHandwritingBounds used wrong matrix" into main
| -rw-r--r-- | core/java/android/view/View.java | 23 | ||||
| -rw-r--r-- | core/java/android/widget/TextView.java | 2 |
2 files changed, 24 insertions, 1 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 523ff38550c1..7b4ea41554f1 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -27377,6 +27377,29 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** + * Modifiers the input matrix such that it maps root view's coordinates to view-local + * coordinates. + * + * @param matrix input matrix to modify + * @hide + */ + public void transformMatrixRootToLocal(@NonNull Matrix matrix) { + final ViewParent parent = mParent; + if (parent instanceof final View vp) { + vp.transformMatrixRootToLocal(matrix); + matrix.postTranslate(vp.mScrollX, vp.mScrollY); + } + // This method is different from transformMatrixToLocal that it doesn't perform any + // transformation for ViewRootImpl + + matrix.postTranslate(-mLeft, -mTop); + + if (!hasIdentityMatrix()) { + matrix.postConcat(getInverseMatrix()); + } + } + + /** * @hide */ @ViewDebug.ExportedProperty(category = "layout", indexMapping = { diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index a346a679ea00..a4b28adae4a1 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -14375,7 +14375,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener Matrix matrix = mTempMatrix; matrix.reset(); - transformMatrixToLocal(matrix); + transformMatrixRootToLocal(matrix); editorBounds.set(rect); // When the view has transformations like scaleX/scaleY computing the global visible // rectangle will already apply the transformations. The getLocalVisibleRect only offsets |