Closed Bug 697842 Opened 13 years ago Closed 13 years ago

cancelling compositonstart causes unexpected result

Categories

(Core :: DOM: Events, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla11

People

(Reporter: maxst, Assigned: masayuki)

References

()

Details

(Keywords: inputmethod)

Attachments

(2 files, 1 obsolete file)

Attached file FirefoxIME.htm (obsolete) —
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.
Attachment #570096 - Attachment mime type: text/plain → text/html
Component: General → DOM: Events
Keywords: inputmethod
Product: Firefox → Core
QA Contact: general → events
Version: 7 Branch → Trunk
Canceling compositionstart causes unexpected result.  This event is "cancelable", so we should support it.  But it may be difficult by OS API/IME implementation.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: Overtyping characters using IME sometimes causes the user to lose the newly added text → Support cancelling compositonstart
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.
Status: NEW → UNCONFIRMED
Ever confirmed: false
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.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: Support cancelling compositonstart → cancelling compositonstart causes unexpected result
Attachment #570096 - Attachment is obsolete: true
Attached patch PatchSplinter Review
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.
Assignee: nobody → masayuki
Status: NEW → ASSIGNED
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.
Attachment #573427 - Flags: review?(ehsan)
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.
Ehsan:

ping.
Comment on attachment 573427 [details] [diff] [review]
Patch

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

r=me
Attachment #573427 - Flags: review?(ehsan) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/2a28403dee33
Flags: in-testsuite?
Whiteboard: [inbound]
Target Milestone: --- → mozilla11
Flags: in-testsuite? → in-testsuite+
OS: Windows 7 → All
Hardware: x86_64 → All
https://hg.mozilla.org/mozilla-central/rev/2a28403dee33
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Whiteboard: [inbound]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: