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

Revert "[macOS] Make FlutterEngine support multiple views" #39536

Merged
merged 1 commit into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 3 additions & 5 deletions shell/platform/darwin/macos/framework/Headers/FlutterEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ extern const uint64_t kFlutterDefaultViewId;

/**
* Coordinates a single instance of execution of a Flutter engine.
*
* A FlutterEngine can only be attached with one controller from the native
* code.
*/
FLUTTER_DARWIN_EXPORT
@interface FlutterEngine : NSObject <FlutterTextureRegistry, FlutterPluginRegistry>
Expand Down Expand Up @@ -79,9 +76,10 @@ FLUTTER_DARWIN_EXPORT
- (BOOL)runWithEntrypoint:(nullable NSString*)entrypoint;

/**
* The `FlutterViewController` of this engine, if any.
* The default `FlutterViewController` associated with this engine, if any.
*
* This view is used by legacy APIs that assume a single view.
* The default view always has ID kFlutterDefaultViewId, and is the view
* operated by the APIs that do not have a view ID specified.
*
* Setting this field from nil to a non-nil view controller also updates
* the view controller's engine and ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,12 @@ FLUTTER_DARWIN_EXPORT
@property(nonnull, readonly) id<FlutterTextureRegistry> textures;

/**
* The default view displaying Flutter content.
* The view displaying Flutter content. May return |nil|, for instance in a headless environment.
*
* This method may return |nil|, for instance in a headless environment.
*
* The default view is a special view operated by single-view APIs.
*/
- (nullable NSView*)view;

/**
* The `NSView` associated with the given view ID, if any.
* WARNING: If/when multiple Flutter views within the same application are supported (#30701), this
* API will change.
*/
- (nullable NSView*)viewForId:(uint64_t)viewId;
@property(nullable, readonly) NSView* view;

/**
* Registers |delegate| to receive handleMethodCall:result: callbacks for the given |channel|.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ FLUTTER_DARWIN_EXPORT
NS_DESIGNATED_INITIALIZER;
- (nonnull instancetype)initWithCoder:(nonnull NSCoder*)nibNameOrNil NS_DESIGNATED_INITIALIZER;
/**
* Initializes this FlutterViewController with an existing `FlutterEngine`.
*
* The initialized view controller will add itself to the engine as part of this process.
* Initializes this FlutterViewController with the specified `FlutterEngine`.
*
* This initializer is suitable for both the first Flutter view controller and
* the following ones of the app.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// TODO(dkwingsmt): This class only supports single-view for now. As more
// classes are gradually converted to multi-view, it should get the view ID
// from somewhere.
FlutterView* view = [view_provider_ viewForId:kFlutterDefaultViewId];
FlutterView* view = [view_provider_ getView:kFlutterDefaultViewId];
if (!view) {
return false;
}
Expand All @@ -37,7 +37,7 @@
bool FlutterCompositor::Present(uint64_t view_id,
const FlutterLayer** layers,
size_t layers_count) {
FlutterView* view = [view_provider_ viewForId:view_id];
FlutterView* view = [view_provider_ getView:view_id];
if (!view) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewProvider.h"
#import "flutter/testing/testing.h"

extern const uint64_t kFlutterDefaultViewId;

@interface FlutterViewMockProvider : NSObject <FlutterViewProvider> {
FlutterView* _defaultView;
}
Expand All @@ -32,7 +30,7 @@ - (nonnull instancetype)initWithDefaultView:(nonnull FlutterView*)view {
return self;
}

- (nullable FlutterView*)viewForId:(uint64_t)viewId {
- (nullable FlutterView*)getView:(uint64_t)viewId {
if (viewId == kFlutterDefaultViewId) {
return _defaultView;
}
Expand Down
Loading