Don't respond to the insertionPointColor selector on iOS 17+ (flutter/engine#46373)
Fixes https://github.com/flutter/flutter/issues/132548 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
@@ -902,7 +902,14 @@ static BOOL IsSelectionRectBoundaryCloserToPoint(CGPoint point,
|
||||
|
||||
// Prevent UIKit from showing selection handles or highlights. This is needed
|
||||
// because Scribble interactions require the view to have it's actual frame on
|
||||
// the screen.
|
||||
// the screen. They're not needed on iOS 17 with the new
|
||||
// UITextSelectionDisplayInteraction API.
|
||||
//
|
||||
// These are undocumented methods. On iOS 17, the insertion point color is also
|
||||
// used as the highlighted background of the selected IME candidate:
|
||||
// https://github.com/flutter/flutter/issues/132548
|
||||
// So the respondsToSelector method is overridden to return NO for this method
|
||||
// on iOS 17+.
|
||||
- (UIColor*)insertionPointColor {
|
||||
return [UIColor clearColor];
|
||||
}
|
||||
@@ -930,6 +937,16 @@ static BOOL IsSelectionRectBoundaryCloserToPoint(CGPoint point,
|
||||
return _textInputPlugin.textInputDelegate;
|
||||
}
|
||||
|
||||
- (BOOL)respondsToSelector:(SEL)selector {
|
||||
if (@available(iOS 17.0, *)) {
|
||||
// See the comment on this method.
|
||||
if (selector == @selector(insertionPointColor)) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
return [super respondsToSelector:selector];
|
||||
}
|
||||
|
||||
- (void)setTextInputClient:(int)client {
|
||||
_textInputClient = client;
|
||||
_hasPlaceholder = NO;
|
||||
|
||||
@@ -786,6 +786,17 @@ FLUTTER_ASSERT_ARC
|
||||
XCTAssertEqual(inputView.spellCheckingType, UITextSpellCheckingTypeNo);
|
||||
}
|
||||
|
||||
- (void)testFlutterTextInputViewOnlyRespondsToInsertionPointColorBelowIOS17 {
|
||||
FlutterTextInputView* inputView = [[FlutterTextInputView alloc] initWithOwner:textInputPlugin];
|
||||
BOOL respondsToInsertionPointColor =
|
||||
[inputView respondsToSelector:@selector(insertionPointColor)];
|
||||
if (@available(iOS 17, *)) {
|
||||
XCTAssertFalse(respondsToInsertionPointColor);
|
||||
} else {
|
||||
XCTAssertTrue(respondsToInsertionPointColor);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - TextEditingDelta tests
|
||||
- (void)testTextEditingDeltasAreGeneratedOnTextInput {
|
||||
FlutterTextInputView* inputView = [[FlutterTextInputView alloc] initWithOwner:textInputPlugin];
|
||||
|
||||
Reference in New Issue
Block a user