Send text selection rects to engine on iPhone (#113048)

This commit is contained in:
Callum Moffat 2022-10-06 19:08:06 -04:00 committed by GitHub
parent 00f36b6466
commit af2d5bc5ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 8 deletions

View File

@ -63,10 +63,6 @@ const Duration _kCursorBlinkHalfPeriod = Duration(milliseconds: 500);
// is shown in an obscured text field.
const int _kObscureShowLatestCharCursorTicks = 3;
// The minimum width of an iPad screen. The smallest iPad is currently the
// iPad Mini 6th Gen according to ios-resolution.com.
const double _kIPadWidth = 1488.0;
/// A controller for an editable text field.
///
/// Whenever the user modifies a text field with an associated
@ -3144,10 +3140,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
if (defaultTargetPlatform != TargetPlatform.iOS) {
return;
}
// This is to avoid sending selection rects on non-iPad devices.
if (WidgetsBinding.instance.window.physicalSize.shortestSide < _kIPadWidth) {
return;
}
final String text = renderEditable.text?.toPlainText(includeSemanticsLabels: false) ?? '';
final List<Rect> firstSelectionBoxes = renderEditable.getBoxesForSelection(const TextSelection(baseOffset: 0, extentOffset: 1));

View File

@ -4624,6 +4624,10 @@ void main() {
});
testWidgets('selection rects are sent when they change', (WidgetTester tester) async {
addTearDown(tester.binding.window.clearPhysicalSizeTestValue);
// Ensure selection rects are sent on iPhone (using SE 3rd gen size)
tester.binding.window.physicalSizeTestValue = const Size(750.0, 1334.0);
final List<MethodCall> log = <MethodCall>[];
SystemChannels.textInput.setMockMethodCallHandler((MethodCall methodCall) async {
log.add(methodCall);