Chromium Code Reviews| 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..d26aa85654d30647e24d20a0d1aee226f20432a1 100644 |
| --- a/ui/views/controls/textfield/textfield.cc |
| +++ b/ui/views/controls/textfield/textfield.cc |
| @@ -409,6 +409,11 @@ void Textfield::UseDefaultSelectionTextColor() { |
| SchedulePaint(); |
| } |
| +void Textfield::SetShadows(const gfx::ShadowValues& shadows) { |
| + shadows_ = shadows; |
| + SchedulePaint(); |
| +} |
| + |
| SkColor Textfield::GetSelectionBackgroundColor() const { |
| return use_default_selection_background_color_ ? |
| GetNativeTheme()->GetSystemColor( |
| @@ -601,7 +606,7 @@ bool Textfield::OnMousePressed(const ui::MouseEvent& event) { |
| ui::Clipboard::GetForCurrentThread(), |
| ui::CLIPBOARD_TYPE_SELECTION).WriteText(base::string16()); |
| OnAfterUserAction(); |
| - } else if(!read_only()) { |
| + } else if (!read_only()) { |
| PasteSelectionClipboard(event); |
| } |
| } |
| @@ -647,8 +652,14 @@ void Textfield::OnMouseReleased(const ui::MouseEvent& event) { |
| } |
| bool Textfield::OnKeyPressed(const ui::KeyEvent& event) { |
| + // Since HandleKeyEvent() might destroy |this|, get a weak pointer and verify |
| + // it isn't null before proceeding. |
|
sadrul
2014/07/02 17:44:04
This change should be in a separate CL, with a cor
|
| + base::WeakPtr<Textfield> textfield(weak_ptr_factory_.GetWeakPtr()); |
| 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 +1599,8 @@ void Textfield::PaintTextAndCursor(gfx::Canvas* canvas) { |
| // Draw the text, cursor, and selection. |
| render_text->set_cursor_visible(cursor_visible_ && !drop_cursor_visible_ && |
| !HasSelection()); |
| + render_text->set_shadows(shadows_); |
| + |
| render_text->Draw(canvas); |
| // Draw the detached drop cursor that marks where the text will be dropped. |