Migrate TextInputSemanticsObject to ARC (flutter/engine#52785)

1. Migrate TextInputSemanticsObject to ARC
2. Rename the Objective-C-only `accessibility_text_entry.*` files to `TextInputSemanticsObject.*`
3. Move `FlutterInactiveTextInput` interface from the header file into the implementation, the only place it's used.

Blocked on `SemanticsObject` ARC migration https://github.com/flutter/engine/pull/52824

Part of https://github.com/flutter/flutter/issues/137801.
This commit is contained in:
Jenn Magder
2024-05-15 12:10:24 -07:00
committed by GitHub
parent 9e404f6bd7
commit bae1009cd1
7 changed files with 51 additions and 65 deletions

View File

@@ -44027,6 +44027,8 @@ ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObj
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTestMocks.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/TextInputSemanticsObject.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/TextInputSemanticsObject.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/UIViewController_FlutterScreenAndSceneIfLoadedTest.mm + ../../../flutter/LICENSE
@@ -44035,8 +44037,6 @@ ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibilit
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge_ios.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/availability_version_check_test.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/connection_collection.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/connection_collection.mm + ../../../flutter/LICENSE
@@ -46917,6 +46917,8 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjec
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTestMocks.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/TextInputSemanticsObject.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/TextInputSemanticsObject.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/UIViewController_FlutterScreenAndSceneIfLoadedTest.mm
@@ -46925,8 +46927,6 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge_ios.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/availability_version_check_test.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/connection_collection.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/connection_collection.mm

View File

@@ -104,6 +104,8 @@ source_set("flutter_framework_source_arc") {
"framework/Source/KeyCodeMap_Internal.h",
"framework/Source/SemanticsObject.h",
"framework/Source/SemanticsObject.mm",
"framework/Source/TextInputSemanticsObject.h",
"framework/Source/TextInputSemanticsObject.mm",
"framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h",
"framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm",
"framework/Source/connection_collection.h",
@@ -181,8 +183,6 @@ source_set("flutter_framework_source") {
"framework/Source/FlutterViewController_Internal.h",
"framework/Source/accessibility_bridge.h",
"framework/Source/accessibility_bridge.mm",
"framework/Source/accessibility_text_entry.h",
"framework/Source/accessibility_text_entry.mm",
"platform_view_ios.h",
"platform_view_ios.mm",
]
@@ -195,7 +195,6 @@ source_set("flutter_framework_source") {
}
deps += [
"//flutter/common",
"//flutter/fml",
"//flutter/runtime",
"//flutter/shell/common",

View File

@@ -10,7 +10,7 @@
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTouchInterceptingView_Test.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTestMocks.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/TextInputSemanticsObject.h"
FLUTTER_ASSERT_ARC

View File

@@ -0,0 +1,23 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_TEXTINPUTSEMANTICSOBJECT_H_
#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_TEXTINPUTSEMANTICSOBJECT_H_
#import <UIKit/UIKit.h>
#import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.h"
/**
* An implementation of `SemanticsObject` specialized for expressing text
* fields.
*
* Delegates to `FlutterTextInputView` when the object corresponds to a text
* field that currently owns input focus. Delegates to
* `FlutterInactiveTextInput` otherwise.
*/
@interface TextInputSemanticsObject : SemanticsObject <UITextInput>
@end
#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_TEXTINPUTSEMANTICSOBJECT_H_

View File

@@ -2,28 +2,33 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <UIKit/UIKit.h>
#import "flutter/shell/platform/darwin/ios/framework/Source/TextInputSemanticsObject.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h"
FLUTTER_ASSERT_ARC
static const UIAccessibilityTraits kUIAccessibilityTraitUndocumentedEmptyLine = 0x800000000000;
@implementation FlutterInactiveTextInput {
}
/**
* An implementation of `UITextInput` used for text fields that do not currently
* have input focus.
*
* This class is used by `TextInputSemanticsObject`.
*/
@interface FlutterInactiveTextInput : UIView <UITextInput>
@property(nonatomic, copy) NSString* text;
@end
@implementation FlutterInactiveTextInput
@synthesize tokenizer = _tokenizer;
@synthesize beginningOfDocument = _beginningOfDocument;
@synthesize endOfDocument = _endOfDocument;
- (void)dealloc {
[_text release];
[_markedText release];
[_markedTextRange release];
[_selectedTextRange release];
[_markedTextStyle release];
[super dealloc];
}
@synthesize inputDelegate = _inputDelegate;
@synthesize markedTextRange = _markedTextRange;
@synthesize markedTextStyle = _markedTextStyle;
@synthesize selectedTextRange = _selectedTextRange;
@synthesize tokenizer = _tokenizer;
- (BOOL)hasText {
return self.text.length > 0;
@@ -193,11 +198,6 @@ static const UIAccessibilityTraits kUIAccessibilityTraitUndocumentedEmptyLine =
return self;
}
- (void)dealloc {
[_inactive_text_input release];
[super dealloc];
}
#pragma mark - SemanticsObject overrides
- (void)setSemanticsNode:(const flutter::SemanticsNode*)node {

View File

@@ -9,7 +9,7 @@
#include "flutter/fml/logging.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/TextInputSemanticsObject.h"
#import "flutter/shell/platform/darwin/ios/platform_view_ios.h"
#pragma GCC diagnostic error "-Wundeclared-selector"

View File

@@ -1,36 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_ACCESSIBILITY_TEXT_ENTRY_H_
#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_ACCESSIBILITY_TEXT_ENTRY_H_
/**
* An implementation of `UITextInput` used for text fields that do not currently
* have input focus.
*
* This class is used by `TextInputSemanticsObject`.
*/
@interface FlutterInactiveTextInput : UIView <UITextInput>
@property(nonatomic, copy) NSString* text;
@property(nonatomic, copy, readonly) NSMutableString* markedText;
@property(copy) UITextRange* selectedTextRange;
@property(nonatomic, strong, readonly) UITextRange* markedTextRange;
@property(nonatomic, copy) NSDictionary<NSAttributedStringKey, id>* markedTextStyle;
@property(nonatomic, assign) id<UITextInputDelegate> inputDelegate;
@end
/**
* An implementation of `SemanticsObject` specialized for expressing text
* fields.
*
* Delegates to `FlutterTextInputView` when the object corresponds to a text
* field that currently owns input focus. Delegates to
* `FlutterInactiveTextInput` otherwise.
*/
@interface TextInputSemanticsObject : SemanticsObject <UITextInput>
@end
#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_ACCESSIBILITY_TEXT_ENTRY_H_