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

Commit b5ce5e5

Browse files
author
Chris Yang
committed
fix tests
1 parent 15f9243 commit b5ce5e5

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

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

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ - (BOOL)flt_hasFirstResponderInViewHierarchySubtree {
3232
}
3333
@end
3434

35-
// Return true if clip_with and clip_on have a non-zero intercetion that
36-
// is smaller than clip_on.
37-
static bool RectClipsRect(const SkRect& clip_with, const SkRect& clip_on) {
38-
return clip_with.intersects(clip_on) && !clip_with.contains(clip_on);
39-
}
40-
4135
namespace flutter {
4236
// Becomes NO if Apple's API changes and blurred backdrop filters cannot be applied.
4337
BOOL canApplyBlurBackdrop = YES;
@@ -445,22 +439,25 @@ static bool RectClipsRect(const SkRect& clip_with, const SkRect& clip_on) {
445439
break;
446440
}
447441
case kClipRect:
448-
if (RectClipsRect(boundingRect, (*iter)->GetRect())) {
449-
[maskView clipRect:(*iter)->GetRect() matrix:finalTransform];
450-
needMask = YES;
442+
if ((*iter)->GetRect().contains(boundingRect)) {
443+
break;
451444
}
445+
[maskView clipRect:(*iter)->GetRect() matrix:finalTransform];
446+
needMask = YES;
452447
break;
453448
case kClipRRect:
454-
if (RectClipsRect(boundingRect, (*iter)->GetRRect().getBounds())) {
455-
[maskView clipRRect:(*iter)->GetRRect() matrix:finalTransform];
456-
needMask = YES;
449+
if ((*iter)->GetRRect().getBounds().contains(boundingRect)) {
450+
break;
457451
}
452+
[maskView clipRRect:(*iter)->GetRRect() matrix:finalTransform];
453+
needMask = YES;
458454
break;
459455
case kClipPath:
460-
if (RectClipsRect(boundingRect, (*iter)->GetPath().getBounds())) {
461-
[maskView clipPath:(*iter)->GetPath() matrix:finalTransform];
462-
needMask = YES;
456+
if ((*iter)->GetPath().getBounds().contains(boundingRect)) {
457+
break;
463458
}
459+
[maskView clipPath:(*iter)->GetPath() matrix:finalTransform];
460+
needMask = YES;
464461
break;
465462
case kOpacity:
466463
embedded_view.alpha = (*iter)->GetAlphaFloat() * embedded_view.alpha;

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,10 +1512,6 @@ - (void)testClipsDoNotInterceptWithPlatformViewShouldNotAddMaskView {
15121512
flutterPlatformViewsController->SetFlutterView(mockFlutterView);
15131513
// Create embedded view params
15141514
flutter::MutatorsStack stack;
1515-
// Layer tree always pushes a screen scale factor to the stack
1516-
SkMatrix screenScaleMatrix =
1517-
SkMatrix::Scale([UIScreen mainScreen].scale, [UIScreen mainScreen].scale);
1518-
stack.PushTransform(screenScaleMatrix);
15191515
SkMatrix translateMatrix = SkMatrix::Translate(5, 5);
15201516
// The platform view's rect for this test will be (5, 5, 10, 10)
15211517
stack.PushTransform(translateMatrix);
@@ -1524,14 +1520,14 @@ - (void)testClipsDoNotInterceptWithPlatformViewShouldNotAddMaskView {
15241520
stack.PushClipRect(rect);
15251521
// Push a clip rrect, big enough to contain the entire platform view bound
15261522
SkRect rect_for_rrect = SkRect::MakeXYWH(0, 0, 24, 24);
1527-
SkRRect rrect = SkRRect::MakeRectXY (rect_for_rrect, 1, 1);
1523+
SkRRect rrect = SkRRect::MakeRectXY(rect_for_rrect, 1, 1);
15281524
stack.PushClipRRect(rrect);
15291525
// Push a clip path, big enough to contain the entire platform view bound
15301526
SkPath path = SkPath::RRect(SkRect::MakeXYWH(0, 0, 23, 23), 1, 1);
15311527
stack.PushClipPath(path);
15321528

15331529
auto embeddedViewParams =
1534-
std::make_unique<flutter::EmbeddedViewParams>(screenScaleMatrix, SkSize::Make(10, 10), stack);
1530+
std::make_unique<flutter::EmbeddedViewParams>(translateMatrix, SkSize::Make(5, 5), stack);
15351531

15361532
flutterPlatformViewsController->PrerollCompositeEmbeddedView(2, std::move(embeddedViewParams));
15371533
flutterPlatformViewsController->CompositeEmbeddedView(2);

0 commit comments

Comments
 (0)