Bug 14331 - WebKit/Windows doesn't support IMEs
Summary: WebKit/Windows doesn't support IMEs
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 523.x (Safari 3)
Hardware: PC Windows XP
: P1 Enhancement
Assignee: Oliver Hunt
URL:
Keywords: InRadar, PlatformOnly
Depends on:
Blocks:
 
Reported: 2007-06-23 03:23 PDT by 808caaa4.8ce9.9cd6c799e9f6
Modified: 2007-07-14 09:55 PDT (History)
4 users (show)

See Also:


Attachments
spyxx log with Safari/IME. example WM sequence. (10.94 KB, text/plain)
2007-06-23 18:39 PDT, 808caaa4.8ce9.9cd6c799e9f6
no flags Details
Basic IME support (18.79 KB, patch)
2007-07-13 21:27 PDT, Oliver Hunt
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description 808caaa4.8ce9.9cd6c799e9f6 2007-06-23 03:23:02 PDT
In Japanese(FE) environment, WebKit/safari cannot accept IME composition result.
So many users shoud use notepad or something to enter Japanese....
(Type Japanese with notepad, copy to clipboard, and paste to Safari/WebKit)

Windows+IME doesn't obey WM_KEYDOWN - WM_CHAR - WM_KEYUP sequence.

At IME composition startup, WM_KEYDOWN with wParam==VK_PROCESSKEY sent without proceeding WM_CHAR/WM_KEYUP.
During IME compotision, WM_KEYDOWN without WM_CHAR is sent.
At candidate selection, result is sent by WM_IME_CHAR without WM_KEYDOWN/WM_KEYUP, and not WM_CHAR.
At IME composition ended, WM_KEYUP without WM_KEYDOWN sent.

Out-of-sequence-WM_KEY-message may takes L"\x0" to text input class,
so sending form content breaks off at that L"\x0" point, as it treated as cstr-terminating.

I think Apple team now implementing 'Full IME support' with Aqua theme, may be.
Many FE evaluator feels Safari for Windows good and try it widely ASAP.

I wish more nice WM_KEY/WM_CHAR handling model in WebViewWndProc implementation
for FE envilonment.

Below is sample implementation. Works almost well with floating composition window.
...works very well, nice experience.

volatile LONG cIMEComposition=0;
volatile LONG cWMKeyMessagesPassThruTicketCount=0;
volatile LONG cWMKeyDownMessagesCountForCheckingPair=0;

LRESULT CALLBACK MyWebVwWndProcW(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch(uMsg){
	case WM_IME_STARTCOMPOSITION:
		cIMEComposition++;
		break;
	case WM_IME_ENDCOMPOSITION:
		cIMEComposition--;
		if(cIMEComposition<0) cIMEComposition=0;
		cWMKeyDownMessagesCountForCheckingPair=0;
		break;

	case WM_IME_CHAR:
		cWMKeyMessagesPassThruTicketCount+=2; // 2 times... WM_KEYDOWN and WM_KEYUP
		PostMessageW(hwnd, WM_KEYDOWN, wParam, lParam);
		PostMessageW(hwnd, WM_CHAR, wParam, lParam);
		PostMessageW(hwnd, WM_KEYUP, wParam, lParam | 0xc0000000);
		return 0;

	case WM_KEYUP:
		if(!cWMKeyDownMessagesCountForCheckingPair) break; // bypass NOT paired with WM_KEYDOWN
		cWMKeyDownMessagesCountForCheckingPair--;
		if(cWMKeyDownMessagesCountForCheckingPair<0) cWMKeyDownMessagesCountForCheckingPair=0;
		goto L1;
	case WM_KEYDOWN:
		if(wParam==VK_PROCESSKEY) break;
		cWMKeyDownMessagesCountForCheckingPair++;
		// -----
L1:
		if(cIMEComposition) {
			// NOT bypass WM_KEY* from WM_IME_CHAR above
			// with this demo code, suppose WM_KEY* reach very soon after PostMessageW above
			if(cWMKeyMessagesPassThruTicketCount){
				cWMKeyMessagesPassThruTicketCount--;
				if(cWMKeyMessagesPassThruTicketCount<0) cWMKeyMessagesPassThruTicketCount=0;
				// thru
			} else {
				break;
			}
		}
		// NOT IME composition mode, pass to WebVwWndProcW
	default:
		return WebVwWndProcW(hwnd,uMsg,wParam,lParam);
	}
	return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}
Comment 1 808caaa4.8ce9.9cd6c799e9f6 2007-06-23 03:28:56 PDT
> ...works very well, nice experience.

means:

Safari/Webkit ...works very well with Japanese, nice experience.
Comment 2 808caaa4.8ce9.9cd6c799e9f6 2007-06-23 18:39:04 PDT
Created attachment 15203 [details]
spyxx log with Safari/IME. example WM sequence.

Example spyxx log.

With Safari, search box. Filtered by 'IME messages'+'Keyboard messages'.
I typed simply 'aaa', and enter IME composition, type 'ringo' and do composition(with Space/Enter Key), and leaved IME.
And typed simply 'yyy' again, and escaped Safari-window with Alt+Tab.
Comment 3 Oliver Hunt 2007-06-27 02:46:11 PDT
<rdar://problem/5231528> 
Comment 4 Oliver Hunt 2007-06-27 20:08:21 PDT
This is clearly a p1, assigning to self.
Comment 5 808caaa4.8ce9.9cd6c799e9f6 2007-07-13 03:39:59 PDT
errata. example below is buggy.
anonymous reporter (2ch,net/software, poster ID:6tWs8t100) said comma cannot be inputed via IME.

need to be fixed like this:

		PostMessageW(hwnd, WM_CHAR, wParam, lParam);
		WebVwWndProcW(hwnd, WM_KEYDOWN, 0xFFFF, lParam);
		PostMessageW(hwnd, WM_KEYUP, 0xFFFF, lParam | 0xc0000000);
Comment 6 Oliver Hunt 2007-07-13 21:27:11 PDT
Created attachment 15511 [details]
Basic IME support
Comment 7 Oliver Hunt 2007-07-14 01:24:51 PDT
Reviewed by darin + alexey

Landed r24285