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

Commit

Permalink
Rebase all
Browse files Browse the repository at this point in the history
  • Loading branch information
dkwingsmt committed Jan 31, 2023
1 parent 999e5e5 commit 74503c6
Show file tree
Hide file tree
Showing 15 changed files with 365 additions and 91 deletions.
39 changes: 36 additions & 3 deletions shell/platform/darwin/macos/framework/Headers/FlutterEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define FLUTTER_FLUTTERENGINE_H_

#import <Foundation/Foundation.h>
#include <stdint.h>

#include <stdint.h>

Expand Down Expand Up @@ -76,10 +77,11 @@ FLUTTER_DARWIN_EXPORT
- (BOOL)runWithEntrypoint:(nullable NSString*)entrypoint;

/**
* The default `FlutterViewController` associated with this engine, if any.
* The default `FlutterViewController` of this engine, if any.
*
* The default view always has ID kFlutterDefaultViewId, and is the view
* operated by the APIs that do not have a view ID specified.
* The default view is the first view added to the engine, always has ID
* kFlutterDefaultViewId, and is operated by the legacy APIs that do not specify
* view IDs.
*
* Setting this field from nil to a non-nil view controller also updates
* the view controller's engine and ID.
Expand All @@ -89,9 +91,40 @@ FLUTTER_DARWIN_EXPORT
*
* Setting this field from non-nil to a different non-nil FlutterViewController
* is prohibited and will throw an assertion error.
*
* This method is deprecated. Querying view controllers should use
* viewControllerForId: instead. Assigning or replacing view controllers do not
* have a replacement. Consider addViewController: and removeViewController:.
*/
@property(nonatomic, nullable, weak) FlutterViewController* viewController;

/**
* Attach a view controller to the engine and associate it with a newly
* generated ID.
*
* The engine holds a weak reference to each attached view controller.
*
* The first added view controller (either with this method or the
* viewController property) will always have ID kFlutterDefaultViewId.
*
* If the given view controller is already attached to an engine, this call
* throws an assertion.
*/
- (void)addViewController:(nonnull FlutterViewController*)viewController;

/**
* Deassociate the given view controller from this engine.
*
* If the view controller is not associated with this engine, this call throws an
* assertion.
*/
- (void)removeViewController:(nonnull FlutterViewController*)viewController;

/**
* The `FlutterViewController` associated with the given view ID, if any.
*/
- (nullable FlutterViewController*)viewControllerForId:(uint64_t)viewId;

/**
* The `FlutterBinaryMessenger` for communicating with this engine.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,20 @@ FLUTTER_DARWIN_EXPORT
@property(nonnull, readonly) id<FlutterTextureRegistry> textures;

/**
* The view displaying Flutter content. May return |nil|, for instance in a headless environment.
* The default view displaying Flutter content.
*
* WARNING: If/when multiple Flutter views within the same application are supported (#30701), this
* API will change.
* This method may return |nil|, for instance in a headless environment.
*
* The default view is a special view operated by the legacy single-view APIs.
* This property is deprecated. Its calls should be replaced with viewForId:
* kFlutterDefaultViewId for viewId.
*/
- (nullable NSView*)view;

/**
* The `NSView` associated with the given view ID, if any.
*/
@property(nullable, readonly) NSView* view;
- (nullable NSView*)viewForId:(uint64_t)viewId;

/**
* 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,7 +89,9 @@ FLUTTER_DARWIN_EXPORT
NS_DESIGNATED_INITIALIZER;
- (nonnull instancetype)initWithCoder:(nonnull NSCoder*)nibNameOrNil NS_DESIGNATED_INITIALIZER;
/**
* Initializes this FlutterViewController with the specified `FlutterEngine`.
* Initializes this FlutterViewController with an existing `FlutterEngine`.
*
* The initialized viewcontroller will add itself to the engine as part of this process.
*
* 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_ getView:kFlutterDefaultViewId];
FlutterView* view = [view_provider_ getDefaultView];
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_ getView:view_id];
FlutterView* view = [view_provider_ getViewForId:view_id];
if (!view) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#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 @@ -30,7 +32,11 @@ - (nonnull instancetype)initWithDefaultView:(nonnull FlutterView*)view {
return self;
}

- (nullable FlutterView*)getView:(uint64_t)viewId {
- (nullable FlutterView*)getDefaultView {
return [self getViewForId:kFlutterDefaultViewId];
}

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

0 comments on commit 74503c6

Please sign in to comment.