[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:
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user