| 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" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/ui/autofill/autofill_popup_view.h" | 12 #include "chrome/browser/ui/autofill/autofill_popup_view.h" |
| 13 #include "components/autofill/core/browser/autofill_popup_delegate.h" | 13 #include "components/autofill/core/browser/autofill_popup_delegate.h" |
| 14 #include "content/public/browser/native_web_keyboard_event.h" | 14 #include "content/public/browser/native_web_keyboard_event.h" |
| 15 #include "grit/webkit_resources.h" | 15 #include "grit/webkit_resources.h" |
| 16 #include "third_party/WebKit/public/web/WebAutofillClient.h" | 16 #include "third_party/WebKit/public/web/WebAutofillClient.h" |
| 17 #include "ui/base/events/event.h" | 17 #include "ui/base/events/event.h" |
| 18 #include "ui/base/text/text_elider.h" | |
| 19 #include "ui/gfx/display.h" | 18 #include "ui/gfx/display.h" |
| 20 #include "ui/gfx/rect_conversions.h" | 19 #include "ui/gfx/rect_conversions.h" |
| 21 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
| 21 #include "ui/gfx/text_elider.h" |
| 22 #include "ui/gfx/vector2d.h" | 22 #include "ui/gfx/vector2d.h" |
| 23 | 23 |
| 24 using base::WeakPtr; | 24 using base::WeakPtr; |
| 25 using WebKit::WebAutofillClient; | 25 using WebKit::WebAutofillClient; |
| 26 | 26 |
| 27 namespace autofill { | 27 namespace autofill { |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 // Used to indicate that no line is currently selected by the user. | 30 // Used to indicate that no line is currently selected by the user. |
| 31 const int kNoSelection = -1; | 31 const int kNoSelection = -1; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 136 |
| 137 // The line can have no strings if it represents a UI element, such as | 137 // The line can have no strings if it represents a UI element, such as |
| 138 // a separator line. | 138 // a separator line. |
| 139 if (total_text_length == 0) | 139 if (total_text_length == 0) |
| 140 continue; | 140 continue; |
| 141 | 141 |
| 142 int available_width = popup_width - RowWidthWithoutText(i); | 142 int available_width = popup_width - RowWidthWithoutText(i); |
| 143 | 143 |
| 144 // Each field recieves space in proportion to its length. | 144 // Each field recieves space in proportion to its length. |
| 145 int name_size = available_width * name_width / total_text_length; | 145 int name_size = available_width * name_width / total_text_length; |
| 146 names_[i] = ui::ElideText(names_[i], | 146 names_[i] = gfx::ElideText(names_[i], |
| 147 GetNameFontForRow(i), | 147 GetNameFontForRow(i), |
| 148 name_size, | 148 name_size, |
| 149 ui::ELIDE_AT_END); | 149 gfx::ELIDE_AT_END); |
| 150 | 150 |
| 151 int subtext_size = available_width * subtext_width / total_text_length; | 151 int subtext_size = available_width * subtext_width / total_text_length; |
| 152 subtexts_[i] = ui::ElideText(subtexts_[i], | 152 subtexts_[i] = gfx::ElideText(subtexts_[i], |
| 153 subtext_font(), | 153 subtext_font(), |
| 154 subtext_size, | 154 subtext_size, |
| 155 ui::ELIDE_AT_END); | 155 gfx::ELIDE_AT_END); |
| 156 } | 156 } |
| 157 #endif | 157 #endif |
| 158 | 158 |
| 159 if (!view_) { | 159 if (!view_) { |
| 160 view_ = AutofillPopupView::Create(this); | 160 view_ = AutofillPopupView::Create(this); |
| 161 | 161 |
| 162 // It is possible to fail to create the popup, in this case | 162 // It is possible to fail to create the popup, in this case |
| 163 // treat the popup as hiding right away. | 163 // treat the popup as hiding right away. |
| 164 if (!view_) { | 164 if (!view_) { |
| 165 Hide(); | 165 Hide(); |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 // The popup can appear below the field. | 733 // The popup can appear below the field. |
| 734 return std::make_pair(bottom_growth_start, popup_required_height); | 734 return std::make_pair(bottom_growth_start, popup_required_height); |
| 735 } else { | 735 } else { |
| 736 // The popup must appear above the field. | 736 // The popup must appear above the field. |
| 737 return std::make_pair(top_growth_end - popup_required_height, | 737 return std::make_pair(top_growth_end - popup_required_height, |
| 738 popup_required_height); | 738 popup_required_height); |
| 739 } | 739 } |
| 740 } | 740 } |
| 741 | 741 |
| 742 } // namespace autofill | 742 } // namespace autofill |
| OLD | NEW |