Commit 9128a7fa authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[UI] Align dropdown menu border with the EditableCombobox border

Before this CL, the code was mistakenly adding internal padding to
the menu position. But both the EditableCombobox and the dropdown
draw their borders similarly and hence they should use the same bounds.

Screenshots:
Before: https://screenshot.googleplex.com/RBcFKJ0WqBC.png
After: https://screenshot.googleplex.com/HfCZTOgE8dv.png

Bug: 1044038
Change-Id: Ib6595b9165518886a88e5513653d22f197534545
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2260879
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Auto-Submit: Mohamed Amir Yosef <mamir@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781512}
parent 69e02417
......@@ -490,9 +490,7 @@ void EditableCombobox::HandleNewContent(const base::string16& new_content) {
}
void EditableCombobox::ShowDropDownMenu(ui::MenuSourceType source_type) {
constexpr int kMenuBorderWidthLeft = 1;
constexpr int kMenuBorderWidthTop = 1;
constexpr int kMenuBorderWidthRight = 1;
if (dropdown_blocked_for_animation_)
return;
......@@ -516,13 +514,13 @@ void EditableCombobox::ShowDropDownMenu(ui::MenuSourceType source_type) {
this, GetWidget()->GetRootView());
gfx::Rect local_bounds = textfield_->GetLocalBounds();
// Menu's requested position's width should be the same as local bounds so the
// border of the menu lines up with the border of the combobox. The y
// coordinate however should be shifted to the bottom with the border width
// not to overlap with the combobox border.
gfx::Point menu_position(local_bounds.origin());
// Inset the menu's requested position so the border of the menu lines up
// with the border of the textfield.
menu_position.set_x(menu_position.x() + kMenuBorderWidthLeft);
menu_position.set_y(menu_position.y() + kMenuBorderWidthTop);
local_bounds.set_width(local_bounds.width() -
(kMenuBorderWidthLeft + kMenuBorderWidthRight));
View::ConvertPointToScreen(this, &menu_position);
gfx::Rect bounds(menu_position, local_bounds.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