Last Comment Bug 697842 - cancelling compositonstart causes unexpected result
: cancelling compositonstart causes unexpected result
Status: RESOLVED FIXED
: inputmethod
Product: Core
Classification: Components
Component: DOM: Events (show other bugs)
: Trunk
: All All
: -- normal (vote)
: mozilla11
Assigned To: Masayuki Nakano [:masayuki] (Mozilla Japan)
:
Mentors:
http://www.w3.org/TR/DOM-Level-3-Even...
Depends on:
Blocks: 543789
  Show dependency treegraph
 
Reported: 2011-10-27 14:50 PDT by maxst
Modified: 2011-11-28 05:24 PST (History)
5 users (show)
masayuki: in‑testsuite+
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
FirefoxIME.htm (1.69 KB, text/html)
2011-10-27 14:50 PDT, maxst
no flags Details
compositionstart only sample (1.70 KB, text/html)
2011-11-09 18:53 PST, Makoto Kato [:m_kato]
no flags Details
Patch (8.54 KB, patch)
2011-11-09 22:17 PST, Masayuki Nakano [:masayuki] (Mozilla Japan)
ehsan: review+
Details | Diff | Review

Description maxst 2011-10-27 14:50:49 PDT
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.
Comment 1 Makoto Kato [:m_kato] 2011-11-09 17:38:03 PST
Canceling compositionstart causes unexpected result.  This event is "cancelable", so we should support it.  But it may be difficult by OS API/IME implementation.
Comment 2 Masayuki Nakano [:masayuki] (Mozilla Japan) 2011-11-09 18:07:06 PST
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.
Comment 3 Makoto Kato [:m_kato] 2011-11-09 18:42:45 PST
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.
Comment 4 Makoto Kato [:m_kato] 2011-11-09 18:53:50 PST
Created attachment 573408 [details]
compositionstart only sample
Comment 5 Masayuki Nakano [:masayuki] (Mozilla Japan) 2011-11-09 22:17:08 PST
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 6 Masayuki Nakano [:masayuki] (Mozilla Japan) 2011-11-10 03:44:45 PST
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.
Comment 7 maxst 2011-11-10 15:59:28 PST
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).
Comment 8 Masayuki Nakano [:masayuki] (Mozilla Japan) 2011-11-10 16:59:06 PST
(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 9 Masayuki Nakano [:masayuki] (Mozilla Japan) 2011-11-22 18:19:59 PST
Ehsan:

ping.
Comment 10 :Ehsan Akhgari (out sick) 2011-11-25 08:56:39 PST
Comment on attachment 573427 [details] [diff] [review]
Patch

Review of attachment 573427 [details] [diff] [review]:
-----------------------------------------------------------------

r=me
Comment 11 Masayuki Nakano [:masayuki] (Mozilla Japan) 2011-11-26 16:40:21 PST
https://hg.mozilla.org/integration/mozilla-inbound/rev/2a28403dee33
Comment 12 Marco Bonardo [::mak] 2011-11-28 05:24:00 PST
https://hg.mozilla.org/mozilla-central/rev/2a28403dee33

Note You need to log in before you can comment on or make changes to this bug.