Commit 972e1bb9 authored by estade@chromium.org's avatar estade@chromium.org

fix layout of requestAutocomplete suggestion dropdown menu on views

BUG=226755


Review URL: https://chromiumcodereview.appspot.com/13482012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193002 0039d316-1c4b-4281-b951-d872f2087c98
parent b904c899
...@@ -875,10 +875,12 @@ void AutofillDialogViews::ButtonPressed(views::Button* sender, ...@@ -875,10 +875,12 @@ void AutofillDialogViews::ButtonPressed(views::Button* sender,
group->container->SetActive(true); group->container->SetActive(true);
// Ignore the result since we don't need to handle a deleted menu specially. // Ignore the result since we don't need to handle a deleted menu specially.
gfx::Rect bounds = group->suggested_button->GetBoundsInScreen();
bounds.Inset(group->suggested_button->GetInsets());
ignore_result( ignore_result(
menu_runner_->RunMenuAt(sender->GetWidget(), menu_runner_->RunMenuAt(sender->GetWidget(),
NULL, NULL,
group->suggested_button->GetBoundsInScreen(), bounds,
views::MenuItemView::TOPRIGHT, views::MenuItemView::TOPRIGHT,
0)); 0));
group->container->SetActive(false); group->container->SetActive(false);
......
...@@ -838,9 +838,7 @@ void MenuItemView::PaintButtonCommon(gfx::Canvas* canvas, ...@@ -838,9 +838,7 @@ void MenuItemView::PaintButtonCommon(gfx::Canvas* canvas,
const gfx::Font& font = GetFont(); const gfx::Font& font = GetFont();
int accel_width = parent_menu_item_->GetSubmenu()->max_accelerator_width(); int accel_width = parent_menu_item_->GetSubmenu()->max_accelerator_width();
int label_start = label_start_ + left_icon_margin_ + right_icon_margin_; int label_start = GetLabelStartForThisItem();
if ((type_ == CHECKBOX || type_ == RADIO) && icon_view_)
label_start += icon_view_->size().width() + config.icon_to_label_padding;
int width = this->width() - label_start - accel_width - int width = this->width() - label_start - accel_width -
(!delegate || (!delegate ||
...@@ -989,7 +987,7 @@ MenuItemView::MenuItemDimensions MenuItemView::CalculateDimensions() { ...@@ -989,7 +987,7 @@ MenuItemView::MenuItemDimensions MenuItemView::CalculateDimensions() {
left_icon_margin_ = 0; left_icon_margin_ = 0;
right_icon_margin_ = 0; right_icon_margin_ = 0;
} }
int label_start = label_start_ + left_icon_margin_ + right_icon_margin_; int label_start = GetLabelStartForThisItem();
dimensions.standard_width = font.GetStringWidth(title_) + label_start + dimensions.standard_width = font.GetStringWidth(title_) + label_start +
item_right_margin_; item_right_margin_;
...@@ -1006,6 +1004,15 @@ MenuItemView::MenuItemDimensions MenuItemView::CalculateDimensions() { ...@@ -1006,6 +1004,15 @@ MenuItemView::MenuItemDimensions MenuItemView::CalculateDimensions() {
return dimensions; return dimensions;
} }
int MenuItemView::GetLabelStartForThisItem() {
int label_start = label_start_ + left_icon_margin_ + right_icon_margin_;
if ((type_ == CHECKBOX || type_ == RADIO) && icon_view_) {
label_start += icon_view_->size().width() +
GetMenuConfig().icon_to_label_padding;
}
return label_start;
}
string16 MenuItemView::GetAcceleratorText() { string16 MenuItemView::GetAcceleratorText() {
if (id() == kEmptyMenuItemViewID) { if (id() == kEmptyMenuItemViewID) {
// Don't query the delegate for menus that represent no children. // Don't query the delegate for menus that represent no children.
......
...@@ -426,6 +426,9 @@ class VIEWS_EXPORT MenuItemView : public View { ...@@ -426,6 +426,9 @@ class VIEWS_EXPORT MenuItemView : public View {
// Calculates and returns the MenuItemDimensions. // Calculates and returns the MenuItemDimensions.
MenuItemDimensions CalculateDimensions(); MenuItemDimensions CalculateDimensions();
// Get the horizontal position at which to draw the menu item's label.
int GetLabelStartForThisItem();
// Used by MenuController to cache the menu position in use by the // Used by MenuController to cache the menu position in use by the
// active menu. // active menu.
MenuPosition actual_menu_position() const { return actual_menu_position_; } MenuPosition actual_menu_position() const { return actual_menu_position_; }
......
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