Merge "Fix TextView#getEditorAndHandwritingBounds used wrong matrix" into main
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 523ff38..7b4ea41 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -27377,6 +27377,29 @@
}
/**
+ * 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 a346a67..a4b28ad 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -14375,7 +14375,7 @@
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