Index: chrome/browser/ui/autofill/password_generation_popup_controller_impl.cc |
diff --git a/chrome/browser/ui/autofill/password_generation_popup_controller_impl.cc b/chrome/browser/ui/autofill/password_generation_popup_controller_impl.cc |
index d946711d78758bd168cc69f858252c4d2900a8f5..9cf9b251967b494a3bd6cbbdc564b377f1e30912 100644 |
--- a/chrome/browser/ui/autofill/password_generation_popup_controller_impl.cc |
+++ b/chrome/browser/ui/autofill/password_generation_popup_controller_impl.cc |
@@ -159,7 +159,7 @@ void PasswordGenerationPopupControllerImpl::PasswordAccepted() { |
int PasswordGenerationPopupControllerImpl::GetDesiredWidth() { |
// Minimum width in pixels. |
- const int minimum_required_width = 300; |
+ const int minimum_required_width = 350; |
Evan Stade
2014/06/24 21:16:58
it's ok to have a minimum width defined in some sh
Garrett Casto
2014/06/24 23:51:30
The first calculation requires information that is
Evan Stade
2014/06/25 00:02:41
You could expose a MinimumWidth() method to the vi
Garrett Casto
2014/06/25 19:38:14
To be clear, you're suggesting that in CalculateBo
Evan Stade
2014/06/25 21:27:29
view_->GetBounds() uses controller_->MinimumWidth(
Garrett Casto
2014/06/25 21:54:55
Done.
|
// If the width of the field is longer than the minimum, use that instead. |
int width = std::max(minimum_required_width, |
@@ -176,62 +176,11 @@ int PasswordGenerationPopupControllerImpl::GetDesiredWidth() { |
return width; |
} |
-int PasswordGenerationPopupControllerImpl::GetDesiredHeight(int width) { |
- // Note that this wrapping isn't exactly what the popup will do. It shouldn't |
- // line break in the middle of the link, but as long as the link isn't longer |
- // than given width this shouldn't affect the height calculated here. The |
- // default width should be wide enough to prevent this from being an issue. |
- int total_length = gfx::GetStringWidth(HelpText(), font_list_); |
- int usable_width = width - 2 * kHorizontalPadding; |
- int text_height = |
- static_cast<int>(ceil(static_cast<double>(total_length)/usable_width)) * |
- font_list_.GetFontSize(); |
- int help_section_height = text_height + 2 * kHelpVerticalPadding; |
- |
- int password_section_height = 0; |
- if (display_password_) { |
- password_section_height = |
- font_list_.GetFontSize() + 2 * kPasswordVerticalPadding; |
- } |
- |
- return (2 * kPopupBorderThickness + |
- help_section_height + |
- password_section_height); |
-} |
- |
void PasswordGenerationPopupControllerImpl::CalculateBounds() { |
int popup_width = GetDesiredWidth(); |
- int popup_height = GetDesiredHeight(popup_width); |
+ int popup_height = view_->SetBoundsForWidth(popup_width); |
Evan Stade
2014/06/24 21:16:58
I think this should be GetHeight(). Just calculate
Garrett Casto
2014/06/24 23:51:30
Done.
|
popup_bounds_ = controller_common_.GetPopupBounds(popup_height, popup_width); |
Evan Stade
2014/06/25 21:27:29
width should always come before height >:(
Garrett Casto
2014/06/25 21:54:55
Switched.
Evan Stade
2014/06/26 00:06:04
thank you
|
- int sub_view_width = popup_bounds_.width() - 2 * kPopupBorderThickness; |
- |
- // Calculate the bounds for the rest of the elements given the bounds of |
- // the popup. |
- if (display_password_) { |
- password_bounds_ = gfx::Rect( |
- kPopupBorderThickness, |
- kPopupBorderThickness, |
- sub_view_width, |
- font_list_.GetFontSize() + 2 * kPasswordVerticalPadding); |
- |
- divider_bounds_ = gfx::Rect(kPopupBorderThickness, |
- password_bounds_.bottom(), |
- sub_view_width, |
- 1 /* divider heigth*/); |
- } else { |
- password_bounds_ = gfx::Rect(); |
- divider_bounds_ = gfx::Rect(); |
- } |
- |
- int help_y = std::max(kPopupBorderThickness, divider_bounds_.bottom()); |
- int help_height = |
- popup_bounds_.height() - help_y - kPopupBorderThickness; |
- help_bounds_ = gfx::Rect( |
- kPopupBorderThickness, |
- help_y, |
- sub_view_width, |
- help_height); |
} |
void PasswordGenerationPopupControllerImpl::Show(bool display_password) { |
@@ -239,12 +188,12 @@ void PasswordGenerationPopupControllerImpl::Show(bool display_password) { |
if (display_password_) |
current_password_ = base::ASCIIToUTF16(generator_->Generate()); |
- CalculateBounds(); |
- |
if (!view_) { |
view_ = PasswordGenerationPopupView::Create(this); |
+ CalculateBounds(); |
view_->Show(); |
} else { |
+ CalculateBounds(); |
view_->UpdateBoundsAndRedrawPopup(); |
} |
@@ -289,7 +238,7 @@ void PasswordGenerationPopupControllerImpl::OnSavedPasswordsLinkClicked() { |
void PasswordGenerationPopupControllerImpl::SetSelectionAtPoint( |
const gfx::Point& point) { |
- PasswordSelected(password_bounds_.Contains(point)); |
+ PasswordSelected(view_->IsPointInPasswordBounds(point)); |
} |
bool PasswordGenerationPopupControllerImpl::AcceptSelectedLine() { |
@@ -316,20 +265,6 @@ const gfx::Rect& PasswordGenerationPopupControllerImpl::popup_bounds() const { |
return popup_bounds_; |
} |
-const gfx::Rect& PasswordGenerationPopupControllerImpl::password_bounds() |
- const { |
- return password_bounds_; |
-} |
- |
-const gfx::Rect& PasswordGenerationPopupControllerImpl::divider_bounds() |
- const { |
- return divider_bounds_; |
-} |
- |
-const gfx::Rect& PasswordGenerationPopupControllerImpl::help_bounds() const { |
- return help_bounds_; |
-} |
- |
bool PasswordGenerationPopupControllerImpl::display_password() const { |
return display_password_; |
} |