[shelf]: Ensure GhostView for shelf is a circle

When dragging an app along the shelf, a ghost view in the shape of a
circle is shown as a placeholder.

Currently, the bounds of the ghost view are not squared, which causes to
show as an oval instead of a circle.

Calculate the square that represents the icon and use that as drop
target for the ghost image view so bounds are calculated as a circle.

Bug: 1323091
Change-Id: Ieba91c20fa7467791a104e5d099c0b32195cf719
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3631195
Commit-Queue: Ana Salazar <anasalazar@chromium.org>
Reviewed-by: Toni Barzic <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1000414}
diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc
index b18b5b3..b038439d 100644
--- a/ash/shelf/shelf_view.cc
+++ b/ash/shelf/shelf_view.cc
@@ -1022,7 +1022,14 @@
                                                        /*icon_scale=*/1.0f)
                                   .size();
         gfx::Rect ghost_view_bounds = ideal_view_bounds;
-        ghost_view_bounds.ClampToCenteredSize(icon_size);
+
+        // Ensure that the ghost_view_bounds are a square that encloses the
+        // icon_size with the same center. The ghost view should draw as a
+        // circle.
+        const int icon_width = std::min(icon_size.width(), icon_size.height());
+        ghost_view_bounds.ClampToCenteredSize(
+            gfx::Size(icon_width, icon_width));
+
         current_ghost_view->Init(ghost_view_bounds,
                                  ghost_view_bounds.width() / 2);