Index: Source/web/WebViewImpl.cpp |
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp |
index 5312dcdbdfd33254c2ee3bda5d186fc542e7e017..2d7746d169b01301bb56332c8472dd1f244daf16 100644 |
--- a/Source/web/WebViewImpl.cpp |
+++ b/Source/web/WebViewImpl.cpp |
@@ -2304,18 +2304,24 @@ bool WebViewImpl::setComposition( |
return false; |
} |
- // If we're not going to fire a keypress event, then the keydown event was |
- // canceled. In that case, cancel any existing composition. |
- if (text.isEmpty() || m_suppressNextKeypressEvent) { |
- // A browser process sent an IPC message which does not contain a valid |
- // string, which means an ongoing composition has been canceled. |
- // If the ongoing composition has been canceled, replace the ongoing |
- // composition string with an empty string and complete it. |
- String emptyString; |
- Vector<CompositionUnderline> emptyUnderlines; |
- inputMethodController.setComposition(emptyString, emptyUnderlines, 0, 0); |
+ // A keypress event is canceled. If an ongoing composition exists, then the |
+ // keydown event should have arisen from a handled key (e.g., backspace), so we |
+ // ignore the cancellation and continue. Otherwise (no ongoing composition) we |
+ // exit and signal success only for attempts to clear the composition. |
+ if (m_suppressNextKeypressEvent && !inputMethodController.hasComposition()) { |
aelias_OOO_until_Jul13
2015/03/02 08:48:57
nit: no braces here
|
return text.isEmpty(); |
} |
+ // An attempt to clear the composition, possibly an attempt to cancel the |
+ // composition by an IPC message from a browser process. |
+ if (text.isEmpty()) { |
aelias_OOO_until_Jul13
2015/03/02 08:48:57
How about deleting this entire block? The setComp
huangs
2015/03/02 16:30:46
We pass different values for underlines, selection
aelias_OOO_until_Jul13
2015/03/02 17:55:37
Yes, but if you look at the implementation in Inpu
huangs
2015/03/02 19:11:15
There's still a code path where |underline| gets u
aelias_OOO_until_Jul13
2015/03/02 19:34:07
I don't think it's some implementation detail that
huangs
2015/03/02 20:09:18
Done.
|
+ if (inputMethodController.hasComposition()) { |
+ // If an ongoing composition exists, replacing it with an empty string. |
+ String emptyString; |
+ Vector<CompositionUnderline> emptyUnderlines; |
+ inputMethodController.setComposition(emptyString, emptyUnderlines, 0, 0); |
+ } |
+ return true; |
+ } |
// When the range of composition underlines overlap with the range between |
// selectionStart and selectionEnd, WebKit somehow won't paint the selection |