|
|
Created:
9 years, 2 months ago by Peng Modified:
9 years, 1 month ago CC:
chromium-reviews, tfarina, dhollowa, darin-cc_chromium.org, brettw-cc_chromium.org, bryeung Visibility:
Public. |
DescriptionSupport IMM32 reconversion on Windows.
BUG=45605
TEST=Tested it with Google Japanese Input method on Win7
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=107934
Patch Set 1 #Patch Set 2 : WIP #Patch Set 3 : wip #Patch Set 4 : wip #Patch Set 5 : wip #Patch Set 6 : wip #Patch Set 7 : wip #Patch Set 8 : wip #Patch Set 9 : wip #Patch Set 10 : wip #Patch Set 11 : Rebase #Patch Set 12 : wip #Patch Set 13 : wip #Patch Set 14 : wip #Patch Set 15 : Fix style issues #Patch Set 16 : wip #
Total comments: 4
Patch Set 17 : Fix review issues #
Total comments: 4
Patch Set 18 : Remove unused header file #
Total comments: 48
Patch Set 19 : Fix review issues #
Total comments: 10
Patch Set 20 : Fix review issues #
Total comments: 2
Patch Set 21 : Fix review issues #Patch Set 22 : update #Patch Set 23 : Fix return values #
Total comments: 19
Patch Set 24 : update #
Total comments: 24
Patch Set 25 : Fix review issues #
Total comments: 20
Patch Set 26 : Fix review issues #
Total comments: 8
Patch Set 27 : Refine some inline comments #Patch Set 28 : Rebase #Messages
Total messages: 32 (0 generated)
i'm not that familiar with this code, so i only scanned it for nits. i assume you added me for content approval, so i defer to Yusuke for the actual review http://codereview.chromium.org/8294026/diff/22016/chrome/browser/renderer_hos... File chrome/browser/renderer_host/render_widget_host_view_views.cc (right): http://codereview.chromium.org/8294026/diff/22016/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.cc:755: DCHECK(range); nit: we avoid DCHECKING pointers before using them. in release builds this does nothing. in debug the crash in the next line is just as useful http://codereview.chromium.org/8294026/diff/22016/content/browser/renderer_ho... File content/browser/renderer_host/render_widget_host_view_win.h (right): http://codereview.chromium.org/8294026/diff/22016/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view_win.h:310: LRESULT OnDocumentFeed(RECONVERTSTRING *reconv); nit: RECONVERTSTRING* reconv and below
[+hbono] hbono, Could you please review this cls? Thanks. http://codereview.chromium.org/8294026/diff/22016/chrome/browser/renderer_hos... File chrome/browser/renderer_host/render_widget_host_view_views.cc (right): http://codereview.chromium.org/8294026/diff/22016/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.cc:755: DCHECK(range); On 2011/10/25 00:32:13, John Abd-El-Malek wrote: > nit: we avoid DCHECKING pointers before using them. in release builds this does > nothing. in debug the crash in the next line is just as useful Done. http://codereview.chromium.org/8294026/diff/22016/content/browser/renderer_ho... File content/browser/renderer_host/render_widget_host_view_win.h (right): http://codereview.chromium.org/8294026/diff/22016/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view_win.h:310: LRESULT OnDocumentFeed(RECONVERTSTRING *reconv); On 2011/10/25 00:32:13, John Abd-El-Malek wrote: > nit: RECONVERTSTRING* reconv and below Done.
content lgtm
http://codereview.chromium.org/8294026/diff/28001/views/ime/text_input_client.h File views/ime/text_input_client.h (right): http://codereview.chromium.org/8294026/diff/28001/views/ime/text_input_client... views/ime/text_input_client.h:12: #include "base/callback.h" Remove this line. http://codereview.chromium.org/8294026/diff/28001/views/ime/text_input_client... views/ime/text_input_client.h:101: // The result will be write in text and actual_range. nit: write in -> written into And please explain the purpose of actual_range. http://codereview.chromium.org/8294026/diff/32001/chrome/browser/renderer_hos... File chrome/browser/renderer_host/render_widget_host_view_views.h (right): http://codereview.chromium.org/8294026/diff/32001/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.h:297: gfx::Rect selection_end_rect_; Can you please add some comment describing the meaning of these selection related variables? Especially selection_text_*_. And looks like we can extract some common selection related code into RenderWidgetHostView, please help look into it. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_ibus.h File views/ime/input_method_ibus.h (right): http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_ibus... views/ime/input_method_ibus.h:23: typedef struct _GAsyncResult GAsyncResult; This forward declaration is not necessary to be in the header file. You should only forward declare the types used in the header file. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_ibus... views/ime/input_method_ibus.h:92: void ProcessKeyEventPostIME(const KeyEvent& key, unsigned int ibus_keycode, Change the corresponding .cc file as well? Or just leave it unchanged? http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_ibus... views/ime/input_method_ibus.h:101: unsigned int ibus_keycode); ditto. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:225: LRESULT InputMethodWin::OnReconvertString(RECONVERTSTRING *reconv) { Please keep the order of methods in .cc file same as those in the .h as much as possible. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:241: size_t need_size = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR); It's better to return some extra content around selection text. The sample provided in Microsoft Windows SDK sends 40 characters surrounding text totally (20 before selection, 20 after selection). See the sample in C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\winui\input\tsf\tsfapps\immpad-level3-step3 http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:244: return need_size; The actual_range returned by TextInputClient::GetTextFromRange() may be different than the request selection range. You need to calculate need_size according to the actual_range rather than the selection range. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:268: LRESULT InputMethodWin::OnDocumentFeed(RECONVERTSTRING *reconv) { Please refer to the Microsoft sample to see how this method should be implemented. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:287: } while (0); nit: I don't like do { } while(0); style myself. It's decrease the code readability. Please avoid it if you can. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:335: *handled = TRUE; should we set *handled to FALSE if any method of TextInputClient returns false? http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.h File views/ime/input_method_win.h (right): http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.h:22: }; This forward declaration is not necessary.
http://codereview.chromium.org/8294026/diff/28001/views/ime/text_input_client.h File views/ime/text_input_client.h (right): http://codereview.chromium.org/8294026/diff/28001/views/ime/text_input_client... views/ime/text_input_client.h:12: #include "base/callback.h" On 2011/10/25 19:15:03, James Su wrote: > Remove this line. Done. http://codereview.chromium.org/8294026/diff/28001/views/ime/text_input_client... views/ime/text_input_client.h:101: // The result will be write in text and actual_range. On 2011/10/25 19:15:03, James Su wrote: > nit: write in -> written into > And please explain the purpose of actual_range. Done. http://codereview.chromium.org/8294026/diff/32001/chrome/browser/renderer_hos... File chrome/browser/renderer_host/render_widget_host_view_views.h (right): http://codereview.chromium.org/8294026/diff/32001/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.h:297: gfx::Rect selection_end_rect_; On 2011/10/25 19:15:03, James Su wrote: > Can you please add some comment describing the meaning of these selection > related variables? Especially selection_text_*_. > > And looks like we can extract some common selection related code into > RenderWidgetHostView, please help look into it. Done. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_ibus.h File views/ime/input_method_ibus.h (right): http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_ibus... views/ime/input_method_ibus.h:23: typedef struct _GAsyncResult GAsyncResult; On 2011/10/25 19:15:03, James Su wrote: > This forward declaration is not necessary to be in the header file. You should > only forward declare the types used in the header file. Done. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_ibus... views/ime/input_method_ibus.h:92: void ProcessKeyEventPostIME(const KeyEvent& key, unsigned int ibus_keycode, On 2011/10/25 19:15:03, James Su wrote: > Change the corresponding .cc file as well? Or just leave it unchanged? Done. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_ibus... views/ime/input_method_ibus.h:101: unsigned int ibus_keycode); On 2011/10/25 19:15:03, James Su wrote: > ditto. Done. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:225: LRESULT InputMethodWin::OnReconvertString(RECONVERTSTRING *reconv) { On 2011/10/25 19:15:03, James Su wrote: > Please keep the order of methods in .cc file same as those in the .h as much as > possible. Done. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:241: size_t need_size = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR); On 2011/10/25 19:15:03, James Su wrote: > It's better to return some extra content around selection text. The sample > provided in Microsoft Windows SDK sends 40 characters surrounding text totally > (20 before selection, 20 after selection). > > See the sample in C:\Program Files\Microsoft > SDKs\Windows\v7.1\Samples\winui\input\tsf\tsfapps\immpad-level3-step3 This logic is same with firefox. And currently we do not implement SetSelectionRange in RHWVV. It is needed when IME want to reconvert piece of text which is not current selection. So returning extra text is not very useful right now. So I would like not support getting extra context right now. And when RHWVV can support SetSelectionRange(), I will change this function. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:244: return need_size; On 2011/10/25 19:15:03, James Su wrote: > The actual_range returned by TextInputClient::GetTextFromRange() may be > different than the request selection range. You need to calculate need_size > according to the actual_range rather than the selection range. Because text range must cover the selection range, so GetTextFromRange will return the same range of selection range. So I think we can use selection_range here. And it could avoid calling GetTextFromRange() and a useless string copying. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:268: LRESULT InputMethodWin::OnDocumentFeed(RECONVERTSTRING *reconv) { On 2011/10/25 19:15:03, James Su wrote: > Please refer to the Microsoft sample to see how this method should be > implemented. It is almost same with MS sample. Only a little different - the dwTarget* is set with range of selection, when chrome does not have composition. This logic is same with firefox. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:287: } while (0); On 2011/10/25 19:15:03, James Su wrote: > nit: I don't like do { } while(0); style myself. It's decrease the code > readability. Please avoid it if you can. I tried using 'if else', but it looks worse. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:335: *handled = TRUE; On 2011/10/25 19:15:03, James Su wrote: > should we set *handled to FALSE if any method of TextInputClient returns false? I think we should set *handled to TRUE, because we handled the request, even if it failed. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.h File views/ime/input_method_win.h (right): http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.h:22: }; On 2011/10/25 19:15:03, James Su wrote: > This forward declaration is not necessary. Done.
Greetings, If I understand this change correctly, this change allows an IME to read text in any editable fields, including password fields. (WebKit replaces password text with U+2022, though.) I notice some IMEs automatically send all its input text to servers and I do not implement it intentionally because it may cause privacy leak. Have you talked with our privacy people about it? Regards, Hironori Bono http://codereview.chromium.org/8294026/diff/29017/chrome/browser/renderer_hos... File chrome/browser/renderer_host/render_widget_host_view_views.cc (left): http://codereview.chromium.org/8294026/diff/29017/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.cc:169: void RenderWidgetHostViewViews::InitAsFullscreen( nit: I'm wondering why this change deletes this function. (I do not think this function does not have connection with IMM32.) http://codereview.chromium.org/8294026/diff/29017/chrome/browser/renderer_hos... File chrome/browser/renderer_host/render_widget_host_view_views.h (right): http://codereview.chromium.org/8294026/diff/29017/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.h:95: const ui::Range& range) OVRERRIDE; nit: OVRERRIDE -> OVERRIDE?
http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:225: LRESULT InputMethodWin::OnReconvertString(RECONVERTSTRING *reconv) { On 2011/10/25 22:01:21, Peng wrote: > On 2011/10/25 19:15:03, James Su wrote: > > Please keep the order of methods in .cc file same as those in the .h as much > as > > possible. > > Done. It's not done yet. OnReconvertString() and OnDocumentFeed() should be put after OnDeadChar() according to the declaration order in the header file. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:241: size_t need_size = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR); On 2011/10/25 22:01:21, Peng wrote: > On 2011/10/25 19:15:03, James Su wrote: > > It's better to return some extra content around selection text. The sample > > provided in Microsoft Windows SDK sends 40 characters surrounding text totally > > (20 before selection, 20 after selection). > > > > See the sample in C:\Program Files\Microsoft > > SDKs\Windows\v7.1\Samples\winui\input\tsf\tsfapps\immpad-level3-step3 > > This logic is same with firefox. And currently we do not implement > SetSelectionRange in RHWVV. It is needed when IME want to reconvert piece of > text which is not current selection. So returning extra text is not very useful > right now. So I would like not support getting extra context right now. And when > RHWVV can support SetSelectionRange(), I will change this function. I think you misunderstood the purpose of those extra context, which is to help the input method improve reconversion accuracy (if the input method supports it, e.g. by feeding the extra context into its language model). It's nothing to do with SetSelectionRange(). http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:244: return need_size; On 2011/10/25 22:01:21, Peng wrote: > On 2011/10/25 19:15:03, James Su wrote: > > The actual_range returned by TextInputClient::GetTextFromRange() may be > > different than the request selection range. You need to calculate need_size > > according to the actual_range rather than the selection range. > > Because text range must cover the selection range, so GetTextFromRange will > return the same range of selection range. So I think we can use selection_range > here. And it could avoid calling GetTextFromRange() and a useless string > copying. You can't assume it here, especially if you want to retrieve some extra context. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:268: LRESULT InputMethodWin::OnDocumentFeed(RECONVERTSTRING *reconv) { On 2011/10/25 22:01:21, Peng wrote: > On 2011/10/25 19:15:03, James Su wrote: > > Please refer to the Microsoft sample to see how this method should be > > implemented. > > It is almost same with MS sample. Only a little different - the dwTarget* is set > with range of selection, when chrome does not have composition. This logic is > same with firefox. > I mean the extra context thing. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:287: } while (0); On 2011/10/25 22:01:21, Peng wrote: > On 2011/10/25 19:15:03, James Su wrote: > > nit: I don't like do { } while(0); style myself. It's decrease the code > > readability. Please avoid it if you can. > > I tried using 'if else', but it looks worse. > Please try your best to rewrite this piece of code to eliminate this do {} while(0); thing. I really don't like it. http://codereview.chromium.org/8294026/diff/29017/content/browser/renderer_ho... File content/browser/renderer_host/render_widget_host_view.h (right): http://codereview.chromium.org/8294026/diff/29017/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view.h:357: // A piece of text which convers the selection in the web page. How about something like: A buffer containing the text inside and around the current selection range. http://codereview.chromium.org/8294026/diff/29017/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view.h:360: // The offset of |selection_text_| in web page. How about something like: The offset of the text stored in |selection_text_| relative to the start of the web page. http://codereview.chromium.org/8294026/diff/29017/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view.h:363: // The selection range in the web page. How about: The current selection range relative to the start of the web page.
On 2011/10/26 02:39:37, hbono wrote: > Greetings, > > If I understand this change correctly, this change allows an IME to read text in > any editable fields, including password fields. (WebKit replaces password text > with U+2022, though.) I notice some IMEs automatically send all its input text > to servers and I do not implement it intentionally because it may cause privacy > leak. Have you talked with our privacy people about it? Thanks for the good question. But it should not be a problem. First, IME is disabled in password field. And even if IME is enabled in password field, webkit just returns "***" to chrome, so IME can not get real chars in password field. Anyway, I added some checking code in WM_IME_REQUEST message handler, to make sure the text field is not a password. I think it is safe enough. > Regards, > > Hironori Bono > > http://codereview.chromium.org/8294026/diff/29017/chrome/browser/renderer_hos... > File chrome/browser/renderer_host/render_widget_host_view_views.cc (left): > > http://codereview.chromium.org/8294026/diff/29017/chrome/browser/renderer_hos... > chrome/browser/renderer_host/render_widget_host_view_views.cc:169: void > RenderWidgetHostViewViews::InitAsFullscreen( > nit: I'm wondering why this change deletes this function. (I do not think this > function does not have connection with IMM32.) > > http://codereview.chromium.org/8294026/diff/29017/chrome/browser/renderer_hos... > File chrome/browser/renderer_host/render_widget_host_view_views.h (right): > > http://codereview.chromium.org/8294026/diff/29017/chrome/browser/renderer_hos... > chrome/browser/renderer_host/render_widget_host_view_views.h:95: const > ui::Range& range) OVRERRIDE; > nit: OVRERRIDE -> OVERRIDE?
http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:225: LRESULT InputMethodWin::OnReconvertString(RECONVERTSTRING *reconv) { On 2011/10/26 04:25:38, James Su wrote: > On 2011/10/25 22:01:21, Peng wrote: > > On 2011/10/25 19:15:03, James Su wrote: > > > Please keep the order of methods in .cc file same as those in the .h as much > > as > > > possible. > > > > Done. > > It's not done yet. OnReconvertString() and OnDocumentFeed() should be put after > OnDeadChar() according to the declaration order in the header file. Sorry. Done again. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:241: size_t need_size = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR); On 2011/10/26 04:25:38, James Su wrote: > On 2011/10/25 22:01:21, Peng wrote: > > On 2011/10/25 19:15:03, James Su wrote: > > > It's better to return some extra content around selection text. The sample > > > provided in Microsoft Windows SDK sends 40 characters surrounding text > totally > > > (20 before selection, 20 after selection). > > > > > > See the sample in C:\Program Files\Microsoft > > > SDKs\Windows\v7.1\Samples\winui\input\tsf\tsfapps\immpad-level3-step3 > > > > This logic is same with firefox. And currently we do not implement > > SetSelectionRange in RHWVV. It is needed when IME want to reconvert piece of > > text which is not current selection. So returning extra text is not very > useful > > right now. So I would like not support getting extra context right now. And > when > > RHWVV can support SetSelectionRange(), I will change this function. > > I think you misunderstood the purpose of those extra context, which is to help > the input method improve reconversion accuracy (if the input method supports it, > e.g. by feeding the extra context into its language model). It's nothing to do > with SetSelectionRange(). Done. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:244: return need_size; On 2011/10/26 04:25:38, James Su wrote: > On 2011/10/25 22:01:21, Peng wrote: > > On 2011/10/25 19:15:03, James Su wrote: > > > The actual_range returned by TextInputClient::GetTextFromRange() may be > > > different than the request selection range. You need to calculate need_size > > > according to the actual_range rather than the selection range. > > > > Because text range must cover the selection range, so GetTextFromRange will > > return the same range of selection range. So I think we can use > selection_range > > here. And it could avoid calling GetTextFromRange() and a useless string > > copying. > > You can't assume it here, especially if you want to retrieve some extra context. Actually, I would like to remove actual_range from GetTextFromRange() which will simply return false, if it can not get whole text in the range. Is OK? http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:268: LRESULT InputMethodWin::OnDocumentFeed(RECONVERTSTRING *reconv) { On 2011/10/26 04:25:38, James Su wrote: > On 2011/10/25 22:01:21, Peng wrote: > > On 2011/10/25 19:15:03, James Su wrote: > > > Please refer to the Microsoft sample to see how this method should be > > > implemented. > > > > It is almost same with MS sample. Only a little different - the dwTarget* is > set > > with range of selection, when chrome does not have composition. This logic is > > same with firefox. > > > I mean the extra context thing. This function returns all text which can be accessed. So it should be enough. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:287: } while (0); On 2011/10/26 04:25:38, James Su wrote: > On 2011/10/25 22:01:21, Peng wrote: > > On 2011/10/25 19:15:03, James Su wrote: > > > nit: I don't like do { } while(0); style myself. It's decrease the code > > > readability. Please avoid it if you can. > > > > I tried using 'if else', but it looks worse. > > > > Please try your best to rewrite this piece of code to eliminate this do {} > while(0); thing. I really don't like it. I think it is not a big deal. It is very common for avoiding goto statement. At same time, it may help reduce {} levels. http://codereview.chromium.org/8294026/diff/29017/chrome/browser/renderer_hos... File chrome/browser/renderer_host/render_widget_host_view_views.cc (left): http://codereview.chromium.org/8294026/diff/29017/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.cc:169: void RenderWidgetHostViewViews::InitAsFullscreen( On 2011/10/26 02:39:37, hbono wrote: > nit: I'm wondering why this change deletes this function. (I do not think this > function does not have connection with IMM32.) Done. http://codereview.chromium.org/8294026/diff/29017/chrome/browser/renderer_hos... File chrome/browser/renderer_host/render_widget_host_view_views.h (right): http://codereview.chromium.org/8294026/diff/29017/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.h:95: const ui::Range& range) OVRERRIDE; On 2011/10/26 02:39:37, hbono wrote: > nit: OVRERRIDE -> OVERRIDE? Done. http://codereview.chromium.org/8294026/diff/29017/content/browser/renderer_ho... File content/browser/renderer_host/render_widget_host_view.h (right): http://codereview.chromium.org/8294026/diff/29017/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view.h:357: // A piece of text which convers the selection in the web page. On 2011/10/26 04:25:38, James Su wrote: > How about something like: A buffer containing the text inside and around the > current selection range. Done. http://codereview.chromium.org/8294026/diff/29017/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view.h:360: // The offset of |selection_text_| in web page. On 2011/10/26 04:25:38, James Su wrote: > How about something like: The offset of the text stored in |selection_text_| > relative to the start of the web page. Done. http://codereview.chromium.org/8294026/diff/29017/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view.h:363: // The selection range in the web page. On 2011/10/26 04:25:38, James Su wrote: > How about: The current selection range relative to the start of the web page. Done.
I'll review your CL again once you fix all these feedbacks. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:244: return need_size; On 2011/10/26 16:20:16, Peng wrote: > On 2011/10/26 04:25:38, James Su wrote: > > On 2011/10/25 22:01:21, Peng wrote: > > > On 2011/10/25 19:15:03, James Su wrote: > > > > The actual_range returned by TextInputClient::GetTextFromRange() may be > > > > different than the request selection range. You need to calculate > need_size > > > > according to the actual_range rather than the selection range. > > > > > > Because text range must cover the selection range, so GetTextFromRange will > > > return the same range of selection range. So I think we can use > > selection_range > > > here. And it could avoid calling GetTextFromRange() and a useless string > > > copying. > > > > You can't assume it here, especially if you want to retrieve some extra > context. > > Actually, I would like to remove actual_range from GetTextFromRange() which will > simply return false, if it can not get whole text in the range. Is OK? > I don't think it's ok. The current api design looks more reasonable. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:268: LRESULT InputMethodWin::OnDocumentFeed(RECONVERTSTRING *reconv) { On 2011/10/26 16:20:16, Peng wrote: > On 2011/10/26 04:25:38, James Su wrote: > > On 2011/10/25 22:01:21, Peng wrote: > > > On 2011/10/25 19:15:03, James Su wrote: > > > > Please refer to the Microsoft sample to see how this method should be > > > > implemented. > > > > > > It is almost same with MS sample. Only a little different - the dwTarget* is > > set > > > with range of selection, when chrome does not have composition. This logic > is > > > same with firefox. > > > > > I mean the extra context thing. > > This function returns all text which can be accessed. So it should be enough. I suggest to do the same thing as the Microsoft SDK sample, as you don't know how large is the whole content will be. It'll be wasteful to return the whole content if it's too large. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:287: } while (0); On 2011/10/26 16:20:16, Peng wrote: > On 2011/10/26 04:25:38, James Su wrote: > > On 2011/10/25 22:01:21, Peng wrote: > > > On 2011/10/25 19:15:03, James Su wrote: > > > > nit: I don't like do { } while(0); style myself. It's decrease the code > > > > readability. Please avoid it if you can. > > > > > > I tried using 'if else', but it looks worse. > > > > > > > Please try your best to rewrite this piece of code to eliminate this do {} > > while(0); thing. I really don't like it. > > I think it is not a big deal. It is very common for avoiding goto statement. At > same time, it may help reduce {} levels. I'd prefer something like: ui::Range target_range; if (client->HasCompositionText()) client->GetCompositionTextRange(&target_range); if (target_range.is_empty()) client->GetSelectionRange(&target_range); ... http://codereview.chromium.org/8294026/diff/35027/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/35027/views/ime/input_method_win.... views/ime/input_method_win.cc:230: ui::TextInputType type = GetTextInputType(); nit: const ui::TextInputType http://codereview.chromium.org/8294026/diff/35027/views/ime/input_method_win.... views/ime/input_method_win.cc:363: size_t len = text_range.length(); It's better not to return all text content, because it'll be wasteful if it's too large.
http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:244: return need_size; On 2011/10/26 18:41:57, James Su wrote: > On 2011/10/26 16:20:16, Peng wrote: > > On 2011/10/26 04:25:38, James Su wrote: > > > On 2011/10/25 22:01:21, Peng wrote: > > > > On 2011/10/25 19:15:03, James Su wrote: > > > > > The actual_range returned by TextInputClient::GetTextFromRange() may be > > > > > different than the request selection range. You need to calculate > > need_size > > > > > according to the actual_range rather than the selection range. > > > > > > > > Because text range must cover the selection range, so GetTextFromRange > will > > > > return the same range of selection range. So I think we can use > > > selection_range > > > > here. And it could avoid calling GetTextFromRange() and a useless string > > > > copying. > > > > > > You can't assume it here, especially if you want to retrieve some extra > > context. > > > > Actually, I would like to remove actual_range from GetTextFromRange() which > will > > simply return false, if it can not get whole text in the range. Is OK? > > > > I don't think it's ok. The current api design looks more reasonable. Remove acutal_range, can make both caller and text input client implementation code simpler. And we do not need call GetTextFromRange twice. It is wasteful. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:268: LRESULT InputMethodWin::OnDocumentFeed(RECONVERTSTRING *reconv) { On 2011/10/26 18:41:57, James Su wrote: > On 2011/10/26 16:20:16, Peng wrote: > > On 2011/10/26 04:25:38, James Su wrote: > > > On 2011/10/25 22:01:21, Peng wrote: > > > > On 2011/10/25 19:15:03, James Su wrote: > > > > > Please refer to the Microsoft sample to see how this method should be > > > > > implemented. > > > > > > > > It is almost same with MS sample. Only a little different - the dwTarget* > is > > > set > > > > with range of selection, when chrome does not have composition. This logic > > is > > > > same with firefox. > > > > > > > I mean the extra context thing. > > > > This function returns all text which can be accessed. So it should be enough. > > I suggest to do the same thing as the Microsoft SDK sample, as you don't know > how large is the whole content will be. It'll be wasteful to return the whole > content if it's too large. It is not easy task to decide how large context is enough. MS is just a simple sample to show how api works, do not mean it is the suitable for us (just an API demo). And in our implementation, the context is from renderer, it is already truncated to reasonable size. We do not need to it again. For omni-box, the content should be in one line. It is not necessary to truncate it. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:287: } while (0); On 2011/10/26 18:41:57, James Su wrote: > On 2011/10/26 16:20:16, Peng wrote: > > On 2011/10/26 04:25:38, James Su wrote: > > > On 2011/10/25 22:01:21, Peng wrote: > > > > On 2011/10/25 19:15:03, James Su wrote: > > > > > nit: I don't like do { } while(0); style myself. It's decrease the code > > > > > readability. Please avoid it if you can. > > > > > > > > I tried using 'if else', but it looks worse. > > > > > > > > > > Please try your best to rewrite this piece of code to eliminate this do {} > > > while(0); thing. I really don't like it. > > > > I think it is not a big deal. It is very common for avoiding goto statement. > At > > same time, it may help reduce {} levels. > > I'd prefer something like: > > ui::Range target_range; > if (client->HasCompositionText()) > client->GetCompositionTextRange(&target_range); Do not need check the return value of GetCompositionTextRange() and GetSelectionRange()? I don't think it is a big deal within reviewing. We do not need wast too much time on it. > if (target_range.is_empty()) > client->GetSelectionRange(&target_range); > ...
http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:244: return need_size; On 2011/10/26 19:36:53, Peng wrote: > On 2011/10/26 18:41:57, James Su wrote: > > On 2011/10/26 16:20:16, Peng wrote: > > > On 2011/10/26 04:25:38, James Su wrote: > > > > On 2011/10/25 22:01:21, Peng wrote: > > > > > On 2011/10/25 19:15:03, James Su wrote: > > > > > > The actual_range returned by TextInputClient::GetTextFromRange() may > be > > > > > > different than the request selection range. You need to calculate > > > need_size > > > > > > according to the actual_range rather than the selection range. > > > > > > > > > > Because text range must cover the selection range, so GetTextFromRange > > will > > > > > return the same range of selection range. So I think we can use > > > > selection_range > > > > > here. And it could avoid calling GetTextFromRange() and a useless string > > > > > copying. > > > > > > > > You can't assume it here, especially if you want to retrieve some extra > > > context. > > > > > > Actually, I would like to remove actual_range from GetTextFromRange() which > > will > > > simply return false, if it can not get whole text in the range. Is OK? > > > > > > > I don't think it's ok. The current api design looks more reasonable. > > Remove acutal_range, can make both caller and text input client implementation > code simpler. And we do not need call GetTextFromRange twice. It is wasteful. actual_range is necessary from the api design point of view. You can make GetTextFromRange() to accept a NULL text pointer to avoid copying the content when not necessary. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:268: LRESULT InputMethodWin::OnDocumentFeed(RECONVERTSTRING *reconv) { On 2011/10/26 19:36:53, Peng wrote: > On 2011/10/26 18:41:57, James Su wrote: > > On 2011/10/26 16:20:16, Peng wrote: > > > On 2011/10/26 04:25:38, James Su wrote: > > > > On 2011/10/25 22:01:21, Peng wrote: > > > > > On 2011/10/25 19:15:03, James Su wrote: > > > > > > Please refer to the Microsoft sample to see how this method should be > > > > > > implemented. > > > > > > > > > > It is almost same with MS sample. Only a little different - the > dwTarget* > > is > > > > set > > > > > with range of selection, when chrome does not have composition. This > logic > > > is > > > > > same with firefox. > > > > > > > > > I mean the extra context thing. > > > > > > This function returns all text which can be accessed. So it should be > enough. > > > > I suggest to do the same thing as the Microsoft SDK sample, as you don't know > > how large is the whole content will be. It'll be wasteful to return the whole > > content if it's too large. > > It is not easy task to decide how large context is enough. MS is just a simple > sample to show how api works, do not mean it is the suitable for us (just an API > demo). And in our implementation, the context is from renderer, it is already > truncated to reasonable size. We do not need to it again. > > For omni-box, the content should be in one line. It is not necessary to truncate > it. The content in omnibox might be huge, especially when dealing with data url (~KB or even ~MB in a single line). And you don't know how a new TextInputClient will be implemented in the future. And somebody else might change the behavior of existing TextInputClient implementations in the future. So please do not assume that you know their internal behavior. You should solely program your part by using the interface exposed to you. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:287: } while (0); On 2011/10/26 19:36:53, Peng wrote: > On 2011/10/26 18:41:57, James Su wrote: > > On 2011/10/26 16:20:16, Peng wrote: > > > On 2011/10/26 04:25:38, James Su wrote: > > > > On 2011/10/25 22:01:21, Peng wrote: > > > > > On 2011/10/25 19:15:03, James Su wrote: > > > > > > nit: I don't like do { } while(0); style myself. It's decrease the > code > > > > > > readability. Please avoid it if you can. > > > > > > > > > > I tried using 'if else', but it looks worse. > > > > > > > > > > > > > Please try your best to rewrite this piece of code to eliminate this do {} > > > > while(0); thing. I really don't like it. > > > > > > I think it is not a big deal. It is very common for avoiding goto statement. > > At > > > same time, it may help reduce {} levels. > > > > I'd prefer something like: > > > > ui::Range target_range; > > if (client->HasCompositionText()) > > client->GetCompositionTextRange(&target_range); > > Do not need check the return value of GetCompositionTextRange() and > GetSelectionRange()? I don't think it is a big deal within reviewing. We do not > need wast too much time on it. The return value is actually not a big deal here. The TextInputClient implementation should not alter the value of target_range if it returns false. Perhaps we should state it explicitly in the method comment. If you do want to check the return value, you can use a local boolean variable to keep the method result and check it after calling the method. It helps keep the code readability. On the contrary, the code readability IS a big deal. Please do whatever you can to keep it. > > > if (target_range.is_empty()) > > client->GetSelectionRange(&target_range); > > ... >
http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:244: return need_size; On 2011/10/26 19:57:17, James Su wrote: > On 2011/10/26 19:36:53, Peng wrote: > > On 2011/10/26 18:41:57, James Su wrote: > > > On 2011/10/26 16:20:16, Peng wrote: > > > > On 2011/10/26 04:25:38, James Su wrote: > > > > > On 2011/10/25 22:01:21, Peng wrote: > > > > > > On 2011/10/25 19:15:03, James Su wrote: > > > > > > > The actual_range returned by TextInputClient::GetTextFromRange() may > > be > > > > > > > different than the request selection range. You need to calculate > > > > need_size > > > > > > > according to the actual_range rather than the selection range. > > > > > > > > > > > > Because text range must cover the selection range, so GetTextFromRange > > > will > > > > > > return the same range of selection range. So I think we can use > > > > > selection_range > > > > > > here. And it could avoid calling GetTextFromRange() and a useless > string > > > > > > copying. > > > > > > > > > > You can't assume it here, especially if you want to retrieve some extra > > > > context. > > > > > > > > Actually, I would like to remove actual_range from GetTextFromRange() > which > > > will > > > > simply return false, if it can not get whole text in the range. Is OK? > > > > > > > > > > I don't think it's ok. The current api design looks more reasonable. > > > > Remove acutal_range, can make both caller and text input client implementation > > code simpler. And we do not need call GetTextFromRange twice. It is wasteful. > > actual_range is necessary from the api design point of view. You can make > GetTextFromRange() to accept a NULL text pointer to avoid copying the content > when not necessary. I didn't get it. Why we must have it from the API design point of view. I remove it from TextInputClient and refined the document for APIs. That makes code simpler. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:268: LRESULT InputMethodWin::OnDocumentFeed(RECONVERTSTRING *reconv) { On 2011/10/26 19:57:17, James Su wrote: > On 2011/10/26 19:36:53, Peng wrote: > > On 2011/10/26 18:41:57, James Su wrote: > > > On 2011/10/26 16:20:16, Peng wrote: > > > > On 2011/10/26 04:25:38, James Su wrote: > > > > > On 2011/10/25 22:01:21, Peng wrote: > > > > > > On 2011/10/25 19:15:03, James Su wrote: > > > > > > > Please refer to the Microsoft sample to see how this method should > be > > > > > > > implemented. > > > > > > > > > > > > It is almost same with MS sample. Only a little different - the > > dwTarget* > > > is > > > > > set > > > > > > with range of selection, when chrome does not have composition. This > > logic > > > > is > > > > > > same with firefox. > > > > > > > > > > > I mean the extra context thing. > > > > > > > > This function returns all text which can be accessed. So it should be > > enough. > > > > > > I suggest to do the same thing as the Microsoft SDK sample, as you don't > know > > > how large is the whole content will be. It'll be wasteful to return the > whole > > > content if it's too large. > > > > It is not easy task to decide how large context is enough. MS is just a simple > > sample to show how api works, do not mean it is the suitable for us (just an > API > > demo). And in our implementation, the context is from renderer, it is already > > truncated to reasonable size. We do not need to it again. > > > > For omni-box, the content should be in one line. It is not necessary to > truncate > > it. > > The content in omnibox might be huge, especially when dealing with data url (~KB > or even ~MB in a single line). And you don't know how a new TextInputClient will > be implemented in the future. And somebody else might change the behavior of > existing TextInputClient implementations in the future. So please do not assume > that you know their internal behavior. You should solely program your part by > using the interface exposed to you. So I think currently it is better to just return the all document right now. Event if in some very minor cases, the size of document could be several KBs or more. In those case, return all document, I don't see any problem. And IMEs could refuse it, if the IMEs think the required size is too big. (Mozc has this logic) http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:287: } while (0); On 2011/10/26 19:57:17, James Su wrote: > On 2011/10/26 19:36:53, Peng wrote: > > On 2011/10/26 18:41:57, James Su wrote: > > > On 2011/10/26 16:20:16, Peng wrote: > > > > On 2011/10/26 04:25:38, James Su wrote: > > > > > On 2011/10/25 22:01:21, Peng wrote: > > > > > > On 2011/10/25 19:15:03, James Su wrote: > > > > > > > nit: I don't like do { } while(0); style myself. It's decrease the > > code > > > > > > > readability. Please avoid it if you can. > > > > > > > > > > > > I tried using 'if else', but it looks worse. > > > > > > > > > > > > > > > > Please try your best to rewrite this piece of code to eliminate this do > {} > > > > > while(0); thing. I really don't like it. > > > > > > > > I think it is not a big deal. It is very common for avoiding goto > statement. > > > At > > > > same time, it may help reduce {} levels. > > > > > > I'd prefer something like: > > > > > > ui::Range target_range; > > > if (client->HasCompositionText()) > > > client->GetCompositionTextRange(&target_range); > > > > Do not need check the return value of GetCompositionTextRange() and > > GetSelectionRange()? I don't think it is a big deal within reviewing. We do > not > > need wast too much time on it. > The return value is actually not a big deal here. The TextInputClient > implementation should not alter the value of target_range if it returns false. > Perhaps we should state it explicitly in the method comment. > > If you do want to check the return value, you can use a local boolean variable > to keep the method result and check it after calling the method. It helps keep > the code readability. > > On the contrary, the code readability IS a big deal. Please do whatever you can > to keep it. > > > > > > if (target_range.is_empty()) > > > client->GetSelectionRange(&target_range); > > > ... > > > Done. http://codereview.chromium.org/8294026/diff/42002/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/42002/views/ime/input_method_win.... views/ime/input_method_win.cc:358: size_t need_size = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR); I checked document of IMR_RECONVERTSTRING & IMR_DOCUMENTFEED. It is just for IME requiring a piece of text which application want to reconvert. If IME want to make it more accurate, the IME could use IMR_DOCUMENTFEED for more content.
http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:244: return need_size; On 2011/10/27 00:28:00, Peng wrote: > On 2011/10/26 19:57:17, James Su wrote: > > On 2011/10/26 19:36:53, Peng wrote: > > > On 2011/10/26 18:41:57, James Su wrote: > > > > On 2011/10/26 16:20:16, Peng wrote: > > > > > On 2011/10/26 04:25:38, James Su wrote: > > > > > > On 2011/10/25 22:01:21, Peng wrote: > > > > > > > On 2011/10/25 19:15:03, James Su wrote: > > > > > > > > The actual_range returned by TextInputClient::GetTextFromRange() > may > > > be > > > > > > > > different than the request selection range. You need to calculate > > > > > need_size > > > > > > > > according to the actual_range rather than the selection range. > > > > > > > > > > > > > > Because text range must cover the selection range, so > GetTextFromRange > > > > will > > > > > > > return the same range of selection range. So I think we can use > > > > > > selection_range > > > > > > > here. And it could avoid calling GetTextFromRange() and a useless > > string > > > > > > > copying. > > > > > > > > > > > > You can't assume it here, especially if you want to retrieve some > extra > > > > > context. > > > > > > > > > > Actually, I would like to remove actual_range from GetTextFromRange() > > which > > > > will > > > > > simply return false, if it can not get whole text in the range. Is OK? > > > > > > > > > > > > > I don't think it's ok. The current api design looks more reasonable. > > > > > > Remove acutal_range, can make both caller and text input client > implementation > > > code simpler. And we do not need call GetTextFromRange twice. It is > wasteful. > > > > actual_range is necessary from the api design point of view. You can make > > GetTextFromRange() to accept a NULL text pointer to avoid copying the content > > when not necessary. > > I didn't get it. Why we must have it from the API design point of view. I remove > it from TextInputClient and refined the document for APIs. That makes code > simpler. Without |actual_range| it's impossible for the client to fulfill the IME's requirement partially. But in some cases, if the IME wants to retrieve some extra context to help increase conversion accuracy, it's ok for the client to return less context, which may affect the conversion accuracy, but won't break the functionality completely. Without the parameter, the functionality will be broken completely. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:268: LRESULT InputMethodWin::OnDocumentFeed(RECONVERTSTRING *reconv) { On 2011/10/27 00:28:00, Peng wrote: > On 2011/10/26 19:57:17, James Su wrote: > > On 2011/10/26 19:36:53, Peng wrote: > > > On 2011/10/26 18:41:57, James Su wrote: > > > > On 2011/10/26 16:20:16, Peng wrote: > > > > > On 2011/10/26 04:25:38, James Su wrote: > > > > > > On 2011/10/25 22:01:21, Peng wrote: > > > > > > > On 2011/10/25 19:15:03, James Su wrote: > > > > > > > > Please refer to the Microsoft sample to see how this method should > > be > > > > > > > > implemented. > > > > > > > > > > > > > > It is almost same with MS sample. Only a little different - the > > > dwTarget* > > > > is > > > > > > set > > > > > > > with range of selection, when chrome does not have composition. This > > > logic > > > > > is > > > > > > > same with firefox. > > > > > > > > > > > > > I mean the extra context thing. > > > > > > > > > > This function returns all text which can be accessed. So it should be > > > enough. > > > > > > > > I suggest to do the same thing as the Microsoft SDK sample, as you don't > > know > > > > how large is the whole content will be. It'll be wasteful to return the > > whole > > > > content if it's too large. > > > > > > It is not easy task to decide how large context is enough. MS is just a > simple > > > sample to show how api works, do not mean it is the suitable for us (just an > > API > > > demo). And in our implementation, the context is from renderer, it is > already > > > truncated to reasonable size. We do not need to it again. > > > > > > For omni-box, the content should be in one line. It is not necessary to > > truncate > > > it. > > > > The content in omnibox might be huge, especially when dealing with data url > (~KB > > or even ~MB in a single line). And you don't know how a new TextInputClient > will > > be implemented in the future. And somebody else might change the behavior of > > existing TextInputClient implementations in the future. So please do not > assume > > that you know their internal behavior. You should solely program your part by > > using the interface exposed to you. > > So I think currently it is better to just return the all document right now. > Event if in some very minor cases, the size of document could be several KBs or > more. In those case, return all document, I don't see any problem. And IMEs > could refuse it, if the IMEs think the required size is too big. (Mozc has this > logic) > As I said, the document might be huge, and if the IME has logic to reject huge document, then the functionality might be broken completely. Even if the IME doesn't reject the huge document, copying the content each time is still wasteful. http://codereview.chromium.org/8294026/diff/42002/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/42002/views/ime/input_method_win.... views/ime/input_method_win.cc:358: size_t need_size = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR); On 2011/10/27 00:28:00, Peng wrote: > I checked document of IMR_RECONVERTSTRING & IMR_DOCUMENTFEED. It is just for IME > requiring a piece of text which application want to reconvert. If IME want to > make it more accurate, the IME could use IMR_DOCUMENTFEED for more content. When doing reconversion, the IME can use the surrounding context provided by IMR_RECONVERTSTRING to improve the accuracy. IMR_DOCUMENTFEED is used when the IME wants to improve the accuracy of normal input, e.g. inserting new text in the middle of existing document.
Greetings, Thanks for your response. I do understand Chrome disables IMEs on password fields and WebKit replaces all password characters with U+2022. I just would like to note we should do our best to prevent leaking such sensitive information. To describe Safari 5.1, its WebProcess returns an empty string when the focused element is a password field even though WebKit replaces all password characters with U+2022. Same as Safari, it may be safer also to sand an empty string to a browser process when the focused element is a password field? Regards, Hironori Bono http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... File chrome/browser/renderer_host/render_widget_host_view_views.cc (right): http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.cc:751: bool RenderWidgetHostViewViews::GetTextRange(ui::Range* range) { nit: I prefer adding 'DCHECK(range)' here. http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.cc:752: *range = ui::Range(selection_text_offset_, nit: can we use operator= for ui::Range? In general, Google coding style does not encourage using copy constructors <http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Copy_C...>. http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.cc:763: bool RenderWidgetHostViewViews::GetSelectionRange(ui::Range* range) { nit: I prefer adding 'DCHECK(range)' here. http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.cc:764: *range = selection_range_; nit: if ui::Range explicitly allows using copy constructors, I prefer replacing it with set_start() and set_end(). http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.cc:782: string16* text) { nit: I prefer adding 'DCHECK(text)' here. http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... File chrome/browser/renderer_host/render_widget_host_view_views.h (right): http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.h:180: string16* text) OVERRIDE; nit: can you add '#include "base/compiler_specific.h"' and '#include "base/string16.h"' at the beginning of this file? http://codereview.chromium.org/8294026/diff/42002/content/browser/renderer_ho... File content/browser/renderer_host/render_widget_host_view.cc (right): http://codereview.chromium.org/8294026/diff/42002/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view.cc:68: selection_range_ = range; nit: if ui::Range explicitly allows using copy constructors, I prefer replacing it with set_start() and set_end().
http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:244: return need_size; On 2011/10/27 04:56:39, James Su wrote: > On 2011/10/27 00:28:00, Peng wrote: > > On 2011/10/26 19:57:17, James Su wrote: > > > On 2011/10/26 19:36:53, Peng wrote: > > > > On 2011/10/26 18:41:57, James Su wrote: > > > > > On 2011/10/26 16:20:16, Peng wrote: > > > > > > On 2011/10/26 04:25:38, James Su wrote: > > > > > > > On 2011/10/25 22:01:21, Peng wrote: > > > > > > > > On 2011/10/25 19:15:03, James Su wrote: > > > > > > > > > The actual_range returned by TextInputClient::GetTextFromRange() > > may > > > > be > > > > > > > > > different than the request selection range. You need to > calculate > > > > > > need_size > > > > > > > > > according to the actual_range rather than the selection range. > > > > > > > > > > > > > > > > Because text range must cover the selection range, so > > GetTextFromRange > > > > > will > > > > > > > > return the same range of selection range. So I think we can use > > > > > > > selection_range > > > > > > > > here. And it could avoid calling GetTextFromRange() and a useless > > > string > > > > > > > > copying. > > > > > > > > > > > > > > You can't assume it here, especially if you want to retrieve some > > extra > > > > > > context. > > > > > > > > > > > > Actually, I would like to remove actual_range from GetTextFromRange() > > > which > > > > > will > > > > > > simply return false, if it can not get whole text in the range. Is OK? > > > > > > > > > > > > > > > > I don't think it's ok. The current api design looks more reasonable. > > > > > > > > Remove acutal_range, can make both caller and text input client > > implementation > > > > code simpler. And we do not need call GetTextFromRange twice. It is > > wasteful. > > > > > > actual_range is necessary from the api design point of view. You can make > > > GetTextFromRange() to accept a NULL text pointer to avoid copying the > content > > > when not necessary. > > > > I didn't get it. Why we must have it from the API design point of view. I > remove > > it from TextInputClient and refined the document for APIs. That makes code > > simpler. > > Without |actual_range| it's impossible for the client to fulfill the IME's > requirement partially. But in some cases, if the IME wants to retrieve some > extra context to help increase conversion accuracy, it's ok for the client to > return less context, which may affect the conversion accuracy, but won't break > the functionality completely. Without the parameter, the functionality will be > broken completely. I refined the document. The text input client must return the whole text in the requested range. It makes the logic simpler. If the client can return text in another range, it will make the code complex. API users have to check if the returned text can cover the range which is needed. And I also refined the document of GetTextRange(), it will return a text range in the document which can be accessed by GetTextFromRange(). So API users can use GetTextRange() to get the accessible range before calling GetTextFrameRange(). It will not break anything. Thanks for your suggestions. But I like define the API in this way which I think is better. http://codereview.chromium.org/8294026/diff/32001/views/ime/input_method_win.... views/ime/input_method_win.cc:268: LRESULT InputMethodWin::OnDocumentFeed(RECONVERTSTRING *reconv) { On 2011/10/27 04:56:39, James Su wrote: > On 2011/10/27 00:28:00, Peng wrote: > > On 2011/10/26 19:57:17, James Su wrote: > > > On 2011/10/26 19:36:53, Peng wrote: > > > > On 2011/10/26 18:41:57, James Su wrote: > > > > > On 2011/10/26 16:20:16, Peng wrote: > > > > > > On 2011/10/26 04:25:38, James Su wrote: > > > > > > > On 2011/10/25 22:01:21, Peng wrote: > > > > > > > > On 2011/10/25 19:15:03, James Su wrote: > > > > > > > > > Please refer to the Microsoft sample to see how this method > should > > > be > > > > > > > > > implemented. > > > > > > > > > > > > > > > > It is almost same with MS sample. Only a little different - the > > > > dwTarget* > > > > > is > > > > > > > set > > > > > > > > with range of selection, when chrome does not have composition. > This > > > > logic > > > > > > is > > > > > > > > same with firefox. > > > > > > > > > > > > > > > I mean the extra context thing. > > > > > > > > > > > > This function returns all text which can be accessed. So it should be > > > > enough. > > > > > > > > > > I suggest to do the same thing as the Microsoft SDK sample, as you don't > > > know > > > > > how large is the whole content will be. It'll be wasteful to return the > > > whole > > > > > content if it's too large. > > > > > > > > It is not easy task to decide how large context is enough. MS is just a > > simple > > > > sample to show how api works, do not mean it is the suitable for us (just > an > > > API > > > > demo). And in our implementation, the context is from renderer, it is > > already > > > > truncated to reasonable size. We do not need to it again. > > > > > > > > For omni-box, the content should be in one line. It is not necessary to > > > truncate > > > > it. > > > > > > The content in omnibox might be huge, especially when dealing with data url > > (~KB > > > or even ~MB in a single line). And you don't know how a new TextInputClient > > will > > > be implemented in the future. And somebody else might change the behavior > of > > > existing TextInputClient implementations in the future. So please do not > > assume > > > that you know their internal behavior. You should solely program your part > by > > > using the interface exposed to you. > > > > So I think currently it is better to just return the all document right now. > > Event if in some very minor cases, the size of document could be several KBs > or > > more. In those case, return all document, I don't see any problem. And IMEs > > could refuse it, if the IMEs think the required size is too big. (Mozc has > this > > logic) > > > > As I said, the document might be huge, and if the IME has logic to reject huge > document, then the functionality might be broken completely. Even if the IME > doesn't reject the huge document, copying the content each time is still > wasteful. I would like to implement this function as firefox does. It only returns the fewest number of paragraphs which can cover the target range. And it searches the '\n' in the text as borders of paragraphs. But I think it is not too necessary to do it now, because our text clients RHWVV returns truncated text, and omnibox returns single line text. As you wish, I truncated the text here. Done. http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... File chrome/browser/renderer_host/render_widget_host_view_views.cc (right): http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.cc:751: bool RenderWidgetHostViewViews::GetTextRange(ui::Range* range) { On 2011/10/27 06:17:47, hbono wrote: > nit: I prefer adding 'DCHECK(range)' here. I used those kind of DHCECK() for input arguments. But some reviewer told me it is not necessary. They think crash in function can be found and resolved easily, even if without DCHECK(). So I removed them. http://codereview.chromium.org/8294026/diff/22016/chrome/browser/renderer_hos... http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.cc:752: *range = ui::Range(selection_text_offset_, On 2011/10/27 06:17:47, hbono wrote: > nit: can we use operator= for ui::Range? In general, Google coding style does > not encourage using copy constructors > <http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Copy_C...>. Done. http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.cc:752: *range = ui::Range(selection_text_offset_, On 2011/10/27 06:17:47, hbono wrote: > nit: can we use operator= for ui::Range? In general, Google coding style does > not encourage using copy constructors > <http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Copy_C...>. Done. http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.cc:763: bool RenderWidgetHostViewViews::GetSelectionRange(ui::Range* range) { On 2011/10/27 06:17:47, hbono wrote: > nit: I prefer adding 'DCHECK(range)' here. ditto http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.cc:764: *range = selection_range_; On 2011/10/27 06:17:47, hbono wrote: > nit: if ui::Range explicitly allows using copy constructors, I prefer replacing > it with set_start() and set_end(). Done. http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.cc:782: string16* text) { On 2011/10/27 06:17:47, hbono wrote: > nit: I prefer adding 'DCHECK(text)' here. ditto http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... File chrome/browser/renderer_host/render_widget_host_view_views.h (right): http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... chrome/browser/renderer_host/render_widget_host_view_views.h:180: string16* text) OVERRIDE; On 2011/10/27 06:17:47, hbono wrote: > nit: can you add '#include "base/compiler_specific.h"' and '#include > "base/string16.h"' at the beginning of this file? Done. http://codereview.chromium.org/8294026/diff/42002/content/browser/renderer_ho... File content/browser/renderer_host/render_widget_host_view.cc (right): http://codereview.chromium.org/8294026/diff/42002/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view.cc:68: selection_range_ = range; On 2011/10/27 06:17:47, hbono wrote: > nit: if ui::Range explicitly allows using copy constructors, I prefer replacing > it with set_start() and set_end(). Done. http://codereview.chromium.org/8294026/diff/42002/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/42002/views/ime/input_method_win.... views/ime/input_method_win.cc:358: size_t need_size = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR); On 2011/10/27 04:56:39, James Su wrote: > On 2011/10/27 00:28:00, Peng wrote: > > I checked document of IMR_RECONVERTSTRING & IMR_DOCUMENTFEED. It is just for > IME > > requiring a piece of text which application want to reconvert. If IME want to > > make it more accurate, the IME could use IMR_DOCUMENTFEED for more content. > > When doing reconversion, the IME can use the surrounding context provided by > IMR_RECONVERTSTRING to improve the accuracy. Because we do not implement the logic to allow IME adjust the reconvert range. And providing extra text to IME can also cause information leaking. So I decide to just return the text in the selection range right now until we can support adjusting the reconvert range and figure out the privacy impact. I am also wondering if I should remove OnDocumentFeed(). I tested with some IMEs, did not find any IME use this message. But this function may have security issue.
http://codereview.chromium.org/8294026/diff/42002/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/42002/views/ime/input_method_win.... views/ime/input_method_win.cc:358: size_t need_size = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR); On 2011/10/27 16:12:24, Peng wrote: > On 2011/10/27 04:56:39, James Su wrote: > > On 2011/10/27 00:28:00, Peng wrote: > > > I checked document of IMR_RECONVERTSTRING & IMR_DOCUMENTFEED. It is just for > > IME > > > requiring a piece of text which application want to reconvert. If IME want > to > > > make it more accurate, the IME could use IMR_DOCUMENTFEED for more content. > > > > When doing reconversion, the IME can use the surrounding context provided by > > IMR_RECONVERTSTRING to improve the accuracy. > > Because we do not implement the logic to allow IME adjust the reconvert range. > And providing extra text to IME can also cause information leaking. So I decide > to just return the text in the selection range right now until we can support > adjusting the reconvert range and figure out the privacy impact. You still don't get the point. 1) This method has nothing to do with the "set reconvert range" thing. They are independent functionalities. 2) Returning some extra surrounding context along with the selection text can improve the reconversion accuracy if the input method can make use the information. 3) I don't think the privacy impact is a big issue, as we already return the text inside the selection range. Returning a little more text won't make the situation worse. > > I am also wondering if I should remove OnDocumentFeed(). I tested with some > IMEs, did not find any IME use this message. But this function may have security > issue. It may not be very easy to find out whether an IME uses this feature or not. Because the IME method will still work without this feature. it'll only affect the conversion accuracy. I think this method is nice to have. And the privacy issue should not be a big deal. As we already support similar feature on Mac. http://codereview.chromium.org/8294026/diff/42003/views/ime/text_input_client.h File views/ime/text_input_client.h (right): http://codereview.chromium.org/8294026/diff/42003/views/ime/text_input_client... views/ime/text_input_client.h:77: // the View. It must cover the composition and selection range. nit: accessabled -> accessible. http://codereview.chromium.org/8294026/diff/42003/views/ime/text_input_client... views/ime/text_input_client.h:101: // The result will be written in text. nit: The result will be stored into |*text|. http://codereview.chromium.org/8294026/diff/42003/views/ime/text_input_client... views/ime/text_input_client.h:103: // given range. nit: ... or the specified range is out of the text range returned by GetTextRange(). Now I understand your intention to remove the |actual_text| parameter. I agree that it's also a feasible way. Comparing the original API, your proposal moves the implementation burden to the input method side. With the original API, the input method can simply call GetTextFromRange() with a range it wants and rely on the text input client to adjust the range to a supported range. The input method does not need to care about if the specified range is out of the text range returned by GetTextRange() or not. Because the text input client ensures the validity of the actual_range value. In another word, in the original API, GetTextRange() method is actually not mandatory. With your proposal, the input method must make sure the required range is inside the text range returned by GetTextRange() before calling GetTextFromRange(), otherwise the call will fail. So you can see that, your proposal actually does not simplify the code as you thought. It just moves the code around. I'd like to see how the code looks with the original API, so that we can compare these two approach to see which one is better.
http://codereview.chromium.org/8294026/diff/42003/content/browser/renderer_ho... File content/browser/renderer_host/render_widget_host_view_win.cc (right): http://codereview.chromium.org/8294026/diff/42003/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view_win.cc:2141: return reinterpret_cast<LRESULT>(reconv); Please consider to extract the common code from this method and InputMethodWin::OnReconvertString() and put them into a shared function in ime_input.cc http://codereview.chromium.org/8294026/diff/42003/views/controls/textfield/na... File views/controls/textfield/native_textfield_views.cc (right): http://codereview.chromium.org/8294026/diff/42003/views/controls/textfield/na... views/controls/textfield/native_textfield_views.cc:798: *text = model_->GetTextFromRange(range); You need to make sure the range is inside the content range and return false if it's not. http://codereview.chromium.org/8294026/diff/42003/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/42003/views/ime/input_method_win.... views/ime/input_method_win.cc:13: static const size_t kExtraNumberOfChars = 100; I think 10~20 should be enough. And how about to add a comment to describe the purpose of this constant? http://codereview.chromium.org/8294026/diff/42003/views/ime/input_method_win.... views/ime/input_method_win.cc:285: LRESULT InputMethodWin::OnDocumentFeed(RECONVERTSTRING *reconv) { Per our discussion, feel free to remove this method if you think it's not important at all. But it'll be best if you can add some comment to explain the reason. And maybe we can add a TODO for it, in case we want it in the future. http://codereview.chromium.org/8294026/diff/42003/views/ime/input_method_win.... views/ime/input_method_win.cc:365: size_t len = selection_range.length(); If you really don't want to return extra surrounding context, please add a comment to explain the reason and add a TODO, in case we want to support it in the future to help improve IMEs' reconversion accuracy. http://codereview.chromium.org/8294026/diff/42003/views/ime/input_method_win.... views/ime/input_method_win.cc:375: if (!GetTextInputClient()->GetTextFromRange(selection_range, &text)) nit: check the text length in case it's shorter than len? http://codereview.chromium.org/8294026/diff/42003/views/ime/input_method_win.... views/ime/input_method_win.cc:389: return reinterpret_cast<LRESULT>(reconv); Though msdn says that this method should return the structure on success, but I'd rather believe it's a mistake of the document, because any implementations I can find on the internet return the structure size instead, even the sample provided by Microsoft.
http://codereview.chromium.org/8294026/diff/42003/content/browser/renderer_ho... File content/browser/renderer_host/render_widget_host_view_win.cc (right): http://codereview.chromium.org/8294026/diff/42003/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view_win.cc:2141: return reinterpret_cast<LRESULT>(reconv); On 2011/10/28 04:20:45, James Su wrote: > Please consider to extract the common code from this method and > InputMethodWin::OnReconvertString() and put them into a shared function in > ime_input.cc I didn't find a easy way to do it. Because ime_input.cc do not have a good way to get the text, text_range, selection_range and etc from TextInputClient and RWHVWin. Probably the only way I can figure out is let RWHVWin implements the TextInputClient interface too, and pass the textinputclient to ime_input.cc. I think it is not must to do, right? http://codereview.chromium.org/8294026/diff/42003/views/controls/textfield/na... File views/controls/textfield/native_textfield_views.cc (right): http://codereview.chromium.org/8294026/diff/42003/views/controls/textfield/na... views/controls/textfield/native_textfield_views.cc:798: *text = model_->GetTextFromRange(range); On 2011/10/28 04:20:45, James Su wrote: > You need to make sure the range is inside the content range and return false if > it's not. Done. http://codereview.chromium.org/8294026/diff/42003/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/42003/views/ime/input_method_win.... views/ime/input_method_win.cc:13: static const size_t kExtraNumberOfChars = 100; On 2011/10/28 04:20:45, James Su wrote: > I think 10~20 should be enough. > And how about to add a comment to describe the purpose of this constant? Done. http://codereview.chromium.org/8294026/diff/42003/views/ime/input_method_win.... views/ime/input_method_win.cc:365: size_t len = selection_range.length(); On 2011/10/28 04:20:45, James Su wrote: > If you really don't want to return extra surrounding context, please add a > comment to explain the reason and add a TODO, in case we want to support it in > the future to help improve IMEs' reconversion accuracy. Done. http://codereview.chromium.org/8294026/diff/42003/views/ime/input_method_win.... views/ime/input_method_win.cc:375: if (!GetTextInputClient()->GetTextFromRange(selection_range, &text)) On 2011/10/28 04:20:45, James Su wrote: > nit: check the text length in case it's shorter than len? The API guarantee the text has right size with given range. So checking it is not necessary. http://codereview.chromium.org/8294026/diff/42003/views/ime/input_method_win.... views/ime/input_method_win.cc:389: return reinterpret_cast<LRESULT>(reconv); On 2011/10/28 04:20:45, James Su wrote: > Though msdn says that this method should return the structure on success, but > I'd rather believe it's a mistake of the document, because any implementations I > can find on the internet return the structure size instead, even the sample > provided by Microsoft. I am not sure. Most IME just tests the return value is not zero. So both are OK. But if some IMEs test the return value with the structure pointer, it may has problem. So I guess following API document is safer. http://codereview.chromium.org/8294026/diff/42003/views/ime/text_input_client.h File views/ime/text_input_client.h (right): http://codereview.chromium.org/8294026/diff/42003/views/ime/text_input_client... views/ime/text_input_client.h:77: // the View. It must cover the composition and selection range. On 2011/10/27 18:39:49, James Su wrote: > nit: accessabled -> accessible. Done. http://codereview.chromium.org/8294026/diff/42003/views/ime/text_input_client... views/ime/text_input_client.h:101: // The result will be written in text. On 2011/10/27 18:39:49, James Su wrote: > nit: The result will be stored into |*text|. Done. http://codereview.chromium.org/8294026/diff/42003/views/ime/text_input_client... views/ime/text_input_client.h:103: // given range. On 2011/10/27 18:39:49, James Su wrote: > nit: ... or the specified range is out of the text range returned by > GetTextRange(). > > Now I understand your intention to remove the |actual_text| parameter. I agree > that it's also a feasible way. Comparing the original API, your proposal moves > the implementation burden to the input method side. > > With the original API, the input method can simply call GetTextFromRange() with > a range it wants and rely on the text input client to adjust the range to a > supported range. The input method does not need to care about if the specified > range is out of the text range returned by GetTextRange() or not. Because the > text input client ensures the validity of the actual_range value. > In another word, in the original API, GetTextRange() method is actually not > mandatory. > > With your proposal, the input method must make sure the required range is inside > the text range returned by GetTextRange() before calling GetTextFromRange(), > otherwise the call will fail. > > So you can see that, your proposal actually does not simplify the code as you > thought. It just moves the code around. > > I'd like to see how the code looks with the original API, so that we can compare > these two approach to see which one is better. Done.
http://codereview.chromium.org/8294026/diff/42003/content/browser/renderer_ho... File content/browser/renderer_host/render_widget_host_view_win.cc (right): http://codereview.chromium.org/8294026/diff/42003/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view_win.cc:2141: return reinterpret_cast<LRESULT>(reconv); On 2011/10/28 15:42:19, Peng wrote: > On 2011/10/28 04:20:45, James Su wrote: > > Please consider to extract the common code from this method and > > InputMethodWin::OnReconvertString() and put them into a shared function in > > ime_input.cc > > I didn't find a easy way to do it. Because ime_input.cc do not have a good way > to get the text, text_range, selection_range and etc from TextInputClient and > RWHVWin. > > Probably the only way I can figure out is let RWHVWin implements the > TextInputClient interface too, and pass the textinputclient to ime_input.cc. I > think it is not must to do, right? > I think at least the part of filling reconv structure can be extracted (line 2121~2141). It helps make the code more maintainable. http://codereview.chromium.org/8294026/diff/39015/content/browser/renderer_ho... File content/browser/renderer_host/render_widget_host_view_win.cc (right): http://codereview.chromium.org/8294026/diff/39015/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view_win.cc:2072: return 0; This method should work even if there is no selection. http://codereview.chromium.org/8294026/diff/39015/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view_win.cc:2098: selection_text_.c_str(), len * sizeof(WCHAR)); nit: alignment http://codereview.chromium.org/8294026/diff/39015/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view_win.cc:2139: selection_text_.c_str() + offset, len * sizeof(WCHAR)); nit: alignment http://codereview.chromium.org/8294026/diff/39015/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/39015/views/ime/input_method_win.... views/ime/input_method_win.cc:328: return 0; nit: DCHECK_EQ(text_range.length(), text.length()); http://codereview.chromium.org/8294026/diff/39015/views/ime/input_method_win.... views/ime/input_method_win.cc:341: text.c_str(), len * sizeof(WCHAR)); nit: alignment. http://codereview.chromium.org/8294026/diff/39015/views/ime/input_method_win.... views/ime/input_method_win.cc:378: // don't return exrat content. I'd suggest to remove this paragraph. As I said returning extra context has nothing to do with adjusting the reconvert range. And I don't think there is a privacy issue. http://codereview.chromium.org/8294026/diff/39015/views/ime/input_method_win.... views/ime/input_method_win.cc:379: // TODO(penghuang): support IME adjusts the reconvert range. Just: // TODO(penghuang): Return some extra context to help improve IME's reconversion accuracy. It's better to put the TODO of adjusting the reconvert range elsewhere. This place has nothing to do with this feature. http://codereview.chromium.org/8294026/diff/39015/views/ime/input_method_win.... views/ime/input_method_win.cc:382: return 0; nit: DCHECK_EQ(selection_range.length(), text.length()); http://codereview.chromium.org/8294026/diff/39015/views/ime/input_method_win.... views/ime/input_method_win.cc:393: text.c_str(), len * sizeof(WCHAR)); nit: alignment. http://codereview.chromium.org/8294026/diff/39015/views/ime/input_method_win.... views/ime/input_method_win.cc:395: return reinterpret_cast<LRESULT>(reconv); If you insistent on returning the pointer here, I'd suggest to add a comment in case somebody else wants to change it back to size in the future.
http://codereview.chromium.org/8294026/diff/39015/content/browser/renderer_ho... File content/browser/renderer_host/render_widget_host_view_win.cc (right): http://codereview.chromium.org/8294026/diff/39015/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view_win.cc:2072: return 0; On 2011/10/28 18:16:04, James Su wrote: > This method should work even if there is no selection. Done. http://codereview.chromium.org/8294026/diff/39015/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view_win.cc:2098: selection_text_.c_str(), len * sizeof(WCHAR)); On 2011/10/28 18:16:04, James Su wrote: > nit: alignment Done. http://codereview.chromium.org/8294026/diff/39015/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view_win.cc:2139: selection_text_.c_str() + offset, len * sizeof(WCHAR)); On 2011/10/28 18:16:04, James Su wrote: > nit: alignment Done. http://codereview.chromium.org/8294026/diff/39015/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/39015/views/ime/input_method_win.... views/ime/input_method_win.cc:328: return 0; On 2011/10/28 18:16:04, James Su wrote: > nit: DCHECK_EQ(text_range.length(), text.length()); Done. http://codereview.chromium.org/8294026/diff/39015/views/ime/input_method_win.... views/ime/input_method_win.cc:341: text.c_str(), len * sizeof(WCHAR)); On 2011/10/28 18:16:04, James Su wrote: > nit: alignment. Done. http://codereview.chromium.org/8294026/diff/39015/views/ime/input_method_win.... views/ime/input_method_win.cc:378: // don't return exrat content. On 2011/10/28 18:16:04, James Su wrote: > I'd suggest to remove this paragraph. As I said returning extra context has > nothing to do with adjusting the reconvert range. And I don't think there is a > privacy issue. Done. http://codereview.chromium.org/8294026/diff/39015/views/ime/input_method_win.... views/ime/input_method_win.cc:379: // TODO(penghuang): support IME adjusts the reconvert range. On 2011/10/28 18:16:04, James Su wrote: > Just: // TODO(penghuang): Return some extra context to help improve IME's > reconversion accuracy. > > It's better to put the TODO of adjusting the reconvert range elsewhere. This > place has nothing to do with this feature. Done. http://codereview.chromium.org/8294026/diff/39015/views/ime/input_method_win.... views/ime/input_method_win.cc:382: return 0; On 2011/10/28 18:16:04, James Su wrote: > nit: DCHECK_EQ(selection_range.length(), text.length()); Done. http://codereview.chromium.org/8294026/diff/39015/views/ime/input_method_win.... views/ime/input_method_win.cc:393: text.c_str(), len * sizeof(WCHAR)); On 2011/10/28 18:16:04, James Su wrote: > nit: alignment. Done. http://codereview.chromium.org/8294026/diff/39015/views/ime/input_method_win.... views/ime/input_method_win.cc:395: return reinterpret_cast<LRESULT>(reconv); On 2011/10/28 18:16:04, James Su wrote: > If you insistent on returning the pointer here, I'd suggest to add a comment in > case somebody else wants to change it back to size in the future. Done.
http://codereview.chromium.org/8294026/diff/42003/content/browser/renderer_ho... File content/browser/renderer_host/render_widget_host_view_win.cc (right): http://codereview.chromium.org/8294026/diff/42003/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view_win.cc:2141: return reinterpret_cast<LRESULT>(reconv); On 2011/10/28 18:16:04, James Su wrote: > On 2011/10/28 15:42:19, Peng wrote: > > On 2011/10/28 04:20:45, James Su wrote: > > > Please consider to extract the common code from this method and > > > InputMethodWin::OnReconvertString() and put them into a shared function in > > > ime_input.cc > > > > I didn't find a easy way to do it. Because ime_input.cc do not have a good way > > to get the text, text_range, selection_range and etc from TextInputClient and > > RWHVWin. > > > > Probably the only way I can figure out is let RWHVWin implements the > > TextInputClient interface too, and pass the textinputclient to ime_input.cc. I > > think it is not must to do, right? > > > > I think at least the part of filling reconv structure can be extracted (line > 2121~2141). It helps make the code more maintainable. I check the code again and do think they can be extracted and unified into a shared function. The function prototype could be: LRESULT FillReconvertString(const string16& text, size_t comp_len, size_t comp_offset, size_t target_len, size_t target_offset, RECONVERTSTRING* reconv); http://codereview.chromium.org/8294026/diff/50003/content/browser/renderer_ho... File content/browser/renderer_host/render_widget_host_view_win.cc (right): http://codereview.chromium.org/8294026/diff/50003/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view_win.cc:2101: // and return reconv, but some applications return need_size. nit: How about: According to Microsoft API document, ... and ... should return reconv, but ... http://codereview.chromium.org/8294026/diff/50003/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view_win.cc:2144: // and return reconv, but some applications return need_size. ditto. http://codereview.chromium.org/8294026/diff/50003/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/50003/views/ime/input_method_win.... views/ime/input_method_win.cc:345: // and return reconv, but some applications return need_size. ditto. http://codereview.chromium.org/8294026/diff/50003/views/ime/input_method_win.... views/ime/input_method_win.cc:398: // and return reconv, but some applications return need_size. ditto.
http://codereview.chromium.org/8294026/diff/42003/content/browser/renderer_ho... File content/browser/renderer_host/render_widget_host_view_win.cc (right): http://codereview.chromium.org/8294026/diff/42003/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view_win.cc:2141: return reinterpret_cast<LRESULT>(reconv); On 2011/10/28 22:26:32, James Su wrote: > On 2011/10/28 18:16:04, James Su wrote: > > On 2011/10/28 15:42:19, Peng wrote: > > > On 2011/10/28 04:20:45, James Su wrote: > > > > Please consider to extract the common code from this method and > > > > InputMethodWin::OnReconvertString() and put them into a shared function in > > > > ime_input.cc > > > > > > I didn't find a easy way to do it. Because ime_input.cc do not have a good > way > > > to get the text, text_range, selection_range and etc from TextInputClient > and > > > RWHVWin. > > > > > > Probably the only way I can figure out is let RWHVWin implements the > > > TextInputClient interface too, and pass the textinputclient to ime_input.cc. > I > > > think it is not must to do, right? > > > > > > > I think at least the part of filling reconv structure can be extracted (line > > 2121~2141). It helps make the code more maintainable. > > I check the code again and do think they can be extracted and unified into a > shared function. The function prototype could be: > > LRESULT FillReconvertString(const string16& text, size_t comp_len, size_t > comp_offset, size_t target_len, size_t target_offset, RECONVERTSTRING* reconv); I agree. Filling structure can be a function. But I will be on a trip next whole week. And can not test any changes. How about I do it later? So I can also think about how to extract more common code. Thanks. http://codereview.chromium.org/8294026/diff/50003/content/browser/renderer_ho... File content/browser/renderer_host/render_widget_host_view_win.cc (right): http://codereview.chromium.org/8294026/diff/50003/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view_win.cc:2101: // and return reconv, but some applications return need_size. On 2011/10/28 22:26:32, James Su wrote: > nit: How about: According to Microsoft API document, ... and ... should return > reconv, but ... Done. http://codereview.chromium.org/8294026/diff/50003/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view_win.cc:2144: // and return reconv, but some applications return need_size. On 2011/10/28 22:26:32, James Su wrote: > ditto. Done. http://codereview.chromium.org/8294026/diff/50003/views/ime/input_method_win.cc File views/ime/input_method_win.cc (right): http://codereview.chromium.org/8294026/diff/50003/views/ime/input_method_win.... views/ime/input_method_win.cc:345: // and return reconv, but some applications return need_size. On 2011/10/28 22:26:32, James Su wrote: > ditto. Done. http://codereview.chromium.org/8294026/diff/50003/views/ime/input_method_win.... views/ime/input_method_win.cc:398: // and return reconv, but some applications return need_size. On 2011/10/28 22:26:32, James Su wrote: > ditto. Done.
LGTM. http://codereview.chromium.org/8294026/diff/42003/content/browser/renderer_ho... File content/browser/renderer_host/render_widget_host_view_win.cc (right): http://codereview.chromium.org/8294026/diff/42003/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view_win.cc:2141: return reinterpret_cast<LRESULT>(reconv); On 2011/10/29 03:28:10, Peng wrote: > On 2011/10/28 22:26:32, James Su wrote: > > On 2011/10/28 18:16:04, James Su wrote: > > > On 2011/10/28 15:42:19, Peng wrote: > > > > On 2011/10/28 04:20:45, James Su wrote: > > > > > Please consider to extract the common code from this method and > > > > > InputMethodWin::OnReconvertString() and put them into a shared function > in > > > > > ime_input.cc > > > > > > > > I didn't find a easy way to do it. Because ime_input.cc do not have a good > > way > > > > to get the text, text_range, selection_range and etc from TextInputClient > > and > > > > RWHVWin. > > > > > > > > Probably the only way I can figure out is let RWHVWin implements the > > > > TextInputClient interface too, and pass the textinputclient to > ime_input.cc. > > I > > > > think it is not must to do, right? > > > > > > > > > > I think at least the part of filling reconv structure can be extracted (line > > > 2121~2141). It helps make the code more maintainable. > > > > I check the code again and do think they can be extracted and unified into a > > shared function. The function prototype could be: > > > > LRESULT FillReconvertString(const string16& text, size_t comp_len, size_t > > comp_offset, size_t target_len, size_t target_offset, RECONVERTSTRING* > reconv); > > I agree. Filling structure can be a function. But I will be on a trip next whole > week. And can not test any changes. How about I do it later? So I can also > think about how to extract more common code. Thanks. > Alright, but please add a TODO to make sure you won't forget it.
http://codereview.chromium.org/8294026/diff/42003/content/browser/renderer_ho... File content/browser/renderer_host/render_widget_host_view_win.cc (right): http://codereview.chromium.org/8294026/diff/42003/content/browser/renderer_ho... content/browser/renderer_host/render_widget_host_view_win.cc:2141: return reinterpret_cast<LRESULT>(reconv); On 2011/10/30 11:48:39, James Su wrote: > On 2011/10/29 03:28:10, Peng wrote: > > On 2011/10/28 22:26:32, James Su wrote: > > > On 2011/10/28 18:16:04, James Su wrote: > > > > On 2011/10/28 15:42:19, Peng wrote: > > > > > On 2011/10/28 04:20:45, James Su wrote: > > > > > > Please consider to extract the common code from this method and > > > > > > InputMethodWin::OnReconvertString() and put them into a shared > function > > in > > > > > > ime_input.cc > > > > > > > > > > I didn't find a easy way to do it. Because ime_input.cc do not have a > good > > > way > > > > > to get the text, text_range, selection_range and etc from > TextInputClient > > > and > > > > > RWHVWin. > > > > > > > > > > Probably the only way I can figure out is let RWHVWin implements the > > > > > TextInputClient interface too, and pass the textinputclient to > > ime_input.cc. > > > I > > > > > think it is not must to do, right? > > > > > > > > > > > > > I think at least the part of filling reconv structure can be extracted > (line > > > > 2121~2141). It helps make the code more maintainable. > > > > > > I check the code again and do think they can be extracted and unified into a > > > shared function. The function prototype could be: > > > > > > LRESULT FillReconvertString(const string16& text, size_t comp_len, size_t > > > comp_offset, size_t target_len, size_t target_offset, RECONVERTSTRING* > > reconv); > > > > I agree. Filling structure can be a function. But I will be on a trip next > whole > > week. And can not test any changes. How about I do it later? So I can also > > think about how to extract more common code. Thanks. > > > > Alright, but please add a TODO to make sure you won't forget it. Done. filed a bug for it.
On 2011/10/27 06:17:47, hbono wrote: > Greetings, > > Thanks for your response. > I do understand Chrome disables IMEs on password fields and WebKit replaces all > password characters with U+2022. I just would like to note we should do our best > to prevent leaking such sensitive information. To describe Safari 5.1, its > WebProcess returns an empty string when the focused element is a password field > even though WebKit replaces all password characters with U+2022. Same as Safari, > it may be safer also to sand an empty string to a browser process when the > focused element is a password field? Hi Hironori Bono, Currently some code in browser relies on the length of selection_range and text. If they are not same, it may cause some problems. If we send empty string to browser process instead of "***", we need check and change some related code. So I think it is better to keep it unchanged right now, and do it in a separated CL, if necessary. Peng > > http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... > File chrome/browser/renderer_host/render_widget_host_view_views.cc (right): > > http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... > chrome/browser/renderer_host/render_widget_host_view_views.cc:751: bool > RenderWidgetHostViewViews::GetTextRange(ui::Range* range) { > nit: I prefer adding 'DCHECK(range)' here. > > http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... > chrome/browser/renderer_host/render_widget_host_view_views.cc:752: *range = > ui::Range(selection_text_offset_, > nit: can we use operator= for ui::Range? In general, Google coding style does > not encourage using copy constructors > <http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Copy_C...>. > > http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... > chrome/browser/renderer_host/render_widget_host_view_views.cc:763: bool > RenderWidgetHostViewViews::GetSelectionRange(ui::Range* range) { > nit: I prefer adding 'DCHECK(range)' here. > > http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... > chrome/browser/renderer_host/render_widget_host_view_views.cc:764: *range = > selection_range_; > nit: if ui::Range explicitly allows using copy constructors, I prefer replacing > it with set_start() and set_end(). > > http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... > chrome/browser/renderer_host/render_widget_host_view_views.cc:782: string16* > text) { > nit: I prefer adding 'DCHECK(text)' here. > > http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... > File chrome/browser/renderer_host/render_widget_host_view_views.h (right): > > http://codereview.chromium.org/8294026/diff/42002/chrome/browser/renderer_hos... > chrome/browser/renderer_host/render_widget_host_view_views.h:180: string16* > text) OVERRIDE; > nit: can you add '#include "base/compiler_specific.h"' and '#include > "base/string16.h"' at the beginning of this file? > > http://codereview.chromium.org/8294026/diff/42002/content/browser/renderer_ho... > File content/browser/renderer_host/render_widget_host_view.cc (right): > > http://codereview.chromium.org/8294026/diff/42002/content/browser/renderer_ho... > content/browser/renderer_host/render_widget_host_view.cc:68: selection_range_ = > range; > nit: if ui::Range explicitly allows using copy constructors, I prefer replacing > it with set_start() and set_end().
LGTM. Thanks for your change. Regards, Hironori Bono
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/penghuang@chromium.org/8294026/55001
Try job failure for 8294026-55001 on linux_clang for steps "update_scripts, update". http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=linux_clan... Step "update" is always a major failure. Look at the try server FAQ for more details.
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/penghuang@chromium.org/8294026/55001
Change committed as 107934 |