From 047a8acf2d0ca262b7397c2e27034b78565eac51 Mon Sep 17 00:00:00 2001 From: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Mon, 27 Sep 2021 11:08:16 -0700 Subject: [PATCH] [iOSTextInput] remove floating cursor asserts (flutter/engine#28868) --- .../ios/framework/Source/FlutterTextInputPlugin.mm | 6 +----- .../ios/framework/Source/FlutterTextInputPluginTest.mm | 10 ++++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index f5b00e33a0..cf77aff62b 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -1368,7 +1368,6 @@ static FlutterAutofillType autofillTypeOf(NSDictionary* configuration) { // It seems impossible to use a negative "width" or "height", as the "convertRect" // call always turns a CGRect's negative dimensions into non-negative values, e.g., // (1, 2, -3, -4) would become (-2, -2, 3, 4). - NSAssert(!_isFloatingCursorActive, @"Another floating cursor is currently active."); _isFloatingCursorActive = true; [self.textInputDelegate updateFloatingCursor:FlutterFloatingCursorDragStateStart withClient:_textInputClient @@ -1376,16 +1375,13 @@ static FlutterAutofillType autofillTypeOf(NSDictionary* configuration) { } - (void)updateFloatingCursorAtPoint:(CGPoint)point { - NSAssert(_isFloatingCursorActive, - @"updateFloatingCursorAtPoint is called without an active floating cursor."); + _isFloatingCursorActive = true; [self.textInputDelegate updateFloatingCursor:FlutterFloatingCursorDragStateUpdate withClient:_textInputClient withPosition:@{@"X" : @(point.x), @"Y" : @(point.y)}]; } - (void)endFloatingCursor { - NSAssert(_isFloatingCursorActive, - @"endFloatingCursor is called without an active floating cursor."); _isFloatingCursorActive = false; [self.textInputDelegate updateFloatingCursor:FlutterFloatingCursorDragStateEnd withClient:_textInputClient diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm index de6e549d10..e8a992ee0a 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm @@ -825,6 +825,16 @@ FLUTTER_ASSERT_ARC } } +- (void)testFloatingCursorDoesNotThrow { + // The keyboard implementation may send unbalanced calls to the input view. + FlutterTextInputView* inputView = [[FlutterTextInputView alloc] init]; + [inputView beginFloatingCursorAtPoint:CGPointMake(123, 321)]; + [inputView beginFloatingCursorAtPoint:CGPointMake(123, 321)]; + [inputView endFloatingCursor]; + [inputView beginFloatingCursorAtPoint:CGPointMake(123, 321)]; + [inputView endFloatingCursor]; +} + - (void)testBoundsForFloatingCursor { FlutterTextInputView* inputView = [[FlutterTextInputView alloc] init];