From 1454c398c448cae7ed2bb10234253a989857edb3 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Mon, 13 May 2024 15:46:09 -0700 Subject: [PATCH] Migrate TextInputSemanticsObject to ARC --- ci/licenses_golden/licenses_flutter | 8 ++-- shell/platform/darwin/ios/BUILD.gn | 5 +-- .../framework/Source/SemanticsObjectTest.mm | 2 +- .../Source/TextInputSemanticsObject.h | 23 +++++++++++ ...t_entry.mm => TextInputSemanticsObject.mm} | 40 +++++++++---------- .../framework/Source/accessibility_bridge.mm | 2 +- .../Source/accessibility_text_entry.h | 36 ----------------- 7 files changed, 51 insertions(+), 65 deletions(-) create mode 100644 shell/platform/darwin/ios/framework/Source/TextInputSemanticsObject.h rename shell/platform/darwin/ios/framework/Source/{accessibility_text_entry.mm => TextInputSemanticsObject.mm} (95%) delete mode 100644 shell/platform/darwin/ios/framework/Source/accessibility_text_entry.h diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 325022f93d6a4..acae397d1e4ca 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -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 diff --git a/shell/platform/darwin/ios/BUILD.gn b/shell/platform/darwin/ios/BUILD.gn index 39c23e8c0de54..f3e3389a3df2f 100644 --- a/shell/platform/darwin/ios/BUILD.gn +++ b/shell/platform/darwin/ios/BUILD.gn @@ -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", diff --git a/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm b/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm index df68327839782..328d32b6914e0 100644 --- a/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm +++ b/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm @@ -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 diff --git a/shell/platform/darwin/ios/framework/Source/TextInputSemanticsObject.h b/shell/platform/darwin/ios/framework/Source/TextInputSemanticsObject.h new file mode 100644 index 0000000000000..a349c716d7c5d --- /dev/null +++ b/shell/platform/darwin/ios/framework/Source/TextInputSemanticsObject.h @@ -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 + +#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 +@end + +#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_TEXTINPUTSEMANTICSOBJECT_H_ diff --git a/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.mm b/shell/platform/darwin/ios/framework/Source/TextInputSemanticsObject.mm similarity index 95% rename from shell/platform/darwin/ios/framework/Source/accessibility_text_entry.mm rename to shell/platform/darwin/ios/framework/Source/TextInputSemanticsObject.mm index 878f61b978078..682799155649c 100644 --- a/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.mm +++ b/shell/platform/darwin/ios/framework/Source/TextInputSemanticsObject.mm @@ -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 +#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 +@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 @@ - (instancetype)initWithBridge:(fml::WeakPtr)br return self; } -- (void)dealloc { - [_inactive_text_input release]; - [super dealloc]; -} - #pragma mark - SemanticsObject overrides - (void)setSemanticsNode:(const flutter::SemanticsNode*)node { diff --git a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm index 54f5dd4ff7acf..7868c593f0732 100644 --- a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm +++ b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm @@ -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" diff --git a/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.h b/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.h deleted file mode 100644 index ee97385f6f064..0000000000000 --- a/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.h +++ /dev/null @@ -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 - -@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* markedTextStyle; -@property(nonatomic, assign) id 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 -@end - -#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_ACCESSIBILITY_TEXT_ENTRY_H_