Loading core/java/android/widget/Editor.java +44 −8 Original line number Diff line number Diff line Loading @@ -1778,6 +1778,18 @@ public class Editor { if (translate) canvas.translate(0, -cursorOffsetVertical); } void invalidateHandlesAndActionMode() { if (mSelectionModifierCursorController != null) { mSelectionModifierCursorController.invalidateHandles(); } if (mInsertionPointCursorController != null) { mInsertionPointCursorController.invalidateHandle(); } if (mTextActionMode != null) { mTextActionMode.invalidate(); } } /** * Invalidates all the sub-display lists that overlap the specified character range */ Loading Loading @@ -4104,6 +4116,14 @@ public class Editor { setMeasuredDimension(getPreferredWidth(), getPreferredHeight()); } @Override public void invalidate() { super.invalidate(); if (isShowing()) { positionAtCursorOffset(getCurrentCursorOffset(), true); } }; private int getPreferredWidth() { return Math.max(mDrawable.getIntrinsicWidth(), mMinSize); } Loading Loading @@ -4170,7 +4190,12 @@ public class Editor { return mTextView.getOffsetAtCoordinate(line, x); } protected void positionAtCursorOffset(int offset, boolean parentScrolled) { /** * @param offset Cursor offset. Must be in [-1, length]. * @param forceUpdatePosition whether to force update the position. This should be true * when If the parent has been scrolled, for example. */ protected void positionAtCursorOffset(int offset, boolean forceUpdatePosition) { // A HandleView relies on the layout, which may be nulled by external methods Layout layout = mTextView.getLayout(); if (layout == null) { Loading @@ -4181,7 +4206,7 @@ public class Editor { layout = mTextView.getLayout(); boolean offsetChanged = offset != mPreviousOffset; if (offsetChanged || parentScrolled) { if (offsetChanged || forceUpdatePosition) { if (offsetChanged) { updateSelection(offset); addPositionToTouchUpFilter(offset); Loading Loading @@ -4782,13 +4807,9 @@ public class Editor { mPrevX = x; } /** * @param offset Cursor offset. Must be in [-1, length]. * @param parentScrolled If the parent has been scrolled or not. */ @Override protected void positionAtCursorOffset(int offset, boolean parentScrolled) { super.positionAtCursorOffset(offset, parentScrolled); protected void positionAtCursorOffset(int offset, boolean forceUpdatePosition) { super.positionAtCursorOffset(offset, forceUpdatePosition); mInWord = (offset != -1) && !getWordIteratorWithText().isBoundary(offset); } Loading Loading @@ -5014,6 +5035,12 @@ public class Editor { public boolean isActive() { return mHandle != null && mHandle.isShowing(); } public void invalidateHandle() { if (mHandle != null) { mHandle.invalidate(); } } } class SelectionModifierCursorController implements CursorController { Loading Loading @@ -5418,6 +5445,15 @@ public class Editor { public boolean isActive() { return mStartHandle != null && mStartHandle.isShowing(); } public void invalidateHandles() { if (mStartHandle != null) { mStartHandle.invalidate(); } if (mEndHandle != null) { mEndHandle.invalidate(); } } } private class CorrectionHighlighter { Loading core/java/android/widget/TextView.java +5 −1 Original line number Diff line number Diff line Loading @@ -3350,7 +3350,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener mShadowColor = color; // Will change text clip region if (mEditor != null) mEditor.invalidateTextDisplayList(); if (mEditor != null) { mEditor.invalidateTextDisplayList(); mEditor.invalidateHandlesAndActionMode(); } invalidate(); } Loading Loading @@ -8306,6 +8309,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (mEditor != null) { if (oldStart >= 0) mEditor.invalidateTextDisplayList(mLayout, oldStart, oldEnd); if (newStart >= 0) mEditor.invalidateTextDisplayList(mLayout, newStart, newEnd); mEditor.invalidateHandlesAndActionMode(); } } Loading Loading
core/java/android/widget/Editor.java +44 −8 Original line number Diff line number Diff line Loading @@ -1778,6 +1778,18 @@ public class Editor { if (translate) canvas.translate(0, -cursorOffsetVertical); } void invalidateHandlesAndActionMode() { if (mSelectionModifierCursorController != null) { mSelectionModifierCursorController.invalidateHandles(); } if (mInsertionPointCursorController != null) { mInsertionPointCursorController.invalidateHandle(); } if (mTextActionMode != null) { mTextActionMode.invalidate(); } } /** * Invalidates all the sub-display lists that overlap the specified character range */ Loading Loading @@ -4104,6 +4116,14 @@ public class Editor { setMeasuredDimension(getPreferredWidth(), getPreferredHeight()); } @Override public void invalidate() { super.invalidate(); if (isShowing()) { positionAtCursorOffset(getCurrentCursorOffset(), true); } }; private int getPreferredWidth() { return Math.max(mDrawable.getIntrinsicWidth(), mMinSize); } Loading Loading @@ -4170,7 +4190,12 @@ public class Editor { return mTextView.getOffsetAtCoordinate(line, x); } protected void positionAtCursorOffset(int offset, boolean parentScrolled) { /** * @param offset Cursor offset. Must be in [-1, length]. * @param forceUpdatePosition whether to force update the position. This should be true * when If the parent has been scrolled, for example. */ protected void positionAtCursorOffset(int offset, boolean forceUpdatePosition) { // A HandleView relies on the layout, which may be nulled by external methods Layout layout = mTextView.getLayout(); if (layout == null) { Loading @@ -4181,7 +4206,7 @@ public class Editor { layout = mTextView.getLayout(); boolean offsetChanged = offset != mPreviousOffset; if (offsetChanged || parentScrolled) { if (offsetChanged || forceUpdatePosition) { if (offsetChanged) { updateSelection(offset); addPositionToTouchUpFilter(offset); Loading Loading @@ -4782,13 +4807,9 @@ public class Editor { mPrevX = x; } /** * @param offset Cursor offset. Must be in [-1, length]. * @param parentScrolled If the parent has been scrolled or not. */ @Override protected void positionAtCursorOffset(int offset, boolean parentScrolled) { super.positionAtCursorOffset(offset, parentScrolled); protected void positionAtCursorOffset(int offset, boolean forceUpdatePosition) { super.positionAtCursorOffset(offset, forceUpdatePosition); mInWord = (offset != -1) && !getWordIteratorWithText().isBoundary(offset); } Loading Loading @@ -5014,6 +5035,12 @@ public class Editor { public boolean isActive() { return mHandle != null && mHandle.isShowing(); } public void invalidateHandle() { if (mHandle != null) { mHandle.invalidate(); } } } class SelectionModifierCursorController implements CursorController { Loading Loading @@ -5418,6 +5445,15 @@ public class Editor { public boolean isActive() { return mStartHandle != null && mStartHandle.isShowing(); } public void invalidateHandles() { if (mStartHandle != null) { mStartHandle.invalidate(); } if (mEndHandle != null) { mEndHandle.invalidate(); } } } private class CorrectionHighlighter { Loading
core/java/android/widget/TextView.java +5 −1 Original line number Diff line number Diff line Loading @@ -3350,7 +3350,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener mShadowColor = color; // Will change text clip region if (mEditor != null) mEditor.invalidateTextDisplayList(); if (mEditor != null) { mEditor.invalidateTextDisplayList(); mEditor.invalidateHandlesAndActionMode(); } invalidate(); } Loading Loading @@ -8306,6 +8309,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (mEditor != null) { if (oldStart >= 0) mEditor.invalidateTextDisplayList(mLayout, oldStart, oldEnd); if (newStart >= 0) mEditor.invalidateTextDisplayList(mLayout, newStart, newEnd); mEditor.invalidateHandlesAndActionMode(); } } Loading