mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[macOS] Rename FlutterViewController.id to viewId (flutter/engine#40323)
[macOS] Rename FlutterViewController.id to viewId
This commit is contained in:
parent
4107e5a226
commit
970c2c031a
@ -61,7 +61,7 @@ FLUTTER_DARWIN_EXPORT
|
||||
* If the view controller is unattached (see FlutterViewController#attached),
|
||||
* reading this property throws an assertion.
|
||||
*/
|
||||
@property(nonatomic, readonly) uint64_t id;
|
||||
@property(nonatomic, readonly) uint64_t viewId;
|
||||
|
||||
/**
|
||||
* The style of mouse tracking to use for the view. Defaults to
|
||||
|
||||
@ -556,7 +556,7 @@ static void OnPlatformMessage(const FlutterPlatformMessage* message, FlutterEngi
|
||||
@"The incoming view controller is already attached to an engine.");
|
||||
NSAssert([_viewControllers objectForKey:@(viewId)] == nil, @"The requested view ID is occupied.");
|
||||
[controller attachToEngine:self withId:viewId];
|
||||
NSAssert(controller.id == viewId, @"Failed to assign view ID.");
|
||||
NSAssert(controller.viewId == viewId, @"Failed to assign view ID.");
|
||||
[_viewControllers setObject:controller forKey:@(viewId)];
|
||||
}
|
||||
|
||||
@ -576,7 +576,7 @@ static void OnPlatformMessage(const FlutterPlatformMessage* message, FlutterEngi
|
||||
|
||||
- (FlutterViewController*)viewControllerForId:(uint64_t)viewId {
|
||||
FlutterViewController* controller = [_viewControllers objectForKey:@(viewId)];
|
||||
NSAssert(controller == nil || controller.id == viewId,
|
||||
NSAssert(controller == nil || controller.viewId == viewId,
|
||||
@"The stored controller has unexpected view ID.");
|
||||
return controller;
|
||||
}
|
||||
@ -598,8 +598,8 @@ static void OnPlatformMessage(const FlutterPlatformMessage* message, FlutterEngi
|
||||
controller.engine);
|
||||
[self registerViewController:controller forId:kFlutterDefaultViewId];
|
||||
} else if (currentController != nil && controller == nil) {
|
||||
NSAssert(currentController.id == kFlutterDefaultViewId,
|
||||
@"The default controller has an unexpected ID %llu", currentController.id);
|
||||
NSAssert(currentController.viewId == kFlutterDefaultViewId,
|
||||
@"The default controller has an unexpected ID %llu", currentController.viewId);
|
||||
// From non-nil to nil.
|
||||
[self deregisterViewControllerForId:kFlutterDefaultViewId];
|
||||
[self shutDownIfNeeded];
|
||||
@ -669,7 +669,7 @@ static void OnPlatformMessage(const FlutterPlatformMessage* message, FlutterEngi
|
||||
- (void)removeViewController:(nonnull FlutterViewController*)viewController {
|
||||
NSAssert([viewController attached] && viewController.engine == self,
|
||||
@"The given view controller is not associated with this engine.");
|
||||
[self deregisterViewControllerForId:viewController.id];
|
||||
[self deregisterViewControllerForId:viewController.viewId];
|
||||
[self shutDownIfNeeded];
|
||||
}
|
||||
|
||||
@ -733,7 +733,7 @@ static void OnPlatformMessage(const FlutterPlatformMessage* message, FlutterEngi
|
||||
}
|
||||
|
||||
- (void)updateWindowMetricsForViewController:(FlutterViewController*)viewController {
|
||||
if (viewController.id != kFlutterDefaultViewId) {
|
||||
if (viewController.viewId != kFlutterDefaultViewId) {
|
||||
// TODO(dkwingsmt): The embedder API only supports single-view for now. As
|
||||
// embedder APIs are converted to multi-view, this method should support any
|
||||
// views.
|
||||
@ -742,7 +742,7 @@ static void OnPlatformMessage(const FlutterPlatformMessage* message, FlutterEngi
|
||||
if (!_engine || !viewController || !viewController.viewLoaded) {
|
||||
return;
|
||||
}
|
||||
NSAssert([self viewControllerForId:viewController.id] == viewController,
|
||||
NSAssert([self viewControllerForId:viewController.viewId] == viewController,
|
||||
@"The provided view controller is not attached to this engine.");
|
||||
NSView* view = viewController.flutterView;
|
||||
CGRect scaledBounds = [view convertRectToBacking:view.bounds];
|
||||
|
||||
@ -646,7 +646,7 @@ TEST_F(FlutterEngineTest, ManageControllersIfInitiatedByController) {
|
||||
@autoreleasepool {
|
||||
// Create FVC1.
|
||||
viewController1 = [[FlutterViewController alloc] initWithProject:project];
|
||||
EXPECT_EQ(viewController1.id, 0ull);
|
||||
EXPECT_EQ(viewController1.viewId, 0ull);
|
||||
|
||||
engine = viewController1.engine;
|
||||
engine.viewController = nil;
|
||||
@ -663,7 +663,7 @@ TEST_F(FlutterEngineTest, ManageControllersIfInitiatedByController) {
|
||||
|
||||
engine.viewController = viewController1;
|
||||
EXPECT_EQ(engine.viewController, viewController1);
|
||||
EXPECT_EQ(viewController1.id, 0ull);
|
||||
EXPECT_EQ(viewController1.viewId, 0ull);
|
||||
}
|
||||
|
||||
TEST_F(FlutterEngineTest, ManageControllersIfInitiatedByEngine) {
|
||||
@ -677,7 +677,7 @@ TEST_F(FlutterEngineTest, ManageControllersIfInitiatedByEngine) {
|
||||
|
||||
@autoreleasepool {
|
||||
viewController1 = [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil];
|
||||
EXPECT_EQ(viewController1.id, 0ull);
|
||||
EXPECT_EQ(viewController1.viewId, 0ull);
|
||||
EXPECT_EQ(engine.viewController, viewController1);
|
||||
|
||||
engine.viewController = nil;
|
||||
@ -685,7 +685,7 @@ TEST_F(FlutterEngineTest, ManageControllersIfInitiatedByEngine) {
|
||||
FlutterViewController* viewController2 = [[FlutterViewController alloc] initWithEngine:engine
|
||||
nibName:nil
|
||||
bundle:nil];
|
||||
EXPECT_EQ(viewController2.id, 0ull);
|
||||
EXPECT_EQ(viewController2.viewId, 0ull);
|
||||
EXPECT_EQ(engine.viewController, viewController2);
|
||||
}
|
||||
// FVC2 is deallocated but FVC1 is retained.
|
||||
@ -694,7 +694,7 @@ TEST_F(FlutterEngineTest, ManageControllersIfInitiatedByEngine) {
|
||||
|
||||
engine.viewController = viewController1;
|
||||
EXPECT_EQ(engine.viewController, viewController1);
|
||||
EXPECT_EQ(viewController1.id, 0ull);
|
||||
EXPECT_EQ(viewController1.viewId, 0ull);
|
||||
}
|
||||
|
||||
TEST_F(FlutterEngineTest, HandlesTerminationRequest) {
|
||||
|
||||
@ -315,11 +315,9 @@ void OnKeyboardLayoutChanged(CFNotificationCenterRef center,
|
||||
FlutterDartProject* _project;
|
||||
|
||||
std::shared_ptr<flutter::AccessibilityBridgeMac> _bridge;
|
||||
|
||||
uint64_t _id;
|
||||
}
|
||||
|
||||
@dynamic id;
|
||||
@synthesize viewId = _viewId;
|
||||
@dynamic view;
|
||||
@dynamic accessibilityBridge;
|
||||
|
||||
@ -341,7 +339,7 @@ static void CommonInit(FlutterViewController* controller, FlutterEngine* engine)
|
||||
@"The FlutterViewController unexpectedly stays unattached after initialization. "
|
||||
@"In unit tests, this is likely because either the FlutterViewController or "
|
||||
@"the FlutterEngine is mocked. Please subclass these classes instead.",
|
||||
controller.engine, controller.id);
|
||||
controller.engine, controller.viewId);
|
||||
controller->_mouseTrackingMode = FlutterMouseTrackingModeInKeyWindow;
|
||||
controller->_textInputPlugin = [[FlutterTextInputPlugin alloc] initWithViewController:controller];
|
||||
[controller initializeKeyboard];
|
||||
@ -457,9 +455,9 @@ static void CommonInit(FlutterViewController* controller, FlutterEngine* engine)
|
||||
[_flutterView setBackgroundColor:_backgroundColor];
|
||||
}
|
||||
|
||||
- (uint64_t)id {
|
||||
- (uint64_t)viewId {
|
||||
NSAssert([self attached], @"This view controller is not attched.");
|
||||
return _id;
|
||||
return _viewId;
|
||||
}
|
||||
|
||||
- (void)onPreEngineRestart {
|
||||
@ -489,7 +487,7 @@ static void CommonInit(FlutterViewController* controller, FlutterEngine* engine)
|
||||
- (void)attachToEngine:(nonnull FlutterEngine*)engine withId:(uint64_t)viewId {
|
||||
NSAssert(_engine == nil, @"Already attached to an engine %@.", _engine);
|
||||
_engine = engine;
|
||||
_id = viewId;
|
||||
_viewId = viewId;
|
||||
}
|
||||
|
||||
- (void)detachFromEngine {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user