Index: ui/views/controls/textfield/textfield.cc |
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc |
index cb3e5423814432168664c60ec7a6ce84ce167ebc..dc48cf72934dd6d29c50c04c82d01e7726826584 100644 |
--- a/ui/views/controls/textfield/textfield.cc |
+++ b/ui/views/controls/textfield/textfield.cc |
@@ -268,6 +268,7 @@ Textfield::Textfield() |
performing_user_action_(false), |
skip_input_method_cancel_composition_(false), |
cursor_visible_(false), |
+ has_shadow_(false), |
drop_cursor_visible_(false), |
initiating_drag_(false), |
aggregated_clicks_(0), |
@@ -431,6 +432,11 @@ void Textfield::UseDefaultSelectionBackgroundColor() { |
SchedulePaint(); |
} |
+void Textfield::SetHasShadow(bool has_shadow) { |
+ has_shadow_ = has_shadow; |
+ SchedulePaint(); |
+} |
+ |
bool Textfield::GetCursorEnabled() const { |
return GetRenderText()->cursor_enabled(); |
} |
@@ -647,8 +653,12 @@ void Textfield::OnMouseReleased(const ui::MouseEvent& event) { |
} |
bool Textfield::OnKeyPressed(const ui::KeyEvent& event) { |
+ base::WeakPtr<Textfield> textfield(weak_ptr_factory_.GetWeakPtr()); |
flackr
2014/06/26 17:33:08
nit: Might be worth a comment that HandleKeyEvent
Nina
2014/06/27 15:20:39
Done.
|
bool handled = controller_ && controller_->HandleKeyEvent(this, event); |
+ if (!textfield) |
+ return handled; |
+ |
#if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
ui::TextEditKeyBindingsDelegateAuraLinux* delegate = |
ui::GetTextEditKeyBindingsDelegate(); |
@@ -1588,6 +1598,14 @@ void Textfield::PaintTextAndCursor(gfx::Canvas* canvas) { |
// Draw the text, cursor, and selection. |
render_text->set_cursor_visible(cursor_visible_ && !drop_cursor_visible_ && |
!HasSelection()); |
+ |
+ if (has_shadow_) { |
+ // Draw a basic shadow underneath the text. |
+ gfx::ShadowValues shadows; |
+ shadows.push_back(gfx::ShadowValue(gfx::Point(0, 1), 10, SK_ColorBLACK)); |
flackr
2014/06/26 17:33:08
Maybe we should pass the ShadowValues in when sett
|
+ render_text->set_shadows(shadows); |
+ } |
+ |
render_text->Draw(canvas); |
// Draw the detached drop cursor that marks where the text will be dropped. |