Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 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 | 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_LAYOUT_MODEL_H_ | 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_LAYOUT_MODEL_H_ |
| 6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_LAYOUT_MODEL_H_ | 6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_LAYOUT_MODEL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 // TODO(mathp): investigate moving ownership of this class to the view. | 25 // TODO(mathp): investigate moving ownership of this class to the view. |
| 26 class AutofillPopupLayoutModel { | 26 class AutofillPopupLayoutModel { |
| 27 public: | 27 public: |
| 28 explicit AutofillPopupLayoutModel(AutofillPopupViewDelegate* delegate); | 28 explicit AutofillPopupLayoutModel(AutofillPopupViewDelegate* delegate); |
| 29 ~AutofillPopupLayoutModel(); | 29 ~AutofillPopupLayoutModel(); |
| 30 | 30 |
| 31 // The minimum amount of padding between the Autofill name and subtext, | 31 // The minimum amount of padding between the Autofill name and subtext, |
| 32 // in pixels. | 32 // in pixels. |
| 33 static const int kNamePadding = 15; | 33 static const int kNamePadding = 15; |
| 34 | 34 |
| 35 // The amount of padding between icons in pixels. | 35 // The minimum amount of padding between the Autofill http warning message |
| 36 // name and subtext, in pixels. | |
| 37 static const int kHttpWarningNamePadding = 8; | |
| 38 | |
| 39 // The amount of padding around icons in pixels. | |
| 36 static const int kIconPadding = 5; | 40 static const int kIconPadding = 5; |
| 37 | 41 |
| 42 // The amount of padding around icons in pixels for HTTP warning message. | |
|
Evan Stade
2016/11/30 16:22:30
nit: add the word horizontal?
lshang
2016/12/01 07:42:14
Done.
| |
| 43 static const int kHttpWarningIconPadding = 8; | |
| 44 | |
| 38 // The amount of padding at the end of the popup in pixels. | 45 // The amount of padding at the end of the popup in pixels. |
| 39 static const int kEndPadding = 8; | 46 static const int kEndPadding = 8; |
| 40 | 47 |
| 41 #if !defined(OS_ANDROID) | 48 #if !defined(OS_ANDROID) |
| 42 // Calculates the desired height of the popup based on its contents. | 49 // Calculates the desired height of the popup based on its contents. |
| 43 int GetDesiredPopupHeight() const; | 50 int GetDesiredPopupHeight() const; |
| 44 | 51 |
| 45 // Calculates the desired width of the popup based on its contents. | 52 // Calculates the desired width of the popup based on its contents. |
| 46 int GetDesiredPopupWidth() const; | 53 int GetDesiredPopupWidth() const; |
| 47 | 54 |
| 48 // Calculate the width of the row, excluding all the text. This provides | 55 // Calculate the width of the row, excluding all the text. This provides |
| 49 // the size of the row that won't be reducible (since all the text can be | 56 // the size of the row that won't be reducible (since all the text can be |
| 50 // elided if there isn't enough space). |with_label| indicates whether a label | 57 // elided if there isn't enough space). |with_label| indicates whether a label |
| 51 // is expected to be present. | 58 // is expected to be present. |
| 52 int RowWidthWithoutText(int row, bool with_label) const; | 59 int RowWidthWithoutText(int row, bool with_label) const; |
| 53 | 60 |
| 54 // Get the available space for the total text width. |with_label| indicates | 61 // Get the available space for the total text width. |with_label| indicates |
| 55 // whether a label is expected to be present. | 62 // whether a label is expected to be present. |
| 56 int GetAvailableWidthForRow(int row, bool with_label) const; | 63 int GetAvailableWidthForRow(int row, bool with_label) const; |
| 57 | 64 |
| 58 // Calculates and sets the bounds of the popup, including placing it properly | 65 // Calculates and sets the bounds of the popup, including placing it properly |
| 59 // to prevent it from going off the screen. | 66 // to prevent it from going off the screen. |
| 60 void UpdatePopupBounds(); | 67 void UpdatePopupBounds(); |
| 61 | 68 |
| 62 // The same font can vary based on the type of data it is showing at the row | 69 // The same font can vary based on the type of data it is showing at the row |
| 63 // |index|. | 70 // |index|. |
| 64 const gfx::FontList& GetValueFontListForRow(size_t index) const; | 71 const gfx::FontList& GetValueFontListForRow(size_t index) const; |
| 65 const gfx::FontList& GetLabelFontList() const; | 72 const gfx::FontList& GetLabelFontListForRow(size_t index) const; |
| 66 | 73 |
| 67 // Returns the value font color of the row item according to its |index|. | 74 // Returns the value font color of the row item according to its |index|. |
| 68 SkColor GetValueFontColorForRow(size_t index) const; | 75 SkColor GetValueFontColorForRow(size_t index) const; |
| 69 | 76 |
| 70 // Returns the icon image of the item at |index| in the popup. | 77 // Returns the icon image of the item at |index| in the popup. |
| 71 gfx::ImageSkia GetIconImage(size_t index) const; | 78 gfx::ImageSkia GetIconImage(size_t index) const; |
| 72 #endif | 79 #endif |
| 73 | 80 |
| 74 // Convert a y-coordinate to the closest line. | 81 // Convert a y-coordinate to the closest line. |
| 75 int LineFromY(int y) const; | 82 int LineFromY(int y) const; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 PopupViewCommon view_common_; | 114 PopupViewCommon view_common_; |
| 108 | 115 |
| 109 AutofillPopupViewDelegate* delegate_; // Weak reference. | 116 AutofillPopupViewDelegate* delegate_; // Weak reference. |
| 110 | 117 |
| 111 DISALLOW_COPY_AND_ASSIGN(AutofillPopupLayoutModel); | 118 DISALLOW_COPY_AND_ASSIGN(AutofillPopupLayoutModel); |
| 112 }; | 119 }; |
| 113 | 120 |
| 114 } // namespace autofill | 121 } // namespace autofill |
| 115 | 122 |
| 116 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_LAYOUT_MODEL_H_ | 123 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_LAYOUT_MODEL_H_ |
| OLD | NEW |