0

ViewShadow modifies rounded corners of view layer

When setting rounded corners to ViewShadow, the same rounded
corners will also be applied to the view. This may cause problems.
For example, the focus ring is a child of the view, and it will be
clipped if the focus ring is outside the view.

We should make the view to decide its layer's rounded corners
instead of letting ViewShadow to modify it.

Bug: b:295205108
Change-Id: Ie61bb129999c3578568d4a48918ba8922da442da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4766327
Reviewed-by: Ahmed Fakhry <afakhry@chromium.org>
Commit-Queue: Xiaodan Zhu <zxdan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1181762}
This commit is contained in:
Xiaodan Zhu
2023-08-09 23:38:47 +00:00
committed by Chromium LUCI CQ
parent b87d0ec00d
commit 4b950eb590
2 changed files with 0 additions and 20 deletions

@ -27,9 +27,6 @@ ViewShadow::~ViewShadow() {
}
void ViewShadow::SetRoundedCornerRadius(int corner_radius) {
if (!view_)
return;
view_->layer()->SetRoundedCornerRadius(gfx::RoundedCornersF(corner_radius));
shadow_->SetRoundedCornerRadius(corner_radius);
}

@ -69,23 +69,6 @@ TEST_F(ViewShadowTest, ShadowBoundsFollowIndirectViewBoundsChange) {
EXPECT_EQ(gfx::Rect(10, 25, 20, 30), shadow.shadow()->content_bounds());
}
TEST_F(ViewShadowTest, ShadowCornerRadius) {
views::View view;
view.SetBoundsRect(gfx::Rect(10, 20, 30, 40));
ViewShadow shadow(&view, 1);
shadow.SetRoundedCornerRadius(5);
EXPECT_EQ(gfx::RoundedCornersF(5), view.layer()->rounded_corner_radii());
EXPECT_EQ(gfx::ShadowDetails::Get(1, 5).values,
shadow.shadow()->details_for_testing()->values);
shadow.SetRoundedCornerRadius(2);
EXPECT_EQ(gfx::RoundedCornersF(2), view.layer()->rounded_corner_radii());
EXPECT_EQ(gfx::ShadowDetails::Get(1, 2).values,
shadow.shadow()->details_for_testing()->values);
}
TEST_F(ViewShadowTest, ViewDestruction) {
views::View root;
root.SetPaintToLayer();