Chromium Code Reviews| Index: ui/views/controls/textfield/native_textfield_views.cc |
| diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc |
| index eabfd3f3158a8e510a3dc3c71a1d6a844bcddb46..d408770cdcec815e4f87c68394fc4871f8cf1e51 100644 |
| --- a/ui/views/controls/textfield/native_textfield_views.cc |
| +++ b/ui/views/controls/textfield/native_textfield_views.cc |
| @@ -5,6 +5,7 @@ |
| #include "ui/views/controls/textfield/native_textfield_views.h" |
| #include <algorithm> |
| +#include <set> |
| #include "base/bind.h" |
| #include "base/command_line.h" |
| @@ -830,6 +831,16 @@ void NativeTextfieldViews::PaintTextAndCursor(gfx::Canvas* canvas) { |
| textfield_->cursor_color()); |
| // Draw the text, cursor, and selection. |
| GetRenderText()->Draw(canvas); |
| + |
| + // Draw placeholder text if needed. |
| + if (model_->GetText().empty() && |
|
msw
2012/05/15 02:29:22
Should placeholder text disappear on textfield foc
xiyuan
2012/05/15 16:20:04
I prefer to show placeholder even if the textfield
|
| + !textfield_->placeholder_text().empty()) { |
| + canvas->DrawStringInt( |
| + textfield_->placeholder_text(), |
| + GetRenderText()->GetFont(), |
| + textfield_->placeholder_text_color(), |
| + GetRenderText()->display_rect()); |
| + } |
| canvas->Restore(); |
| } |
| @@ -1097,7 +1108,7 @@ void NativeTextfieldViews::HandleMousePressEvent(const MouseEvent& event) { |
| initiating_drag_ = false; |
| bool can_drag = true; |
| - switch(aggregated_clicks_) { |
| + switch (aggregated_clicks_) { |
| case 0: |
| if (can_drag && GetRenderText()->IsPointInSelection(event.location())) |
| initiating_drag_ = true; |