Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Unified Diff: ui/views/controls/textfield/native_textfield_views.cc

Issue 10310131: Support placeholder text in NativeTextfieldViews. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix lint Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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() &&
+ !textfield_->placeholder_text().empty()) {
+ canvas->DrawStringInt(
+ textfield_->placeholder_text(),
+ GetRenderText()->GetFont(),
+ textfield_->placeholder_text_color(),
+ GetRenderText()->display_rect());
oshima 2012/05/14 21:07:24 does this work with RTL text?
xiyuan 2012/05/14 21:13:30 Think it should. The code paints the placehold t
oshima 2012/05/14 22:05:36 It does, but DrawStringInt and RenderText handle t
+ }
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;

Powered by Google App Engine
This is Rietveld 408576698