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

Commit 554bfa5

Browse files
committed
Break dependency cycle of FlutterViewController <-> FlutterPlatformView
1 parent a9a6f59 commit 554bfa5

10 files changed

+24
-66
lines changed

shell/platform/darwin/ios/framework/Source/FlutterOverlayView.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@
88
#include <Metal/Metal.h>
99
#include <UIKit/UIKit.h>
1010

11-
#include <memory>
12-
13-
#include "flutter/fml/memory/weak_ptr.h"
14-
#include "flutter/shell/common/shell.h"
15-
#import "flutter/shell/platform/darwin/ios/ios_surface.h"
16-
#include "fml/platform/darwin/cf_utils.h"
17-
18-
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h"
19-
2011
/// UIViews that are used by |FlutterPlatformViews| to present Flutter
2112
/// rendering on top of system compositor rendering (ex. a web view).
2213
///

shell/platform/darwin/ios/framework/Source/FlutterOverlayView.mm

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,11 @@
33
// found in the LICENSE file.
44

55
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.h"
6+
67
#include <CoreGraphics/CGColorSpace.h>
7-
#include <Metal/Metal.h>
88

9-
#include "flutter/common/settings.h"
10-
#include "flutter/common/task_runners.h"
11-
#include "flutter/flow/layers/layer_tree.h"
12-
#include "flutter/fml/platform/darwin/cf_utils.h"
13-
#include "flutter/fml/synchronization/waitable_event.h"
14-
#include "flutter/fml/trace_event.h"
15-
#include "flutter/shell/common/platform_view.h"
16-
#include "flutter/shell/common/rasterizer.h"
179
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h"
18-
#import "flutter/shell/platform/darwin/ios/ios_surface_software.h"
19-
#include "third_party/skia/include/utils/mac/SkCGUtils.h"
10+
#include "fml/platform/darwin/cf_utils.h"
2011

2112
// This is mostly a duplication of FlutterView.
2213
// TODO(amirh): once GL support is in evaluate if we can merge this with FlutterView.

shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,13 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#include <Metal/Metal.h>
6-
#import <UIKit/UIGestureRecognizerSubclass.h>
5+
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h"
76

8-
#include <list>
9-
#include <map>
10-
#include <memory>
11-
#include <string>
7+
#include <Metal/Metal.h>
128

13-
#include "flutter/common/graphics/persistent_cache.h"
149
#include "flutter/fml/platform/darwin/scoped_nsobject.h"
15-
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h"
1610
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.h"
17-
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h"
1811
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h"
19-
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h"
2012
#import "flutter/shell/platform/darwin/ios/ios_surface.h"
2113

2214
@implementation UIView (FirstResponder)
@@ -171,11 +163,11 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
171163
}
172164

173165
void FlutterPlatformViewsController::SetFlutterViewController(
174-
UIViewController* flutter_view_controller) {
166+
UIViewController<FlutterViewResponder>* flutter_view_controller) {
175167
flutter_view_controller_.reset([flutter_view_controller retain]);
176168
}
177169

178-
UIViewController* FlutterPlatformViewsController::getFlutterViewController() {
170+
UIViewController<FlutterViewResponder>* FlutterPlatformViewsController::getFlutterViewController() {
179171
return flutter_view_controller_.get();
180172
}
181173

@@ -1147,7 +1139,7 @@ @implementation ForwardingGestureRecognizer {
11471139
// This gesture recognizer retains the `FlutterViewController` until the
11481140
// end of a gesture sequence, that is all the touches in touchesBegan are concluded
11491141
// with |touchesCancelled| or |touchesEnded|.
1150-
fml::scoped_nsobject<UIViewController> _flutterViewController;
1142+
fml::scoped_nsobject<UIViewController<FlutterViewResponder>> _flutterViewController;
11511143
}
11521144

11531145
- (instancetype)initWithTarget:(id)target
@@ -1198,7 +1190,7 @@ - (void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event {
11981190
// Flutter needs all the cancelled touches to be "cancelled" change types in order to correctly
11991191
// handle gesture sequence.
12001192
// We always override the change type to "cancelled".
1201-
[((FlutterViewController*)_flutterViewController.get()) forceTouchesCancelled:touches];
1193+
[_flutterViewController.get() forceTouchesCancelled:touches];
12021194
_currentTouchPointersCount -= touches.count;
12031195
if (_currentTouchPointersCount == 0) {
12041196
self.state = UIGestureRecognizerStateFailed;

shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
#import <UIKit/UIKit.h>
77
#import <XCTest/XCTest.h>
88

9-
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterBinaryMessenger.h"
9+
#import "flutter/fml/thread.h"
1010
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
1111
#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterPlatformViews.h"
1212
#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h"
1313
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h"
1414
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTouchInterceptingView_Test.h"
15-
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h"
1615
#import "flutter/shell/platform/darwin/ios/platform_view_ios.h"
1716

1817
FLUTTER_ASSERT_ARC
@@ -2158,7 +2157,7 @@ - (void)testSetFlutterViewControllerInTheMiddleOfTouchEventShouldStillAllowGestu
21582157
[forwardGectureRecognizer touchesBegan:touches1 withEvent:event1];
21592158
OCMVerify([mockFlutterViewContoller touchesBegan:touches1 withEvent:event1]);
21602159

2161-
UIViewController* mockFlutterViewContoller2 = OCMClassMock([UIViewController class]);
2160+
FlutterViewController* mockFlutterViewContoller2 = OCMClassMock([FlutterViewController class]);
21622161
flutterPlatformViewsController->SetFlutterViewController(mockFlutterViewContoller2);
21632162

21642163
// Touch events should still send to the old FlutterViewController if FlutterViewController

shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERPLATFORMVIEWS_INTERNAL_H_
66
#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERPLATFORMVIEWS_INTERNAL_H_
77

8+
#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterPlatformViews.h"
9+
810
#include <Metal/Metal.h>
9-
#include "flutter/flow/embedded_views.h"
11+
12+
#include "flutter/flow/surface.h"
13+
#include "flutter/fml/memory/weak_ptr.h"
1014
#include "flutter/fml/platform/darwin/scoped_nsobject.h"
11-
#include "flutter/shell/common/shell.h"
12-
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterBinaryMessenger.h"
15+
#include "flutter/fml/trace_event.h"
1316
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h"
14-
#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterPlatformViews.h"
1517
#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h"
16-
#import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.h"
18+
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewResponder.h"
1719
#import "flutter/shell/platform/darwin/ios/ios_context.h"
1820

1921
@class FlutterTouchInterceptingView;
@@ -210,9 +212,9 @@ class FlutterPlatformViewsController {
210212

211213
void SetFlutterView(UIView* flutter_view);
212214

213-
void SetFlutterViewController(UIViewController* flutter_view_controller);
215+
void SetFlutterViewController(UIViewController<FlutterViewResponder>* flutter_view_controller);
214216

215-
UIViewController* getFlutterViewController();
217+
UIViewController<FlutterViewResponder>* getFlutterViewController();
216218

217219
void RegisterViewFactory(
218220
NSObject<FlutterPlatformViewFactory>* factory,
@@ -353,7 +355,7 @@ class FlutterPlatformViewsController {
353355

354356
fml::scoped_nsobject<FlutterMethodChannel> channel_;
355357
fml::scoped_nsobject<UIView> flutter_view_;
356-
fml::scoped_nsobject<UIViewController> flutter_view_controller_;
358+
fml::scoped_nsobject<UIViewController<FlutterViewResponder>> flutter_view_controller_;
357359
fml::scoped_nsobject<FlutterClippingMaskViewPool> mask_view_pool_;
358360
std::map<std::string, fml::scoped_nsobject<NSObject<FlutterPlatformViewFactory>>> factories_;
359361
std::map<int64_t, fml::scoped_nsobject<NSObject<FlutterPlatformView>>> views_;

shell/platform/darwin/ios/framework/Source/FlutterView.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@
55
#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERVIEW_H_
66
#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_FLUTTERVIEW_H_
77

8-
#include <Metal/Metal.h>
8+
#import <Metal/Metal.h>
99
#import <UIKit/UIKit.h>
1010

11-
#include <memory>
12-
13-
#include "flutter/fml/memory/weak_ptr.h"
14-
#include "flutter/shell/common/shell.h"
11+
#include "flutter/shell/common/rasterizer.h"
1512
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h"
16-
#import "flutter/shell/platform/darwin/ios/ios_context.h"
17-
#import "flutter/shell/platform/darwin/ios/ios_surface.h"
1813

1914
@protocol FlutterViewEngineDelegate <NSObject>
2015

shell/platform/darwin/ios/framework/Source/FlutterView.mm

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,8 @@
33
// found in the LICENSE file.
44

55
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h"
6-
#include <Metal/Metal.h>
76

8-
#include "flutter/common/settings.h"
9-
#include "flutter/common/task_runners.h"
10-
#include "flutter/flow/layers/layer_tree.h"
117
#include "flutter/fml/platform/darwin/cf_utils.h"
12-
#include "flutter/fml/synchronization/waitable_event.h"
13-
#include "flutter/fml/trace_event.h"
14-
#include "flutter/shell/common/platform_view.h"
15-
#include "flutter/shell/common/rasterizer.h"
16-
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h"
17-
#import "flutter/shell/platform/darwin/ios/ios_surface_software.h"
18-
#include "third_party/skia/include/utils/mac/SkCGUtils.h"
198

209
@implementation FlutterView {
2110
id<FlutterViewEngineDelegate> _delegate;

shell/platform/darwin/ios/framework/Source/FlutterViewResponder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
1616
- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event;
1717
- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event;
1818
- (void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event;
19+
- (void)forceTouchesCancelled:(NSSet*)touches;
1920
- (void)touchesEstimatedPropertiesUpdated:(NSSet*)touches;
2021

2122
@end

shell/platform/darwin/ios/framework/Source/FlutterViewTest.mm

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
#import <XCTest/XCTest.h>
66

7-
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
8-
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h"
97
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h"
108

119
FLUTTER_ASSERT_ARC

shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#import <OCMock/OCMock.h>
66
#import <XCTest/XCTest.h>
77

8-
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterBinaryMessenger.h"
8+
#import "flutter/fml/thread.h"
99
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
1010
#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterPlatformViews.h"
1111
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h"

0 commit comments

Comments
 (0)