7#import "flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h"
8#import "flutter/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.h"
15@synthesize tokenizer = _tokenizer;
16@synthesize beginningOfDocument = _beginningOfDocument;
17@synthesize endOfDocument = _endOfDocument;
21 [_markedText release];
22 [_markedTextRange release];
23 [_selectedTextRange release];
24 [_markedTextStyle release];
32- (NSString*)textInRange:(UITextRange*)range {
37 @"Expected a FlutterTextRange for range (got %@).", [range class]);
39 NSAssert(textRange.location != NSNotFound,
@"Expected a valid text range.");
40 return [
self.text substringWithRange:textRange];
43- (void)replaceRange:(UITextRange*)range withText:(NSString*)text {
49- (void)setMarkedText:(NSString*)markedText selectedRange:(NSRange)markedSelectedRange {
61- (UITextRange*)textRangeFromPosition:(UITextPosition*)fromPosition
62 toPosition:(UITextPosition*)toPosition {
68- (UITextPosition*)positionFromPosition:(UITextPosition*)position offset:(NSInteger)offset {
75- (UITextPosition*)positionFromPosition:(UITextPosition*)position
76 inDirection:(UITextLayoutDirection)direction
77 offset:(NSInteger)offset {
84- (NSComparisonResult)comparePosition:(UITextPosition*)position toPosition:(UITextPosition*)other {
91- (NSInteger)offsetFromPosition:(UITextPosition*)from toPosition:(UITextPosition*)toPosition {
98- (UITextPosition*)positionWithinRange:(UITextRange*)range
99 farthestInDirection:(UITextLayoutDirection)direction {
106- (UITextRange*)characterRangeByExtendingPosition:(UITextPosition*)position
107 inDirection:(UITextLayoutDirection)direction {
114- (UITextWritingDirection)baseWritingDirectionForPosition:(UITextPosition*)position
115 inDirection:(UITextStorageDirection)direction {
117 return UITextWritingDirectionNatural;
120- (void)setBaseWritingDirection:(UITextWritingDirection)writingDirection
121 forRange:(UITextRange*)range {
125- (CGRect)firstRectForRange:(UITextRange*)range {
139- (UITextPosition*)closestPositionToPoint:(CGPoint)point {
146- (UITextPosition*)closestPositionToPoint:(CGPoint)point withinRange:(UITextRange*)range {
153- (NSArray*)selectionRectsForRange:(UITextRange*)range {
160- (UITextRange*)characterRangeAtPoint:(CGPoint)point {
167- (void)insertText:(NSString*)text {
173- (void)deleteBackward {
185- (instancetype)initWithBridge:(
fml::
WeakPtr<
flutter::AccessibilityBridgeIos>)bridge
187 self = [
super initWithBridge:bridge uid:uid];
197 [_inactive_text_input release];
201#pragma mark - SemanticsObject overrides
203- (void)setSemanticsNode:(const
flutter::SemanticsNode*)node {
204 [
super setSemanticsNode:node];
205 _inactive_text_input.text = @(node->value.data());
208 textInput.backingTextInputAccessibilityObject =
self;
211 textInput.frame = CGRectMake(0.0, 0.0, 1.0, 1.0);
212 }
else if (textInput.backingTextInputAccessibilityObject ==
self) {
213 textInput.backingTextInputAccessibilityObject = nil;
217#pragma mark - UIAccessibility overrides
227- (UIView<UITextInput>*)textInputSurrogate {
229 return [
self bridge]->textInputView();
231 return _inactive_text_input;
235- (UIView*)textInputView {
236 return [
self textInputSurrogate];
239- (void)accessibilityElementDidBecomeFocused {
240 if (![
self isAccessibilityBridgeAlive]) {
243 [[
self textInputSurrogate] accessibilityElementDidBecomeFocused];
244 [
super accessibilityElementDidBecomeFocused];
247- (void)accessibilityElementDidLoseFocus {
248 if (![
self isAccessibilityBridgeAlive]) {
251 [[
self textInputSurrogate] accessibilityElementDidLoseFocus];
252 [
super accessibilityElementDidLoseFocus];
255- (
BOOL)accessibilityElementIsFocused {
256 if (![
self isAccessibilityBridgeAlive]) {
262- (
BOOL)accessibilityActivate {
263 if (![
self isAccessibilityBridgeAlive]) {
266 return [[
self textInputSurrogate] accessibilityActivate];
269- (NSString*)accessibilityLabel {
270 if (![
self isAccessibilityBridgeAlive]) {
274 NSString* label = [
super accessibilityLabel];
278 return [
self textInputSurrogate].accessibilityLabel;
281- (NSString*)accessibilityHint {
282 if (![
self isAccessibilityBridgeAlive]) {
285 NSString* hint = [
super accessibilityHint];
289 return [
self textInputSurrogate].accessibilityHint;
292- (NSString*)accessibilityValue {
293 if (![
self isAccessibilityBridgeAlive]) {
296 NSString*
value = [
super accessibilityValue];
300 return [
self textInputSurrogate].accessibilityValue;
303- (UIAccessibilityTraits)accessibilityTraits {
304 if (![
self isAccessibilityBridgeAlive]) {
307 UIAccessibilityTraits results =
308 [
super accessibilityTraits] | [
self textInputSurrogate].accessibilityTraits;
312 return results & (~kUIAccessibilityTraitUndocumentedEmptyLine);
315#pragma mark - UITextInput overrides
317- (NSString*)textInRange:(UITextRange*)range {
318 return [[
self textInputSurrogate] textInRange:range];
321- (void)replaceRange:(UITextRange*)range withText:(NSString*)text {
322 return [[
self textInputSurrogate] replaceRange:range withText:text];
325- (
BOOL)shouldChangeTextInRange:(UITextRange*)range replacementText:(NSString*)text {
326 return [[
self textInputSurrogate] shouldChangeTextInRange:range replacementText:text];
330 return [[
self textInputSurrogate] selectedTextRange];
333- (void)setSelectedTextRange:(UITextRange*)range {
334 [[
self textInputSurrogate] setSelectedTextRange:range];
338 return [[
self textInputSurrogate] markedTextRange];
342 return [[
self textInputSurrogate] markedTextStyle];
345- (void)setMarkedTextStyle:(NSDictionary*)style {
346 [[
self textInputSurrogate] setMarkedTextStyle:style];
349- (void)setMarkedText:(NSString*)markedText selectedRange:(NSRange)selectedRange {
350 [[
self textInputSurrogate] setMarkedText:markedText selectedRange:selectedRange];
354 [[
self textInputSurrogate] unmarkText];
357- (UITextStorageDirection)selectionAffinity {
358 return [[
self textInputSurrogate] selectionAffinity];
361- (UITextPosition*)beginningOfDocument {
362 return [[
self textInputSurrogate] beginningOfDocument];
365- (UITextPosition*)endOfDocument {
366 return [[
self textInputSurrogate] endOfDocument];
370 return [[
self textInputSurrogate] inputDelegate];
373- (void)setInputDelegate:(
id<UITextInputDelegate>)delegate {
374 [[
self textInputSurrogate] setInputDelegate:delegate];
377- (
id<UITextInputTokenizer>)tokenizer {
378 return [[
self textInputSurrogate] tokenizer];
381- (UITextRange*)textRangeFromPosition:(UITextPosition*)fromPosition
382 toPosition:(UITextPosition*)toPosition {
383 return [[
self textInputSurrogate] textRangeFromPosition:fromPosition toPosition:toPosition];
386- (UITextPosition*)positionFromPosition:(UITextPosition*)position offset:(NSInteger)offset {
387 return [[
self textInputSurrogate] positionFromPosition:position offset:offset];
390- (UITextPosition*)positionFromPosition:(UITextPosition*)position
391 inDirection:(UITextLayoutDirection)direction
392 offset:(NSInteger)offset {
393 return [[
self textInputSurrogate] positionFromPosition:position
394 inDirection:direction
398- (NSComparisonResult)comparePosition:(UITextPosition*)position toPosition:(UITextPosition*)other {
399 return [[
self textInputSurrogate] comparePosition:position toPosition:other];
402- (NSInteger)offsetFromPosition:(UITextPosition*)from toPosition:(UITextPosition*)toPosition {
403 return [[
self textInputSurrogate] offsetFromPosition:from toPosition:toPosition];
406- (UITextPosition*)positionWithinRange:(UITextRange*)range
407 farthestInDirection:(UITextLayoutDirection)direction {
408 return [[
self textInputSurrogate] positionWithinRange:range farthestInDirection:direction];
411- (UITextRange*)characterRangeByExtendingPosition:(UITextPosition*)position
412 inDirection:(UITextLayoutDirection)direction {
413 return [[
self textInputSurrogate] characterRangeByExtendingPosition:position
414 inDirection:direction];
417- (UITextWritingDirection)baseWritingDirectionForPosition:(UITextPosition*)position
418 inDirection:(UITextStorageDirection)direction {
419 return [[
self textInputSurrogate] baseWritingDirectionForPosition:position inDirection:direction];
422- (void)setBaseWritingDirection:(UITextWritingDirection)writingDirection
423 forRange:(UITextRange*)range {
424 [[
self textInputSurrogate] setBaseWritingDirection:writingDirection forRange:range];
427- (CGRect)firstRectForRange:(UITextRange*)range {
428 return [[
self textInputSurrogate] firstRectForRange:range];
432 return [[
self textInputSurrogate] caretRectForPosition:position];
435- (UITextPosition*)closestPositionToPoint:(CGPoint)point {
436 return [[
self textInputSurrogate] closestPositionToPoint:point];
439- (UITextPosition*)closestPositionToPoint:(CGPoint)point withinRange:(UITextRange*)range {
440 return [[
self textInputSurrogate] closestPositionToPoint:point withinRange:range];
443- (NSArray*)selectionRectsForRange:(UITextRange*)range {
444 return [[
self textInputSurrogate] selectionRectsForRange:range];
447- (UITextRange*)characterRangeAtPoint:(CGPoint)point {
448 return [[
self textInputSurrogate] characterRangeAtPoint:point];
451- (void)insertText:(NSString*)text {
452 [[
self textInputSurrogate] insertText:text];
455- (void)deleteBackward {
456 [[
self textInputSurrogate] deleteBackward];
459#pragma mark - UIKeyInput overrides
462 return [[
self textInputSurrogate] hasText];
static const UIAccessibilityTraits kUIAccessibilityTraitUndocumentedEmptyLine
NSDictionary * markedTextStyle
UITextRange * markedTextRange
id< UITextInputDelegate > inputDelegate
API_AVAILABLE(ios(13.0)) @interface FlutterTextPlaceholder UITextRange * selectedTextRange
CGRect caretRectForPosition
auto WeakPtr(std::shared_ptr< T > pointer)