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 2bb3e822ca82468a0d386dc9980f1f4b756353e6..c2373ed624928a7cd4ef953024c0d756aa887984 100644 |
| --- a/ui/views/controls/textfield/textfield.cc |
| +++ b/ui/views/controls/textfield/textfield.cc |
| @@ -41,6 +41,7 @@ |
| #include "ui/views/controls/menu/menu_runner.h" |
| #include "ui/views/controls/native/native_view_host.h" |
| #include "ui/views/controls/textfield/textfield_controller.h" |
| +#include "ui/views/controls/views_text_services_context_menu.h" |
| #include "ui/views/drag_utils.h" |
| #include "ui/views/native_cursor.h" |
| #include "ui/views/painter.h" |
| @@ -1082,6 +1083,13 @@ bool Textfield::GetDecoratedWordAtPoint(const gfx::Point& point, |
| baseline_point); |
| } |
| +bool Textfield::GetDecoratedTextFromSelection( |
| + gfx::DecoratedText* decorated_text, |
| + gfx::Point* baseline_point) { |
| + return GetRenderText()->GetDecoratedTextAndBaselineForRange( |
| + GetRenderText()->selection(), decorated_text, baseline_point); |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // Textfield, SelectionControllerDelegate overrides: |
| @@ -1176,10 +1184,20 @@ void Textfield::DestroyTouchSelection() { |
| // Textfield, ui::SimpleMenuModel::Delegate overrides: |
| bool Textfield::IsCommandIdChecked(int command_id) const { |
| + if (text_services_context_menu_ && |
| + text_services_context_menu_->IsTextServicesCommandId(command_id)) { |
| + return text_services_context_menu_->IsCommandIdChecked(command_id); |
| + } |
| + |
| return true; |
| } |
| bool Textfield::IsCommandIdEnabled(int command_id) const { |
| + if (text_services_context_menu_ && |
| + text_services_context_menu_->IsTextServicesCommandId(command_id)) { |
| + return text_services_context_menu_->IsCommandIdEnabled(command_id); |
| + } |
| + |
| return Textfield::IsTextEditCommandEnabled( |
| GetTextEditCommandFromMenuCommand(command_id, HasSelection())); |
| } |
| @@ -1213,6 +1231,12 @@ bool Textfield::GetAcceleratorForCommandId(int command_id, |
| } |
| void Textfield::ExecuteCommand(int command_id, int event_flags) { |
| + if (text_services_context_menu_ && |
| + text_services_context_menu_->IsTextServicesCommandId(command_id)) { |
| + text_services_context_menu_->ExecuteCommand(command_id, event_flags); |
| + return; |
| + } |
| + |
| Textfield::ExecuteTextEditCommand( |
| GetTextEditCommandFromMenuCommand(command_id, HasSelection())); |
| } |
| @@ -1931,6 +1955,8 @@ void Textfield::OnCaretBoundsChanged() { |
| GetInputMethod()->OnCaretBoundsChanged(this); |
| if (touch_selection_controller_) |
| touch_selection_controller_->SelectionChanged(); |
| + |
| + context_menu_contents_.reset(); |
|
tapted
2016/12/16 07:01:19
this should have a comment
spqchan
2016/12/17 00:34:21
Done.
|
| } |
| void Textfield::OnBeforeUserAction() { |
| @@ -1992,7 +2018,11 @@ void Textfield::UpdateContextMenu() { |
| // IsCommandIdEnabled() as appropriate, for the commands added. |
| if (controller_) |
| controller_->UpdateContextMenu(context_menu_contents_.get()); |
| + |
| + text_services_context_menu_ = ViewsTextServicesContextMenu::Create( |
| + context_menu_contents_.get(), this); |
| } |
| + |
| context_menu_runner_.reset(new MenuRunner(context_menu_contents_.get(), |
| MenuRunner::HAS_MNEMONICS | |
| MenuRunner::CONTEXT_MENU | |