From a982decb84dd3f8f1c56ff0d68c6caca6e9855ca Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Fri, 17 May 2019 19:59:10 -0700 Subject: [PATCH] Fabric: Stopping messing with `clipToBounds` in RCTViewComponentView Summary: There was a reason why it exists: on iOS if you want to implement a view with rounded corners with a non-transparent background you need to set `clipToBounds = YES` to enabling clipping because besides drawing borders we need to clip the background otherwise it will "stick out". There were a bunch of problems with this implementation and approach: * It's overshooting. It applies `clipToBounds` no matter which border-radius is and no matter is there a background or not. So, it's kinda heuristic implementation and it's totally unexpected behavior sometimes. * The previous problems can lead to performance problems as well (clipping requires additional work to do for CoreGraphics/GPU). * The border-radius that we assigned to contentView is incorrect because it does not take border-width into account. * This functionality only applies to non-null `contentView` which is a rear and custom case in which that can always be done manually for components that require that for some reason. Reviewed By: mdvacca Differential Revision: D15397282 fbshipit-source-id: 1599882ca8e591a9c4edb4d2b845bbf3d147bfce --- .../Mounting/ComponentViews/View/RCTViewComponentView.mm | 4 ---- 1 file changed, 4 deletions(-) diff --git a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm index d1e23ad3f35..39425793a0f 100644 --- a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm @@ -412,8 +412,6 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle) CGColorRelease(borderColor); layer.cornerRadius = (CGFloat)borderMetrics.borderRadii.topLeft; layer.backgroundColor = _backgroundColor.CGColor; - _contentView.layer.cornerRadius = (CGFloat)borderMetrics.borderRadii.topLeft; - _contentView.layer.masksToBounds = YES; } else { if (!_borderLayer) { _borderLayer = [[CALayer alloc] init]; @@ -427,8 +425,6 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle) layer.borderWidth = 0; layer.borderColor = nil; layer.cornerRadius = 0; - _contentView.layer.cornerRadius = 0; - _contentView.layer.masksToBounds = NO; UIImage *image = RCTGetBorderImage( RCTBorderStyleFromBorderStyle(borderMetrics.borderStyles.left),