Created attachment 570096 [details] FirefoxIME.htm User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1 Build ID: 20110928134238 Steps to reproduce: I've attached a reduced repro (FirefoxIME.htm). Here are the repro steps: 1) Load the document FirefoxIME.htm in Firefox (I was using 7.0.1) 2) Click to get an IP in the box 3) Start typing in English. Text isn't typed because we're cancelling the key events. Notification of each cancelled event is displayed below the box. 4) Refresh the page (must click the refresh button next to the address bar since keyboard shortcuts won't work while we're cancelling key events) 5) Click to get an IP in the box 6) Start typing using the Japanese IME. Actual results: Notification of cancelled events shows up below the box. The IME starts and inputs characters. (The characters aren't quite what are expected). Expected results: Notification of cancelled events show up below the box. No typing happens. The IME doesn't start because we've cancelled the typing events. Basically, we want to be able to stop the IME from typing by cancelling events just like we can in English. We're getting into a bad state where we don't save the contents because we don't believe the IME is active. This happens because we expect that the start of overtyping causes the content to be deleted but the IME not to be active. The next character typed then activates the IME so we begin IME typing normally. Instead, we don't stop the IME on the first keypress so we don't hear the IME starting on the second keypress. Thus we don't know to save the contents.
Canceling compositionstart causes unexpected result. This event is "cancelable", so we should support it. But it may be difficult by OS API/IME implementation.
http://mxr.mozilla.org/mozilla-central/source/widget/public/nsGUIEvent.h?mark=1194-1197#1191 > 1194 // XXX compositionstart is cancelable in draft of DOM3 Events. > 1195 // However, it doesn't make sense for us, we cannot cancel composition > 1196 // when we send compositionstart event. > 1197 flags |= NS_EVENT_FLAG_CANT_CANCEL; It's intentionally. See also: http://lists.w3.org/Archives/Public/www-dom/2011JulSep/0112.html We need to wait the W3C's decision.
at the least, canceling compositionstart causes unexpected result. If we don't support cancel on compostionstart, we should really be ignore. Current implementation is that Gecko show unexpected duplicated string. ex. 1. input "あ" 2. cancel compositionstart 3. "あ" apppears 4. input "あ" again 5. "あああ" appears. This is invalid. "ああ" should appears.
Created attachment 573408 [details] compositionstart only sample
Created attachment 573427 [details] [diff] [review] Patch The cause is, our editor listens the events with non-system group. Therefore, stopPropagation() causes the events not reaching editor. I'm testing this patch in tryserver now.
Comment on attachment 573427 [details] [diff] [review] Patch This patch also refuses untrusted events. Note that web applications cannot emulate IME composition even on current build. The untrusted events can only break native IME composition.
Note that without being able to cancel the composition start, a page cannot stop an IME from typing in all cases whereas it can with other non-IME keyboards (basically, if someone thought it was important enough to let a webpage cancel other key events, the same should apply for composition events).
(In reply to maxst from comment #7) > Note that without being able to cancel the composition start, a page cannot > stop an IME from typing in all cases whereas it can with other non-IME > keyboards (basically, if someone thought it was important enough to let a > webpage cancel other key events, the same should apply for composition > events). You should know that some platforms don't have an API to finish composition forcibly. And also, even if we can do it, we shouldn't do it at compositionstart since the forcibly committing composition makes a lot of events. WebKit can block composition only when you call preventDefault() of *keydown* event. That is better approach for both Web developers and browser implementers.
Comment on attachment 573427 [details] [diff] [review] Patch Review of attachment 573427 [details] [diff] [review]: ----------------------------------------------------------------- r=me