Joone Blog

IME composition events are handled inconsistently in WebKit

Posted on Jul 26, 2010

I have been working on a Korean Hangul composition issue in WebKitGtk. While doing so, I noticed that IME composition events are handled inconsistently across the different WebKit ports.

According to W3C DOM Level 3 Events:

  1. A browser should fire compositionstart, compositionupdate, and compositionend events during a composition.
  2. The textInput event should be dispatched after a compositionend event if the composition has not been canceled.
  3. While a composition session is active, keyboard events should not be dispatched to the DOM (i.e., the text composition system "swallows" the keyboard events), and only compositionupdate events may be dispatched to indicate the composition process.

However, all WebKit ports handle composition and textInput events in inconsistent ways. Even keyboard events are still dispatched to the DOM during a composition.

Therefore, the following problems need to be fixed:

  1. IME composition events should be handled consistently in all WebKit ports.
  2. Keyboard events should not be dispatched during a composition.
  3. The textInput event should be dispatched after a compositionend event.

The following table shows the status of DOM events in WebKit during a Hangul (Korean Alphabet) composition.

Korean Hangul Composition Event Test in WebKit-based browsers

You can find a test case here. I filed a bug for this issue in WebKit Bugzilla.