OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/views/autofill/decorated_textfield.h" | 5 #include "chrome/browser/ui/views/autofill/decorated_textfield.h" |
6 | 6 |
7 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" | 7 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" |
8 #include "chrome/browser/ui/views/autofill/tooltip_icon.h" | 8 #include "chrome/browser/ui/views/autofill/tooltip_icon.h" |
9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
10 #include "ui/views/background.h" | 10 #include "ui/views/background.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 return kViewClassName; | 99 return kViewClassName; |
100 } | 100 } |
101 | 101 |
102 views::View* DecoratedTextfield::GetEventHandlerForRect(const gfx::Rect& rect) { | 102 views::View* DecoratedTextfield::GetEventHandlerForRect(const gfx::Rect& rect) { |
103 views::View* handler = views::Textfield::GetEventHandlerForRect(rect); | 103 views::View* handler = views::Textfield::GetEventHandlerForRect(rect); |
104 if (handler->GetClassName() == TooltipIcon::kViewClassName) | 104 if (handler->GetClassName() == TooltipIcon::kViewClassName) |
105 return handler; | 105 return handler; |
106 return this; | 106 return this; |
107 } | 107 } |
108 | 108 |
109 gfx::Size DecoratedTextfield::GetPreferredSize() { | 109 gfx::Size DecoratedTextfield::GetPreferredSize() const { |
110 static const int height = | 110 static const int height = |
111 views::LabelButton(NULL, base::string16()).GetPreferredSize().height(); | 111 views::LabelButton(NULL, base::string16()).GetPreferredSize().height(); |
112 const gfx::Size size = views::Textfield::GetPreferredSize(); | 112 const gfx::Size size = views::Textfield::GetPreferredSize(); |
113 return gfx::Size(size.width(), std::max(size.height(), height)); | 113 return gfx::Size(size.width(), std::max(size.height(), height)); |
114 } | 114 } |
115 | 115 |
116 void DecoratedTextfield::Layout() { | 116 void DecoratedTextfield::Layout() { |
117 views::Textfield::Layout(); | 117 views::Textfield::Layout(); |
118 | 118 |
119 if (icon_view_ && icon_view_->visible()) { | 119 if (icon_view_ && icon_view_->visible()) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } | 159 } |
160 | 160 |
161 void DecoratedTextfield::IconChanged() { | 161 void DecoratedTextfield::IconChanged() { |
162 // Don't show the icon if nothing else is showing. | 162 // Don't show the icon if nothing else is showing. |
163 icon_view_->SetVisible(editable_ || !text().empty()); | 163 icon_view_->SetVisible(editable_ || !text().empty()); |
164 UpdateBorder(); | 164 UpdateBorder(); |
165 Layout(); | 165 Layout(); |
166 } | 166 } |
167 | 167 |
168 } // namespace autofill | 168 } // namespace autofill |
OLD | NEW |