Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Migrate iOS text input plugin to use ARC #38179

Merged
merged 5 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions shell/platform/darwin/ios/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,31 @@ _flutter_framework_headers = [

_flutter_framework_headers_copy_dir = "$_flutter_framework_dir/Headers"

source_set("flutter_framework_source_arc") {
visibility = [ ":*" ]
cflags_objc = flutter_cflags_objc_arc
cflags_objcc = flutter_cflags_objcc_arc

defines = [ "FLUTTER_FRAMEWORK=1" ]
allow_circular_includes_from = [ ":flutter_framework_source" ]
deps = [
":flutter_framework_source",
"//flutter/fml",
"//flutter/shell/platform/common:common_cpp_input",
"//flutter/shell/platform/darwin/common:framework_shared",
"//third_party/icu",
]
public_configs = [ "//flutter:config" ]

sources = [
"framework/Source/FlutterTextInputDelegate.h",
"framework/Source/FlutterTextInputPlugin.h",
"framework/Source/FlutterTextInputPlugin.mm",
]

frameworks = [ "UIKit.framework" ]
}

source_set("flutter_framework_source") {
visibility = [ ":*" ]
cflags_objc = flutter_cflags_objc
Expand Down Expand Up @@ -81,9 +106,6 @@ source_set("flutter_framework_source") {
"framework/Source/FlutterSemanticsScrollView.mm",
"framework/Source/FlutterSpellCheckPlugin.h",
"framework/Source/FlutterSpellCheckPlugin.mm",
"framework/Source/FlutterTextInputDelegate.h",
"framework/Source/FlutterTextInputPlugin.h",
"framework/Source/FlutterTextInputPlugin.mm",
"framework/Source/FlutterUIPressProxy.h",
"framework/Source/FlutterUIPressProxy.mm",
"framework/Source/FlutterUndoManagerDelegate.h",
Expand Down Expand Up @@ -209,6 +231,7 @@ source_set("ios_test_flutter_mrc") {
]
deps = [
":flutter_framework_source",
":flutter_framework_source_arc",
"//flutter/common:common",
"//flutter/lib/ui:ui",
"//flutter/shell/common:common",
Expand Down Expand Up @@ -267,6 +290,7 @@ shared_library("ios_test_flutter") {
deps = [
":flutter_framework",
":flutter_framework_source",
":flutter_framework_source_arc",
":ios_gpu_configuration",
":ios_test_flutter_mrc",
"//flutter/common:common",
Expand Down Expand Up @@ -295,7 +319,10 @@ shared_library("create_flutter_framework_dylib") {

public = _flutter_framework_headers

deps = [ ":flutter_framework_source" ]
deps = [
":flutter_framework_source",
":flutter_framework_source_arc",
]

public_configs = [ "//flutter:config" ]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#import <UIKit/UIKit.h>

#import "flutter/fml/memory/weak_ptr.h"
#import "flutter/shell/platform/common/text_editing_delta.h"
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterIndirectScribbleDelegate.h"
Expand All @@ -30,8 +29,8 @@ typedef NS_ENUM(NSInteger, FlutterScribbleInteractionStatus) {
@interface FlutterTextInputPlugin
: NSObject <FlutterKeySecondaryResponder, UIIndirectScribbleInteractionDelegate>

@property(nonatomic, assign) UIViewController* viewController;
@property(nonatomic, assign) id<FlutterIndirectScribbleDelegate> indirectScribbleDelegate;
@property(nonatomic, weak) UIViewController* viewController;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does flutter view controller retains the FlutterTextInputPlugin (opposite direction)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes FlutterViewController seems to retain an engine instance: fml::scoped_nsobject<FlutterEngine> _engine

@property(nonatomic, weak) id<FlutterIndirectScribbleDelegate> indirectScribbleDelegate;
@property(nonatomic, strong)
NSMutableDictionary<UIScribbleElementIdentifier, NSValue*>* scribbleElements;

Expand Down Expand Up @@ -125,7 +124,7 @@ FLUTTER_DARWIN_EXPORT
@property(readwrite, copy) UITextRange* selectedTextRange;
@property(nonatomic, strong) UITextRange* markedTextRange;
@property(nonatomic, copy) NSDictionary* markedTextStyle;
@property(nonatomic, assign) id<UITextInputDelegate> inputDelegate;
@property(nonatomic, weak) id<UITextInputDelegate> inputDelegate;

// UITextInputTraits
@property(nonatomic) UITextAutocapitalizationType autocapitalizationType;
Expand All @@ -141,10 +140,10 @@ FLUTTER_DARWIN_EXPORT
@property(nonatomic) UITextSmartDashesType smartDashesType API_AVAILABLE(ios(11.0));
@property(nonatomic, copy) UITextContentType textContentType API_AVAILABLE(ios(10.0));

@property(nonatomic, assign) UIAccessibilityElement* backingTextInputAccessibilityObject;
@property(nonatomic, weak) UIAccessibilityElement* backingTextInputAccessibilityObject;

// Scribble Support
@property(nonatomic, assign) id<FlutterViewResponder> viewResponder;
@property(nonatomic, weak) id<FlutterViewResponder> viewResponder;
@property(nonatomic) FlutterScribbleFocusStatus scribbleFocusStatus;
@property(nonatomic, strong) NSArray<FlutterTextSelectionRect*>* selectionRects;
- (void)resetScribbleInteractionStatusIfEnding;
Expand Down
Loading