|
|
Description[IME] Fix s_suppressNextKeypressEvent logic in WebViewImpl::setComposition().
This implements suzhe@'s suggested fix, as alternative to the attempt in https://codereview.chromium.org/956133002/ .
Also ported the new test over.
BUG=453499
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=191167
Patch Set 1 #
Total comments: 7
Patch Set 2 : Fixing comments. #Patch Set 3 : Cleaning up logic. #
Messages
Total messages: 21 (3 generated)
huangs@chromium.org changed reviewers: + aelias@chromium.org, kbr@chromium.org, suzhe@chromium.org
PTAL.
The change LGTM. Does it solve the original problem?
Yes, now backspace does not cancel composition, regardless of autocomplete.
On 2015/03/02 04:00:44, huangs wrote: > Yes, now backspace does not cancel composition, regardless of autocomplete. Great to hear it. Let's wait for other reviewer's feedback.
kbr@chromium.org changed reviewers: + boliu@chromium.org, tkent@chromium.org
I'd like to defer my review to aelias@, boliu@, tkent@, or other reviewers they may suggest. I'll be happy to rubber-stamp the fix afterward if necessary.
https://codereview.chromium.org/970743002/diff/1/Source/web/WebViewImpl.cpp File Source/web/WebViewImpl.cpp (right): https://codereview.chromium.org/970743002/diff/1/Source/web/WebViewImpl.cpp#n... Source/web/WebViewImpl.cpp:2311: if (m_suppressNextKeypressEvent && !inputMethodController.hasComposition()) { nit: no braces here https://codereview.chromium.org/970743002/diff/1/Source/web/WebViewImpl.cpp#n... Source/web/WebViewImpl.cpp:2316: if (text.isEmpty()) { How about deleting this entire block? The setComposition here does the same thing as the setComposition just below anyway, and the "hasComposition()" early out is not needed. So the only actual behavior change caused by this block is the "return true;". So I propose deleting this and at the bottom of this method right above the "return inputMethodController.hasComposition();", putting: "if (text.isEmpty()) return true;"
Updated, but didn't remove the code block yet. PTAL. https://codereview.chromium.org/970743002/diff/1/Source/web/WebViewImpl.cpp File Source/web/WebViewImpl.cpp (right): https://codereview.chromium.org/970743002/diff/1/Source/web/WebViewImpl.cpp#n... Source/web/WebViewImpl.cpp:2316: if (text.isEmpty()) { We pass different values for underlines, selectionStart, and selectionEnd though?
https://codereview.chromium.org/970743002/diff/1/Source/web/WebViewImpl.cpp File Source/web/WebViewImpl.cpp (right): https://codereview.chromium.org/970743002/diff/1/Source/web/WebViewImpl.cpp#n... Source/web/WebViewImpl.cpp:2316: if (text.isEmpty()) { On 2015/03/02 16:30:46, huangs wrote: > We pass different values for underlines, selectionStart, and selectionEnd > though? Yes, but if you look at the implementation in InputMethodController, that has no effect.
https://codereview.chromium.org/970743002/diff/1/Source/web/WebViewImpl.cpp File Source/web/WebViewImpl.cpp (right): https://codereview.chromium.org/970743002/diff/1/Source/web/WebViewImpl.cpp#n... Source/web/WebViewImpl.cpp:2316: if (text.isEmpty()) { There's still a code path where |underline| gets used but text.isEmpty() is true. And even if not, we would be using the knowledge that a parameter would be unused based on InputMethodController::setComposition()'s implementation details -- I think that would make code fragile and harder to maintain?
https://codereview.chromium.org/970743002/diff/1/Source/web/WebViewImpl.cpp File Source/web/WebViewImpl.cpp (right): https://codereview.chromium.org/970743002/diff/1/Source/web/WebViewImpl.cpp#n... Source/web/WebViewImpl.cpp:2316: if (text.isEmpty()) { On 2015/03/02 19:11:15, huangs wrote: > There's still a code path where |underline| gets used but text.isEmpty() is > true. And even if not, we would be using the knowledge that a parameter would > be unused based on InputMethodController::setComposition()'s implementation > details -- I think that would make code fragile and harder to maintain? I don't think it's some implementation detail that if we pass in an empty text string, then the composition is deleted and the other parameters are ignored. That's a basic part of the contract that we're already relying on. As far as |underlines| goes, do you have a reason to believe passing in the actual data the browser gave us would be harmful, to the extent we should go out of our way to suppress it with additional complexity here? If that data needs to be cleaned up (which it likely doesn't), it's usually better to do that at the sending side, not at some intermediate plumbing stage. As far as I can see, this codepath existed before only because some synthetic stuff needed to be created for the m_suppressNextKeypressEvent case where the string could be non-empty. Now that we're getting rid of that and the parameters are a good mapping, we should use straight-line code that plumbs the arguments cleanly through.
Okay I'll remove the block and test.
Updated. Unittest and manual testing looks okay. However, I think I found a new bug (also in existing Chrome, so likely unrelated to this CL): when backspace deletes the last character of a composition CompositionEnd fires (okay) with event.data assigned to the composition *before* the final backspace. On Windows Chrome, I'd get event.data == "". https://codereview.chromium.org/970743002/diff/1/Source/web/WebViewImpl.cpp File Source/web/WebViewImpl.cpp (right): https://codereview.chromium.org/970743002/diff/1/Source/web/WebViewImpl.cpp#n... Source/web/WebViewImpl.cpp:2316: if (text.isEmpty()) { On 2015/03/02 19:34:07, aelias wrote: > On 2015/03/02 19:11:15, huangs wrote: > > There's still a code path where |underline| gets used but text.isEmpty() is > > true. And even if not, we would be using the knowledge that a parameter would > > be unused based on InputMethodController::setComposition()'s implementation > > details -- I think that would make code fragile and harder to maintain? > > I don't think it's some implementation detail that if we pass in an empty text > string, then the composition is deleted and the other parameters are ignored. > That's a basic part of the contract that we're already relying on. > > As far as |underlines| goes, do you have a reason to believe passing in the > actual data the browser gave us would be harmful, to the extent we should go out > of our way to suppress it with additional complexity here? If that data needs > to be cleaned up (which it likely doesn't), it's usually better to do that at > the sending side, not at some intermediate plumbing stage. > > As far as I can see, this codepath existed before only because some synthetic > stuff needed to be created for the m_suppressNextKeypressEvent case where the > string could be non-empty. Now that we're getting rid of that and the > parameters are a good mapping, we should use straight-line code that plumbs the > arguments cleanly through. Done.
lgtm as far as this goes. On 2015/03/02 at 20:09:18, huangs wrote: > Updated. Unittest and manual testing looks okay. However, I think I found a new bug (also in existing Chrome, so likely unrelated to this CL): when backspace deletes the last character of a composition CompositionEnd fires (okay) with event.data assigned to the composition *before* the final backspace. OK, it sounds like that would be a fix on the browser side?
Looking into CompositionEnd specs in https://developer.mozilla.org/en-US/docs/Web/Events/compositionend , it states that event.data is "he original string being edited, otherwise the empty string. Read only." So the Android behavior might be understandable?? Meanwhile, perhaps the Windows behavior of empty string is buggy, and could be related to crbug.com/431735 . Anyway, these are irrelevant to our present CL. Meanwhile I want to hear suzhe@ again before submitting.
LGTM
The CQ bit was checked by huangs@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/970743002/40001
Thanks, submitting! Please note that I advised torne@ that we should try to merge this into m40 WebView to fix the stable blocker.
Message was sent while issue was closed.
Committed patchset #3 (id:40001) as https://src.chromium.org/viewvc/blink?view=rev&revision=191167 |