Reviewed by Maciej.
authoroliver <oliver@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Jul 2007 01:40:23 +0000 (01:40 +0000)
committeroliver <oliver@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Jul 2007 01:40:23 +0000 (01:40 +0000)
        Fix for <rdar://problem/5334826> Chinese IME composition window does not appear in the correct location

        Respect IME requests for character position.

        * WebView.cpp:
        (WebView::onIMERequestCharPosition):
        (WebView::onIMERequest):
        * WebView.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@24343 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/win/ChangeLog
WebKit/win/WebView.cpp
WebKit/win/WebView.h

index 1810709776bb4b43bf17866d2648f11dd03302a6..66b4dad69209915c1d541a7393a386a963b9217a 100644 (file)
@@ -1,3 +1,16 @@
+2007-07-16  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Maciej.
+
+        Fix for <rdar://problem/5334826> Chinese IME composition window does not appear in the correct location
+
+        Respect IME requests for character position.
+
+        * WebView.cpp:
+        (WebView::onIMERequestCharPosition):
+        (WebView::onIMERequest):
+        * WebView.h:
+
 2007-07-16  Adam Roben  <aroben@apple.com>
 
         WebKit/win part of <rdar://problem/5336005> Calling window.print() on a subframe prints whole page, should only print that subframe
index 06dfd6115c4e508fe3ad9d78a928de91a74507ee..1b41fd45ee06c4d2e69fc739f2a0bb4b36c213fa 100644 (file)
@@ -3911,8 +3911,36 @@ bool WebView::onIMENotify(WPARAM, LPARAM, LRESULT*)
     return false;
 }
 
-bool WebView::onIMERequest(WPARAM, LPARAM, LRESULT*)
+bool WebView::onIMERequestCharPosition(IMECHARPOSITION* charPos, LRESULT* result)
+{    
+    IntRect caret;
+    Frame* targetFrame = m_page->focusController()->focusedOrMainFrame();
+    if (!targetFrame)
+        return true;
+    if (RefPtr<Range> range = targetFrame->selectionController()->selection().toRange()) {
+        ExceptionCode ec = 0;
+        RefPtr<Range> tempRange = range->cloneRange(ec);
+        caret = targetFrame->firstRectForRange(tempRange.get());
+    }
+    caret = targetFrame->view()->contentsToWindow(caret);
+    charPos->pt.x = caret.x();
+    charPos->pt.y = caret.y();
+    ::ClientToScreen(m_viewWindow, &charPos->pt);
+    charPos->cLineHeight = caret.height();
+    ::GetWindowRect(m_viewWindow, &charPos->rcDocument);
+    *result = TRUE;
+    return true;
+}
+
+bool WebView::onIMERequest(WPARAM request, LPARAM data, LRESULT* result)
 {
+    switch (request) {
+        case IMR_RECONVERTSTRING:
+            return false;
+
+        case IMR_QUERYCHARPOSITION:
+            return onIMERequestCharPosition((IMECHARPOSITION*)data, result);
+    }
     return false;
 }
 
index ff8b4369b27619812272d08235e82c53b252bca4..d5ee1a2bfcea0e2f13c118f17ee3afbf8c7a8e3e 100644 (file)
@@ -675,6 +675,7 @@ protected:
     void initializeToolTipWindow();
     void prepareCandidateWindow(WebCore::Frame*, HIMC);
     void updateSelectionForIME();
+    bool onIMERequestCharPosition(IMECHARPOSITION*, LRESULT*);
     ULONG m_refCount;
     WebCore::String m_groupName;
     HWND m_hostWindow;