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

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

Issue 1570783003: [Autofill] Move functions from the AutofillPopupController to AutofillPopupLayoutModel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: layout model Created 4 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
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_LAYOUT_MODEL_H_
6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_LAYOUT_MODEL_H_
7
8 #include <stddef.h>
9
10 #include "base/strings/string16.h"
11 #include "chrome/browser/ui/autofill/autofill_popup_view_delegate.h"
12 #include "chrome/browser/ui/autofill/popup_view_common.h"
13 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/native_widget_types.h"
15
16 namespace gfx {
17 class Display;
18 class Point;
19 }
20
21 namespace ui {
22 class KeyEvent;
23 }
24
25 namespace autofill {
26
27 // Helper class which keeps tracks of popup bounds and related view information.
28 // TODO(mathp): investigate moving ownership of this class to the view.
29 class AutofillPopupLayoutModel {
30 public:
31 explicit AutofillPopupLayoutModel(AutofillPopupViewDelegate* delegate);
32
33 // The minimum amount of padding between the Autofill name and subtext,
34 // in pixels.
35 static const size_t kNamePadding = 15;
Evan Stade 2016/01/20 19:15:49 why size_t when the others are int? Normally we us
Mathieu 2016/01/20 19:27:05 Done.
36
37 // The amount of padding between icons in pixels.
38 static const int kIconPadding = 5;
39
40 // The amount of padding at the end of the popup in pixels.
41 static const int kEndPadding = 3;
42
43 #if !defined(OS_ANDROID)
44 // Calculates the desired height of the popup based on its contents.
45 int GetDesiredPopupHeight() const;
46
47 // Calculates the desired width of the popup based on its contents.
48 int GetDesiredPopupWidth() const;
49
50 // Calculate the width of the row, excluding all the text. This provides
51 // the size of the row that won't be reducible (since all the text can be
52 // elided if there isn't enough space). |with_label| indicates whether a label
53 // is expected to be present.
54 int RowWidthWithoutText(int row, bool with_label) const;
55
56 // Get the available space for the total text width. |with_label| indicates
57 // whether a label is expected to be present.
58 int GetAvailableWidthForRow(int row, bool with_label) const;
59
60 // Calculates and sets the bounds of the popup, including placing it properly
61 // to prevent it from going off the screen.
62 void UpdatePopupBounds();
63 #endif
64
65 // Convert a y-coordinate to the closest line.
66 int LineFromY(int y) const;
67
68 const gfx::Rect popup_bounds() const { return popup_bounds_; }
69
70 // Returns the bounds of the item at |index| in the popup, relative to
71 // the top left of the popup.
72 gfx::Rect GetRowBounds(size_t index) const;
73
74 // Gets the resource value for the given resource, returning -1 if the
75 // resource isn't recognized.
76 int GetIconResourceID(const base::string16& resource_name) const;
77
78 private:
79 // Returns the enclosing rectangle for the element_bounds.
80 const gfx::Rect RoundedElementBounds() const;
81
82 // The bounds of the Autofill popup.
83 gfx::Rect popup_bounds_;
84
85 PopupViewCommon view_common_;
86
87 AutofillPopupViewDelegate* delegate_; // Weak reference.
88
89 DISALLOW_COPY_AND_ASSIGN(AutofillPopupLayoutModel);
90 };
91
92 } // namespace autofill
93
94 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_LAYOUT_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698