Skip to content

Commit 989b3f6

Browse files
jorge-cabfacebook-github-bot
authored andcommitted
Fix clipToPaddingBox on new Background and Border drawable (#51055)
Summary: Pull Request resolved: #51055 When clipping to the padding box without a background or border set, we should default to clipping to the drawing rectangle. This ensures accurate clipping behavior when there is no background or border set. This is because it seems bounds accommodates the contents of the drawables but when no content is present (either a background or a border) the bounds are 0. In which case we want to rely on the drawing rect instead of the bounds for this edge case. Changelog: [Android][Fixed] - Fix incorrect clip to padding box on new Background and Border drawables Reviewed By: NickGerleman Differential Revision: D74014372 fbshipit-source-id: bd5a496db6de44c4185760ed72b3013d9f2faa00
1 parent d45c041 commit 989b3f6

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BackgroundStyleApplicator.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,16 @@ public object BackgroundStyleApplicator {
346346

347347
@JvmStatic
348348
public fun clipToPaddingBox(view: View, canvas: Canvas): Unit {
349-
// The canvas may be scrolled, so we need to offset
350349
if (ReactNativeFeatureFlags.enableNewBackgroundAndBorderDrawables()) {
351350
val drawingRect = Rect()
352351
view.getDrawingRect(drawingRect)
353-
val composite = ensureCompositeBackgroundDrawable(view)
352+
353+
val composite = getCompositeBackgroundDrawable(view)
354+
if (composite == null) {
355+
canvas.clipRect(drawingRect)
356+
return
357+
}
358+
354359
val paddingBoxRect = RectF()
355360

356361
val computedBorderInsets =

0 commit comments

Comments
 (0)