Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: chrome/browser/ui/autofill/autofill_popup_controller_impl.h

Issue 11817051: Elide text in the new Autofill UI (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_
6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ 6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_
7 7
8 #include "base/gtest_prod_util.h" 8 #include "base/gtest_prod_util.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" 10 #include "chrome/browser/ui/autofill/autofill_popup_controller.h"
11 #include "content/public/browser/keyboard_listener.h" 11 #include "content/public/browser/keyboard_listener.h"
12 #include "ui/gfx/font.h" 12 #include "ui/gfx/font.h"
13 #include "ui/gfx/rect.h" 13 #include "ui/gfx/rect.h"
14 14
15 class AutofillPopupDelegate; 15 class AutofillPopupDelegate;
16 class AutofillPopupView; 16 class AutofillPopupView;
17 17
18 namespace gfx {
19 class Display;
20 }
21
18 namespace ui { 22 namespace ui {
19 class KeyEvent; 23 class KeyEvent;
20 } 24 }
21 25
22 // This class is a controller for an AutofillPopupView. It implements 26 // This class is a controller for an AutofillPopupView. It implements
23 // AutofillPopupController to allow calls from AutofillPopupView. The 27 // AutofillPopupController to allow calls from AutofillPopupView. The
24 // other, public functions are available to its instantiator. 28 // other, public functions are available to its instantiator.
25 class AutofillPopupControllerImpl : public AutofillPopupController, 29 class AutofillPopupControllerImpl : public AutofillPopupController,
26 public content::KeyboardListener { 30 public content::KeyboardListener {
27 public: 31 public:
(...skipping 26 matching lines...) Expand all
54 virtual ~AutofillPopupControllerImpl(); 58 virtual ~AutofillPopupControllerImpl();
55 59
56 // AutofillPopupController implementation. 60 // AutofillPopupController implementation.
57 virtual void ViewDestroyed() OVERRIDE; 61 virtual void ViewDestroyed() OVERRIDE;
58 virtual void UpdateBoundsAndRedrawPopup() OVERRIDE; 62 virtual void UpdateBoundsAndRedrawPopup() OVERRIDE;
59 virtual void MouseHovered(int x, int y) OVERRIDE; 63 virtual void MouseHovered(int x, int y) OVERRIDE;
60 virtual void MouseClicked(int x, int y) OVERRIDE; 64 virtual void MouseClicked(int x, int y) OVERRIDE;
61 virtual void MouseExitedPopup() OVERRIDE; 65 virtual void MouseExitedPopup() OVERRIDE;
62 virtual void AcceptSuggestion(size_t index) OVERRIDE; 66 virtual void AcceptSuggestion(size_t index) OVERRIDE;
63 virtual int GetIconResourceID(const string16& resource_name) OVERRIDE; 67 virtual int GetIconResourceID(const string16& resource_name) OVERRIDE;
64 virtual bool CanDelete(size_t index) OVERRIDE; 68 virtual bool CanDelete(size_t index) const OVERRIDE;
65 #if !defined(OS_ANDROID)
66 virtual int GetPopupRequiredWidth() OVERRIDE;
67 virtual int GetPopupRequiredHeight() OVERRIDE;
68 #endif
69 virtual gfx::Rect GetRowBounds(size_t index) OVERRIDE; 69 virtual gfx::Rect GetRowBounds(size_t index) OVERRIDE;
70 virtual void SetPopupBounds(const gfx::Rect& bounds) OVERRIDE; 70 virtual void SetPopupBounds(const gfx::Rect& bounds) OVERRIDE;
71 virtual const gfx::Rect& popup_bounds() const OVERRIDE; 71 virtual const gfx::Rect& popup_bounds() const OVERRIDE;
72 virtual gfx::NativeView container_view() const OVERRIDE; 72 virtual gfx::NativeView container_view() const OVERRIDE;
73 virtual const gfx::Rect& element_bounds() const OVERRIDE; 73 virtual const gfx::Rect& element_bounds() const OVERRIDE;
74 virtual const std::vector<string16>& names() const OVERRIDE; 74 virtual const std::vector<string16>& names() const OVERRIDE;
75 virtual const std::vector<string16>& subtexts() const OVERRIDE; 75 virtual const std::vector<string16>& subtexts() const OVERRIDE;
76 virtual const std::vector<string16>& icons() const OVERRIDE; 76 virtual const std::vector<string16>& icons() const OVERRIDE;
77 virtual const std::vector<int>& identifiers() const OVERRIDE; 77 virtual const std::vector<int>& identifiers() const OVERRIDE;
78 #if !defined(OS_ANDROID) 78 #if !defined(OS_ANDROID)
(...skipping 23 matching lines...) Expand all
102 // The user has choosen the selected line. 102 // The user has choosen the selected line.
103 bool AcceptSelectedLine(); 103 bool AcceptSelectedLine();
104 104
105 // The user has removed a suggestion. 105 // The user has removed a suggestion.
106 bool RemoveSelectedLine(); 106 bool RemoveSelectedLine();
107 107
108 // Convert a y-coordinate to the closest line. 108 // Convert a y-coordinate to the closest line.
109 int LineFromY(int y); 109 int LineFromY(int y);
110 110
111 // Returns the height of a row depending on its type. 111 // Returns the height of a row depending on its type.
112 int GetRowHeightFromId(int identifier); 112 int GetRowHeightFromId(int identifier) const;
113 113
114 // Returns true if the given |x| and |y| coordinates refer to a point that 114 // Returns true if the given |x| and |y| coordinates refer to a point that
115 // hits the delete icon in the current selected line. 115 // hits the delete icon in the current selected line.
116 bool DeleteIconIsUnder(int x, int y); 116 bool DeleteIconIsUnder(int x, int y);
117 117
118 // Returns true if the given id refers to an element that can be accepted. 118 // Returns true if the given id refers to an element that can be accepted.
119 bool CanAccept(int id); 119 bool CanAccept(int id);
120 120
121 // Returns true if the popup still has non-options entries to show the user. 121 // Returns true if the popup still has non-options entries to show the user.
122 bool HasSuggestions(); 122 bool HasSuggestions();
123 123
124 AutofillPopupView* view() { return view_; } 124 AutofillPopupView* view() { return view_; }
125 125
126 // |view_| pass throughs (virtual for testing). 126 // |view_| pass throughs (virtual for testing).
127 virtual void ShowView(); 127 virtual void ShowView();
128 virtual void InvalidateRow(size_t row); 128 virtual void InvalidateRow(size_t row);
129 129
130 // Protected so tests can access.
131 #if !defined(OS_ANDROID)
132 // Calculates the desired width of the popup based on its contents.
133 int GetDesiredPopupWidth() const;
134
135 // Calculates the desired height of the popup based on its contents.
136 int GetDesiredPopupHeight() const;
137 #endif
138
130 private: 139 private:
140 #if !defined(OS_ANDROID)
141 // Calculate the width of the row, excluding all the text. This provides
142 // the size of the row that won't be reducible (since all the text can be
143 // elided if there isn't enough space).
144 int RowWidthWithoutText(int row) const;
145
146 // Calculates and sets the bounds of the popup, including placing it properly
147 // to prevent it from going off the screen.
148 void UpdatePopupBounds();
149 #endif
150
151 // A helper function to get the display closest to the given point (virtual
152 // for testing).
153 virtual gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const;
154
155 // Calculates the width of the popup and the x position of it. These values
156 // will stay on the screen.
157 std::pair<int, int> CalculatePopupXAndWidth(
158 const gfx::Display& left_display,
159 const gfx::Display& right_display,
160 int popup_required_width) const;
161
162 // Calculates the height of the popup and the y position of it. These values
163 // will stay on the screen.
164 std::pair<int, int> CalculatePopupYAndHeight(
165 const gfx::Display& top_display,
166 const gfx::Display& bottom_display,
167 int popup_required_height) const;
168
131 AutofillPopupView* view_; // Weak reference. 169 AutofillPopupView* view_; // Weak reference.
132 AutofillPopupDelegate* delegate_; // Weak reference. 170 AutofillPopupDelegate* delegate_; // Weak reference.
133 gfx::NativeView container_view_; // Weak reference. 171 gfx::NativeView container_view_; // Weak reference.
134 172
135 // The bounds of the text element that is the focus of the Autofill. 173 // The bounds of the text element that is the focus of the Autofill.
136 // These coordinates are in screen space. 174 // These coordinates are in screen space.
137 const gfx::Rect element_bounds_; 175 const gfx::Rect element_bounds_;
138 176
139 // The bounds of the Autofill popup. 177 // The bounds of the Autofill popup.
140 gfx::Rect popup_bounds_; 178 gfx::Rect popup_bounds_;
(...skipping 18 matching lines...) Expand all
159 bool delete_icon_hovered_; 197 bool delete_icon_hovered_;
160 198
161 // True if |HideInternal| has already been called. 199 // True if |HideInternal| has already been called.
162 bool is_hiding_; 200 bool is_hiding_;
163 201
164 // True if the delegate should be informed when |this| is destroyed. 202 // True if the delegate should be informed when |this| is destroyed.
165 bool inform_delegate_of_destruction_; 203 bool inform_delegate_of_destruction_;
166 }; 204 };
167 205
168 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ 206 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698