| 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 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h" | 5 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 } // namespace | 70 } // namespace |
| 71 | 71 |
| 72 AutofillPopupLayoutModel::AutofillPopupLayoutModel( | 72 AutofillPopupLayoutModel::AutofillPopupLayoutModel( |
| 73 AutofillPopupViewDelegate* delegate) | 73 AutofillPopupViewDelegate* delegate) |
| 74 : delegate_(delegate) { | 74 : delegate_(delegate) { |
| 75 #if !defined(OS_ANDROID) | 75 #if !defined(OS_ANDROID) |
| 76 smaller_font_list_ = | 76 smaller_font_list_ = |
| 77 normal_font_list_.DeriveWithSizeDelta(kSmallerFontSizeDelta); | 77 normal_font_list_.DeriveWithSizeDelta(kSmallerFontSizeDelta); |
| 78 bold_font_list_ = normal_font_list_.DeriveWithWeight(gfx::Font::Weight::BOLD); | 78 bold_font_list_ = normal_font_list_.DeriveWithWeight(gfx::Font::Weight::BOLD); |
| 79 #if defined(OS_MACOSX) | |
| 80 // There is no italic version of the system font. | |
| 81 warning_font_list_ = normal_font_list_; | |
| 82 #else | |
| 83 warning_font_list_ = normal_font_list_.DeriveWithStyle(gfx::Font::ITALIC); | |
| 84 #endif | |
| 85 #endif | 79 #endif |
| 86 } | 80 } |
| 87 | 81 |
| 88 AutofillPopupLayoutModel::~AutofillPopupLayoutModel() {} | 82 AutofillPopupLayoutModel::~AutofillPopupLayoutModel() {} |
| 89 | 83 |
| 90 #if !defined(OS_ANDROID) | 84 #if !defined(OS_ANDROID) |
| 91 int AutofillPopupLayoutModel::GetDesiredPopupHeight() const { | 85 int AutofillPopupLayoutModel::GetDesiredPopupHeight() const { |
| 92 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions(); | 86 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions(); |
| 93 int popup_height = 2 * kPopupBorderThickness; | 87 int popup_height = 2 * kPopupBorderThickness; |
| 94 | 88 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions(); | 155 std::vector<autofill::Suggestion> suggestions = delegate_->GetSuggestions(); |
| 162 | 156 |
| 163 // Autofill values have positive |frontend_id|. | 157 // Autofill values have positive |frontend_id|. |
| 164 if (suggestions[index].frontend_id > 0) | 158 if (suggestions[index].frontend_id > 0) |
| 165 return bold_font_list_; | 159 return bold_font_list_; |
| 166 | 160 |
| 167 // All other message types are defined here. | 161 // All other message types are defined here. |
| 168 PopupItemId id = static_cast<PopupItemId>(suggestions[index].frontend_id); | 162 PopupItemId id = static_cast<PopupItemId>(suggestions[index].frontend_id); |
| 169 switch (id) { | 163 switch (id) { |
| 170 case POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE: | 164 case POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE: |
| 171 return warning_font_list_; | |
| 172 case POPUP_ITEM_ID_CLEAR_FORM: | 165 case POPUP_ITEM_ID_CLEAR_FORM: |
| 173 case POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO: | 166 case POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO: |
| 174 case POPUP_ITEM_ID_AUTOFILL_OPTIONS: | 167 case POPUP_ITEM_ID_AUTOFILL_OPTIONS: |
| 175 case POPUP_ITEM_ID_SCAN_CREDIT_CARD: | 168 case POPUP_ITEM_ID_SCAN_CREDIT_CARD: |
| 176 case POPUP_ITEM_ID_SEPARATOR: | 169 case POPUP_ITEM_ID_SEPARATOR: |
| 177 case POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE: | 170 case POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE: |
| 178 return normal_font_list_; | 171 return normal_font_list_; |
| 179 case POPUP_ITEM_ID_TITLE: | 172 case POPUP_ITEM_ID_TITLE: |
| 180 case POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY: | 173 case POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY: |
| 181 case POPUP_ITEM_ID_DATALIST_ENTRY: | 174 case POPUP_ITEM_ID_DATALIST_ENTRY: |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 #endif | 269 #endif |
| 277 | 270 |
| 278 return result; | 271 return result; |
| 279 } | 272 } |
| 280 | 273 |
| 281 const gfx::Rect AutofillPopupLayoutModel::RoundedElementBounds() const { | 274 const gfx::Rect AutofillPopupLayoutModel::RoundedElementBounds() const { |
| 282 return gfx::ToEnclosingRect(delegate_->element_bounds()); | 275 return gfx::ToEnclosingRect(delegate_->element_bounds()); |
| 283 } | 276 } |
| 284 | 277 |
| 285 } // namespace autofill | 278 } // namespace autofill |
| OLD | NEW |