0

[MacViews] Fix for disabled submenu items in textfield context menu

Bug: 832631
Change-Id: I211b693337c93a53fabd5aacd41bc4024cefc7c2
Reviewed-on: https://chromium-review.googlesource.com/1013877
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Sarah Chan <spqchan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551153}
This commit is contained in:
spqchan
2018-04-16 22:37:05 +00:00
committed by Commit Bot
parent 51b5b7bc42
commit 639c091c17
3 changed files with 26 additions and 1 deletions

@ -101,6 +101,21 @@ void TextServicesContextMenu::AppendEditableItems(SimpleMenuModel* model) {
&bidi_submenu_model_);
}
bool TextServicesContextMenu::SupportsCommand(int command_id) const {
switch (command_id) {
case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_MENU:
case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_DEFAULT:
case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_LTR:
case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_RTL:
case IDS_SPEECH_MAC:
case IDS_SPEECH_START_SPEAKING_MAC:
case IDS_SPEECH_STOP_SPEAKING_MAC:
return true;
}
return false;
}
bool TextServicesContextMenu::IsCommandIdChecked(int command_id) const {
switch (command_id) {
case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_DEFAULT:
@ -119,6 +134,9 @@ bool TextServicesContextMenu::IsCommandIdChecked(int command_id) const {
bool TextServicesContextMenu::IsCommandIdEnabled(int command_id) const {
switch (command_id) {
case IDS_SPEECH_MAC:
case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_MENU:
return true;
case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_DEFAULT:
case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_LTR:
case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_RTL:

@ -50,6 +50,9 @@ class UI_BASE_EXPORT TextServicesContextMenu
// submenu is added for bidirection, which |this| serves as a delegate for.
void AppendEditableItems(SimpleMenuModel* model);
// Returns true if |command_id| is handled by this class.
bool SupportsCommand(int command_id) const;
// SimpleMenuModel::Delegate:
bool IsCommandIdChecked(int command_id) const override;
bool IsCommandIdEnabled(int command_id) const override;

@ -59,7 +59,8 @@ class ViewsTextServicesContextMenuMac
// ViewsTextServicesContextMenu:
bool SupportsCommand(int command_id) const override {
return command_id == IDS_CONTENT_CONTEXT_EMOJI ||
return text_services_menu_.SupportsCommand(command_id) ||
command_id == IDS_CONTENT_CONTEXT_EMOJI ||
command_id == IDS_CONTENT_CONTEXT_LOOK_UP;
}
@ -69,6 +70,9 @@ class ViewsTextServicesContextMenuMac
}
bool IsCommandIdEnabled(int command_id) const override {
if (text_services_menu_.SupportsCommand(command_id))
return text_services_menu_.IsCommandIdEnabled(command_id);
switch (command_id) {
case IDS_CONTENT_CONTEXT_EMOJI:
return true;