Chromium Code Reviews| Index: chrome/browser/ui/autofill/autofill_popup_view.h |
| diff --git a/chrome/browser/ui/autofill/autofill_popup_view.h b/chrome/browser/ui/autofill/autofill_popup_view.h |
| index 82bf79d0ccda096d31f9cc069826a8d57406028a..61dc21148f4bd2bc7b5266adee958a198331014a 100644 |
| --- a/chrome/browser/ui/autofill/autofill_popup_view.h |
| +++ b/chrome/browser/ui/autofill/autofill_popup_view.h |
| @@ -7,10 +7,15 @@ |
| #include <stddef.h> |
| +#include "base/strings/string16.h" |
| +#include "chrome/browser/ui/autofill/autofill_popup_view_delegate.h" |
| +#include "chrome/browser/ui/autofill/popup_view_utils.h" |
| +#include "ui/gfx/geometry/rect.h" |
| #include "ui/gfx/native_widget_types.h" |
| namespace gfx { |
| -class Rect; |
| +class Display; |
| +class Point; |
| } |
| namespace ui { |
| @@ -25,6 +30,9 @@ class AutofillPopupController; |
| // AutofillPopupView. |
| class AutofillPopupView { |
| public: |
| + explicit AutofillPopupView(AutofillPopupViewDelegate* delegate); |
| + virtual ~AutofillPopupView() {} |
| + |
| // The minimum amount of padding between the Autofill name and subtext, |
| // in pixels. |
| static const size_t kNamePadding = 15; |
| @@ -53,11 +61,62 @@ class AutofillPopupView { |
| // Refreshes the position of the popup. |
| virtual void UpdateBoundsAndRedrawPopup() = 0; |
| +#if !defined(OS_ANDROID) |
| + // Calculates the desired height of the popup based on its contents. |
| + int GetDesiredPopupHeight() const; |
|
Evan Stade
2016/01/09 00:19:02
This design uses multiple inheritance, which is no
Mathieu
2016/01/09 00:53:17
In your mind, would AutofillPopupViewViews extend
|
| + |
| + // Calculates the desired width of the popup based on its contents. |
| + int GetDesiredPopupWidth() const; |
| + |
| + // Calculate the width of the row, excluding all the text. This provides |
| + // the size of the row that won't be reducible (since all the text can be |
| + // elided if there isn't enough space). |with_label| indicates whether a label |
| + // is expected to be present. |
| + int RowWidthWithoutText(int row, bool with_label) const; |
| + |
| + // Get the available space for the total text width. |with_label| indicates |
| + // whether a label is expected to be present. |
| + int GetAvailableWidthForRow(int row, bool with_label) const; |
| + |
| + // Calculates and sets the bounds of the popup, including placing it properly |
| + // to prevent it from going off the screen. |
| + void UpdatePopupBounds(); |
| +#endif |
| + |
| + // Convert a y-coordinate to the closest line. |
| + int LineFromY(int y); |
| + |
| + const gfx::Rect popup_bounds() { return popup_bounds_; } |
| + |
| // Factory function for creating the view. |
| static AutofillPopupView* Create(AutofillPopupController* controller); |
| protected: |
| - virtual ~AutofillPopupView() {} |
| + // Returns the bounds of the item at |index| in the popup, relative to |
| + // the top left of the popup. |
| + gfx::Rect GetRowBounds(size_t index); |
| + |
| + // Returns the bounds that the popup should be placed at, given the desired |
| + // width and height. By default this places the popup below |element_bounds| |
| + // but it will be placed above if there isn't enough space. |
| + gfx::Rect GetPopupBounds(int desired_width, int desired_height) const; |
| + |
| + // Gets the resource value for the given resource, returning -1 if the |
| + // resource isn't recognized. |
| + int GetIconResourceID(const base::string16& resource_name) const; |
| + |
| + AutofillPopupViewDelegate* delegate_; // Weak reference. |
| + |
| + private: |
| + // Returns the enclosing rectangle for the element_bounds. |
| + const gfx::Rect RoundedElementBounds() const; |
| + |
| + // The bounds of the Autofill popup. |
| + gfx::Rect popup_bounds_; |
| + |
| + autofill::view_utils::PopupViewUtils view_utils_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AutofillPopupView); |
| }; |
| } // namespace autofill |