|
|
Created:
4 years, 5 months ago by spqchan Modified:
3 years, 10 months ago CC:
chromium-reviews, tfarina, James Su, shuchen+watch_chromium.org, yusukes+watch_chromium.org, nona+watch_chromium.org Base URL:
https://chromium.googlesource.com/chromium/src.git@master Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
Description[MacViews] Implemented text context menu
- Added Speech, Writing Direction and Look Up
- Introduced text_services_context_menu to create and handle the items
- Moved the the code from render_view_context_menu_mac into text_services_context_menu
- Created views_text_context_menu to bridge Views with text_services_context_menu
BUG=617436
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation
Review-Url: https://codereview.chromium.org/2164483006
Cr-Commit-Position: refs/heads/master@{#448526}
Committed: https://chromium.googlesource.com/chromium/src/+/375ddabe9cdc45673e112c5b1b06cc754aa45759
Patch Set 1 #Patch Set 2 : ditto #
Total comments: 49
Patch Set 3 : Addressed tapted's comments and made things work #
Total comments: 113
Patch Set 4 : Fix for tapted #
Total comments: 12
Patch Set 5 : Fix for tapted 2 #
Total comments: 8
Patch Set 6 : Fix for tapted 3 #
Total comments: 70
Patch Set 7 : Addressed tapted's comments and fixed tests #
Total comments: 14
Patch Set 8 : Addressed tapted's comments and added a test #
Total comments: 29
Patch Set 9 : Addressed msw's comments, changed 2016 to 2017 #
Total comments: 19
Patch Set 10 : Rebased #
Total comments: 20
Patch Set 11 : Addressed comments #
Total comments: 9
Patch Set 12 : Added test suite for TextServicesContextMenu #
Total comments: 30
Patch Set 13 : Addressed comments #Patch Set 14 : At->For #Patch Set 15 : rebased #Messages
Total messages: 229 (185 generated)
Description was changed from ========== Experimenting with text context menu on MacViews lol I kinda forgot what I was doing. BUG= ========== to ========== Experimenting with text context menu on MacViews lol I kinda forgot what I was doing. BUG= CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_site_isolation ==========
Description was changed from ========== Experimenting with text context menu on MacViews lol I kinda forgot what I was doing. BUG= CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_site_isolation ========== to ========== Experimenting with text context menu on MacViews ==========
Description was changed from ========== Experimenting with text context menu on MacViews ========== to ========== Experimenting with text context menu on MacViews - Creating a parity for the speech menu between MacViews and RenderWidgetHostView ==========
tapted@chromium.org changed reviewers: + tapted@chromium.org
this direction looks pretty good! left some suggestions https://codereview.chromium.org/2164483006/diff/140001/chrome/browser/ui/coco... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h (right): https://codereview.chromium.org/2164483006/diff/140001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h:21: TextContextMenu::Delegate { public https://codereview.chromium.org/2164483006/diff/140001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h:75: std::unique_ptr<TextContextMenu> text_context_menu_; could this just be a value member? -- no need for unique_ptr https://codereview.chromium.org/2164483006/diff/140001/content/browser/render... File content/browser/renderer_host/render_widget_host_view_mac.mm (right): https://codereview.chromium.org/2164483006/diff/140001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:142: // These are not documented, so use only after checking -respondsToSelector:. Can these all be deleted? (if callers remain in RWHVM they should call text_context_menu instead) https://codereview.chromium.org/2164483006/diff/140001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:1179: TextContextMenu::SpeakText(base::ASCIIToUTF16(selected_text_)); ASCII -> UTF8 (but also ... the selected_text_ member should really be a base::string16 so that it's not first converted _from_ UTF16 in RenderWidgetHostViewMac::SelectionChanged - but that should be a separate CL) https://codereview.chromium.org/2164483006/diff/140001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:1759: TextContextMenu::SpeakText(base::ASCIIToUTF16(text)); ASCII -> UTF8 https://codereview.chromium.org/2164483006/diff/140001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:3319: - (void)startSpeaking:(id)sender { BridgedContentView will need to implement these if we want it to respond to the items in the mainMenu bar (as well as the context menu). They can be implemented in terms of the textInputClient_ member on BridgedContentView (see later comment) It can probably be implemented something like ViewsTextServicesMenuMac::SpeakTextInputClient(textInputClient_) -- see later comments (and SpeakTextInputClient could possibly even go on TextServicesContextMenu, since I think it's allowed to depend on ui::TextInputClient [but not views]) https://codereview.chromium.org/2164483006/diff/140001/ui/base/cocoa/text_con... File ui/base/cocoa/text_context_menu.h (right): https://codereview.chromium.org/2164483006/diff/140001/ui/base/cocoa/text_con... ui/base/cocoa/text_context_menu.h:12: class TextContextMenu : public ui::SimpleMenuModel::Delegate { Maybe TextServicesContextMenu? (also namespace ui. the class should have a comment too) https://codereview.chromium.org/2164483006/diff/140001/ui/base/cocoa/text_con... ui/base/cocoa/text_context_menu.h:16: virtual void StartSpeaking() = 0; I think we should rename this to something like OnSpeakRequested() alternatively, the separation might be nicer with something like: virtual void ProvideTextForSpeaking(const base::Callback<void(std::string16)>& callback) = 0; This hides details about speech operation from the delegate -- it just becomes a "selected text provider" But since |callback| will always be &SpeakText, I couldn't convince myself that this is actually any better than having the delegate just call SpeakText. (but OnSpeakRequested() should get a comment saying the delegate is expected to call SpeakText) https://codereview.chromium.org/2164483006/diff/140001/ui/base/cocoa/text_con... ui/base/cocoa/text_context_menu.h:19: TextContextMenu(Delegate* delegate); explicit https://codereview.chromium.org/2164483006/diff/140001/ui/base/cocoa/text_con... File ui/base/cocoa/text_context_menu.mm (right): https://codereview.chromium.org/2164483006/diff/140001/ui/base/cocoa/text_con... ui/base/cocoa/text_context_menu.mm:11: #include "chrome/app/chrome_command_ids.h" we can't add a chrome dependency here, but I don't think IDC_CONTENT_CONTEXT_SPEECH_START/STOP_SPEAKING are used for anything else -- even their numeric values don't appear in any .xib files, so it should be fine simply to use IDS_SPEECH_START_SPEAKING_MAC as both the command id and the string id, then delete the IDC_ versions from chrome_command_ids.h https://codereview.chromium.org/2164483006/diff/140001/ui/base/cocoa/text_con... ui/base/cocoa/text_context_menu.mm:15: // These are not documented, so use only after checking -respondsToSelector:. huh.. we should probably use the public API, SpeakCFString etc. but not in this CL https://codereview.chromium.org/2164483006/diff/140001/ui/base/cocoa/text_con... ui/base/cocoa/text_context_menu.mm:25: void TextContextMenu::SpeakText(const base::string16& text) { (ensure function order matches header https://codereview.chromium.org/2164483006/diff/140001/ui/base/cocoa/text_con... ui/base/cocoa/text_context_menu.mm:66: default: default not needed https://codereview.chromium.org/2164483006/diff/140001/ui/base/cocoa/text_con... ui/base/cocoa/text_context_menu.mm:84: default: default case not needed https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... File ui/views/controls/textfield/textfield.cc (right): https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... ui/views/controls/textfield/textfield.cc:1919: if (!text_context_menu_.get()) { this `if` check shouldn't be needed.. https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... ui/views/controls/textfield/textfield.cc:1921: text_context_menu_->UpdateContextMenu(context_menu_contents_.get()); but there should be a check before this to ensure that Create() didn't just return nullptr https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... File ui/views/controls/textfield/views_text_context_menu.h (right): https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... ui/views/controls/textfield/views_text_context_menu.h:22: virtual void UpdateContextMenu(ui::SimpleMenuModel* menu) = 0; Can |menu| just be passed in via |Create|? https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... File ui/views/controls/textfield/views_text_context_menu_mac.cc (right): https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... ui/views/controls/textfield/views_text_context_menu_mac.cc:11: ViewsTextContextMenu* ViewsTextContextMenu::Create(Textfield* textfield) { // static https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... ui/views/controls/textfield/views_text_context_menu_mac.cc:27: base::string16 text = textfield_->GetSelectedText(); instead of GetSelectedText, this could use the TextInputClient API and GetSelectionRange(&foo) GetTextFromRange(foo, &text); this has a benefit of not trying to read out password fields, and it reduces the coupling to `views`. I'm unsure if this is better though - it might be wrong to couple it with IME. And it's not always "input" that we can read out. The coupling to views could also be done by having ViewsTextContextMenuMac declare its own, custom delegate interface, and have Textfield implement it, rather than just leaning on Textfield's full interface. Right now, I'm leaning towards using TextInputClient. We should also support speaking when there is no selected text. This is also straightforward-- if the range reported by GetSelectionRange is empty, just get a range from GetTextRange() to read out the whole textfield https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... File ui/views/controls/textfield/views_text_context_menu_mac.h (right): https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... ui/views/controls/textfield/views_text_context_menu_mac.h:1: // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2016 https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... ui/views/controls/textfield/views_text_context_menu_mac.h:14: class VIEWS_EXPORT ViewsTextContextMenuMac : public ViewsTextContextMenu { I'd probably call this ViewsTextServicesMenuMac and put it in ui/views/cocoa. We should be able to remove the `Textfield` dependency (see other comments). https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... ui/views/controls/textfield/views_text_context_menu_mac.h:16: ViewsTextContextMenuMac(Textfield* textfield); explicit https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... ui/views/controls/textfield/views_text_context_menu_mac.h:25: std::unique_ptr<TextContextMenu> menu_; value member should work https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... ui/views/controls/textfield/views_text_context_menu_mac.h:26: }; nit: DISALLOW_COPY..etc
Description was changed from ========== Experimenting with text context menu on MacViews - Creating a parity for the speech menu between MacViews and RenderWidgetHostView ========== to ========== Experimenting with text context menu on MacViews - Creating a parity for the speech menu between MacViews and RenderWidgetHostView CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation ==========
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_compile_dbg_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_comp...)
Description was changed from ========== Experimenting with text context menu on MacViews - Creating a parity for the speech menu between MacViews and RenderWidgetHostView CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation ========== to ========== [MacViews] Implemented text context menu - Added Speech, Writing Direction and Look Up - Moved the the code from render_view_text ==========
Description was changed from ========== [MacViews] Implemented text context menu - Added Speech, Writing Direction and Look Up - Moved the the code from render_view_text ========== to ========== [MacViews] Implemented text context menu - Added Speech, Writing Direction and Look Up - Moved the the code from render_view_context_menu_mac into text_co ==========
Description was changed from ========== [MacViews] Implemented text context menu - Added Speech, Writing Direction and Look Up - Moved the the code from render_view_context_menu_mac into text_co ========== to ========== [MacViews] Implemented text context menu - Added Speech, Writing Direction and Look Up - Introduced text_services_context_menu to create and handle the items - Moved the the code from render_view_context_menu_mac into text_services_context_menu - Created views_text_context_menu to bridge Views with text_services_context_menu ==========
Description was changed from ========== [MacViews] Implemented text context menu - Added Speech, Writing Direction and Look Up - Introduced text_services_context_menu to create and handle the items - Moved the the code from render_view_context_menu_mac into text_services_context_menu - Created views_text_context_menu to bridge Views with text_services_context_menu ========== to ========== [MacViews] Implemented text context menu - Added Speech, Writing Direction and Look Up - Introduced text_services_context_menu to create and handle the items - Moved the the code from render_view_context_menu_mac into text_services_context_menu - Created views_text_context_menu to bridge Views with text_services_context_menu CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation ==========
PTAL Haha sorry it took so long. It was a bit tricky to go through some > 4 month comments :) https://codereview.chromium.org/2164483006/diff/140001/chrome/browser/ui/coco... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h (right): https://codereview.chromium.org/2164483006/diff/140001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h:21: TextContextMenu::Delegate { On 2016/07/22 03:06:42, tapted wrote: > public Done. https://codereview.chromium.org/2164483006/diff/140001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h:75: std::unique_ptr<TextContextMenu> text_context_menu_; On 2016/07/22 03:06:42, tapted wrote: > could this just be a value member? -- no need for unique_ptr Done. https://codereview.chromium.org/2164483006/diff/140001/content/browser/render... File content/browser/renderer_host/render_widget_host_view_mac.mm (right): https://codereview.chromium.org/2164483006/diff/140001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:142: // These are not documented, so use only after checking -respondsToSelector:. On 2016/07/22 03:06:42, tapted wrote: > Can these all be deleted? (if callers remain in RWHVM they should call > text_context_menu instead) Done. https://codereview.chromium.org/2164483006/diff/140001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:1179: TextContextMenu::SpeakText(base::ASCIIToUTF16(selected_text_)); On 2016/07/22 03:06:42, tapted wrote: > ASCII -> UTF8 > > (but also ... the selected_text_ member should really be a base::string16 so > that it's not first converted _from_ UTF16 in > RenderWidgetHostViewMac::SelectionChanged - but that should be a separate CL) Done. https://codereview.chromium.org/2164483006/diff/140001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:1759: TextContextMenu::SpeakText(base::ASCIIToUTF16(text)); On 2016/07/22 03:06:42, tapted wrote: > ASCII -> UTF8 Done. https://codereview.chromium.org/2164483006/diff/140001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:3319: - (void)startSpeaking:(id)sender { On 2016/07/22 03:06:42, tapted wrote: > BridgedContentView will need to implement these if we want it to respond to the > items in the mainMenu bar (as well as the context menu). They can be implemented > in terms of the textInputClient_ member on BridgedContentView (see later > comment) > > It can probably be implemented something like > > ViewsTextServicesMenuMac::SpeakTextInputClient(textInputClient_) -- see later > comments > > > (and SpeakTextInputClient could possibly even go on TextServicesContextMenu, > since I think it's allowed to depend on ui::TextInputClient [but not views]) I'm a bit confused with what you mean about BridgedContentView since the speak menu on the main menu is current working with MacViews. Can you elaborate? Thanks! https://codereview.chromium.org/2164483006/diff/140001/ui/base/cocoa/text_con... File ui/base/cocoa/text_context_menu.h (right): https://codereview.chromium.org/2164483006/diff/140001/ui/base/cocoa/text_con... ui/base/cocoa/text_context_menu.h:12: class TextContextMenu : public ui::SimpleMenuModel::Delegate { On 2016/07/22 03:06:42, tapted wrote: > Maybe TextServicesContextMenu? (also namespace ui. the class should have a > comment too) Done. https://codereview.chromium.org/2164483006/diff/140001/ui/base/cocoa/text_con... ui/base/cocoa/text_context_menu.h:16: virtual void StartSpeaking() = 0; On 2016/07/22 03:06:42, tapted wrote: > I think we should rename this to something like > > OnSpeakRequested() > > alternatively, the separation might be nicer with something like: > > virtual void ProvideTextForSpeaking(const base::Callback<void(std::string16)>& > callback) = 0; > > This hides details about speech operation from the delegate -- it just becomes a > "selected text provider" > > But since |callback| will always be &SpeakText, I couldn't convince myself that > this is actually any better than having the delegate just call SpeakText. (but > OnSpeakRequested() should get a comment saying the delegate is expected to call > SpeakText) Done. https://codereview.chromium.org/2164483006/diff/140001/ui/base/cocoa/text_con... ui/base/cocoa/text_context_menu.h:19: TextContextMenu(Delegate* delegate); On 2016/07/22 03:06:42, tapted wrote: > explicit Done. https://codereview.chromium.org/2164483006/diff/140001/ui/base/cocoa/text_con... File ui/base/cocoa/text_context_menu.mm (right): https://codereview.chromium.org/2164483006/diff/140001/ui/base/cocoa/text_con... ui/base/cocoa/text_context_menu.mm:11: #include "chrome/app/chrome_command_ids.h" On 2016/07/22 03:06:42, tapted wrote: > we can't add a chrome dependency here, but I don't think > IDC_CONTENT_CONTEXT_SPEECH_START/STOP_SPEAKING are used for anything else -- > even their numeric values don't appear in any .xib files, so it should be fine > simply to use IDS_SPEECH_START_SPEAKING_MAC as both the command id and the > string id, then delete the IDC_ versions from chrome_command_ids.h Done. https://codereview.chromium.org/2164483006/diff/140001/ui/base/cocoa/text_con... ui/base/cocoa/text_context_menu.mm:15: // These are not documented, so use only after checking -respondsToSelector:. On 2016/07/22 03:06:42, tapted wrote: > huh.. we should probably use the public API, SpeakCFString etc. but not in this > CL Done. https://codereview.chromium.org/2164483006/diff/140001/ui/base/cocoa/text_con... ui/base/cocoa/text_context_menu.mm:25: void TextContextMenu::SpeakText(const base::string16& text) { On 2016/07/22 03:06:42, tapted wrote: > (ensure function order matches header Done. https://codereview.chromium.org/2164483006/diff/140001/ui/base/cocoa/text_con... ui/base/cocoa/text_context_menu.mm:66: default: On 2016/07/22 03:06:42, tapted wrote: > default not needed Done. https://codereview.chromium.org/2164483006/diff/140001/ui/base/cocoa/text_con... ui/base/cocoa/text_context_menu.mm:84: default: On 2016/07/22 03:06:42, tapted wrote: > default case not needed Done. https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... File ui/views/controls/textfield/textfield.cc (right): https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... ui/views/controls/textfield/textfield.cc:1919: if (!text_context_menu_.get()) { On 2016/07/22 03:06:42, tapted wrote: > this `if` check shouldn't be needed.. Done. https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... ui/views/controls/textfield/textfield.cc:1921: text_context_menu_->UpdateContextMenu(context_menu_contents_.get()); On 2016/07/22 03:06:42, tapted wrote: > but there should be a check before this to ensure that Create() didn't just > return nullptr Removed text_context_menu_ https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... File ui/views/controls/textfield/views_text_context_menu.h (right): https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... ui/views/controls/textfield/views_text_context_menu.h:22: virtual void UpdateContextMenu(ui::SimpleMenuModel* menu) = 0; On 2016/07/22 03:06:42, tapted wrote: > Can |menu| just be passed in via |Create|? Done. https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... File ui/views/controls/textfield/views_text_context_menu_mac.cc (right): https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... ui/views/controls/textfield/views_text_context_menu_mac.cc:11: ViewsTextContextMenu* ViewsTextContextMenu::Create(Textfield* textfield) { On 2016/07/22 03:06:42, tapted wrote: > // static Done. https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... ui/views/controls/textfield/views_text_context_menu_mac.cc:27: base::string16 text = textfield_->GetSelectedText(); On 2016/07/22 03:06:42, tapted wrote: > instead of GetSelectedText, this could use the TextInputClient API and > > GetSelectionRange(&foo) > GetTextFromRange(foo, &text); > > this has a benefit of not trying to read out password fields, and it reduces the > coupling to `views`. I'm unsure if this is better though - it might be wrong to > couple it with IME. And it's not always "input" that we can read out. > > The coupling to views could also be done by having ViewsTextContextMenuMac > declare its own, custom delegate interface, and have Textfield implement it, > rather than just leaning on Textfield's full interface. > > Right now, I'm leaning towards using TextInputClient. We should also support > speaking when there is no selected text. This is also straightforward-- if the > range reported by GetSelectionRange is empty, just get a range from > GetTextRange() to read out the whole textfield Sounds good, I switched to TextInputClient and moved the files https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... File ui/views/controls/textfield/views_text_context_menu_mac.h (right): https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... ui/views/controls/textfield/views_text_context_menu_mac.h:1: // Copyright (c) 2012 The Chromium Authors. All rights reserved. On 2016/07/22 03:06:43, tapted wrote: > 2016 Done. https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... ui/views/controls/textfield/views_text_context_menu_mac.h:14: class VIEWS_EXPORT ViewsTextContextMenuMac : public ViewsTextContextMenu { On 2016/07/22 03:06:42, tapted wrote: > I'd probably call this ViewsTextServicesMenuMac and put it in ui/views/cocoa. We > should be able to remove the `Textfield` dependency (see other comments). Done. https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... ui/views/controls/textfield/views_text_context_menu_mac.h:16: ViewsTextContextMenuMac(Textfield* textfield); On 2016/07/22 03:06:42, tapted wrote: > explicit Done. https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... ui/views/controls/textfield/views_text_context_menu_mac.h:25: std::unique_ptr<TextContextMenu> menu_; On 2016/07/22 03:06:43, tapted wrote: > value member should work Done. https://codereview.chromium.org/2164483006/diff/140001/ui/views/controls/text... ui/views/controls/textfield/views_text_context_menu_mac.h:26: }; On 2016/07/22 03:06:43, tapted wrote: > nit: DISALLOW_COPY..etc Done.
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_x64_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_x64_...)
Ah snap, forgot to add a views_text_services_context_menu.cc file. Going to upload a patch with the file
haven't dived in yet, but just answering question https://codereview.chromium.org/2164483006/diff/140001/content/browser/render... File content/browser/renderer_host/render_widget_host_view_mac.mm (right): https://codereview.chromium.org/2164483006/diff/140001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:3319: - (void)startSpeaking:(id)sender { On 2016/12/12 19:32:27, spqchan wrote: > On 2016/07/22 03:06:42, tapted wrote: > > BridgedContentView will need to implement these if we want it to respond to > the > > items in the mainMenu bar (as well as the context menu). They can be > implemented > > in terms of the textInputClient_ member on BridgedContentView (see later > > comment) > > > > It can probably be implemented something like > > > > ViewsTextServicesMenuMac::SpeakTextInputClient(textInputClient_) -- see later > > comments > > > > > > (and SpeakTextInputClient could possibly even go on TextServicesContextMenu, > > since I think it's allowed to depend on ui::TextInputClient [but not views]) > > I'm a bit confused with what you mean about BridgedContentView since the speak > menu on the main menu is current working with MacViews. Can you elaborate? > Thanks! I think selecting 'Start Speaking' from the mainMenu will hunt through the responder chain until it finds a class implementing `startSpeaking:`. BridgedContentView doesn't implement it, so currently on MacViews (e.g. the bookmark bubble) `Edit -> Speech -> StartSpeaking` will read out the web page (since it skips over the views::Widget but then finds this implementation), but on Cocoa it will read out the contents of the `Name:` textfield in the bookmarks bubble.
Make sure there's a BUG= Needs a few tests too -- the writing direction checked/not-checked with a views::TextField is a nice case to test. Ensuring the menu updates when the selection changes would be another good test case. (speech is obviously hard to test..) https://codereview.chromium.org/2164483006/diff/440001/chrome/browser/ui/coco... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm (right): https://codereview.chromium.org/2164483006/diff/440001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:247: switch (command_id) { no need to switch here https://codereview.chromium.org/2164483006/diff/440001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:267: if (text_services_context_menu_.IsTextServicesCommandId(command_id)) Is it only IDS_CONTENT_CONTEXT_LOOK_UP that comes through here? (should the others go directly to TextServicesContextMenu since that is the delegate for the submenus?) https://codereview.chromium.org/2164483006/diff/440001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:296: index += 1; // Place it below the separator. I think the "it" here is IDS_CONTENT_CONTEXT_LOOK_UP which has been moved to text_services_context_menu, so the stuff from `if (params_.link_url.is_empty()) {` should move into text_services_context_menu as well. that is, InitToolkitMenu() should just be void RenderViewContextMenuMac::InitToolkitMenu() { text_services_context_menu_.AppendToContextMenu(&menu_model_); } with the logic above implemented using delegate interfaces https://codereview.chromium.org/2164483006/diff/440001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:380: if (direction == ui::WritingDirection::DEFAULT) nit: DCHECK_NE(ui::WritingDirection::DEFAULT, direction) https://codereview.chromium.org/2164483006/diff/440001/content/browser/render... File content/browser/renderer_host/render_widget_host_view_mac.mm (right): https://codereview.chromium.org/2164483006/diff/440001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:1101: ui::TextServicesContextMenu::SpeakText(base::UTF8ToUTF16(selected_text_)); Can we make |selected_text_| a string16? It looks like it's just RenderWidgetHostViewMac::OnTextSelectionChanged that sets it, and it's doing base::UTF16ToUTF8 of course RenderViewImpl::OnGetRenderedText() and ViewMsg_GetRenderedTextCompleted should also change to string16 :/. But that's IPC stuff - maybe better for a follow-up. [see next comment] https://codereview.chromium.org/2164483006/diff/440001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:1655: ui::TextServicesContextMenu::SpeakText(base::UTF8ToUTF16(text)); i.e. Ideally this uses string16 as well, but maybe just a TODO() comment above to update RenderViewImpl::OnGetRenderedText and the IPC message to use string16 https://codereview.chromium.org/2164483006/diff/440001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:2722: return is_render_view; can we do something like && ui::TextServicesContextMenu::IsSpeaking() here? I think this is needed for the mainMenu to match the context menu. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... File ui/base/cocoa/text_services_context_menu.h (right): https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:9: #include <CoreAudio/CoreAudio.h> move to the .mm? https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:17: enum class WritingDirection { DEFAULT, LTR, RTL }; I think ui:: is too broad a scope for something new like this. But can we use i18n::TextDirection from base/i18n/rtl.h instead? This would make ViewsTextServicesContextMenuMac::UpdateTextDirection() simpler too https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:21: class UI_BASE_EXPORT TextServicesContextMenu nit: #include ui/base/ui_base_export.h https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:22: : public ui::SimpleMenuModel::Delegate { nit: no `ui::` https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:26: // Returns the selected text nit: full stop at end https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:27: virtual base::string16 GetSelectedText() const = 0; #include string16 https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:58: // Methods for appending items to the context menu. The comment should say what the difference between the two methods is, since it's not obvious. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:59: void AppendToContextMenu(ui::SimpleMenuModel* model); nit: no ui::, (4 others, below) https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:75: WritingDirection GetWritingDirectionFromCommandId(int command_id) const; move to anonymous namespace in .mm https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:83: Delegate* delegate_; // weak nit: "// Weak." https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:86: static SpeechChannel speechChannel; Can this move to an anonymous namespace in the .mm? I think we can get rid of #include <ApplicationServices/ApplicationServices.h> then -- just have it in the .mm. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:90: } nit: blank line before + } // namespace ui https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... File ui/base/cocoa/text_services_context_menu.mm (right): https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:9: #import <Cocoa/Cocoa.h> We might not need this now that we're not calling private methods on NSApp. Which I think means that this file doesn't need to be ObjectiveC -- we can make it a .cc file instead. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:18: SpeechChannel TextServicesContextMenu::speechChannel; i.e. namespace { SpeechChannel g_speech_channel; /* other stuff */ } // namespace https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:34: NewSpeechChannel(NULL, &speechChannel); NULL -> nullptr. Same below. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:47: void TextServicesContextMenu::AppendToContextMenu(ui::SimpleMenuModel* model) { nit: no ui:: https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:53: model->InsertItemAt(0, IDS_CONTENT_CONTEXT_LOOK_UP, I guess this `0` was previously the calculated index - do we need to calculate it here to avoid a regression for the render view context menu? https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:58: model->AddSeparator(ui::NORMAL_SEPARATOR); nit: no ui:: https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:59: speech_submenu_model_.AddItemWithStringId(IDS_SPEECH_START_SPEAKING_MAC, Can we do these `AddItemWithStringId` calls on the submenu in the constructor instead? I think they're always the same -- no need to recreate each time. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:68: ui::SimpleMenuModel* model) { nit: no ui:: https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:70: IDS_CONTENT_CONTEXT_WRITING_DIRECTION_DEFAULT, Same here - I think these calls can be made in the constructor, and we just add the submenu here. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:89: case IDS_CONTENT_CONTEXT_LOOK_UP: For the others it might be OK, but do we risk a command_id conflict using IDS_CONTENT_CONTEXT_LOOK_UP here? That is, can we can guarantee that the renderer context menu doesn't decide to use a command_id equal to whatever value IDS_CONTENT_CONTEXT_LOOK_UP takes from the generated header? https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:119: } default: NOTREACHED()? https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:149: return false; NOTREACHED(); before this? https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:155: return false; this matches the default implementation, so I think this method override can be removed https://codereview.chromium.org/2164483006/diff/440001/ui/gfx/decorated_text_... File ui/gfx/decorated_text_mac.h (right): https://codereview.chromium.org/2164483006/diff/440001/ui/gfx/decorated_text_... ui/gfx/decorated_text_mac.h:8: #include "ui/gfx/decorated_text.h" nit: forward declare https://codereview.chromium.org/2164483006/diff/440001/ui/gfx/decorated_text_... ui/gfx/decorated_text_mac.h:16: GFX_EXPORT NSAttributedString* GetAttributedStringFromDecoratedText( ooh nice, I like this :) https://codereview.chromium.org/2164483006/diff/440001/ui/gfx/render_text.h File ui/gfx/render_text.h (right): https://codereview.chromium.org/2164483006/diff/440001/ui/gfx/render_text.h#n... ui/gfx/render_text.h:732: virtual bool GetDecoratedTextForRange(const Range& range, It's confusing to have a virtual and a non-virtual method with the same name. I think this needs to be renamed to something like GetDecoratedTextForRangeImpl https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/text... File ui/views/controls/textfield/textfield.cc (right): https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/text... ui/views/controls/textfield/textfield.cc:1186: if (text_services_context_menu_->IsTextServicesCommandId(command_id)) same here - I think only LOOK_UP should get here. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/text... ui/views/controls/textfield/textfield.cc:1193: if (text_services_context_menu_->IsTextServicesCommandId(command_id)) text_services_context_menu_ can be null currently, so that needs to be checked here and in IsCommandIdChecked Another option could be to return a "dummy" implementation with stub methods, so that this call works. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/text... ui/views/controls/textfield/textfield.cc:2020: text_services_context_menu_.reset(text_services_menu); we should be able to assign directly, so long as `Create` returns a std:unique_ptr. i.e. text_services_context_menu_ = ViewsTextServicesContextMenu::Create(..); https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/text... ui/views/controls/textfield/textfield.cc:2024: context_menu_runner_.reset(new MenuRunner(context_menu_contents_.get(), this should be outside the `if` I think ? (i.e. below the curly brace on lin 2028) https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/text... File ui/views/controls/textfield/textfield.h (right): https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/text... ui/views/controls/textfield/textfield.h:31: #include "ui/views/controls/views_text_services_context_menu.h" nit: forward declare? https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... File ui/views/controls/views_text_services_context_menu.cc (right): https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu.cc:7: #include "ui/base/ime/text_input_client.h" no need for these #includes https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... File ui/views/controls/views_text_services_context_menu_mac.h (right): https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.h:5: #ifndef UI_VIEWS_CONTROLS_VIEWS_TEXT_SERVICES_CONTEXT_MENU_MAC_H_ Is this header required? (can all of ViewsTextServicesContextMenuMac be defined in an anonymous namespace?) https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.h:28: explicit ViewsTextServicesContextMenuMac(ui::TextInputClient* text_client, nit: explicit not required https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.h:34: // ViewsTextContextMenu: ViewsTextServicesContextMenu: https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.h:41: // TextServicesContextMenu::Delegate nit: colon at end https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.h:55: WordLookupClient* lookup_client_; I think text_client_ and lookup_client_ will both be a views::TextField? I think we can just use views::Textfield here. Then the ownership is clearer, since it's the Textfield that will own |this|. i.e. we can say views::TextField* client_; // Weak. Owns |this|. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.h:61: View* view_; ah, this is probably the TextField too? https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.h:64: // determine if the context menu needs to updated. insert "be" -> "needs to be updated" https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... File ui/views/controls/views_text_services_context_menu_mac.mm (right): https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:25: return new ViewsTextServicesContextMenuMac(text_client, lookup_client, menu, return base::MakeUnique<ViewsTextServicesContextMenuMac>(client, menu); https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:45: bool ViewsTextServicesContextMenuMac::ShouldUpdateMenu() const { You might be able to remove this delegate method (and seletion_text_ member), just by calling `context_menu_contents_.reset()` in Textfield::OnCaretBoundsChanged() (with an appropriate comment above it) https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:56: menu_.ExecuteCommand(command_id, event_flags); maybe DCHECK(IsTextServicesCommandId(..))? https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:80: gfx::Range range; If client_ is a TextField, we can now just call something like client_->HasSelection() https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:86: gfx::Point baselinePoint; nit: baseline_point https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:115: return text_client_->GetTextDirection() == base::i18n::LEFT_TO_RIGHT; we should add some test coverage for this using views::Textfield https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:121: if (direction == ui::WritingDirection::DEFAULT) DCHECK_NE
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_chromeos_ozone_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: cast_shell_linux on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/cast_shell_linu...)
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Description was changed from ========== [MacViews] Implemented text context menu - Added Speech, Writing Direction and Look Up - Introduced text_services_context_menu to create and handle the items - Moved the the code from render_view_context_menu_mac into text_services_context_menu - Created views_text_context_menu to bridge Views with text_services_context_menu CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation ========== to ========== [MacViews] Implemented text context menu - Added Speech, Writing Direction and Look Up - Introduced text_services_context_menu to create and handle the items - Moved the the code from render_view_context_menu_mac into text_services_context_menu - Created views_text_context_menu to bridge Views with text_services_context_menu BUG=617436 ==========
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromeos_daisy_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_daisy_...)
Description was changed from ========== [MacViews] Implemented text context menu - Added Speech, Writing Direction and Look Up - Introduced text_services_context_menu to create and handle the items - Moved the the code from render_view_context_menu_mac into text_services_context_menu - Created views_text_context_menu to bridge Views with text_services_context_menu BUG=617436 ========== to ========== [MacViews] Implemented text context menu - Added Speech, Writing Direction and Look Up - Introduced text_services_context_menu to create and handle the items - Moved the the code from render_view_context_menu_mac into text_services_context_menu - Created views_text_context_menu to bridge Views with text_services_context_menu BUG=617436 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation ==========
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_compile_dbg_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_comp...) win_chromium_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_...) win_clang on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_clang/builds/...)
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromeos_amd64-generic_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_amd64-...)
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Patchset #28 (id:540001) has been deleted
Patchset #27 (id:520001) has been deleted
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
PTAL https://codereview.chromium.org/2164483006/diff/440001/chrome/browser/ui/coco... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm (right): https://codereview.chromium.org/2164483006/diff/440001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:247: switch (command_id) { On 2016/12/13 05:11:22, tapted wrote: > no need to switch here Done. https://codereview.chromium.org/2164483006/diff/440001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:267: if (text_services_context_menu_.IsTextServicesCommandId(command_id)) On 2016/12/13 05:11:22, tapted wrote: > Is it only IDS_CONTENT_CONTEXT_LOOK_UP that comes through here? (should the > others go directly to TextServicesContextMenu since that is the delegate for the > submenus?) Yes, only lookup goes through here. I'm a bit confused with what you mean with your second statement https://codereview.chromium.org/2164483006/diff/440001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:296: index += 1; // Place it below the separator. On 2016/12/13 05:11:22, tapted wrote: > I think the "it" here is IDS_CONTENT_CONTEXT_LOOK_UP which has been moved to > text_services_context_menu, so the stuff from `if (params_.link_url.is_empty()) > {` should move into text_services_context_menu as well. > > that is, InitToolkitMenu() should just be > > void RenderViewContextMenuMac::InitToolkitMenu() { > text_services_context_menu_.AppendToContextMenu(&menu_model_); > } > > with the logic above implemented using delegate interfaces I'm a bit confused. I'm pretty sure that this section is for the spellchecks and adding new words into the dictionary. https://codereview.chromium.org/2164483006/diff/440001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:380: if (direction == ui::WritingDirection::DEFAULT) On 2016/12/13 05:11:22, tapted wrote: > nit: DCHECK_NE(ui::WritingDirection::DEFAULT, direction) Done. https://codereview.chromium.org/2164483006/diff/440001/content/browser/render... File content/browser/renderer_host/render_widget_host_view_mac.mm (right): https://codereview.chromium.org/2164483006/diff/440001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:1101: ui::TextServicesContextMenu::SpeakText(base::UTF8ToUTF16(selected_text_)); On 2016/12/13 05:11:22, tapted wrote: > Can we make |selected_text_| a string16? > > It looks like it's just RenderWidgetHostViewMac::OnTextSelectionChanged that > sets it, and it's doing base::UTF16ToUTF8 > > of course RenderViewImpl::OnGetRenderedText() and > ViewMsg_GetRenderedTextCompleted should also change to string16 :/. But that's > IPC stuff - maybe better for a follow-up. [see next comment] Added a TODO https://codereview.chromium.org/2164483006/diff/440001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:1655: ui::TextServicesContextMenu::SpeakText(base::UTF8ToUTF16(text)); On 2016/12/13 05:11:22, tapted wrote: > i.e. Ideally this uses string16 as well, but maybe just a TODO() comment above > to update RenderViewImpl::OnGetRenderedText and the IPC message to use string16 Acknowledged. https://codereview.chromium.org/2164483006/diff/440001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:2722: return is_render_view; On 2016/12/13 05:11:22, tapted wrote: > can we do something like && ui::TextServicesContextMenu::IsSpeaking() here? I > think this is needed for the mainMenu to match the context menu. Whoops, thanks for the catch https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... File ui/base/cocoa/text_services_context_menu.h (right): https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:9: #include <CoreAudio/CoreAudio.h> On 2016/12/13 05:11:23, tapted wrote: > move to the .mm? Done. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:17: enum class WritingDirection { DEFAULT, LTR, RTL }; On 2016/12/13 05:11:23, tapted wrote: > I think ui:: is too broad a scope for something new like this. But can we use > i18n::TextDirection from base/i18n/rtl.h instead? This would make > ViewsTextServicesContextMenuMac::UpdateTextDirection() simpler too Done. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:21: class UI_BASE_EXPORT TextServicesContextMenu On 2016/12/13 05:11:23, tapted wrote: > nit: #include ui/base/ui_base_export.h Done. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:22: : public ui::SimpleMenuModel::Delegate { On 2016/12/13 05:11:23, tapted wrote: > nit: no `ui::` Done. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:26: // Returns the selected text On 2016/12/13 05:11:23, tapted wrote: > nit: full stop at end Done. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:27: virtual base::string16 GetSelectedText() const = 0; On 2016/12/13 05:11:23, tapted wrote: > #include string16 Done. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:58: // Methods for appending items to the context menu. On 2016/12/13 05:11:23, tapted wrote: > The comment should say what the difference between the two methods is, since > it's not obvious. Removed AppendPlatformEditableItems, I don't think there's any point with keeping it https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:59: void AppendToContextMenu(ui::SimpleMenuModel* model); On 2016/12/13 05:11:23, tapted wrote: > nit: no ui::, (4 others, below) Done. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:75: WritingDirection GetWritingDirectionFromCommandId(int command_id) const; On 2016/12/13 05:11:23, tapted wrote: > move to anonymous namespace in .mm Done. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:83: Delegate* delegate_; // weak On 2016/12/13 05:11:23, tapted wrote: > nit: "// Weak." Done. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:86: static SpeechChannel speechChannel; On 2016/12/13 05:11:23, tapted wrote: > Can this move to an anonymous namespace in the .mm? > > I think we can get rid of #include <ApplicationServices/ApplicationServices.h> > then -- just have it in the .mm. Done. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:90: } On 2016/12/13 05:11:22, tapted wrote: > nit: blank line before + } // namespace ui Done. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... File ui/base/cocoa/text_services_context_menu.mm (right): https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:9: #import <Cocoa/Cocoa.h> On 2016/12/13 05:11:23, tapted wrote: > We might not need this now that we're not calling private methods on NSApp. > > Which I think means that this file doesn't need to be ObjectiveC -- we can make > it a .cc file instead. Done. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:18: SpeechChannel TextServicesContextMenu::speechChannel; On 2016/12/13 05:11:23, tapted wrote: > i.e. > > namespace { > > SpeechChannel g_speech_channel; > > /* other stuff */ > > } // namespace Done. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:34: NewSpeechChannel(NULL, &speechChannel); On 2016/12/13 05:11:23, tapted wrote: > NULL -> nullptr. Same below. Done. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:47: void TextServicesContextMenu::AppendToContextMenu(ui::SimpleMenuModel* model) { On 2016/12/13 05:11:23, tapted wrote: > nit: no ui:: Done. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:53: model->InsertItemAt(0, IDS_CONTENT_CONTEXT_LOOK_UP, On 2016/12/13 05:11:23, tapted wrote: > I guess this `0` was previously the calculated index - do we need to calculate > it here to avoid a regression for the render view context menu? Yes, we need it so that the LookUp item actually appears at the top of the menu. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:58: model->AddSeparator(ui::NORMAL_SEPARATOR); On 2016/12/13 05:11:23, tapted wrote: > nit: no ui:: Done. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:59: speech_submenu_model_.AddItemWithStringId(IDS_SPEECH_START_SPEAKING_MAC, On 2016/12/13 05:11:23, tapted wrote: > Can we do these `AddItemWithStringId` calls on the submenu in the constructor > instead? I think they're always the same -- no need to recreate each time. Done https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:68: ui::SimpleMenuModel* model) { On 2016/12/13 05:11:23, tapted wrote: > nit: no ui:: Done. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:70: IDS_CONTENT_CONTEXT_WRITING_DIRECTION_DEFAULT, On 2016/12/13 05:11:23, tapted wrote: > Same here - I think these calls can be made in the constructor, and we just add > the submenu here. Done. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:89: case IDS_CONTENT_CONTEXT_LOOK_UP: On 2016/12/13 05:11:23, tapted wrote: > For the others it might be OK, but do we risk a command_id conflict using > IDS_CONTENT_CONTEXT_LOOK_UP here? That is, can we can guarantee that the > renderer context menu doesn't decide to use a command_id equal to whatever value > IDS_CONTENT_CONTEXT_LOOK_UP takes from the generated header? That's true. AFAIK. there's no conflict now, but I'm not sure how to prevent this I'm not really sure how to do it without using chrome_command_ids. I can include chrome_command_ids.h and use the IDC values, or copy the values to text_services_menu and add a comment about that. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:119: } On 2016/12/13 05:11:23, tapted wrote: > default: NOTREACHED()? Done. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:149: return false; On 2016/12/13 05:11:23, tapted wrote: > NOTREACHED(); before this? Done. https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:155: return false; On 2016/12/13 05:11:23, tapted wrote: > this matches the default implementation, so I think this method override can be > removed Done. https://codereview.chromium.org/2164483006/diff/440001/ui/gfx/decorated_text_... File ui/gfx/decorated_text_mac.h (right): https://codereview.chromium.org/2164483006/diff/440001/ui/gfx/decorated_text_... ui/gfx/decorated_text_mac.h:8: #include "ui/gfx/decorated_text.h" On 2016/12/13 05:11:23, tapted wrote: > nit: forward declare Done. https://codereview.chromium.org/2164483006/diff/440001/ui/gfx/decorated_text_... ui/gfx/decorated_text_mac.h:16: GFX_EXPORT NSAttributedString* GetAttributedStringFromDecoratedText( On 2016/12/13 05:11:23, tapted wrote: > ooh nice, I like this :) Acknowledged. https://codereview.chromium.org/2164483006/diff/440001/ui/gfx/render_text.h File ui/gfx/render_text.h (right): https://codereview.chromium.org/2164483006/diff/440001/ui/gfx/render_text.h#n... ui/gfx/render_text.h:732: virtual bool GetDecoratedTextForRange(const Range& range, On 2016/12/13 05:11:23, tapted wrote: > It's confusing to have a virtual and a non-virtual method with the same name. I > think this needs to be renamed to something like GetDecoratedTextForRangeImpl How about GetDecoratedTextAndBasepointForRange? If this is good, I can rename GetDecoratedWordAtPoint and etc to GetDecoratedWordAndBaselineAtPoint https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/text... File ui/views/controls/textfield/textfield.cc (right): https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/text... ui/views/controls/textfield/textfield.cc:1186: if (text_services_context_menu_->IsTextServicesCommandId(command_id)) On 2016/12/13 05:11:24, tapted wrote: > same here - I think only LOOK_UP should get here. Acknowledged. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/text... ui/views/controls/textfield/textfield.cc:1193: if (text_services_context_menu_->IsTextServicesCommandId(command_id)) On 2016/12/13 05:11:24, tapted wrote: > text_services_context_menu_ can be null currently, so that needs to be checked > here and in IsCommandIdChecked > > Another option could be to return a "dummy" implementation with stub methods, so > that this call works. Done. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/text... ui/views/controls/textfield/textfield.cc:2020: text_services_context_menu_.reset(text_services_menu); On 2016/12/13 05:11:24, tapted wrote: > we should be able to assign directly, so long as `Create` returns a > std:unique_ptr. i.e. > > text_services_context_menu_ = ViewsTextServicesContextMenu::Create(..); Done. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/text... ui/views/controls/textfield/textfield.cc:2024: context_menu_runner_.reset(new MenuRunner(context_menu_contents_.get(), On 2016/12/13 05:11:24, tapted wrote: > this should be outside the `if` I think ? (i.e. below the curly brace on lin > 2028) Done. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/text... File ui/views/controls/textfield/textfield.h (right): https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/text... ui/views/controls/textfield/textfield.h:31: #include "ui/views/controls/views_text_services_context_menu.h" On 2016/12/13 05:11:24, tapted wrote: > nit: forward declare? Done. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... File ui/views/controls/views_text_services_context_menu.cc (right): https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu.cc:7: #include "ui/base/ime/text_input_client.h" On 2016/12/13 05:11:24, tapted wrote: > no need for these #includes Done. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... File ui/views/controls/views_text_services_context_menu_mac.h (right): https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.h:5: #ifndef UI_VIEWS_CONTROLS_VIEWS_TEXT_SERVICES_CONTEXT_MENU_MAC_H_ On 2016/12/13 05:11:24, tapted wrote: > Is this header required? > > (can all of ViewsTextServicesContextMenuMac be defined in an anonymous > namespace?) Done. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.h:28: explicit ViewsTextServicesContextMenuMac(ui::TextInputClient* text_client, On 2016/12/13 05:11:24, tapted wrote: > nit: explicit not required Done. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.h:34: // ViewsTextContextMenu: On 2016/12/13 05:11:24, tapted wrote: > ViewsTextServicesContextMenu: Done. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.h:41: // TextServicesContextMenu::Delegate On 2016/12/13 05:11:24, tapted wrote: > nit: colon at end Done. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.h:55: WordLookupClient* lookup_client_; On 2016/12/13 05:11:24, tapted wrote: > I think text_client_ and lookup_client_ will both be a views::TextField? I think > we can just use views::Textfield here. Then the ownership is clearer, since it's > the Textfield that will own |this|. i.e. we can say > > views::TextField* client_; // Weak. Owns |this|. Done. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.h:61: View* view_; On 2016/12/13 05:11:24, tapted wrote: > ah, this is probably the TextField too? Done. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.h:64: // determine if the context menu needs to updated. On 2016/12/13 05:11:24, tapted wrote: > insert "be" -> "needs to be updated" Done. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... File ui/views/controls/views_text_services_context_menu_mac.mm (right): https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:25: return new ViewsTextServicesContextMenuMac(text_client, lookup_client, menu, On 2016/12/13 05:11:24, tapted wrote: > return base::MakeUnique<ViewsTextServicesContextMenuMac>(client, menu); Done. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:45: bool ViewsTextServicesContextMenuMac::ShouldUpdateMenu() const { On 2016/12/13 05:11:24, tapted wrote: > You might be able to remove this delegate method (and seletion_text_ member), > just by calling `context_menu_contents_.reset()` in > Textfield::OnCaretBoundsChanged() (with an appropriate comment above it) Done. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:56: menu_.ExecuteCommand(command_id, event_flags); On 2016/12/13 05:11:24, tapted wrote: > maybe DCHECK(IsTextServicesCommandId(..))? Done. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:80: gfx::Range range; On 2016/12/13 05:11:24, tapted wrote: > If client_ is a TextField, we can now just call something like > client_->HasSelection() Done. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:86: gfx::Point baselinePoint; On 2016/12/13 05:11:24, tapted wrote: > nit: baseline_point Done. https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:115: return text_client_->GetTextDirection() == base::i18n::LEFT_TO_RIGHT; On 2016/12/13 05:11:24, tapted wrote: > we should add some test coverage for this using views::Textfield I added some test coverage in textfield_unittest. Let me know if I'm missing anything https://codereview.chromium.org/2164483006/diff/440001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:121: if (direction == ui::WritingDirection::DEFAULT) On 2016/12/13 05:11:24, tapted wrote: > DCHECK_NE Done.
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
(review still in progress, but I gotta run for now) https://codereview.chromium.org/2164483006/diff/440001/chrome/browser/ui/coco... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm (right): https://codereview.chromium.org/2164483006/diff/440001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:296: index += 1; // Place it below the separator. On 2016/12/15 23:29:00, spqchan wrote: > On 2016/12/13 05:11:22, tapted wrote: > > I think the "it" here is IDS_CONTENT_CONTEXT_LOOK_UP which has been moved to > > text_services_context_menu, so the stuff from `if > (params_.link_url.is_empty()) > > {` should move into text_services_context_menu as well. > > > > that is, InitToolkitMenu() should just be > > > > void RenderViewContextMenuMac::InitToolkitMenu() { > > text_services_context_menu_.AppendToContextMenu(&menu_model_); > > } > > > > with the logic above implemented using delegate interfaces > > I'm a bit confused. I'm pretty sure that this section is for the spellchecks and > adding new words into the dictionary. The problem is that all the code between `if (params_.link_url.is_empty()) {` and here just sets a value for |index|. That |index| was then used to insert IDC_CONTENT_CONTEXT_LOOK_UP immediately followed by a separator. Now it just inserts a separator at some location, but there's no link between that separator and IDC_CONTENT_CONTEXT_LOOK_UP since that's now inserted elsewhere. So shouldn't the InsertSeparatorAt line below (and the |index| calculation here) happen where IDC_CONTENT_CONTEXT_LOOK_UP is inserted? https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... File ui/base/cocoa/text_services_context_menu.mm (right): https://codereview.chromium.org/2164483006/diff/440001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.mm:89: case IDS_CONTENT_CONTEXT_LOOK_UP: On 2016/12/15 23:29:01, spqchan wrote: > On 2016/12/13 05:11:23, tapted wrote: > > For the others it might be OK, but do we risk a command_id conflict using > > IDS_CONTENT_CONTEXT_LOOK_UP here? That is, can we can guarantee that the > > renderer context menu doesn't decide to use a command_id equal to whatever > value > > IDS_CONTENT_CONTEXT_LOOK_UP takes from the generated header? > > That's true. AFAIK. there's no conflict now, but I'm not sure how to prevent > this I'm not really sure how to do it without using chrome_command_ids. > > I can include chrome_command_ids.h and use the IDC values, or copy the values to > text_services_menu and add a comment about that. So one way to avoid it could be to use MenuModel rather than SimpleMenuModel. MenuModel uses the index in the menu rather than the command_id to refer to items. However, I think that will add extra complexity. RenderViewContextMenu is pretty heavy on the command_id thing. I think this does need a proper solution. I think for now we should pass the command_id to use for "lookup" to the method that adds that item. https://codereview.chromium.org/2164483006/diff/440001/ui/gfx/render_text.h File ui/gfx/render_text.h (right): https://codereview.chromium.org/2164483006/diff/440001/ui/gfx/render_text.h#n... ui/gfx/render_text.h:732: virtual bool GetDecoratedTextForRange(const Range& range, On 2016/12/15 23:29:01, spqchan wrote: > On 2016/12/13 05:11:23, tapted wrote: > > It's confusing to have a virtual and a non-virtual method with the same name. > I > > think this needs to be renamed to something like GetDecoratedTextForRangeImpl > > How about GetDecoratedTextAndBasepointForRange? If this is good, I can rename > GetDecoratedWordAtPoint and etc to GetDecoratedWordAndBaselineAtPoint With GetDecoratedTextAndBasepointForRange -> GetDecoratedTextAndBaselinePointForRange that's good too. I don't feel strongly (so long as they're different), but a ui/gfx/OWNER (probably msw) might have a preference. https://codereview.chromium.org/2164483006/diff/580001/chrome/browser/ui/coco... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h (right): https://codereview.chromium.org/2164483006/diff/580001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h:33: // TextServicesContextMenu: nit: TextServicesContextMenu::Delegate: https://codereview.chromium.org/2164483006/diff/580001/chrome/browser/ui/coco... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm (left): https://codereview.chromium.org/2164483006/diff/580001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:334: void RenderViewContextMenuMac::AppendPlatformEditableItems() { There might be a regression here. RenderViewContextMenu::InitMenu() invokes this between if (content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_EDITABLE)) { menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); AppendLanguageSettings(); AppendPlatformEditableItems(); } So, do we now add the Bidi submenu when right-clicking non-editable elements on a web page? https://codereview.chromium.org/2164483006/diff/580001/chrome/browser/ui/coco... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm (right): https://codereview.chromium.org/2164483006/diff/580001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:283: index += 1; // Place it below the separator. per comment on prior patchset (and with the separator insert moved), |index| is unused after this line, so the code above to calculate |index| isn't utilised. https://codereview.chromium.org/2164483006/diff/580001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:345: default: nit: I think the convention is to do case TEXT_DIRECTION_NUM_DIRECTIONS: } NOTREACHED(); return false; This is because we get a warning if someone adds to the enum. It's also clearer that the function always returns a value -- I think MSVC is ok now with "default:", but with the above change it would sometimes warn defensively about a function that may not return a value. (more below) https://codereview.chromium.org/2164483006/diff/580001/content/browser/render... File content/browser/renderer_host/render_widget_host_view_mac.mm (right): https://codereview.chromium.org/2164483006/diff/580001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:1101: // TODO(spqchan): Change |selected_text_|'s type to string16. I think changing |selected_text_| can be included -- it should be an easy change :). The TODO should then go into OnGetRenderedTextCompleted (to change the |text| argument to string16) https://codereview.chromium.org/2164483006/diff/580001/ui/views/controls/text... File ui/views/controls/textfield/textfield.cc (right): https://codereview.chromium.org/2164483006/diff/580001/ui/views/controls/text... ui/views/controls/textfield/textfield.cc:1959: context_menu_contents_.reset(); this should have a comment
Take your time :) I made changes according to what you put out so far https://codereview.chromium.org/2164483006/diff/580001/chrome/browser/ui/coco... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h (right): https://codereview.chromium.org/2164483006/diff/580001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h:33: // TextServicesContextMenu: On 2016/12/16 07:01:19, tapted wrote: > nit: TextServicesContextMenu::Delegate: Done. https://codereview.chromium.org/2164483006/diff/580001/chrome/browser/ui/coco... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm (left): https://codereview.chromium.org/2164483006/diff/580001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:334: void RenderViewContextMenuMac::AppendPlatformEditableItems() { On 2016/12/16 07:01:19, tapted wrote: > There might be a regression here. RenderViewContextMenu::InitMenu() invokes this > between > > if (content_type_->SupportsGroup( > ContextMenuContentType::ITEM_GROUP_EDITABLE)) { > menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); > AppendLanguageSettings(); > AppendPlatformEditableItems(); > } > > So, do we now add the Bidi submenu when right-clicking non-editable elements on > a web page? Augh, can't believe I missed this. Thanks for catching it! https://codereview.chromium.org/2164483006/diff/580001/chrome/browser/ui/coco... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm (right): https://codereview.chromium.org/2164483006/diff/580001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:283: index += 1; // Place it below the separator. On 2016/12/16 07:01:19, tapted wrote: > per comment on prior patchset (and with the separator insert moved), |index| is > unused after this line, so the code above to calculate |index| isn't utilised. Doh, I see what you mean. Fixed it, thanks :) https://codereview.chromium.org/2164483006/diff/580001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:345: default: On 2016/12/16 07:01:19, tapted wrote: > nit: I think the convention is to do > > case TEXT_DIRECTION_NUM_DIRECTIONS: > } > > NOTREACHED(); > return false; > > > This is because we get a warning if someone adds to the enum. It's also clearer > that the function always returns a value -- I think MSVC is ok now with > "default:", but with the above change it would sometimes warn defensively about > a function that may not return a value. > > (more below) Done. Note, I put NOTREACHED(); return false; under case TEXT_DIRECTION_NUM_DIRECTIONS: because it needs something under it. Alternatively, I can just put a semicolon after case TEXT_DIRECTION_NUM_DIRECTIONS: https://codereview.chromium.org/2164483006/diff/580001/content/browser/render... File content/browser/renderer_host/render_widget_host_view_mac.mm (right): https://codereview.chromium.org/2164483006/diff/580001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:1101: // TODO(spqchan): Change |selected_text_|'s type to string16. On 2016/12/16 07:01:19, tapted wrote: > I think changing |selected_text_| can be included -- it should be an easy change > :). The TODO should then go into OnGetRenderedTextCompleted (to change the > |text| argument to string16) Done. https://codereview.chromium.org/2164483006/diff/580001/ui/views/controls/text... File ui/views/controls/textfield/textfield.cc (right): https://codereview.chromium.org/2164483006/diff/580001/ui/views/controls/text... ui/views/controls/textfield/textfield.cc:1959: context_menu_contents_.reset(); On 2016/12/16 07:01:19, tapted wrote: > this should have a comment Done.
aw man this is tough. We can't depend on src/chrome from src/u There' doesn't seem to be precedent for something like src/ui/ui_command_ids.h (we could then coordinate with chrome_comand_ids.h to ensure there's no overlap) that might be something we need to explore though. There are two other options below. I think my preferred one at the moment is to just have RenderContextMenu and TextfiledContextMenu handle the lookup word option themselves, and pass in |index| to AppendToContextMenu (and call it Insert*) https://codereview.chromium.org/2164483006/diff/600001/content/browser/render... File content/browser/renderer_host/render_widget_host_view_mac.mm (right): https://codereview.chromium.org/2164483006/diff/600001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:3392: base::scoped_nsobject<NSString> text(SysUTF16ToNSString(str)); This might be a refcounting bug (nsobject expects a retained object, but SysUTF16ToNSString will return an autoreleased one). I think we can just get rid of |text|, and pass SysUTF16ToNSString(str) on to the setString: arg in the return statement. https://codereview.chromium.org/2164483006/diff/600001/ui/base/cocoa/DEPS File ui/base/cocoa/DEPS (right): https://codereview.chromium.org/2164483006/diff/600001/ui/base/cocoa/DEPS#new... ui/base/cocoa/DEPS:2: "+chrome/app/chrome_command_ids.h", ui/base can't depend on chrome. I think we will need to pass this in via the delegate interface. Perhaps IsLookUpAvailable() can take an int* for the command_id to use. Then I think it's OK to keep using the IDS_ versions of the other commands (i.e. those that appear in submenus rather than in the root level menu). However, we can't use `IsTextServicesCommandId` the same way, since we can't guarantee there's no overlap. However, this shouldn't be a big problem, since it's just the lookup command that the root menu should see. https://codereview.chromium.org/2164483006/diff/600001/ui/base/cocoa/text_ser... File ui/base/cocoa/text_services_context_menu.cc (right): https://codereview.chromium.org/2164483006/diff/600001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:87: void TextServicesContextMenu::AppendToContextMenu(SimpleMenuModel* model) { we can perhaps just pass in |index|? (see below) https://codereview.chromium.org/2164483006/diff/600001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:96: int index = model->GetIndexOfCommandId(IDC_SPELLCHECK_ADD_TO_DICTIONARY); which means this is hard to fix (i.e. if we can't depend on chrome). Another thing to try might be to keep both RendererContextMenu and the TextfieldContextMenu responsible for handling the "lookup" command. i.e. TextServicesContextMenu only adds submenus. I think this will remove the need for IsTextServicesCommand(..) too
PTAL https://codereview.chromium.org/2164483006/diff/600001/content/browser/render... File content/browser/renderer_host/render_widget_host_view_mac.mm (right): https://codereview.chromium.org/2164483006/diff/600001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:3392: base::scoped_nsobject<NSString> text(SysUTF16ToNSString(str)); On 2016/12/19 07:41:21, tapted wrote: > This might be a refcounting bug (nsobject expects a retained object, but > SysUTF16ToNSString will return an autoreleased one). > > I think we can just get rid of |text|, and pass SysUTF16ToNSString(str) on to > the setString: arg in the return statement. Done. https://codereview.chromium.org/2164483006/diff/600001/ui/base/cocoa/DEPS File ui/base/cocoa/DEPS (right): https://codereview.chromium.org/2164483006/diff/600001/ui/base/cocoa/DEPS#new... ui/base/cocoa/DEPS:2: "+chrome/app/chrome_command_ids.h", On 2016/12/19 07:41:21, tapted wrote: > ui/base can't depend on chrome. I think we will need to pass this in via the > delegate interface. > > Perhaps IsLookUpAvailable() can take an int* for the command_id to use. > > Then I think it's OK to keep using the IDS_ versions of the other commands (i.e. > those that appear in submenus rather than in the root level menu). > > However, we can't use `IsTextServicesCommandId` the same way, since we can't > guarantee there's no overlap. However, this shouldn't be a big problem, since > it's just the lookup command that the root menu should see. That works too. I think we should just take lookup out completely, since the code would be a bit cleaner too https://codereview.chromium.org/2164483006/diff/600001/ui/base/cocoa/text_ser... File ui/base/cocoa/text_services_context_menu.cc (right): https://codereview.chromium.org/2164483006/diff/600001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:87: void TextServicesContextMenu::AppendToContextMenu(SimpleMenuModel* model) { On 2016/12/19 07:41:21, tapted wrote: > we can perhaps just pass in |index|? (see below) I think it's better to just get rid of look up from TextServicesContextMenu. https://codereview.chromium.org/2164483006/diff/600001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:96: int index = model->GetIndexOfCommandId(IDC_SPELLCHECK_ADD_TO_DICTIONARY); On 2016/12/19 07:41:21, tapted wrote: > which means this is hard to fix (i.e. if we can't depend on chrome). > > Another thing to try might be to keep both RendererContextMenu and the > TextfieldContextMenu responsible for handling the "lookup" command. > > i.e. TextServicesContextMenu only adds submenus. > > I think this will remove the need for IsTextServicesCommand(..) too > Sounds good, let's just make it add only submenus
https://codereview.chromium.org/2164483006/diff/660001/chrome/browser/ui/coco... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm (right): https://codereview.chromium.org/2164483006/diff/660001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:248: if (text_services_context_menu_.IsTextServicesCommandId(command_id)) I think this isn't needed now (text services commands should go straight to the submenu?) https://codereview.chromium.org/2164483006/diff/660001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:257: if (text_services_context_menu_.IsTextServicesCommandId(command_id)) same here, and below https://codereview.chromium.org/2164483006/diff/660001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:261: else nit: "no else after return" - https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md... . same below https://codereview.chromium.org/2164483006/diff/660001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:296: menu_model_.InsertSeparatorAt(index + 1, ui::NORMAL_SEPARATOR); I don't think this will be the same due to postfix increment - just |index|? https://codereview.chromium.org/2164483006/diff/660001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:341: bool RenderViewContextMenuMac::IsTextDirectionEnabled( nit: method order should match the header https://codereview.chromium.org/2164483006/diff/660001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:345: return params_.writing_direction_default & nit: I think this needs a private helper method: int RenderViewContextMenuMac::BiDiParamsForDirection(base::i18n::TextDirection direction) { switch (direction): case base::i18n::TextDirection::UNKNOWN_DIRECTION: return params_.writing_direction_default; etc. Then just do return BiDiParamsForDirection(direction) & blink::WebContextMenuData::CheckableMenuItemEnabled; here and return BiDiParamsForDirection(direction) & blink::WebContextMenuData::CheckableMenuItemChecked; below https://codereview.chromium.org/2164483006/diff/660001/content/public/browser... File content/public/browser/render_widget_host_view.h (right): https://codereview.chromium.org/2164483006/diff/660001/content/public/browser... content/public/browser/render_widget_host_view.h:188: // Tells the view to speak the currently selected text. this comment should be updated to also say. "If there is no selection, reads everything." https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... File ui/base/cocoa/text_services_context_menu.cc (right): https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:20: SpeechChannel speechChannel; speechChannel -> g_speech_channel https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:42: ////////////////////////////////////////////////////////////////// nit: I wouldn't worry about this style of comments - it's used for really big classes, but here it's fine to omit. same below https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:51: // Add items to the speech submenu. nit: submenu -> submenu model. Same below. Or I think we could also just omit this comments. https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:58: bidi_submenu_model_.AddCheckItem( AddCheckItemWithStringId ? https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:88: if (printable_selection_text.empty()) Hmmm - it looks like we can still speak when there is no selection, but only when selecting from the Edit menu. But does this mean we need OnSpeakRequested()? i.e. instead of delegate_->OnSpeakRequested(); can we just do SpeakText(delegate_->GetSelectedText()) https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:93: model->AddSubMenu(IDS_SPEECH_MAC, l10n_util::GetStringUTF16(IDS_SPEECH_MAC), AddSubMenuWithStringId ? https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:98: model->AddSubMenu( AddSubMenuWithStringId ? https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... File ui/base/cocoa/text_services_context_menu.h (right): https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:16: // This class is used to append and handle the Speech and BiDi submenu to the nit: submenu to the -> submenu for the https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:52: // Appends editable items to the context menu. Appends items to the context menu applicable to editable content. https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:56: bool IsTextServicesCommandId(int command_id) const; (I think we can delete this) https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:59: void ExecuteCommand(int command_id, int event_flags) override; nit: this order should match the order of SimpleMenuModel::Delegate (i.e. ExecuteCommand last). don't forget to update .cc too https://codereview.chromium.org/2164483006/diff/660001/ui/gfx/decorated_text_... File ui/gfx/decorated_text_mac.mm (right): https://codereview.chromium.org/2164483006/diff/660001/ui/gfx/decorated_text_... ui/gfx/decorated_text_mac.mm:5: #include "ui/gfx/decorated_text_mac.h" nit: import https://codereview.chromium.org/2164483006/diff/660001/ui/views/cocoa/bridged... File ui/views/cocoa/bridged_content_view.mm (right): https://codereview.chromium.org/2164483006/diff/660001/ui/views/cocoa/bridged... ui/views/cocoa/bridged_content_view.mm:26: #include "ui/gfx/decorated_text_mac.h" nit: import https://codereview.chromium.org/2164483006/diff/660001/ui/views/cocoa/bridged... ui/views/cocoa/bridged_content_view.mm:234: // TODO(spqchan): Implement support with the Speech submenu is the main menu. is -> in https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/text... File ui/views/controls/textfield/textfield.cc (right): https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/text... ui/views/controls/textfield/textfield.cc:1188: if (text_services_context_menu_ && These changes might no longer be needed https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... File ui/views/controls/views_text_services_context_menu.h (right): https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu.h:35: virtual void ExecuteCommand(int command_id, int event_flags) = 0; nit: reorder to match https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... File ui/views/controls/views_text_services_context_menu_mac.mm (right): https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:4: #import <Cocoa/Cocoa.h> nit: blank line before https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:11: #include "ui/gfx/decorated_text_mac.h" nit: import https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:14: #include "ui/views/controls/views_text_services_context_menu.h" I think you can put this one first (before Cocoa) https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:23: int kLookupMenuIndex = 0; constexpr https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:38: // ViewTextServiceContextMenu: Service -> Services https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:40: void ExecuteCommand(int command_id, int event_flags) override; nit: reorder https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:57: // The view associated with the menu. Weak. add "Owns |this|." https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:79: client_->GetDecoratedTextAndBaselineFromSelection(&text, &baseline_point); check return value? https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:121: gfx::Range range; I think client_->GetSelectedText() will work now https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:157: direction == base::i18n::TextDirection::LEFT_TO_RIGHT I think the `TextDirection::` part of this is redundant. So this is just doing `text_direction = direction`. There might be other places in the CL with a redundant `TextDirection::` part - they should be removed too
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
I made some changes according to your review and is heading out for the holiday. I haven't had the chance to review my patch, but I'll look over it when I get back in January. I'll let me know once it's ready. Anyway, happy holidays :) Thanks for looking over this! https://codereview.chromium.org/2164483006/diff/660001/chrome/browser/ui/coco... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm (right): https://codereview.chromium.org/2164483006/diff/660001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:248: if (text_services_context_menu_.IsTextServicesCommandId(command_id)) On 2016/12/21 11:20:25, tapted wrote: > I think this isn't needed now (text services commands should go straight to the > submenu?) Done. https://codereview.chromium.org/2164483006/diff/660001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:257: if (text_services_context_menu_.IsTextServicesCommandId(command_id)) On 2016/12/21 11:20:26, tapted wrote: > same here, and below Done. https://codereview.chromium.org/2164483006/diff/660001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:261: else On 2016/12/21 11:20:26, tapted wrote: > nit: "no else after return" - > https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md... > . same below Done. https://codereview.chromium.org/2164483006/diff/660001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:296: menu_model_.InsertSeparatorAt(index + 1, ui::NORMAL_SEPARATOR); On 2016/12/21 11:20:26, tapted wrote: > I don't think this will be the same due to postfix increment - just |index|? Done. https://codereview.chromium.org/2164483006/diff/660001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:341: bool RenderViewContextMenuMac::IsTextDirectionEnabled( On 2016/12/21 11:20:25, tapted wrote: > nit: method order should match the header Done. https://codereview.chromium.org/2164483006/diff/660001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:345: return params_.writing_direction_default & On 2016/12/21 11:20:26, tapted wrote: > nit: I think this needs a private helper method: > > int RenderViewContextMenuMac::BiDiParamsForDirection(base::i18n::TextDirection > direction) { > switch (direction): > case base::i18n::TextDirection::UNKNOWN_DIRECTION: > return params_.writing_direction_default; > etc. > > Then just do > > return BiDiParamsForDirection(direction) & > blink::WebContextMenuData::CheckableMenuItemEnabled; > > here and > > return BiDiParamsForDirection(direction) & > blink::WebContextMenuData::CheckableMenuItemChecked; > > below Done. https://codereview.chromium.org/2164483006/diff/660001/content/public/browser... File content/public/browser/render_widget_host_view.h (right): https://codereview.chromium.org/2164483006/diff/660001/content/public/browser... content/public/browser/render_widget_host_view.h:188: // Tells the view to speak the currently selected text. On 2016/12/21 11:20:26, tapted wrote: > this comment should be updated to also say. "If there is no selection, reads > everything." Done. https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... File ui/base/cocoa/text_services_context_menu.cc (right): https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:20: SpeechChannel speechChannel; On 2016/12/21 11:20:26, tapted wrote: > speechChannel -> g_speech_channel Done. Quick question, why the g_? https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:42: ////////////////////////////////////////////////////////////////// On 2016/12/21 11:20:26, tapted wrote: > nit: I wouldn't worry about this style of comments - it's used for really big > classes, but here it's fine to omit. same below Done. https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:51: // Add items to the speech submenu. On 2016/12/21 11:20:26, tapted wrote: > nit: submenu -> submenu model. Same below. Or I think we could also just omit > this comments. Done. https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:58: bidi_submenu_model_.AddCheckItem( On 2016/12/21 11:20:26, tapted wrote: > AddCheckItemWithStringId ? Done. https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:88: if (printable_selection_text.empty()) On 2016/12/21 11:20:26, tapted wrote: > Hmmm - it looks like we can still speak when there is no selection, but only > when selecting from the Edit menu. But does this mean we need > OnSpeakRequested()? i.e. instead of > > delegate_->OnSpeakRequested(); > > can we just do > > SpeakText(delegate_->GetSelectedText()) We still need OnSpeakRequested() because if nothing is selected, then the host view will send an async request to retrieve all of the text. https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:93: model->AddSubMenu(IDS_SPEECH_MAC, l10n_util::GetStringUTF16(IDS_SPEECH_MAC), On 2016/12/21 11:20:26, tapted wrote: > AddSubMenuWithStringId ? Done. https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:98: model->AddSubMenu( On 2016/12/21 11:20:26, tapted wrote: > AddSubMenuWithStringId ? Done. https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... File ui/base/cocoa/text_services_context_menu.h (right): https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:16: // This class is used to append and handle the Speech and BiDi submenu to the On 2016/12/21 11:20:26, tapted wrote: > nit: submenu to the -> submenu for the Done. https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:52: // Appends editable items to the context menu. On 2016/12/21 11:20:26, tapted wrote: > Appends items to the context menu applicable to editable content. Done. https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:56: bool IsTextServicesCommandId(int command_id) const; On 2016/12/21 11:20:26, tapted wrote: > (I think we can delete this) Done. https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.h:59: void ExecuteCommand(int command_id, int event_flags) override; On 2016/12/21 11:20:27, tapted wrote: > nit: this order should match the order of SimpleMenuModel::Delegate (i.e. > ExecuteCommand last). don't forget to update .cc too Done. https://codereview.chromium.org/2164483006/diff/660001/ui/gfx/decorated_text_... File ui/gfx/decorated_text_mac.mm (right): https://codereview.chromium.org/2164483006/diff/660001/ui/gfx/decorated_text_... ui/gfx/decorated_text_mac.mm:5: #include "ui/gfx/decorated_text_mac.h" On 2016/12/21 11:20:27, tapted wrote: > nit: import Done. https://codereview.chromium.org/2164483006/diff/660001/ui/views/cocoa/bridged... File ui/views/cocoa/bridged_content_view.mm (right): https://codereview.chromium.org/2164483006/diff/660001/ui/views/cocoa/bridged... ui/views/cocoa/bridged_content_view.mm:26: #include "ui/gfx/decorated_text_mac.h" On 2016/12/21 11:20:27, tapted wrote: > nit: import Done. https://codereview.chromium.org/2164483006/diff/660001/ui/views/cocoa/bridged... ui/views/cocoa/bridged_content_view.mm:234: // TODO(spqchan): Implement support with the Speech submenu is the main menu. On 2016/12/21 11:20:27, tapted wrote: > is -> in Done. https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/text... File ui/views/controls/textfield/textfield.cc (right): https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/text... ui/views/controls/textfield/textfield.cc:1188: if (text_services_context_menu_ && On 2016/12/21 11:20:27, tapted wrote: > These changes might no longer be needed This is needed since ViewsTextServicesContextMenu handles lookup. https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... File ui/views/controls/views_text_services_context_menu.h (right): https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu.h:35: virtual void ExecuteCommand(int command_id, int event_flags) = 0; On 2016/12/21 11:20:27, tapted wrote: > nit: reorder to match Done. https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... File ui/views/controls/views_text_services_context_menu_mac.mm (right): https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:4: #import <Cocoa/Cocoa.h> On 2016/12/21 11:20:27, tapted wrote: > nit: blank line before Done. https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:11: #include "ui/gfx/decorated_text_mac.h" On 2016/12/21 11:20:27, tapted wrote: > nit: import Done. https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:14: #include "ui/views/controls/views_text_services_context_menu.h" On 2016/12/21 11:20:27, tapted wrote: > I think you can put this one first (before Cocoa) Done. https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:23: int kLookupMenuIndex = 0; On 2016/12/21 11:20:27, tapted wrote: > constexpr Done. https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:38: // ViewTextServiceContextMenu: On 2016/12/21 11:20:27, tapted wrote: > Service -> Services Done. https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:40: void ExecuteCommand(int command_id, int event_flags) override; On 2016/12/21 11:20:27, tapted wrote: > nit: reorder Done. https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:57: // The view associated with the menu. Weak. On 2016/12/21 11:20:27, tapted wrote: > add "Owns |this|." Done. https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:79: client_->GetDecoratedTextAndBaselineFromSelection(&text, &baseline_point); On 2016/12/21 11:20:27, tapted wrote: > check return value? Done. https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:121: gfx::Range range; On 2016/12/21 11:20:27, tapted wrote: > I think client_->GetSelectedText() will work now Done. https://codereview.chromium.org/2164483006/diff/660001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:157: direction == base::i18n::TextDirection::LEFT_TO_RIGHT On 2016/12/21 11:20:27, tapted wrote: > I think the `TextDirection::` part of this is redundant. So this is just doing > `text_direction = direction`. There might be other places in the CL with a > redundant `TextDirection::` part - they should be removed too Done.
I made some changes according to your review and is heading out for the holiday. I haven't had the chance to review my patch, but I'll look over it when I get back in January. I'll let you know once it's ready. Anyway, happy holidays :) Thanks for looking over this!
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: ios-device-xcode-clang on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-device-xcode-...) ios-simulator-xcode-clang on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator-xco...) mac_chromium_compile_dbg_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_comp...) mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
Have a great holiday! Yeah no rush - I'm away until Jan 3rd. https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... File ui/base/cocoa/text_services_context_menu.cc (right): https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:20: SpeechChannel speechChannel; On 2016/12/21 22:00:13, spqchan (OOO until Jan 9) wrote: > On 2016/12/21 11:20:26, tapted wrote: > > speechChannel -> g_speech_channel > > Done. Quick question, why the g_? This is to make it clear that we're declaring/referencing a global variable. (i.e. even though it has internal linkage and isn't "global" in that sense, the g_ makes it clear when referencing it that there is only one object). It's commonly used (see e.g. `git grep '[^ ].* g_.*=.*;' -- '*.cc'`. There's no style guideline for naming global variables, but this doesn't break any rules either :) https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:88: if (printable_selection_text.empty()) On 2016/12/21 22:00:13, spqchan (OOO until Jan 9) wrote: > On 2016/12/21 11:20:26, tapted wrote: > > Hmmm - it looks like we can still speak when there is no selection, but only > > when selecting from the Edit menu. But does this mean we need > > OnSpeakRequested()? i.e. instead of > > > > delegate_->OnSpeakRequested(); > > > > can we just do > > > > SpeakText(delegate_->GetSelectedText()) > > We still need OnSpeakRequested() because if nothing is selected, then the host > view will send an async request to retrieve all of the text. But the logic here will not add the menu item if nothing is selected, so OnSpeakRequested() _can't_ be called if nothing is selected :) The async request only comes into play when selecting Edit->Speech->Start Speaking. So we still need a public `SpeakText` so that -[RWHVC startSpeaking:] can call it. However, the right-click context menu shouldn't need it.
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: ios-device on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-device/builds...) ios-device-xcode-clang on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-device-xcode-...) ios-simulator on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator/bui...) ios-simulator-xcode-clang on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator-xco...)
Patchset #35 (id:720001) has been deleted
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...) mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_compile_dbg_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_asan_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...) linux_chromium_compile_dbg_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...) mac_chromium_compile_dbg_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_comp...) mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
Patchset #37 (id:780001) has been deleted
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Rebased and fixed the tests. PTAL thanks :) https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... File ui/base/cocoa/text_services_context_menu.cc (right): https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:20: SpeechChannel speechChannel; On 2016/12/21 22:13:16, tapted wrote: > On 2016/12/21 22:00:13, spqchan (OOO until Jan 9) wrote: > > On 2016/12/21 11:20:26, tapted wrote: > > > speechChannel -> g_speech_channel > > > > Done. Quick question, why the g_? > > This is to make it clear that we're declaring/referencing a global variable. > (i.e. even though it has internal linkage and isn't "global" in that sense, the > g_ makes it clear when referencing it that there is only one object). It's > commonly used (see e.g. `git grep '[^ ].* g_.*=.*;' -- '*.cc'`. There's no style > guideline for naming global variables, but this doesn't break any rules either > :) Gotcha, thanks! https://codereview.chromium.org/2164483006/diff/660001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:88: if (printable_selection_text.empty()) On 2016/12/21 22:13:15, tapted wrote: > On 2016/12/21 22:00:13, spqchan (OOO until Jan 9) wrote: > > On 2016/12/21 11:20:26, tapted wrote: > > > Hmmm - it looks like we can still speak when there is no selection, but only > > > when selecting from the Edit menu. But does this mean we need > > > OnSpeakRequested()? i.e. instead of > > > > > > delegate_->OnSpeakRequested(); > > > > > > can we just do > > > > > > SpeakText(delegate_->GetSelectedText()) > > > > We still need OnSpeakRequested() because if nothing is selected, then the host > > view will send an async request to retrieve all of the text. > > But the logic here will not add the menu item if nothing is selected, so > OnSpeakRequested() _can't_ be called if nothing is selected :) > > The async request only comes into play when selecting Edit->Speech->Start > Speaking. So we still need a public `SpeakText` so that -[RWHVC startSpeaking:] > can call it. However, the right-click context menu shouldn't need it. Doh, I see what you mean. Removed it :)
basically lg - worth looping in some OWNERS. Probably avi for the src/content stuff, and I'd recommend msw for the render_text and views/controls changes. We maybe want to change the prefix from IDS_CONTENT to something else, since they are moving out of src/content to src/ui - but that's perhaps good for a follow-up https://codereview.chromium.org/2164483006/diff/850001/chrome/browser/ui/coco... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h (right): https://codereview.chromium.org/2164483006/diff/850001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h:28: // SimpleMenuModel::Delegate:: nit: :: -> : https://codereview.chromium.org/2164483006/diff/850001/content/browser/render... File content/browser/renderer_host/render_widget_host_view_mac.mm (right): https://codereview.chromium.org/2164483006/diff/850001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:1095: if (![NSApp respondsToSelector:@selector(speakString:)]) ooh - I think this is no longer needed, since we're using the C APIs https://codereview.chromium.org/2164483006/diff/850001/ui/strings/ui_strings.grd File ui/strings/ui_strings.grd (right): https://codereview.chromium.org/2164483006/diff/850001/ui/strings/ui_strings.... ui/strings/ui_strings.grd:314: </if> can the stuff below be in the <if expr="is_macosx"> above as well? https://codereview.chromium.org/2164483006/diff/850001/ui/views/cocoa/bridged... File ui/views/cocoa/bridged_content_view.mm (right): https://codereview.chromium.org/2164483006/diff/850001/ui/views/cocoa/bridged... ui/views/cocoa/bridged_content_view.mm:235: // TODO(spqchan): Implement support with the Speech submenu is in the main nit: with -> when https://codereview.chromium.org/2164483006/diff/850001/ui/views/controls/text... File ui/views/controls/textfield/textfield_unittest.cc (right): https://codereview.chromium.org/2164483006/diff/850001/ui/views/controls/text... ui/views/controls/textfield/textfield_unittest.cc:3063: TEST_F(TextfieldTest, TextServicesContextMenuTextDirectionTest) { nit: add a comment explaining the test https://codereview.chromium.org/2164483006/diff/850001/ui/views/controls/text... ui/views/controls/textfield/textfield_unittest.cc:3073: test_api_->UpdateContextMenu(); can we add a test that verifies the context menu resets/updates when the selection changes? That seems like a subtle thing that could break https://codereview.chromium.org/2164483006/diff/850001/ui/views/controls/view... File ui/views/controls/views_text_services_context_menu_mac.mm (right): https://codereview.chromium.org/2164483006/diff/850001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:24: const int kLookupMenuIndex = 0; nit: constexpr
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromium_presubmit on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presub...) ios-device on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-device/builds...) ios-device-xcode-clang on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-device-xcode-...) ios-simulator on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator/bui...) ios-simulator-xcode-clang on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator-xco...) mac_chromium_compile_dbg_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_comp...)
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: android_n5x_swarming_rel on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_n5x_...)
spqchan@chromium.org changed reviewers: + asvitkine@chromium.org, msw@chromium.org, nasko@chromium.org
Thanks! Addressed your comments. It looks like avi is OOO until February + msw Please review render_text and views/controls changes + asvitkine Please review the mac code in content/browser/renderer_host/ + nasko Please review content/browser/frame_host Apologies in advance if I added you incorrectly into this C :) https://codereview.chromium.org/2164483006/diff/850001/chrome/browser/ui/coco... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h (right): https://codereview.chromium.org/2164483006/diff/850001/chrome/browser/ui/coco... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h:28: // SimpleMenuModel::Delegate:: On 2017/01/13 21:37:33, tapted wrote: > nit: :: -> : Done. https://codereview.chromium.org/2164483006/diff/850001/content/browser/render... File content/browser/renderer_host/render_widget_host_view_mac.mm (right): https://codereview.chromium.org/2164483006/diff/850001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.mm:1095: if (![NSApp respondsToSelector:@selector(speakString:)]) On 2017/01/13 21:37:33, tapted wrote: > ooh - I think this is no longer needed, since we're using the C APIs Done. https://codereview.chromium.org/2164483006/diff/850001/ui/strings/ui_strings.grd File ui/strings/ui_strings.grd (right): https://codereview.chromium.org/2164483006/diff/850001/ui/strings/ui_strings.... ui/strings/ui_strings.grd:314: </if> On 2017/01/13 21:37:33, tapted wrote: > can the stuff below be in the <if expr="is_macosx"> above as well? I don't think so, they're not Mac exclusive https://codereview.chromium.org/2164483006/diff/850001/ui/views/cocoa/bridged... File ui/views/cocoa/bridged_content_view.mm (right): https://codereview.chromium.org/2164483006/diff/850001/ui/views/cocoa/bridged... ui/views/cocoa/bridged_content_view.mm:235: // TODO(spqchan): Implement support with the Speech submenu is in the main On 2017/01/13 21:37:33, tapted wrote: > nit: with -> when Done. https://codereview.chromium.org/2164483006/diff/850001/ui/views/controls/text... File ui/views/controls/textfield/textfield_unittest.cc (right): https://codereview.chromium.org/2164483006/diff/850001/ui/views/controls/text... ui/views/controls/textfield/textfield_unittest.cc:3063: TEST_F(TextfieldTest, TextServicesContextMenuTextDirectionTest) { On 2017/01/13 21:37:33, tapted wrote: > nit: add a comment explaining the test Done. https://codereview.chromium.org/2164483006/diff/850001/ui/views/controls/text... ui/views/controls/textfield/textfield_unittest.cc:3073: test_api_->UpdateContextMenu(); On 2017/01/13 21:37:33, tapted wrote: > can we add a test that verifies the context menu resets/updates when the > selection changes? That seems like a subtle thing that could break Done. https://codereview.chromium.org/2164483006/diff/850001/ui/views/controls/view... File ui/views/controls/views_text_services_context_menu_mac.mm (right): https://codereview.chromium.org/2164483006/diff/850001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:24: const int kLookupMenuIndex = 0; On 2017/01/13 21:37:33, tapted wrote: > nit: constexpr Done.
mostly minor comments https://codereview.chromium.org/2164483006/diff/890001/ui/gfx/decorated_text_... File ui/gfx/decorated_text_mac.h (right): https://codereview.chromium.org/2164483006/diff/890001/ui/gfx/decorated_text_... ui/gfx/decorated_text_mac.h:16: // Returns a NSAttributedString from |decorated_text|. optional nit: I'd potentially put this in decorated_text.h as DecoratedText::ToNSAttributedString() like CGPoint stuff in ui/gfx/point.* https://codereview.chromium.org/2164483006/diff/890001/ui/gfx/render_text.h File ui/gfx/render_text.h (right): https://codereview.chromium.org/2164483006/diff/890001/ui/gfx/render_text.h#n... ui/gfx/render_text.h:530: // the baseline point of the leftmost glyph of the |word| in the view's optional nit: |word| is not an identifier here (or below); use "of the word" here and "of the range" below. https://codereview.chromium.org/2164483006/diff/890001/ui/gfx/render_text_uni... File ui/gfx/render_text_unittest.cc (right): https://codereview.chromium.org/2164483006/diff/890001/ui/gfx/render_text_uni... ui/gfx/render_text_unittest.cc:4001: // Verify GetDecoratedWordAndBaselineAtPoint returns the correct baseline point Please add a basic test fixture for the new range-based function. https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/labe... File ui/views/controls/label.cc (right): https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/labe... ui/views/controls/label.cc:654: return false; Should this be implemented in this CL, or should you leave a TODO & bug? https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/text... File ui/views/controls/textfield/textfield_unittest.cc (right): https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/text... ui/views/controls/textfield/textfield_unittest.cc:3117: #endif nit: add a comment: "#endif // OS_MACOSX" and add a blank line above. https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... File ui/views/controls/views_text_services_context_menu.h (right): https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu.h:8: #include <memory> nit: remove https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu.h:11: #include "ui/views/views_export.h" nit: remove if export isn't needed https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu.h:27: // Creates a ViewsTextContextMenu object. nit: ViewsTextServicesContextMenu https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu.h:42: virtual bool IsTextDirectionItemChecked( nit: IsTextDirectionItemCheckedForTest[ing] https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... File ui/views/controls/views_text_services_context_menu_mac.mm (right): https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:9: #include "ui/base/cocoa/text_services_context_menu.h" nit: I think this belongs at the top (like textfield.h in textfield.cc) https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:24: constexpr int kLookupMenuIndex = 0; optional nit: put this in the ctor (only used there) https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:33: ViewsTextServicesContextMenuMac(ui::SimpleMenuModel* menu, Textfield* client); optional nit: define all these methods inline https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:135: switch (direction) { optional nit: return direction != base::i18n::UNKNOWN_DIRECTION && client_->GetTextDirection() == direction; https://codereview.chromium.org/2164483006/diff/890001/ui/views/word_lookup_c... File ui/views/word_lookup_client.h (right): https://codereview.chromium.org/2164483006/diff/890001/ui/views/word_lookup_c... ui/views/word_lookup_client.h:23: // correspond to the baseline point of the leftmost glyph of the |word| in the ditto nit about |word| here and below.
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromeos_daisy_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_daisy_...) linux_chromium_chromeos_ozone_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
content/ changes seem mostly moving code around. I do have one question though. https://codereview.chromium.org/2164483006/diff/950001/content/browser/frame_... File content/browser/frame_host/render_widget_host_view_guest.cc (right): https://codereview.chromium.org/2164483006/diff/950001/content/browser/frame_... content/browser/frame_host/render_widget_host_view_guest.cc:474: void RenderWidgetHostViewGuest::SpeakSelection() { Why does this method stay around and the others are removed? I'd expect they all go together.
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_site_isolation on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_site_isol...)
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
PTAL, I added a test and addressed the comments from msw and nasko https://codereview.chromium.org/2164483006/diff/890001/ui/gfx/decorated_text_... File ui/gfx/decorated_text_mac.h (right): https://codereview.chromium.org/2164483006/diff/890001/ui/gfx/decorated_text_... ui/gfx/decorated_text_mac.h:16: // Returns a NSAttributedString from |decorated_text|. On 2017/01/26 20:59:16, msw wrote: > optional nit: I'd potentially put this in decorated_text.h as > DecoratedText::ToNSAttributedString() like CGPoint stuff in ui/gfx/point.* Acknowledged. https://codereview.chromium.org/2164483006/diff/890001/ui/gfx/render_text.h File ui/gfx/render_text.h (right): https://codereview.chromium.org/2164483006/diff/890001/ui/gfx/render_text.h#n... ui/gfx/render_text.h:530: // the baseline point of the leftmost glyph of the |word| in the view's On 2017/01/26 20:59:16, msw wrote: > optional nit: |word| is not an identifier here (or below); use "of the word" > here and "of the range" below. Done. https://codereview.chromium.org/2164483006/diff/890001/ui/gfx/render_text_uni... File ui/gfx/render_text_unittest.cc (right): https://codereview.chromium.org/2164483006/diff/890001/ui/gfx/render_text_uni... ui/gfx/render_text_unittest.cc:4001: // Verify GetDecoratedWordAndBaselineAtPoint returns the correct baseline point On 2017/01/26 20:59:16, msw wrote: > Please add a basic test fixture for the new range-based function. Done. https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/labe... File ui/views/controls/label.cc (right): https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/labe... ui/views/controls/label.cc:654: return false; On 2017/01/26 20:59:16, msw wrote: > Should this be implemented in this CL, or should you leave a TODO & bug? Implemented https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/text... File ui/views/controls/textfield/textfield_unittest.cc (right): https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/text... ui/views/controls/textfield/textfield_unittest.cc:3117: #endif On 2017/01/26 20:59:16, msw wrote: > nit: add a comment: "#endif // OS_MACOSX" and add a blank line above. Done. https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... File ui/views/controls/views_text_services_context_menu.h (right): https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu.h:8: #include <memory> On 2017/01/26 20:59:16, msw wrote: > nit: remove I need it for std::unique_ptr. Should I use something else? https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu.h:11: #include "ui/views/views_export.h" On 2017/01/26 20:59:16, msw wrote: > nit: remove if export isn't needed Done. https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu.h:27: // Creates a ViewsTextContextMenu object. On 2017/01/26 20:59:16, msw wrote: > nit: ViewsTextServicesContextMenu Done. https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu.h:42: virtual bool IsTextDirectionItemChecked( On 2017/01/26 20:59:16, msw wrote: > nit: IsTextDirectionItemCheckedForTest[ing] Done. https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... File ui/views/controls/views_text_services_context_menu_mac.mm (right): https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:9: #include "ui/base/cocoa/text_services_context_menu.h" On 2017/01/26 20:59:16, msw wrote: > nit: I think this belongs at the top (like textfield.h in textfield.cc) Done. https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:24: constexpr int kLookupMenuIndex = 0; On 2017/01/26 20:59:16, msw wrote: > optional nit: put this in the ctor (only used there) Done. https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:33: ViewsTextServicesContextMenuMac(ui::SimpleMenuModel* menu, Textfield* client); On 2017/01/26 20:59:16, msw wrote: > optional nit: define all these methods inline Done. https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:135: switch (direction) { On 2017/01/26 20:59:16, msw wrote: > optional nit: return direction != base::i18n::UNKNOWN_DIRECTION && > client_->GetTextDirection() == direction; Done. https://codereview.chromium.org/2164483006/diff/890001/ui/views/word_lookup_c... File ui/views/word_lookup_client.h (right): https://codereview.chromium.org/2164483006/diff/890001/ui/views/word_lookup_c... ui/views/word_lookup_client.h:23: // correspond to the baseline point of the leftmost glyph of the |word| in the On 2017/01/26 20:59:16, msw wrote: > ditto nit about |word| here and below. Done. https://codereview.chromium.org/2164483006/diff/950001/content/browser/frame_... File content/browser/frame_host/render_widget_host_view_guest.cc (right): https://codereview.chromium.org/2164483006/diff/950001/content/browser/frame_... content/browser/frame_host/render_widget_host_view_guest.cc:474: void RenderWidgetHostViewGuest::SpeakSelection() { On 2017/01/31 15:37:29, nasko (very slow) wrote: > Why does this method stay around and the others are removed? I'd expect they all > go together. In Mac, there is a menu item in the main menu that lets you select "Speak Text". If nothing is selection, a message gets sent to the renderer to get all of the text in the web content. This is async, so we need the method in RenderWidgetHostView. IsSpeaking() and StopSpeaking() can be removed and handled in text_services_context_menu because they're not async.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_site_isolation on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_site_isol...)
In the future, you may find it helpful (and some reviewers will too), if you try to keep the number of patch sets that you upload to a minimum (or go back and delete ones that weren't actually used for review or important for tracking progress). 46 is a lot, and makes Rietveld a bit tough to use! https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... File ui/views/controls/views_text_services_context_menu.h (right): https://codereview.chromium.org/2164483006/diff/890001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu.h:8: #include <memory> On 2017/02/01 00:32:38, spqchan wrote: > On 2017/01/26 20:59:16, msw wrote: > > nit: remove > > I need it for std::unique_ptr. Should I use something else? Ah, I missed that; thanks for pointing it out. https://codereview.chromium.org/2164483006/diff/950001/ui/gfx/render_text_uni... File ui/gfx/render_text_unittest.cc (right): https://codereview.chromium.org/2164483006/diff/950001/ui/gfx/render_text_uni... ui/gfx/render_text_unittest.cc:4001: // Verify GetDecoratedWordAndBaselineAtRange returns the correct baseline point nit: GetDecoratedTextAndBaselineAtRange https://codereview.chromium.org/2164483006/diff/950001/ui/gfx/render_text_uni... ui/gfx/render_text_unittest.cc:4003: TEST_P(RenderTextHarfBuzzTest, GetDecoratedWordAndBaselineAtRange) { nit: GetDecoratedTextAndBaselineAtRange https://codereview.chromium.org/2164483006/diff/950001/ui/gfx/render_text_uni... ui/gfx/render_text_unittest.cc:4021: for (size_t i = 0; i < expected_text_1.text.length(); i++) { Can you do this without a loop, like: expected_text_1.attributes.push_back(CreateRangedAttribute(font_spans, 0, expected_text_1.text.length(), Font::Weight::NORMAL, UNDERLINE_MASK)); https://codereview.chromium.org/2164483006/diff/950001/ui/gfx/render_text_uni... ui/gfx/render_text_unittest.cc:4032: { Remove this block if you're not using SCOPED_TRACE https://codereview.chromium.org/2164483006/diff/950001/ui/gfx/render_text_uni... ui/gfx/render_text_unittest.cc:4040: expected_text_2.text = ASCIIToUTF16("boxfish"); It seems like the point of this new function is to handle ranges that don't exactly match a word (eg. multiple words, part of a word, parts of multiple words), am I right? If so, please modify one or both of your test cases to check a range that isn't exactly one word. https://codereview.chromium.org/2164483006/diff/950001/ui/gfx/render_text_uni... ui/gfx/render_text_unittest.cc:4041: for (size_t i = 0; i < expected_text_2.text.length(); i++) { Can you do this without a loop, like: expected_text_2.attributes.push_back(CreateRangedAttribute(font_spans, 0, expected_text_2.text.length(), Font::Weight::SEMIBOLD, ITALIC_MASK)); https://codereview.chromium.org/2164483006/diff/950001/ui/gfx/render_text_uni... ui/gfx/render_text_unittest.cc:4049: { Remove this block if you're not using SCOPED_TRACE https://codereview.chromium.org/2164483006/diff/950001/ui/views/controls/view... File ui/views/controls/views_text_services_context_menu_mac.mm (right): https://codereview.chromium.org/2164483006/diff/950001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:4: #include "ui/base/cocoa/text_services_context_menu.h" Darn, I'm sorry, but my earlier comment was wrong. This doesn't belong here; move it back down below ptr_util.h, and restore the blank line that was here, above views_text_services_context_menu.h (which is the correct top include)
Patchset #2 (id:20001) has been deleted
Patchset #2 (id:40001) has been deleted
Patchset #2 (id:60001) has been deleted
Patchset #2 (id:80001) has been deleted
Patchset #2 (id:100001) has been deleted
Patchset #31 (id:760001) has been deleted
Patchset #12 (id:320001) has been deleted
Patchset #5 (id:180001) has been deleted
Patchset #28 (id:740001) has been deleted
Patchset #15 (id:420001) has been deleted
Patchset #8 (id:260001) has been deleted
Patchset #10 (id:340001) has been deleted
Patchset #8 (id:280001) has been deleted
Patchset #9 (id:360001) has been deleted
Patchset #22 (id:700001) has been deleted
Patchset #2 (id:120001) has been deleted
Patchset #9 (id:400001) has been deleted
Patchset #22 (id:830001) has been deleted
Patchset #17 (id:640001) has been deleted
Patchset #8 (id:380001) has been deleted
Patchset #11 (id:500001) has been deleted
Patchset #17 (id:800001) has been deleted
Patchset #6 (id:240001) has been deleted
Patchset #21 (id:930001) has been deleted
Patchset #5 (id:220001) has been deleted
Patchset #7 (id:460001) has been deleted
Patchset #8 (id:560001) has been deleted
Patchset #7 (id:480001) has been deleted
Patchset #4 (id:200001) has been deleted
Patchset #15 (id:910001) has been deleted
Patchset #13 (id:870001) has been deleted
Patchset #4 (id:300001) has been deleted
Patchset #3 (id:160001) has been deleted
Patchset #9 (id:820001) has been deleted
Patchset #8 (id:680001) has been deleted
Patchset #6 (id:620001) has been deleted
https://codereview.chromium.org/2164483006/diff/970001/content/browser/render... File content/browser/renderer_host/render_widget_host_view_mac.h (right): https://codereview.chromium.org/2164483006/diff/970001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.h:485: // TODO(spqchan): Change |text| to be the type string16. Can you provide more context here? Why is string16 preferable? If it's to avoid some conversions - maybe the TODO should live where the conversions happen? https://codereview.chromium.org/2164483006/diff/970001/ui/base/cocoa/text_ser... File ui/base/cocoa/text_services_context_menu.cc (right): https://codereview.chromium.org/2164483006/diff/970001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:19: // The speech channel used for speaking. Can you expand comment to mention why it makes sense for this to be a global? https://codereview.chromium.org/2164483006/diff/970001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:68: NewSpeechChannel(nullptr, &g_speech_channel); What happens if g_speech_channel already exists? Should the OSErr return value of this be checked? Can there be test coverage of this code? I know it might be weird to have unit tests speaking stuff... but I think having tests the exercise the APIs we're using is preferred to the side effect of some stuff being spoken... https://codereview.chromium.org/2164483006/diff/970001/ui/views/controls/labe... File ui/views/controls/label.cc (right): https://codereview.chromium.org/2164483006/diff/970001/ui/views/controls/labe... ui/views/controls/label.cc:665: : false; Nit: This looks pretty ugly. Suggest a separate "if (!render_text)" statement with an early return. https://codereview.chromium.org/2164483006/diff/970001/ui/views/controls/text... File ui/views/controls/textfield/textfield_unittest.cc (right): https://codereview.chromium.org/2164483006/diff/970001/ui/views/controls/text... ui/views/controls/textfield/textfield_unittest.cc:3094: Nit: Remove empty line. https://codereview.chromium.org/2164483006/diff/970001/ui/views/controls/text... ui/views/controls/textfield/textfield_unittest.cc:3098: using base::i18n::TextDirection; Nit: Since you break line before you use this in this test, the extra namespace prefixes won't cause extra wrapping so I'd just spell things out in the test and remove this using. https://codereview.chromium.org/2164483006/diff/970001/ui/views/controls/text... ui/views/controls/textfield/textfield_unittest.cc:3130: Nit: Remove empty line. https://codereview.chromium.org/2164483006/diff/970001/ui/views/controls/text... ui/views/controls/textfield/textfield_unittest.cc:3131: #endif // OS_MACOSX defined(OS_MACOSX)
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Patchset #11 (id:990001) has been deleted
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
Patchset #11 (id:1010001) has been deleted
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
msw@, thanks of the heads up. I deleted the extra patches :) Addressed the comments from msw@ and asvitkine@. PTAL https://codereview.chromium.org/2164483006/diff/950001/ui/gfx/render_text_uni... File ui/gfx/render_text_unittest.cc (right): https://codereview.chromium.org/2164483006/diff/950001/ui/gfx/render_text_uni... ui/gfx/render_text_unittest.cc:4001: // Verify GetDecoratedWordAndBaselineAtRange returns the correct baseline point On 2017/02/01 01:52:28, msw wrote: > nit: GetDecoratedTextAndBaselineAtRange Done. https://codereview.chromium.org/2164483006/diff/950001/ui/gfx/render_text_uni... ui/gfx/render_text_unittest.cc:4003: TEST_P(RenderTextHarfBuzzTest, GetDecoratedWordAndBaselineAtRange) { On 2017/02/01 01:52:28, msw wrote: > nit: GetDecoratedTextAndBaselineAtRange Done. https://codereview.chromium.org/2164483006/diff/950001/ui/gfx/render_text_uni... ui/gfx/render_text_unittest.cc:4021: for (size_t i = 0; i < expected_text_1.text.length(); i++) { On 2017/02/01 01:52:28, msw wrote: > Can you do this without a loop, like: > expected_text_1.attributes.push_back(CreateRangedAttribute(font_spans, 0, > expected_text_1.text.length(), Font::Weight::NORMAL, UNDERLINE_MASK)); No, it's weird like that. You need to apply an attribute to every character on the text. https://codereview.chromium.org/2164483006/diff/950001/ui/gfx/render_text_uni... ui/gfx/render_text_unittest.cc:4032: { On 2017/02/01 01:52:28, msw wrote: > Remove this block if you're not using SCOPED_TRACE Done. https://codereview.chromium.org/2164483006/diff/950001/ui/gfx/render_text_uni... ui/gfx/render_text_unittest.cc:4040: expected_text_2.text = ASCIIToUTF16("boxfish"); On 2017/02/01 01:52:28, msw wrote: > It seems like the point of this new function is to handle ranges that don't > exactly match a word (eg. multiple words, part of a word, parts of multiple > words), am I right? If so, please modify one or both of your test cases to check > a range that isn't exactly one word. Sure thing, it now checks for both words https://codereview.chromium.org/2164483006/diff/950001/ui/gfx/render_text_uni... ui/gfx/render_text_unittest.cc:4041: for (size_t i = 0; i < expected_text_2.text.length(); i++) { On 2017/02/01 01:52:28, msw wrote: > Can you do this without a loop, like: > expected_text_2.attributes.push_back(CreateRangedAttribute(font_spans, 0, > expected_text_2.text.length(), Font::Weight::SEMIBOLD, ITALIC_MASK)); Ditto from above. https://codereview.chromium.org/2164483006/diff/950001/ui/gfx/render_text_uni... ui/gfx/render_text_unittest.cc:4049: { On 2017/02/01 01:52:28, msw wrote: > Remove this block if you're not using SCOPED_TRACE Done. https://codereview.chromium.org/2164483006/diff/950001/ui/views/controls/view... File ui/views/controls/views_text_services_context_menu_mac.mm (right): https://codereview.chromium.org/2164483006/diff/950001/ui/views/controls/view... ui/views/controls/views_text_services_context_menu_mac.mm:4: #include "ui/base/cocoa/text_services_context_menu.h" On 2017/02/01 01:52:29, msw wrote: > Darn, I'm sorry, but my earlier comment was wrong. This doesn't belong here; > move it back down below ptr_util.h, and restore the blank line that was here, > above views_text_services_context_menu.h (which is the correct top include) No worries :) https://codereview.chromium.org/2164483006/diff/970001/content/browser/render... File content/browser/renderer_host/render_widget_host_view_mac.h (right): https://codereview.chromium.org/2164483006/diff/970001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.h:485: // TODO(spqchan): Change |text| to be the type string16. On 2017/02/01 19:12:37, Alexei Svitkine (very slow) wrote: > Can you provide more context here? Why is string16 preferable? > > If it's to avoid some conversions - maybe the TODO should live where the > conversions happen? This is done to avoid some conversions, since selected_text always get converted from UTF16 to UTF8. Do you mean putting it in render_view_impl.cc? I kind of prefer putting it here but I don't feel strongly about it so if you want me to move it there, I can do that. https://codereview.chromium.org/2164483006/diff/970001/ui/base/cocoa/text_ser... File ui/base/cocoa/text_services_context_menu.cc (right): https://codereview.chromium.org/2164483006/diff/970001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:19: // The speech channel used for speaking. On 2017/02/01 19:12:37, Alexei Svitkine (very slow) wrote: > Can you expand comment to mention why it makes sense for this to be a global? Done. https://codereview.chromium.org/2164483006/diff/970001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:68: NewSpeechChannel(nullptr, &g_speech_channel); Whoops, that's a good point. I added a check for it. Currently it just created a new one but we can just reuse the old one I added a check for the OSErr return value too. I added a TODO for a test suite. I'm not sure if I'll be able to write unit tests for the speech stuff but I can give it a try. https://codereview.chromium.org/2164483006/diff/970001/ui/views/controls/labe... File ui/views/controls/label.cc (right): https://codereview.chromium.org/2164483006/diff/970001/ui/views/controls/labe... ui/views/controls/label.cc:665: : false; On 2017/02/01 19:12:37, Alexei Svitkine (very slow) wrote: > Nit: This looks pretty ugly. Suggest a separate "if (!render_text)" statement > with an early return. Done. https://codereview.chromium.org/2164483006/diff/970001/ui/views/controls/text... File ui/views/controls/textfield/textfield_unittest.cc (right): https://codereview.chromium.org/2164483006/diff/970001/ui/views/controls/text... ui/views/controls/textfield/textfield_unittest.cc:3094: On 2017/02/01 19:12:38, Alexei Svitkine (very slow) wrote: > Nit: Remove empty line. Done. https://codereview.chromium.org/2164483006/diff/970001/ui/views/controls/text... ui/views/controls/textfield/textfield_unittest.cc:3098: using base::i18n::TextDirection; On 2017/02/01 19:12:38, Alexei Svitkine (very slow) wrote: > Nit: Since you break line before you use this in this test, the extra namespace > prefixes won't cause extra wrapping so I'd just spell things out in the test and > remove this using. Done. https://codereview.chromium.org/2164483006/diff/970001/ui/views/controls/text... ui/views/controls/textfield/textfield_unittest.cc:3130: On 2017/02/01 19:12:37, Alexei Svitkine (very slow) wrote: > Nit: Remove empty line. Done. https://codereview.chromium.org/2164483006/diff/970001/ui/views/controls/text... ui/views/controls/textfield/textfield_unittest.cc:3131: #endif // OS_MACOSX On 2017/02/01 19:12:38, Alexei Svitkine (very slow) wrote: > defined(OS_MACOSX) Done.
https://codereview.chromium.org/2164483006/diff/970001/content/browser/render... File content/browser/renderer_host/render_widget_host_view_mac.h (right): https://codereview.chromium.org/2164483006/diff/970001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.h:485: // TODO(spqchan): Change |text| to be the type string16. On 2017/02/02 20:35:05, spqchan wrote: > On 2017/02/01 19:12:37, Alexei Svitkine (very slow) wrote: > > Can you provide more context here? Why is string16 preferable? > > > > If it's to avoid some conversions - maybe the TODO should live where the > > conversions happen? > > This is done to avoid some conversions, since selected_text always get converted > from UTF16 to UTF8. > Do you mean putting it in render_view_impl.cc? I kind of prefer putting it here > but I don't feel strongly about it so if you want me to move it there, I can do > that. If you keep it here, expand the comment to refer to the conversion in question so that it's clear *why*. (But yeah my suggestion was to put in .cc so it's clear the conversion it's talking about.) https://codereview.chromium.org/2164483006/diff/970001/ui/base/cocoa/text_ser... File ui/base/cocoa/text_services_context_menu.cc (right): https://codereview.chromium.org/2164483006/diff/970001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:68: NewSpeechChannel(nullptr, &g_speech_channel); On 2017/02/02 20:35:06, spqchan wrote: > Whoops, that's a good point. I added a check for it. Currently it just created a > new one but we can just reuse the old one > I added a check for the OSErr return value too. > > I added a TODO for a test suite. I'm not sure if I'll be able to write unit > tests for the speech stuff but I can give it a try. I would prefer it's done in this CL so that it's not forgotten. I think it can be pretty basic to start with - e.g. exercising the functions to make sure they don't crash. For the context menu stuff, seems tests should be pretty easy too - check if entries were added to the model, etc.
https://codereview.chromium.org/2164483006/diff/950001/ui/gfx/render_text_uni... File ui/gfx/render_text_unittest.cc (right): https://codereview.chromium.org/2164483006/diff/950001/ui/gfx/render_text_uni... ui/gfx/render_text_unittest.cc:4021: for (size_t i = 0; i < expected_text_1.text.length(); i++) { On 2017/02/02 20:35:05, spqchan wrote: > On 2017/02/01 01:52:28, msw wrote: > > Can you do this without a loop, like: > > expected_text_1.attributes.push_back(CreateRangedAttribute(font_spans, 0, > > expected_text_1.text.length(), Font::Weight::NORMAL, UNDERLINE_MASK)); > > No, it's weird like that. You need to apply an attribute to every character on > the text. There are numerous other places in the code that call CreateRangedAttribute once with a non-empty range... why is this different? https://codereview.chromium.org/2164483006/diff/1030001/ui/gfx/render_text_un... File ui/gfx/render_text_unittest.cc (right): https://codereview.chromium.org/2164483006/diff/1030001/ui/gfx/render_text_un... ui/gfx/render_text_unittest.cc:4001: // Verify GetDecoratedTextAndBaselineAtRange returns the correct baseline point GetDecoratedTextAndBaselineForRange - please just make sure this matches the name of the function you're testing... https://codereview.chromium.org/2164483006/diff/1030001/ui/gfx/render_text_un... ui/gfx/render_text_unittest.cc:4003: TEST_P(RenderTextHarfBuzzTest, GetDecoratedTextAndBaselineAtRange) { GetDecoratedTextAndBaselineForRange - please just make sure this matches the name of the function you're testing... https://codereview.chromium.org/2164483006/diff/1030001/ui/gfx/render_text_un... ui/gfx/render_text_unittest.cc:4059: expected_text_3.attributes.push_back(CreateRangedAttribute( Can you build the attributes from the earlier words? eg: expected_text_3.attributes.insert(expected_text_3.attributes.begin(), expected_text_1.attributes.begin(), expected_text_1.attributes.end()); expected_text_3.attributes.push_back(CreateRangedAttribute(font_spans, 6, 6, Font::Weight::NORMAL, STRIKE_MASK)); expected_text_3.attributes.insert(expected_text_3.attributes.end(), expected_text_2.attributes.begin(), expected_text_2.attributes.end()); https://codereview.chromium.org/2164483006/diff/1030001/ui/gfx/render_text_un... ui/gfx/render_text_unittest.cc:4071: const Rect left_glyph_3 = render_text->GetCursorBounds( nit: remove this and just use |left_glyph_1|?
lgtm - mostly just nits and a few thoughts https://codereview.chromium.org/2164483006/diff/1050001/content/browser/rende... File content/browser/renderer_host/render_widget_host_view_mac.h (right): https://codereview.chromium.org/2164483006/diff/1050001/content/browser/rende... content/browser/renderer_host/render_widget_host_view_mac.h:518: // selected text on the renderer. nit (while you're here) selected -> Selected https://codereview.chromium.org/2164483006/diff/1050001/content/browser/rende... content/browser/renderer_host/render_widget_host_view_mac.h:551: base::string16 selection_text_; huh - this is new. A little confusing having |selected_text_| and |selection_text_| -- I think this is only text selected in an editable element (and from the TODO I guess it's going away). https://codereview.chromium.org/2164483006/diff/1050001/content/browser/rende... File content/browser/renderer_host/render_widget_host_view_mac_unittest.mm (right): https://codereview.chromium.org/2164483006/diff/1050001/content/browser/rende... content/browser/renderer_host/render_widget_host_view_mac_unittest.mm:1349: EXPECT_EQ(base::UTF8ToUTF16("world"), selected_text()); nit: ASCIIToUTF16, same below https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... File ui/base/cocoa/text_services_context_menu.cc (right): https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu.cc:71: DCHECK_EQ(0, result); OSSTATUS_DCHECK(result == noErr, result); https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... File ui/base/cocoa/text_services_context_menu_unittest.mm (right): https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu_unittest.mm:49: ui::TextServicesContextMenu menu_; protected: before this https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu_unittest.mm:54: }; nit: private: DISALLOW_COPY_AND_ASSIGN(..) https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu_unittest.mm:103: menu_.SpeakText(base::UTF8ToUTF16("boxfish")); nit: ASCIIToUTF16 https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu_unittest.mm:104: EXPECT_TRUE(menu_.IsSpeaking()); It's likely this will be OK - I'm not sure how it will play with the test parallelisation and things (e.g. race conditions). It theory, there might be a context switch away from the process before this, which stalls the process long enough for the string to be spoken entirely. Hopefully that's unlikely though. https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu_unittest.mm:130: menu_.SpeakText(base::UTF8ToUTF16("boxfish")); ASCII Also I think IsSpeaking() depends on global system state -- it doesn't just use the speech channel. If this test and SpeechApi run simultaneously there could be unexpected behaviour, but I don't think enough to make the test fail. https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu_unittest.mm:180: } // namespace namespace ui
lgtm % comments https://codereview.chromium.org/2164483006/diff/1050001/chrome/browser/ui/coc... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h (right): https://codereview.chromium.org/2164483006/diff/1050001/chrome/browser/ui/coc... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h:62: // Helper method that returns the BiDi parameter value for |direction|. Nit: No need to say "Helper method". Just "Returns the ..." What's a BiDi parameter? Can this either explain what the returned int values mean or point to some other place in the codebase where this is defined? Especially since you use this as an bool in some calling logic and it's entirely not obvious to me what the values are. https://codereview.chromium.org/2164483006/diff/1050001/chrome/browser/ui/coc... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm (right): https://codereview.chromium.org/2164483006/diff/1050001/chrome/browser/ui/coc... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:234: content::RenderViewHost* view_host = GetRenderViewHost(); Nit: Move this above line 242 right before it's used. https://codereview.chromium.org/2164483006/diff/1050001/content/browser/rende... File content/browser/renderer_host/render_widget_host_view_mac.h (right): https://codereview.chromium.org/2164483006/diff/1050001/content/browser/rende... content/browser/renderer_host/render_widget_host_view_mac.h:485: // TODO(spqchan): Change |text| to be the type string16. Nit: Still my previous comment of giving more context here - or moving this to the .cc file. The context here could be " in order to avoid a string conversion in Xyz()". https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... File ui/base/cocoa/text_services_context_menu.cc (right): https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu.cc:77: void TextServicesContextMenu::StopSpeaking() { Add a DCHECK here that g_speech_channel isn't null? https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... File ui/base/cocoa/text_services_context_menu_unittest.mm (right): https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu_unittest.mm:12: #include "ui/base/cocoa/text_services_context_menu.h" This should be the first include. https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu_unittest.mm:104: EXPECT_TRUE(menu_.IsSpeaking()); On 2017/02/03 10:14:51, tapted wrote: > It's likely this will be OK - I'm not sure how it will play with the test > parallelisation and things (e.g. race conditions). It theory, there might be a > context switch away from the process before this, which stalls the process long > enough for the string to be spoken entirely. Hopefully that's unlikely though. Yeah - maybe worth making the text string a bit longer to minimize this chance? e.g. a few paragraphs
lgtm % comments https://codereview.chromium.org/2164483006/diff/1050001/chrome/browser/ui/coc... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h (right): https://codereview.chromium.org/2164483006/diff/1050001/chrome/browser/ui/coc... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h:62: // Helper method that returns the BiDi parameter value for |direction|. Nit: No need to say "Helper method". Just "Returns the ..." What's a BiDi parameter? Can this either explain what the returned int values mean or point to some other place in the codebase where this is defined? Especially since you use this as an bool in some calling logic and it's entirely not obvious to me what the values are. https://codereview.chromium.org/2164483006/diff/1050001/chrome/browser/ui/coc... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm (right): https://codereview.chromium.org/2164483006/diff/1050001/chrome/browser/ui/coc... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:234: content::RenderViewHost* view_host = GetRenderViewHost(); Nit: Move this above line 242 right before it's used. https://codereview.chromium.org/2164483006/diff/1050001/content/browser/rende... File content/browser/renderer_host/render_widget_host_view_mac.h (right): https://codereview.chromium.org/2164483006/diff/1050001/content/browser/rende... content/browser/renderer_host/render_widget_host_view_mac.h:485: // TODO(spqchan): Change |text| to be the type string16. Nit: Still my previous comment of giving more context here - or moving this to the .cc file. The context here could be " in order to avoid a string conversion in Xyz()". https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... File ui/base/cocoa/text_services_context_menu.cc (right): https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu.cc:77: void TextServicesContextMenu::StopSpeaking() { Add a DCHECK here that g_speech_channel isn't null? https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... File ui/base/cocoa/text_services_context_menu_unittest.mm (right): https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu_unittest.mm:12: #include "ui/base/cocoa/text_services_context_menu.h" This should be the first include. https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu_unittest.mm:104: EXPECT_TRUE(menu_.IsSpeaking()); On 2017/02/03 10:14:51, tapted wrote: > It's likely this will be OK - I'm not sure how it will play with the test > parallelisation and things (e.g. race conditions). It theory, there might be a > context switch away from the process before this, which stalls the process long > enough for the string to be spoken entirely. Hopefully that's unlikely though. Yeah - maybe worth making the text string a bit longer to minimize this chance? e.g. a few paragraphs
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_compile_dbg_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_comp...)
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Patchset #13 (id:1070001) has been deleted
PTAL, addressed all of the comments. Let me know if I missed any, thanks! https://codereview.chromium.org/2164483006/diff/970001/content/browser/render... File content/browser/renderer_host/render_widget_host_view_mac.h (right): https://codereview.chromium.org/2164483006/diff/970001/content/browser/render... content/browser/renderer_host/render_widget_host_view_mac.h:485: // TODO(spqchan): Change |text| to be the type string16. On 2017/02/02 20:50:24, Alexei Svitkine (very slow) wrote: > On 2017/02/02 20:35:05, spqchan wrote: > > On 2017/02/01 19:12:37, Alexei Svitkine (very slow) wrote: > > > Can you provide more context here? Why is string16 preferable? > > > > > > If it's to avoid some conversions - maybe the TODO should live where the > > > conversions happen? > > > > This is done to avoid some conversions, since selected_text always get > converted > > from UTF16 to UTF8. > > Do you mean putting it in render_view_impl.cc? I kind of prefer putting it > here > > but I don't feel strongly about it so if you want me to move it there, I can > do > > that. > > If you keep it here, expand the comment to refer to the conversion in question > so that it's clear *why*. (But yeah my suggestion was to put in .cc so it's > clear the conversion it's talking about.) Done. https://codereview.chromium.org/2164483006/diff/970001/ui/base/cocoa/text_ser... File ui/base/cocoa/text_services_context_menu.cc (right): https://codereview.chromium.org/2164483006/diff/970001/ui/base/cocoa/text_ser... ui/base/cocoa/text_services_context_menu.cc:68: NewSpeechChannel(nullptr, &g_speech_channel); On 2017/02/02 20:50:24, Alexei Svitkine (very slow) wrote: > On 2017/02/02 20:35:06, spqchan wrote: > > Whoops, that's a good point. I added a check for it. Currently it just created > a > > new one but we can just reuse the old one > > I added a check for the OSErr return value too. > > > > I added a TODO for a test suite. I'm not sure if I'll be able to write unit > > tests for the speech stuff but I can give it a try. > > I would prefer it's done in this CL so that it's not forgotten. > > I think it can be pretty basic to start with - e.g. exercising the functions to > make sure they don't crash. > > For the context menu stuff, seems tests should be pretty easy too - check if > entries were added to the model, etc. Done. https://codereview.chromium.org/2164483006/diff/1030001/ui/gfx/render_text_un... File ui/gfx/render_text_unittest.cc (right): https://codereview.chromium.org/2164483006/diff/1030001/ui/gfx/render_text_un... ui/gfx/render_text_unittest.cc:4001: // Verify GetDecoratedTextAndBaselineAtRange returns the correct baseline point On 2017/02/02 22:16:08, msw wrote: > GetDecoratedTextAndBaselineForRange - please just make sure this matches the > name of the function you're testing... I'm a bit confused. Isn't it matching? https://codereview.chromium.org/2164483006/diff/1030001/ui/gfx/render_text_un... ui/gfx/render_text_unittest.cc:4003: TEST_P(RenderTextHarfBuzzTest, GetDecoratedTextAndBaselineAtRange) { On 2017/02/02 22:16:08, msw wrote: > GetDecoratedTextAndBaselineForRange - please just make sure this matches the > name of the function you're testing... Ditto from above https://codereview.chromium.org/2164483006/diff/1030001/ui/gfx/render_text_un... ui/gfx/render_text_unittest.cc:4059: expected_text_3.attributes.push_back(CreateRangedAttribute( On 2017/02/02 22:16:08, msw wrote: > Can you build the attributes from the earlier words? eg: > expected_text_3.attributes.insert(expected_text_3.attributes.begin(), > expected_text_1.attributes.begin(), expected_text_1.attributes.end()); > > expected_text_3.attributes.push_back(CreateRangedAttribute(font_spans, 6, 6, > Font::Weight::NORMAL, STRIKE_MASK)); > > expected_text_3.attributes.insert(expected_text_3.attributes.end(), > expected_text_2.attributes.begin(), expected_text_2.attributes.end()); Sure thing, I can use it for expected_text_1, but not expected_text_2 since the |range| value in expected_text_2's attributes start from 0, not 7. https://codereview.chromium.org/2164483006/diff/1030001/ui/gfx/render_text_un... ui/gfx/render_text_unittest.cc:4071: const Rect left_glyph_3 = render_text->GetCursorBounds( On 2017/02/02 22:16:08, msw wrote: > nit: remove this and just use |left_glyph_1|? Done. https://codereview.chromium.org/2164483006/diff/1050001/chrome/browser/ui/coc... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h (right): https://codereview.chromium.org/2164483006/diff/1050001/chrome/browser/ui/coc... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.h:62: // Helper method that returns the BiDi parameter value for |direction|. On 2017/02/03 15:43:25, Alexei Svitkine (very slow) wrote: > Nit: No need to say "Helper method". Just "Returns the ..." > > What's a BiDi parameter? Can this either explain what the returned int values > mean or point to some other place in the codebase where this is defined? > Especially since you use this as an bool in some calling logic and it's entirely > not obvious to me what the values are. Done. https://codereview.chromium.org/2164483006/diff/1050001/chrome/browser/ui/coc... File chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm (right): https://codereview.chromium.org/2164483006/diff/1050001/chrome/browser/ui/coc... chrome/browser/ui/cocoa/renderer_context_menu/render_view_context_menu_mac.mm:234: content::RenderViewHost* view_host = GetRenderViewHost(); On 2017/02/03 15:43:27, Alexei Svitkine (very slow) wrote: > Nit: Move this above line 242 right before it's used. Done. https://codereview.chromium.org/2164483006/diff/1050001/content/browser/rende... File content/browser/renderer_host/render_widget_host_view_mac.h (right): https://codereview.chromium.org/2164483006/diff/1050001/content/browser/rende... content/browser/renderer_host/render_widget_host_view_mac.h:485: // TODO(spqchan): Change |text| to be the type string16. On 2017/02/03 15:43:30, Alexei Svitkine (very slow) wrote: > Nit: Still my previous comment of giving more context here - or moving this to > the .cc file. > > The context here could be " in order to avoid a string conversion in Xyz()". Done. https://codereview.chromium.org/2164483006/diff/1050001/content/browser/rende... content/browser/renderer_host/render_widget_host_view_mac.h:518: // selected text on the renderer. On 2017/02/03 10:14:51, tapted wrote: > nit (while you're here) selected -> Selected Done. https://codereview.chromium.org/2164483006/diff/1050001/content/browser/rende... content/browser/renderer_host/render_widget_host_view_mac.h:551: base::string16 selection_text_; On 2017/02/03 10:14:51, tapted wrote: > huh - this is new. A little confusing having |selected_text_| and > |selection_text_| -- I think this is only text selected in an editable element > (and from the TODO I guess it's going away). Added a comment for it https://codereview.chromium.org/2164483006/diff/1050001/content/browser/rende... File content/browser/renderer_host/render_widget_host_view_mac_unittest.mm (right): https://codereview.chromium.org/2164483006/diff/1050001/content/browser/rende... content/browser/renderer_host/render_widget_host_view_mac_unittest.mm:1349: EXPECT_EQ(base::UTF8ToUTF16("world"), selected_text()); On 2017/02/03 10:14:51, tapted wrote: > nit: ASCIIToUTF16, same below Done. https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... File ui/base/cocoa/text_services_context_menu.cc (right): https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu.cc:71: DCHECK_EQ(0, result); On 2017/02/03 10:14:51, tapted wrote: > OSSTATUS_DCHECK(result == noErr, result); Done. https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu.cc:77: void TextServicesContextMenu::StopSpeaking() { On 2017/02/03 15:43:32, Alexei Svitkine (very slow) wrote: > Add a DCHECK here that g_speech_channel isn't null? Done. https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... File ui/base/cocoa/text_services_context_menu_unittest.mm (right): https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu_unittest.mm:12: #include "ui/base/cocoa/text_services_context_menu.h" On 2017/02/03 15:43:32, Alexei Svitkine (very slow) wrote: > This should be the first include. Done. https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu_unittest.mm:49: ui::TextServicesContextMenu menu_; On 2017/02/03 10:14:51, tapted wrote: > protected: before this Done. https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu_unittest.mm:54: }; On 2017/02/03 10:14:51, tapted wrote: > nit: > private: > DISALLOW_COPY_AND_ASSIGN(..) Done. https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu_unittest.mm:103: menu_.SpeakText(base::UTF8ToUTF16("boxfish")); On 2017/02/03 10:14:51, tapted wrote: > nit: ASCIIToUTF16 Done. https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu_unittest.mm:104: EXPECT_TRUE(menu_.IsSpeaking()); On 2017/02/03 15:43:33, Alexei Svitkine (very slow) wrote: > On 2017/02/03 10:14:51, tapted wrote: > > It's likely this will be OK - I'm not sure how it will play with the test > > parallelisation and things (e.g. race conditions). It theory, there might be a > > context switch away from the process before this, which stalls the process > long > > enough for the string to be spoken entirely. Hopefully that's unlikely though. > > Yeah - maybe worth making the text string a bit longer to minimize this chance? > e.g. a few paragraphs Done. https://codereview.chromium.org/2164483006/diff/1050001/ui/base/cocoa/text_se... ui/base/cocoa/text_services_context_menu_unittest.mm:130: menu_.SpeakText(base::UTF8ToUTF16("boxfish")); On 2017/02/03 10:14:51, tapted wrote: > ASCII > > Also I think IsSpeaking() depends on global system state -- it doesn't just use > the speech channel. If this test and SpeechApi run simultaneously there could be > unexpected behaviour, but I don't think enough to make the test fail. That's a good point. I removed SpeechAPI test since this one is covering it anyway.
lgtm with 'At' -> 'For' comment addressed. https://codereview.chromium.org/2164483006/diff/1030001/ui/gfx/render_text_un... File ui/gfx/render_text_unittest.cc (right): https://codereview.chromium.org/2164483006/diff/1030001/ui/gfx/render_text_un... ui/gfx/render_text_unittest.cc:4001: // Verify GetDecoratedTextAndBaselineAtRange returns the correct baseline point On 2017/02/03 23:32:10, spqchan wrote: > On 2017/02/02 22:16:08, msw wrote: > > GetDecoratedTextAndBaselineForRange - please just make sure this matches the > > name of the function you're testing... > > I'm a bit confused. Isn't it matching? Your comment and test fixture say "GetDecoratedTextAndBaselineAtRange", the function you are adding is named "GetDecoratedTextAndBaselineForRange" ('At' vs. 'For'), the function name should be searchable, please make sure they match.
The CQ bit was checked by spqchan@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
On 2017/02/03 23:38:35, msw wrote: > lgtm with 'At' -> 'For' comment addressed. > > https://codereview.chromium.org/2164483006/diff/1030001/ui/gfx/render_text_un... > File ui/gfx/render_text_unittest.cc (right): > > https://codereview.chromium.org/2164483006/diff/1030001/ui/gfx/render_text_un... > ui/gfx/render_text_unittest.cc:4001: // Verify > GetDecoratedTextAndBaselineAtRange returns the correct baseline point > On 2017/02/03 23:32:10, spqchan wrote: > > On 2017/02/02 22:16:08, msw wrote: > > > GetDecoratedTextAndBaselineForRange - please just make sure this matches the > > > name of the function you're testing... > > > > I'm a bit confused. Isn't it matching? > > Your comment and test fixture say "GetDecoratedTextAndBaselineAtRange", the > function you are adding is named "GetDecoratedTextAndBaselineForRange" ('At' vs. > 'For'), the function name should be searchable, please make sure they match. Augh, thanks! Fixed it. Just need a LGTM from nasko@
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Rubberstamp LGTM on content/ bits.
On 2017/02/06 19:23:15, nasko (very slow) wrote: > Rubberstamp LGTM on content/ bits. thanks!
The CQ bit was checked by spqchan@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from tapted@chromium.org, asvitkine@chromium.org, msw@chromium.org Link to the patchset: https://codereview.chromium.org/2164483006/#ps1110001 (title: "At->For")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: chromium_presubmit on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presub...)
The CQ bit was checked by spqchan@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: chromium_presubmit on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presub...)
spqchan@chromium.org changed reviewers: + sky@chromium.org
+sky for chrome/app/chrome_command_ids.h ownership
LGTM
On 2017/02/07 00:00:12, sky wrote: > LGTM thanks!
The CQ bit was checked by spqchan@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Failed to apply patch for content/browser/frame_host/render_widget_host_view_child_frame.h: While running git apply --index -p1; error: patch failed: content/browser/frame_host/render_widget_host_view_child_frame.h:150 error: content/browser/frame_host/render_widget_host_view_child_frame.h: patch does not apply Patch: content/browser/frame_host/render_widget_host_view_child_frame.h Index: content/browser/frame_host/render_widget_host_view_child_frame.h diff --git a/content/browser/frame_host/render_widget_host_view_child_frame.h b/content/browser/frame_host/render_widget_host_view_child_frame.h index 5af60501e45fe44aed6484782f857184b04476b8..18930c0e2c34f3697539e8d456a5794cbdd43bd3 100644 --- a/content/browser/frame_host/render_widget_host_view_child_frame.h +++ b/content/browser/frame_host/render_widget_host_view_child_frame.h @@ -150,10 +150,7 @@ class CONTENT_EXPORT RenderWidgetHostViewChildFrame ui::AcceleratedWidgetMac* GetAcceleratedWidgetMac() const override; void SetActive(bool active) override; void ShowDefinitionForSelection() override; - bool SupportsSpeech() const override; void SpeakSelection() override; - bool IsSpeaking() const override; - void StopSpeaking() override; #endif // defined(OS_MACOSX) // RenderWidgetHostViewBase implementation.
The CQ bit was checked by spqchan@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from tapted@chromium.org, asvitkine@chromium.org, sky@chromium.org, nasko@chromium.org, msw@chromium.org Link to the patchset: https://codereview.chromium.org/2164483006/#ps1130001 (title: "rebased")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch. Bot data: {"patchset_id": 1130001, "attempt_start_ts": 1486429432045330, "parent_rev": "2f2e19599e1d1658516378245c256456318392c9", "commit_rev": "375ddabe9cdc45673e112c5b1b06cc754aa45759"}
Message was sent while issue was closed.
Description was changed from ========== [MacViews] Implemented text context menu - Added Speech, Writing Direction and Look Up - Introduced text_services_context_menu to create and handle the items - Moved the the code from render_view_context_menu_mac into text_services_context_menu - Created views_text_context_menu to bridge Views with text_services_context_menu BUG=617436 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation ========== to ========== [MacViews] Implemented text context menu - Added Speech, Writing Direction and Look Up - Introduced text_services_context_menu to create and handle the items - Moved the the code from render_view_context_menu_mac into text_services_context_menu - Created views_text_context_menu to bridge Views with text_services_context_menu BUG=617436 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation Review-Url: https://codereview.chromium.org/2164483006 Cr-Commit-Position: refs/heads/master@{#448526} Committed: https://chromium.googlesource.com/chromium/src/+/375ddabe9cdc45673e112c5b1b06... ==========
Message was sent while issue was closed.
Committed patchset #15 (id:1130001) as https://chromium.googlesource.com/chromium/src/+/375ddabe9cdc45673e112c5b1b06... |