[macOS] FlutterTextInputPlugin should clip to bounds (flutter/engine#46142)

Fixes https://github.com/flutter/flutter/issues/135219
(formerly https://github.com/flutter/flutter/issues/128956)

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
Matej Knopp
2023-09-28 21:05:55 +02:00
committed by GitHub
parent 53a111dc8a
commit c94d335b6b
3 changed files with 8 additions and 1 deletions

View File

@@ -9,6 +9,11 @@
@class FlutterTextField;
@interface NSView (ClipsToBounds)
// This property is available since macOS 10.9 but only declared in macOS 14 SDK.
@property BOOL clipsToBounds API_AVAILABLE(macos(10.9));
@end
/**
* A plugin to handle text input.
*

View File

@@ -342,6 +342,7 @@ static char markerKey;
// The view needs an empty frame otherwise it is visible on dark background.
// https://github.com/flutter/flutter/issues/118504
self = [super initWithFrame:NSZeroRect];
self.clipsToBounds = YES;
if (self != nil) {
_flutterViewController = viewController;
_channel = [FlutterMethodChannel methodChannelWithName:kTextInputChannel

View File

@@ -1962,7 +1962,7 @@ TEST(FlutterTextInputPluginTest, IsAddedAndRemovedFromViewHierarchy) {
ASSERT_FALSE(window.firstResponder == viewController.textInputPlugin);
}
TEST(FlutterTextInputPluginTest, HasZeroSize) {
TEST(FlutterTextInputPluginTest, HasZeroSizeAndClipsToBounds) {
id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
id binaryMessengerMock = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
OCMStub( // NOLINT(google-objc-avoid-throwing-exception)
@@ -1977,6 +1977,7 @@ TEST(FlutterTextInputPluginTest, HasZeroSize) {
[[FlutterTextInputPlugin alloc] initWithViewController:viewController];
ASSERT_TRUE(NSIsEmptyRect(plugin.frame));
ASSERT_TRUE(plugin.clipsToBounds);
}
} // namespace flutter::testing