| OLD | NEW |
| 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 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" | 5 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 // Size difference between name and subtext in pixels. | 33 // Size difference between name and subtext in pixels. |
| 34 const int kLabelFontSizeDelta = -2; | 34 const int kLabelFontSizeDelta = -2; |
| 35 | 35 |
| 36 // The vertical height of each row in pixels. | 36 // The vertical height of each row in pixels. |
| 37 const size_t kRowHeight = 24; | 37 const size_t kRowHeight = 24; |
| 38 | 38 |
| 39 // The vertical height of a separator in pixels. | 39 // The vertical height of a separator in pixels. |
| 40 const size_t kSeparatorHeight = 1; | 40 const size_t kSeparatorHeight = 1; |
| 41 | 41 |
| 42 // The amount of minimum padding between the Autofill name and subtext in | |
| 43 // pixels. | |
| 44 const size_t kNamePadding = 15; | |
| 45 | |
| 46 // The maximum amount of characters to display from either the name or subtext. | 42 // The maximum amount of characters to display from either the name or subtext. |
| 47 const size_t kMaxTextLength = 15; | 43 const size_t kMaxTextLength = 15; |
| 48 | 44 |
| 49 #if !defined(OS_ANDROID) | 45 #if !defined(OS_ANDROID) |
| 46 const size_t kNamePadding = AutofillPopupView::kNamePadding; |
| 50 const size_t kIconPadding = AutofillPopupView::kIconPadding; | 47 const size_t kIconPadding = AutofillPopupView::kIconPadding; |
| 51 const size_t kEndPadding = AutofillPopupView::kEndPadding; | 48 const size_t kEndPadding = AutofillPopupView::kEndPadding; |
| 52 const size_t kAutofillIconWidth = AutofillPopupView::kAutofillIconWidth; | 49 const size_t kAutofillIconWidth = AutofillPopupView::kAutofillIconWidth; |
| 53 #endif | 50 #endif |
| 54 | 51 |
| 55 struct DataResource { | 52 struct DataResource { |
| 56 const char* name; | 53 const char* name; |
| 57 int id; | 54 int id; |
| 58 }; | 55 }; |
| 59 | 56 |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 int popup_height = 0; | 491 int popup_height = 0; |
| 495 | 492 |
| 496 for (size_t i = 0; i < identifiers().size(); ++i) { | 493 for (size_t i = 0; i < identifiers().size(); ++i) { |
| 497 popup_height += GetRowHeightFromId(identifiers()[i]); | 494 popup_height += GetRowHeightFromId(identifiers()[i]); |
| 498 } | 495 } |
| 499 | 496 |
| 500 return popup_height; | 497 return popup_height; |
| 501 } | 498 } |
| 502 | 499 |
| 503 int AutofillPopupControllerImpl::RowWidthWithoutText(int row) const { | 500 int AutofillPopupControllerImpl::RowWidthWithoutText(int row) const { |
| 504 int row_size = kEndPadding + kNamePadding; | 501 int row_size = kEndPadding; |
| 502 |
| 503 if (!subtexts_[row].empty()) |
| 504 row_size += kNamePadding; |
| 505 | 505 |
| 506 // Add the Autofill icon size, if required. | 506 // Add the Autofill icon size, if required. |
| 507 if (!icons_[row].empty()) | 507 if (!icons_[row].empty()) |
| 508 row_size += kAutofillIconWidth + kIconPadding; | 508 row_size += kAutofillIconWidth + kIconPadding; |
| 509 | 509 |
| 510 // Add the padding at the end | 510 // Add the padding at the end |
| 511 row_size += kEndPadding; | 511 row_size += kEndPadding; |
| 512 | 512 |
| 513 return row_size; | 513 return row_size; |
| 514 } | 514 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 // The popup can appear below the field. | 620 // The popup can appear below the field. |
| 621 return std::make_pair(bottom_growth_start, popup_required_height); | 621 return std::make_pair(bottom_growth_start, popup_required_height); |
| 622 } else { | 622 } else { |
| 623 // The popup must appear above the field. | 623 // The popup must appear above the field. |
| 624 return std::make_pair(top_growth_end - popup_required_height, | 624 return std::make_pair(top_growth_end - popup_required_height, |
| 625 popup_required_height); | 625 popup_required_height); |
| 626 } | 626 } |
| 627 } | 627 } |
| 628 | 628 |
| 629 } // namespace autofill | 629 } // namespace autofill |
| OLD | NEW |