Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,9 @@ - (void)invalidateLayer
RCTCornerRadiiFromBorderRadii(borderMetrics.borderRadii),
RCTUIEdgeInsetsFromEdgeInsets(borderMetrics.borderWidths),
self.layer.bounds.size);
shadowLayer.zPosition = _borderLayer.zPosition;
// CSS paints box shadows above the background and below the border and the children
// (https://drafts.csswg.org/css-backgrounds-3/#box-shadow).
shadowLayer.zPosition = BACKGROUND_COLOR_ZPOSITION + 0.5;
[layer addSublayer:shadowLayer];
[_boxShadowLayers addObject:shadowLayer];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,4 +408,26 @@ - (void)testSquareDottedAndDashedOutlinesAreDrawnWithCoreGraphics
}
}

#pragma mark - box shadow paint order

- (void)testInsetBoxShadowIsBelowChildrenWithoutBorderLayer
{
RCTViewComponentView *view = [RCTViewComponentView new];
view.frame = CGRectMake(0, 0, 100, 100);

// A view without borders draws with Core Animation and has no border layer.
auto props = std::make_shared<ViewProps>();
props->boxShadow = {BoxShadow{.spreadDistance = 8, .color = colorFromRGBA(0, 0, 0, 255), .inset = true}};
[view updateProps:props oldProps:ViewShadowNode::defaultSharedProps()];

UIView *child = [UIView new];
[view addSubview:child];
[view finalizeUpdates:RNComponentViewUpdateMaskProps];

NSArray<CALayer *> *shadowLayers = [view valueForKey:@"_boxShadowLayers"];
XCTAssertEqual(shadowLayers.count, 1u);
XCTAssertNil([view valueForKey:@"_borderLayer"]);
XCTAssertLessThan(shadowLayers.firstObject.zPosition, child.layer.zPosition);
}

@end
Loading