[macOS] FlutterMutatorView should clip to bounds (flutter/engine#46463)

*Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.*

*List which issues are fixed by this PR. You must list at least one issue.*

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
Matej Knopp
2023-10-17 00:14:57 +03:00
committed by GitHub
parent 97eae1ceed
commit 64af1329c2
7 changed files with 25 additions and 6 deletions

View File

@@ -3503,6 +3503,7 @@ ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterVie
ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewTest.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap.g.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap_Internal.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/NSView+ClipsToBounds.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/TestFlutterPlatformView.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/TestFlutterPlatformView.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/embedder/embedder.cc + ../../../flutter/LICENSE
@@ -6288,6 +6289,7 @@ FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewP
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewTest.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap.g.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap_Internal.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/NSView+ClipsToBounds.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/TestFlutterPlatformView.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/TestFlutterPlatformView.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/module.modulemap

View File

@@ -5,12 +5,13 @@
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterMutatorView.h"
#include <QuartzCore/QuartzCore.h>
#include <vector>
#include "flutter/fml/logging.h"
#include "flutter/shell/platform/embedder/embedder.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/NSView+ClipsToBounds.h"
@interface FlutterMutatorView () {
// Each of these views clips to a CGPathRef. These views, if present,
// are nested (first is child of FlutterMutatorView and last is parent of
@@ -395,6 +396,7 @@ NSMutableArray* ClipPathFromMutations(CGRect master_clip, const MutationVector&
_platformView = platformView;
_pathClipViews = [NSMutableArray array];
self.wantsLayer = YES;
self.clipsToBounds = YES;
}
return self;
}

View File

@@ -6,6 +6,8 @@
#include "third_party/googletest/googletest/include/gtest/gtest.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/NSView+ClipsToBounds.h"
@interface FlutterMutatorView (Private)
@property(readonly, nonatomic, nonnull) NSMutableArray<NSView*>* pathClipViews;
@@ -96,6 +98,12 @@ TEST(FlutterMutatorViewTest, BasicFrameIsCorrect) {
EXPECT_NE(mutatorView.platformViewContainer, nil);
}
TEST(FlutterMutatorViewTest, ClipsToBounds) {
NSView* platformView = [[NSView alloc] init];
FlutterMutatorView* mutatorView = [[FlutterMutatorView alloc] initWithPlatformView:platformView];
EXPECT_TRUE(mutatorView.clipsToBounds);
}
TEST(FlutterMutatorViewTest, TransformedFrameIsCorrect) {
NSView* platformView = [[NSView alloc] init];
FlutterMutatorView* mutatorView = [[FlutterMutatorView alloc] initWithPlatformView:platformView];

View File

@@ -9,11 +9,6 @@
@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

@@ -16,6 +16,7 @@
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterCodecs.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterTextInputSemanticsObject.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/NSView+ClipsToBounds.h"
static NSString* const kTextInputChannel = @"flutter/textinput";

View File

@@ -9,6 +9,7 @@
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterTextInputSemanticsObject.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/NSView+ClipsToBounds.h"
#import <OCMock/OCMock.h>
#import "flutter/testing/testing.h"

View File

@@ -0,0 +1,10 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <Cocoa/Cocoa.h>
@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