未验证 提交 c3e9c145 编写于 作者: S stuartmorgan 提交者: GitHub

Rename macOS FLE* classes to Flutter* (#11010)

Renames all FLE* classes in the macOS embedding to Flutter*. With the exception
of -[FlutterDartProject engineSwitches], which is very clearly called out in the
comment, the APIs should be stable at this point, so the marker prefix is no
longer needed.

This is a breaking change for macOS embedders, but going forward breaking
changes at the source level for the macOS API should now be rare.

Some of these classes will likely merge with the iOS versions in the future (e.g.,
FlutterDartProject), but that will be an implementation detail that will not affect
clients.

Fixes flutter/flutter#31735
上级 ff484d4f
......@@ -784,25 +784,25 @@ FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_software.mm
FILE: ../../../flutter/shell/platform/darwin/ios/platform_view_ios.h
FILE: ../../../flutter/shell/platform/darwin/ios/platform_view_ios.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/FlutterMacOS.podspec
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FLEDartProject.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FLEEngine.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FLEViewController.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterDartProject.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterEngine.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterMacOS.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterPluginMacOS.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Info.plist
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLEDartProject.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLEDartProject_Internal.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLEEngine.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLEEngine_Internal.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLETextInputModel.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLETextInputModel.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLETextInputPlugin.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLETextInputPlugin.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLEViewController.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FLEViewController_Internal.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterTextInputModel.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterTextInputModel.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterView.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterView.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/module.modulemap
FILE: ../../../flutter/shell/platform/embedder/assets/EmbedderInfo.plist
FILE: ../../../flutter/shell/platform/embedder/assets/embedder.modulemap
......
......@@ -29,12 +29,12 @@ _flutter_framework_dir = "$root_out_dir/$_flutter_framework_filename"
# The headers that will be copied to the framework and be accessed from outside
# the Flutter engine source root.
_flutter_framework_headers = [
"framework/Headers/FlutterDartProject.h",
"framework/Headers/FlutterEngine.h",
"framework/Headers/FlutterMacOS.h",
"framework/Headers/FlutterPluginMacOS.h",
"framework/Headers/FlutterPluginRegistrarMacOS.h",
"framework/Headers/FLEDartProject.h",
"framework/Headers/FLEEngine.h",
"framework/Headers/FLEViewController.h",
"framework/Headers/FlutterViewController.h",
]
_flutter_framework_headers_copy_dir =
......@@ -46,18 +46,18 @@ shared_library("create_flutter_framework_dylib") {
output_name = "$_flutter_framework_name"
sources = [
"framework/Source/FLEDartProject.mm",
"framework/Source/FLEDartProject_Internal.h",
"framework/Source/FLEEngine.mm",
"framework/Source/FLEEngine_Internal.h",
"framework/Source/FLETextInputModel.h",
"framework/Source/FLETextInputModel.mm",
"framework/Source/FLETextInputPlugin.h",
"framework/Source/FLETextInputPlugin.mm",
"framework/Source/FLEViewController.mm",
"framework/Source/FLEViewController_Internal.h",
"framework/Source/FlutterDartProject.mm",
"framework/Source/FlutterDartProject_Internal.h",
"framework/Source/FlutterEngine.mm",
"framework/Source/FlutterEngine_Internal.h",
"framework/Source/FlutterTextInputModel.h",
"framework/Source/FlutterTextInputModel.mm",
"framework/Source/FlutterTextInputPlugin.h",
"framework/Source/FlutterTextInputPlugin.mm",
"framework/Source/FlutterView.h",
"framework/Source/FlutterView.mm",
"framework/Source/FlutterViewController.mm",
"framework/Source/FlutterViewController_Internal.h",
]
sources += _flutter_framework_headers
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_FLEDARTPROJECT_H_
#define FLUTTER_FLEDARTPROJECT_H_
#ifndef FLUTTER_FLUTTERDARTPROJECT_H_
#define FLUTTER_FLUTTERDARTPROJECT_H_
#import <Foundation/Foundation.h>
......@@ -12,10 +12,10 @@
/**
* A set of Flutter and Dart assets used by a `FlutterEngine` to initialize execution.
*
* TODO(stuartmorgan): Align API with FlutterDartProject.
* TODO(stuartmorgan): Align API with FlutterDartProject, and combine.
*/
FLUTTER_EXPORT
@interface FLEDartProject : NSObject
@interface FlutterDartProject : NSObject
/**
* Initializes a Flutter Dart project from a bundle.
......@@ -26,18 +26,20 @@ FLUTTER_EXPORT
* @param bundle The bundle containing the Flutter assets directory. If nil, the main bundle is
* used.
*/
- (nonnull instancetype)initWithBundle:(nullable NSBundle*)bundle NS_DESIGNATED_INITIALIZER;
- (nonnull instancetype)initWithPrecompiledDartBundle:(nullable NSBundle*)bundle
NS_DESIGNATED_INITIALIZER;
/**
* Switches to pass to the Flutter engine. See
* https://github.com/flutter/engine/blob/master/shell/common/switches.h
* for details. Not all switches will apply to embedding mode.
* for details. Not all switches will apply to embedding mode. Switches have not stability
* guarantee, and are subject to change without notice.
*
* Note: This property is likely to be removed in the future in favor of exposing specific switches
* via their own APIs.
* Note: This property WILL BE REMOVED in the future. If you use this property, please see
* https://github.com/flutter/flutter/issue/38569.
*/
@property(nullable) NSArray<NSString*>* engineSwitches;
@end
#endif // FLUTTER_FLEDARTPROJECT_H_
#endif // FLUTTER_FLUTTERDARTPROJECT_H_
......@@ -2,46 +2,45 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_FLEENGINE_H_
#define FLUTTER_FLEENGINE_H_
#ifndef FLUTTER_FLUTTERENGINE_H_
#define FLUTTER_FLUTTERENGINE_H_
#import <Foundation/Foundation.h>
#include "FLEDartProject.h"
#include "FlutterBinaryMessenger.h"
#include "FlutterDartProject.h"
#include "FlutterMacros.h"
#include "FlutterPluginRegistrarMacOS.h"
@class FLEViewController;
// TODO: Merge this file with the iOS FlutterEngine.h.
@class FlutterViewController;
/**
* Coordinates a single instance of execution of a Flutter engine.
*
* TODO(stuartmorgan): Finish aligning this (and ideally merging) with FlutterEngine. Currently
* this is largely usable only as an implementation detail of FLEViewController.
*/
FLUTTER_EXPORT
@interface FLEEngine : NSObject <FlutterPluginRegistry>
@interface FlutterEngine : NSObject <FlutterPluginRegistry>
/**
* Initializes an engine with the given viewController.
*
* @param labelPrefix Currently unused; in the future, may be used for labelling threads
* as with the iOS FlutterEngine.
* @param project The project configuration. If nil, a default FLEDartProject will be used.
* @param project The project configuration. If nil, a default FlutterDartProject will be used.
*/
- (nonnull instancetype)initWithName:(nonnull NSString*)labelPrefix
project:(nullable FLEDartProject*)project;
project:(nullable FlutterDartProject*)project;
/**
* Initializes an engine with the given viewController.
*
* @param labelPrefix Currently unused; in the future, may be used for labelling threads
* as with the iOS FlutterEngine.
* @param project The project configuration. If nil, a default FLEDartProject will be used.
* @param project The project configuration. If nil, a default FlutterDartProject will be used.
*/
- (nonnull instancetype)initWithName:(nonnull NSString*)labelPrefix
project:(nullable FLEDartProject*)project
project:(nullable FlutterDartProject*)project
allowHeadlessExecution:(BOOL)allowHeadlessExecution NS_DESIGNATED_INITIALIZER;
- (nonnull instancetype)init NS_UNAVAILABLE;
......@@ -63,9 +62,9 @@ FLUTTER_EXPORT
- (BOOL)runWithEntrypoint:(nullable NSString*)entrypoint;
/**
* The `FLEViewController` associated with this engine, if any.
* The `FlutterViewController` associated with this engine, if any.
*/
@property(nonatomic, nullable, weak) FLEViewController* viewController;
@property(nonatomic, nullable, weak) FlutterViewController* viewController;
/**
* The `FlutterBinaryMessenger` for communicating with this engine.
......@@ -74,4 +73,4 @@ FLUTTER_EXPORT
@end
#endif // FLUTTER_FLEENGINE_H_
#endif // FLUTTER_FLUTTERENGINE_H_
......@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "FLEDartProject.h"
#import "FLEEngine.h"
#import "FLEViewController.h"
#import "FlutterBinaryMessenger.h"
#import "FlutterChannels.h"
#import "FlutterCodecs.h"
#import "FlutterDartProject.h"
#import "FlutterEngine.h"
#import "FlutterMacros.h"
#import "FlutterPluginMacOS.h"
#import "FlutterPluginRegistrarMacOS.h"
#import "FlutterViewController.h"
......@@ -4,10 +4,13 @@
#import <Cocoa/Cocoa.h>
#import "FLEEngine.h"
#import "FlutterEngine.h"
#import "FlutterMacros.h"
#import "FlutterPluginRegistrarMacOS.h"
/**
* Values for the `mouseTrackingMode` property.
*/
typedef NS_ENUM(NSInteger, FlutterMouseTrackingMode) {
// Hover events will never be sent to Flutter.
FlutterMouseTrackingModeNone = 0,
......@@ -20,19 +23,15 @@ typedef NS_ENUM(NSInteger, FlutterMouseTrackingMode) {
};
/**
* Controls embedder plugins and communication with the underlying Flutter engine, managing a view
* intended to handle key inputs and drawing protocols (see |view|).
*
* Can be launched headless (no managed view), at which point a Dart executable will be run on the
* Flutter engine in non-interactive mode, or with a drawable Flutter canvas.
* Controls a view that displays Flutter content and manages input.
*/
FLUTTER_EXPORT
@interface FLEViewController : NSViewController <FlutterPluginRegistry>
@interface FlutterViewController : NSViewController <FlutterPluginRegistry>
/**
* The Flutter engine associated with this view controller.
*/
@property(nonatomic, nonnull, readonly) FLEEngine* engine;
@property(nonatomic, nonnull, readonly) FlutterEngine* engine;
/**
* The style of mouse tracking to use for the view. Defaults to
......@@ -43,10 +42,11 @@ FLUTTER_EXPORT
/**
* Initializes a controller that will run the given project.
*
* @param project The project to run in this view controller. If nil, a default `FLEDartProject`
* @param project The project to run in this view controller. If nil, a default `FlutterDartProject`
* will be used.
*/
- (nonnull instancetype)initWithProject:(nullable FLEDartProject*)project NS_DESIGNATED_INITIALIZER;
- (nonnull instancetype)initWithProject:(nullable FlutterDartProject*)project
NS_DESIGNATED_INITIALIZER;
- (nonnull instancetype)initWithNibName:(nullable NSString*)nibNameOrNil
bundle:(nullable NSBundle*)nibBundleOrNil
......
......@@ -2,22 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "flutter/shell/platform/darwin/macos/framework/Headers/FLEDartProject.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FLEDartProject_Internal.h"
#import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterDartProject.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h"
#include <vector>
static NSString* const kICUBundlePath = @"icudtl.dat";
@implementation FLEDartProject {
@implementation FlutterDartProject {
NSBundle* _bundle;
}
- (instancetype)init {
return [self initWithBundle:nil];
return [self initWithPrecompiledDartBundle:nil];
}
- (instancetype)initWithBundle:(NSBundle*)bundle {
- (instancetype)initWithPrecompiledDartBundle:(NSBundle*)bundle {
self = [super init];
NSAssert(self, @"Super init cannot be nil");
......
......@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLEDARTPROJECT_INTERNAL_H_
#define SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLEDARTPROJECT_INTERNAL_H_
#ifndef SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERDARTPROJECT_INTERNAL_H_
#define SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERDARTPROJECT_INTERNAL_H_
#import "flutter/shell/platform/darwin/macos/framework/Headers/FLEDartProject.h"
#import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterDartProject.h"
#include <vector>
/**
* Provides access to data needed to construct a FlutterProjectArgs for the project.
*/
@interface FLEDartProject ()
@interface FlutterDartProject ()
/**
* The path to the Flutter assets directory.
......@@ -35,4 +35,4 @@
@end
#endif // SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLEDARTPROJECT_INTERNAL_H_
\ No newline at end of file
#endif // SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERDARTPROJECT_INTERNAL_H_
\ No newline at end of file
......@@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "flutter/shell/platform/darwin/macos/framework/Headers/FLEEngine.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FLEEngine_Internal.h"
#import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterEngine.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h"
#include <vector>
#import "flutter/shell/platform/darwin/macos/framework/Source/FLEDartProject_Internal.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FLEViewController_Internal.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h"
#import "flutter/shell/platform/embedder/embedder.h"
/**
* Private interface declaration for FLEEngine.
* Private interface declaration for FlutterEngine.
*/
@interface FLEEngine () <FlutterBinaryMessenger>
@interface FlutterEngine () <FlutterBinaryMessenger>
/**
* Called by the engine to make the context the engine should draw into current.
......@@ -55,15 +55,15 @@
*/
@interface FlutterEngineRegistrar : NSObject <FlutterPluginRegistrar>
- (instancetype)initWithPlugin:(nonnull NSString*)pluginKey
flutterEngine:(nonnull FLEEngine*)flutterEngine;
flutterEngine:(nonnull FlutterEngine*)flutterEngine;
@end
@implementation FlutterEngineRegistrar {
NSString* _pluginKey;
FLEEngine* _flutterEngine;
FlutterEngine* _flutterEngine;
}
- (instancetype)initWithPlugin:(NSString*)pluginKey flutterEngine:(FLEEngine*)flutterEngine {
- (instancetype)initWithPlugin:(NSString*)pluginKey flutterEngine:(FlutterEngine*)flutterEngine {
self = [super init];
if (self) {
_pluginKey = [pluginKey copy];
......@@ -94,39 +94,39 @@
// Callbacks provided to the engine. See the called methods for documentation.
#pragma mark - Static methods provided to engine configuration
static bool OnMakeCurrent(FLEEngine* engine) {
static bool OnMakeCurrent(FlutterEngine* engine) {
return [engine engineCallbackOnMakeCurrent];
}
static bool OnClearCurrent(FLEEngine* engine) {
static bool OnClearCurrent(FlutterEngine* engine) {
return [engine engineCallbackOnClearCurrent];
}
static bool OnPresent(FLEEngine* engine) {
static bool OnPresent(FlutterEngine* engine) {
return [engine engineCallbackOnPresent];
}
static uint32_t OnFBO(FLEEngine* engine) {
static uint32_t OnFBO(FlutterEngine* engine) {
// There is currently no case where a different FBO is used, so no need to forward.
return 0;
}
static bool OnMakeResourceCurrent(FLEEngine* engine) {
static bool OnMakeResourceCurrent(FlutterEngine* engine) {
return [engine engineCallbackOnMakeResourceCurrent];
}
static void OnPlatformMessage(const FlutterPlatformMessage* message, FLEEngine* engine) {
static void OnPlatformMessage(const FlutterPlatformMessage* message, FlutterEngine* engine) {
[engine engineCallbackOnPlatformMessage:message];
}
#pragma mark - FLEEngine implementation
#pragma mark -
@implementation FLEEngine {
@implementation FlutterEngine {
// The embedding-API-level engine object.
FLUTTER_API_SYMBOL(FlutterEngine) _engine;
// The project being run by this engine.
FLEDartProject* _project;
FlutterDartProject* _project;
// The context provided to the Flutter engine for resource loading.
NSOpenGLContext* _resourceContext;
......@@ -138,17 +138,17 @@ static void OnPlatformMessage(const FlutterPlatformMessage* message, FLEEngine*
BOOL _allowHeadlessExecution;
}
- (instancetype)initWithName:(NSString*)labelPrefix project:(FLEDartProject*)project {
- (instancetype)initWithName:(NSString*)labelPrefix project:(FlutterDartProject*)project {
return [self initWithName:labelPrefix project:project allowHeadlessExecution:YES];
}
- (instancetype)initWithName:(NSString*)labelPrefix
project:(FLEDartProject*)project
project:(FlutterDartProject*)project
allowHeadlessExecution:(BOOL)allowHeadlessExecution {
self = [super init];
NSAssert(self, @"Super init cannot be nil");
_project = project ?: [[FLEDartProject alloc] init];
_project = project ?: [[FlutterDartProject alloc] init];
_messageHandlers = [[NSMutableDictionary alloc] init];
_allowHeadlessExecution = allowHeadlessExecution;
......@@ -179,7 +179,7 @@ static void OnPlatformMessage(const FlutterPlatformMessage* message, FLEEngine*
.open_gl.make_resource_current = (BoolCallback)OnMakeResourceCurrent,
};
// TODO(stuartmorgan): Move internal channel registration from FLEViewController to here.
// TODO(stuartmorgan): Move internal channel registration from FlutterViewController to here.
FlutterProjectArgs flutterArguments = {};
flutterArguments.struct_size = sizeof(FlutterProjectArgs);
......@@ -201,7 +201,7 @@ static void OnPlatformMessage(const FlutterPlatformMessage* message, FLEEngine*
return YES;
}
- (void)setViewController:(FLEViewController*)controller {
- (void)setViewController:(FlutterViewController*)controller {
_viewController = controller;
if (!controller && !_allowHeadlessExecution) {
[self shutDownEngine];
......
......@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "flutter/shell/platform/darwin/macos/framework/Headers/FLEEngine.h"
#import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterEngine.h"
#import <Cocoa/Cocoa.h>
#import "flutter/shell/platform/embedder/embedder.h"
@interface FLEEngine ()
@interface FlutterEngine ()
/**
* True if the engine is currently running.
......
......@@ -9,12 +9,15 @@
* a line break, the cursor may be drawn either at the end of the current line (upstream)
* or at the beginning of the next (downstream).
*/
typedef NS_ENUM(NSUInteger, FLETextAffinity) { FLETextAffinityUpstream, FLETextAffinityDownstream };
typedef NS_ENUM(NSUInteger, FlutterTextAffinity) {
FlutterTextAffinityUpstream,
FlutterTextAffinityDownstream
};
/**
* Data model representing text input state during an editing session.
*/
@interface FLETextInputModel : NSObject
@interface FlutterTextInputModel : NSObject
/**
* The full text being edited.
......@@ -28,7 +31,7 @@ typedef NS_ENUM(NSUInteger, FLETextAffinity) { FLETextAffinityUpstream, FLETextA
/**
* The affinity for the current cursor position.
*/
@property FLETextAffinity textAffinity;
@property FlutterTextAffinity textAffinity;
/**
* The range of text that is marked for edit, i.e. under the effects of a multi-keystroke input
* combination.
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "flutter/shell/platform/darwin/macos/framework/Source/FLETextInputModel.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterTextInputModel.h"
static NSString* const kTextAffinityDownstream = @"TextAffinity.downstream";
static NSString* const kTextAffinityUpstream = @"TextAffinity.upstream";
......@@ -62,7 +62,7 @@ static long GetExtentForRange(NSRange range) {
return range.location + range.length;
}
@implementation FLETextInputModel
@implementation FlutterTextInputModel
- (instancetype)initWithClientID:(NSNumber*)clientID configuration:(NSDictionary*)config {
self = [super init];
......@@ -81,14 +81,15 @@ static long GetExtentForRange(NSRange range) {
_text = [[NSMutableString alloc] init];
_selectedRange = NSMakeRange(NSNotFound, 0);
_markedRange = NSMakeRange(NSNotFound, 0);
_textAffinity = FLETextAffinityUpstream;
_textAffinity = FlutterTextAffinityUpstream;
}
return self;
}
- (NSDictionary*)state {
NSString* const textAffinity =
(_textAffinity == FLETextAffinityUpstream) ? kTextAffinityUpstream : kTextAffinityDownstream;
NSString* const textAffinity = (_textAffinity == FlutterTextAffinityUpstream)
? kTextAffinityUpstream
: kTextAffinityDownstream;
NSDictionary* state = @{
kSelectionBaseKey : @(GetBaseForRange(_selectedRange)),
kSelectionExtentKey : @(GetExtentForRange(_selectedRange)),
......@@ -110,8 +111,8 @@ static long GetExtentForRange(NSRange range) {
NSString* selectionAffinity = state[kSelectionAffinityKey];
if (selectionAffinity != nil) {
_textAffinity = [selectionAffinity isEqualToString:kTextAffinityUpstream]
? FLETextAffinityUpstream
: FLETextAffinityDownstream;
? FlutterTextAffinityUpstream
: FlutterTextAffinityDownstream;
}
_markedRange =
UpdateRangeFromBaseExtent(state[kComposingBaseKey], state[kComposingExtentKey], _markedRange);
......
......@@ -5,7 +5,7 @@
#import <Cocoa/Cocoa.h>
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterBinaryMessenger.h"
#import "flutter/shell/platform/darwin/macos/framework/Headers/FLEViewController.h"
#import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h"
/**
* A plugin to handle text input.
......@@ -13,14 +13,14 @@
* Responsible for bridging the native macOS text input system with the Flutter framework text
* editing classes, via system channels.
*
* This is not an FlutterPlugin since it needs access to FLEViewController internals, so needs to be
* managed differently.
* This is not an FlutterPlugin since it needs access to FlutterViewController internals, so needs
* to be managed differently.
*/
@interface FLETextInputPlugin : NSResponder
@interface FlutterTextInputPlugin : NSResponder
/**
* Initializes a text input plugin that coordinates key event handling with |viewController|.
*/
- (instancetype)initWithViewController:(FLEViewController*)viewController;
- (instancetype)initWithViewController:(FlutterViewController*)viewController;
@end
......@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "flutter/shell/platform/darwin/macos/framework/Source/FLETextInputPlugin.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.h"
#import <objc/message.h>
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterCodecs.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FLETextInputModel.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FLEViewController_Internal.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterTextInputModel.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h"
static NSString* const kTextInputChannel = @"flutter/textinput";
......@@ -25,7 +25,7 @@ static NSString* const kMultilineInputType = @"TextInputType.multiline";
/**
* Private properties of FlutterTextInputPlugin.
*/
@interface FLETextInputPlugin () <NSTextInputClient>
@interface FlutterTextInputPlugin () <NSTextInputClient>
/**
* A text input context, representing a connection to the Cocoa text input system.
......@@ -36,7 +36,7 @@ static NSString* const kMultilineInputType = @"TextInputType.multiline";
* A dictionary of text input models, one per client connection, keyed
* by the client connection ID.
*/
@property(nonatomic) NSMutableDictionary<NSNumber*, FLETextInputModel*>* textInputModels;
@property(nonatomic) NSMutableDictionary<NSNumber*, FlutterTextInputModel*>* textInputModels;
/**
* The currently active client connection ID.
......@@ -46,7 +46,7 @@ static NSString* const kMultilineInputType = @"TextInputType.multiline";
/**
* The currently active text input model.
*/
@property(nonatomic, readonly, nullable) FLETextInputModel* activeModel;
@property(nonatomic, readonly, nullable) FlutterTextInputModel* activeModel;
/**
* The channel used to communicate with Flutter.
......@@ -54,9 +54,9 @@ static NSString* const kMultilineInputType = @"TextInputType.multiline";
@property(nonatomic) FlutterMethodChannel* channel;
/**
* The FLEViewController to manage input for.
* The FlutterViewController to manage input for.
*/
@property(nonatomic, weak) FLEViewController* flutterViewController;
@property(nonatomic, weak) FlutterViewController* flutterViewController;
/**
* Handles a Flutter system message on the text input channel.
......@@ -65,16 +65,16 @@ static NSString* const kMultilineInputType = @"TextInputType.multiline";
@end
@implementation FLETextInputPlugin
@implementation FlutterTextInputPlugin
- (instancetype)initWithViewController:(FLEViewController*)viewController {
- (instancetype)initWithViewController:(FlutterViewController*)viewController {
self = [super init];
if (self != nil) {
_flutterViewController = viewController;
_channel = [FlutterMethodChannel methodChannelWithName:kTextInputChannel
binaryMessenger:viewController.engine.binaryMessenger
codec:[FlutterJSONMethodCodec sharedInstance]];
__weak FLETextInputPlugin* weakSelf = self;
__weak FlutterTextInputPlugin* weakSelf = self;
[_channel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
[weakSelf handleMethodCall:call result:result];
}];
......@@ -86,7 +86,7 @@ static NSString* const kMultilineInputType = @"TextInputType.multiline";
#pragma mark - Private
- (FLETextInputModel*)activeModel {
- (FlutterTextInputModel*)activeModel {
return (_activeClientID == nil) ? nil : _textInputModels[_activeClientID];
}
......@@ -106,8 +106,8 @@ static NSString* const kMultilineInputType = @"TextInputType.multiline";
(_activeClientID == nil || ![_activeClientID isEqualToNumber:clientID])) {
_activeClientID = clientID;
// TODO: Do we need to preserve state across setClient calls?
FLETextInputModel* inputModel =
[[FLETextInputModel alloc] initWithClientID:clientID configuration:call.arguments[1]];
FlutterTextInputModel* inputModel =
[[FlutterTextInputModel alloc] initWithClientID:clientID configuration:call.arguments[1]];
if (!inputModel) {
result([FlutterError errorWithCode:@"error"
message:@"Failed to create an input model"
......
......@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "flutter/shell/platform/darwin/macos/framework/Headers/FLEViewController.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FLEViewController_Internal.h"
#import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h"
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h"
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterCodecs.h"
#import "flutter/shell/platform/darwin/macos/framework/Headers/FLEEngine.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FLEEngine_Internal.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FLETextInputPlugin.h"
#import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterEngine.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterView.h"
#import "flutter/shell/platform/embedder/embedder.h"
......@@ -65,9 +65,9 @@ struct MouseState {
#pragma mark - Private interface declaration.
/**
* Private interface declaration for FLEViewController.
* Private interface declaration for FlutterViewController.
*/
@interface FLEViewController () <FlutterViewReshapeListener>
@interface FlutterViewController () <FlutterViewReshapeListener>
/**
* A list of additional responders to keyboard events. Keybord events are forwarded to all of them.
......@@ -146,15 +146,15 @@ struct MouseState {
@end
#pragma mark - FLEViewController implementation.
#pragma mark - FlutterViewController implementation.
@implementation FLEViewController {
@implementation FlutterViewController {
// The project to run in this controller's engine.
FLEDartProject* _project;
FlutterDartProject* _project;
// The plugin used to handle text input. This is not an FlutterPlugin, so must be owned
// separately.
FLETextInputPlugin* _textInputPlugin;
FlutterTextInputPlugin* _textInputPlugin;
// A message channel for passing key events to the Flutter engine. This should be replaced with
// an embedding API; see Issue #47.
......@@ -172,10 +172,10 @@ struct MouseState {
/**
* Performs initialization that's common between the different init paths.
*/
static void CommonInit(FLEViewController* controller) {
controller->_engine = [[FLEEngine alloc] initWithName:@"io.flutter"
project:controller->_project
allowHeadlessExecution:NO];
static void CommonInit(FlutterViewController* controller) {
controller->_engine = [[FlutterEngine alloc] initWithName:@"io.flutter"
project:controller->_project
allowHeadlessExecution:NO];
controller->_additionalKeyResponders = [[NSMutableOrderedSet alloc] init];
controller->_mouseTrackingMode = FlutterMouseTrackingModeInKeyWindow;
}
......@@ -196,7 +196,7 @@ static void CommonInit(FLEViewController* controller) {
return self;
}
- (instancetype)initWithProject:(nullable FLEDartProject*)project {
- (instancetype)initWithProject:(nullable FlutterDartProject*)project {
self = [super initWithNibName:nil bundle:nil];
NSAssert(self, @"Super init cannot be nil");
......@@ -301,7 +301,7 @@ static void CommonInit(FLEViewController* controller) {
}
- (void)addInternalPlugins {
_textInputPlugin = [[FLETextInputPlugin alloc] initWithViewController:self];
_textInputPlugin = [[FlutterTextInputPlugin alloc] initWithViewController:self];
_keyEventChannel =
[FlutterBasicMessageChannel messageChannelWithName:@"flutter/keyevent"
binaryMessenger:_engine.binaryMessenger
......@@ -314,7 +314,7 @@ static void CommonInit(FLEViewController* controller) {
[FlutterMethodChannel methodChannelWithName:@"flutter/platform"
binaryMessenger:_engine.binaryMessenger
codec:[FlutterJSONMethodCodec sharedInstance]];
__weak FLEViewController* weakSelf = self;
__weak FlutterViewController* weakSelf = self;
[_platformChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
[weakSelf handleMethodCall:call result:result];
}];
......
......@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "flutter/shell/platform/darwin/macos/framework/Headers/FLEViewController.h"
#import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterView.h"
@interface FLEViewController ()
@interface FlutterViewController ()
// The FlutterView for this view controller.
@property(nonatomic, readonly, nullable) FlutterView* flutterView;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册