Commit f1c12e66 authored by Fabio Tirelo's avatar Fabio Tirelo Committed by Commit Bot

[af] Adjust dropdown so it doesn't look so close to the input element

Bug: 847980
Change-Id: I3000a303d016d68dc86a21211399bc24c204a8a0
Reviewed-on: https://chromium-review.googlesource.com/1080689
Commit-Queue: Fabio Tirelo <ftirelo@chromium.org>
Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569022}
parent 3b84bceb
......@@ -53,6 +53,10 @@ const SkColor kSelectedBackgroundColor = gfx::kGoogleGrey200;
const SkColor kFooterBackgroundColor = gfx::kGoogleGrey050;
const SkColor kSeparatorColor = gfx::kGoogleGrey200;
// A space between the input element and the dropdown, so that the dropdown's
// border doesn't look too close to the element.
constexpr int kElementBorderPadding = 1;
int GetCornerRadius() {
return ChromeLayoutProvider::Get()->GetCornerRadiusMetric(
views::EMPHASIS_MEDIUM);
......@@ -573,9 +577,18 @@ void AutofillPopupViewNativeViews::DoUpdateBoundsAndRedrawPopup() {
gfx::Size size = CalculatePreferredSize();
gfx::Rect popup_bounds;
PopupViewCommon().CalculatePopupVerticalBounds(
size.height(), gfx::ToEnclosingRect(controller_->element_bounds()),
controller_->container_view(), &popup_bounds);
// When a bubble border is shown, the contents area (inside the shadow) is
// supposed to be aligned with input element boundaries.
gfx::Rect element_bounds =
gfx::ToEnclosingRect(controller_->element_bounds());
// Consider the element is |kElementBorderPadding| pixels larger at the top
// and at the bottom in order to reposition the dropdown, so that it doesn't
// look too close to the element.
element_bounds.Inset(/*horizontal=*/0, /*vertical=*/-kElementBorderPadding);
PopupViewCommon().CalculatePopupVerticalBounds(size.height(), element_bounds,
controller_->container_view(),
&popup_bounds);
// Adjust the width to compensate for a scroll bar, if necessary, and for
// other rules.
......@@ -592,8 +605,8 @@ void AutofillPopupViewNativeViews::DoUpdateBoundsAndRedrawPopup() {
size.set_width(AdjustWidth(size.width() + scroll_width));
PopupViewCommon().CalculatePopupHorizontalBounds(
size.width(), gfx::ToEnclosingRect(controller_->element_bounds()),
controller_->container_view(), controller_->IsRTL(), &popup_bounds);
size.width(), element_bounds, controller_->container_view(),
controller_->IsRTL(), &popup_bounds);
SetSize(size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment