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..164ae266dff6b35e04e8f8dc05b40563cdb39939 100644 |
--- a/ui/views/controls/textfield/textfield.cc |
+++ b/ui/views/controls/textfield/textfield.cc |
@@ -1082,6 +1082,13 @@ bool Textfield::GetDecoratedWordAtPoint(const gfx::Point& point, |
baseline_point); |
} |
+bool Textfield::GetDecoratedTextFromSelection( |
+ gfx::DecoratedText* decorated_text, |
+ gfx::Point* baseline_point) { |
+ return GetRenderText()->GetDecoratedTextForRange( |
+ GetRenderText()->selection(), decorated_text, baseline_point); |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// Textfield, SelectionControllerDelegate overrides: |
@@ -1176,10 +1183,16 @@ void Textfield::DestroyTouchSelection() { |
// Textfield, ui::SimpleMenuModel::Delegate overrides: |
bool Textfield::IsCommandIdChecked(int command_id) const { |
+ if (text_services_context_menu_->IsTextServicesCommandId(command_id)) |
tapted
2016/12/13 05:11:24
same here - I think only LOOK_UP should get here.
spqchan
2016/12/15 23:29:01
Acknowledged.
|
+ return text_services_context_menu_->IsCommandIdChecked(command_id); |
+ |
return true; |
} |
bool Textfield::IsCommandIdEnabled(int command_id) const { |
+ if (text_services_context_menu_->IsTextServicesCommandId(command_id)) |
tapted
2016/12/13 05:11:24
text_services_context_menu_ can be null currently,
spqchan
2016/12/15 23:29:01
Done.
|
+ return text_services_context_menu_->IsCommandIdEnabled(command_id); |
+ |
return Textfield::IsTextEditCommandEnabled( |
GetTextEditCommandFromMenuCommand(command_id, HasSelection())); |
} |
@@ -1213,6 +1226,11 @@ bool Textfield::GetAcceleratorForCommandId(int command_id, |
} |
void Textfield::ExecuteCommand(int command_id, int event_flags) { |
+ if (text_services_context_menu_->IsTextServicesCommandId(command_id)) { |
+ text_services_context_menu_->ExecuteCommand(command_id, event_flags); |
+ return; |
+ } |
+ |
Textfield::ExecuteTextEditCommand( |
GetTextEditCommandFromMenuCommand(command_id, HasSelection())); |
} |
@@ -1976,7 +1994,9 @@ bool Textfield::Paste() { |
} |
void Textfield::UpdateContextMenu() { |
- if (!context_menu_contents_.get()) { |
+ if (!context_menu_contents_.get() || |
+ (text_services_context_menu_ && |
+ text_services_context_menu_->ShouldUpdateMenu())) { |
context_menu_contents_.reset(new ui::SimpleMenuModel(this)); |
context_menu_contents_->AddItemWithStringId(IDS_APP_UNDO, IDS_APP_UNDO); |
context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); |
@@ -1992,11 +2012,20 @@ void Textfield::UpdateContextMenu() { |
// IsCommandIdEnabled() as appropriate, for the commands added. |
if (controller_) |
controller_->UpdateContextMenu(context_menu_contents_.get()); |
+ |
+ ViewsTextServicesContextMenu* text_services_menu = |
+ ViewsTextServicesContextMenu::Create( |
+ this, this, context_menu_contents_.get(), this); |
+ if (text_services_menu) |
+ text_services_context_menu_.reset(text_services_menu); |
tapted
2016/12/13 05:11:24
we should be able to assign directly, so long as `
spqchan
2016/12/15 23:29:01
Done.
|
+ else |
+ text_services_context_menu_.reset(); |
+ |
+ context_menu_runner_.reset(new MenuRunner(context_menu_contents_.get(), |
tapted
2016/12/13 05:11:24
this should be outside the `if` I think ? (i.e. be
spqchan
2016/12/15 23:29:01
Done.
|
+ MenuRunner::HAS_MNEMONICS | |
+ MenuRunner::CONTEXT_MENU | |
+ MenuRunner::ASYNC)); |
} |
- context_menu_runner_.reset(new MenuRunner(context_menu_contents_.get(), |
- MenuRunner::HAS_MNEMONICS | |
- MenuRunner::CONTEXT_MENU | |
- MenuRunner::ASYNC)); |
} |
bool Textfield::ImeEditingAllowed() const { |