Reviewed by Maciej.
authoroliver <oliver@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Jul 2007 05:28:43 +0000 (05:28 +0000)
committeroliver <oliver@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Jul 2007 05:28:43 +0000 (05:28 +0000)
        Fix for <rdar://problem/5334818> Support IME reconversion in windows

        Also includes a small amount of IME refactoring.

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

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

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

index 7f2180c8beff599665998c823d5aa6bfcf8a8f72..63deedcbbad5fe0debe48220cbc8c8bcdd4d0aa1 100644 (file)
@@ -1,3 +1,17 @@
+2007-07-16  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Maciej.
+
+        Fix for <rdar://problem/5334818> Support IME reconversion in windows
+
+        Also includes a small amount of IME refactoring.
+
+        * WebView.cpp:
+        (WebView::onIMERequestCharPosition):
+        (WebView::onIMERequestReconvertString):
+        (WebView::onIMERequest):
+        * WebView.h:
+
 2007-07-16  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Adam
index 1b41fd45ee06c4d2e69fc739f2a0bb4b36c213fa..93e2e3d2e8591105c9d56970947de097ff70fb27 100644 (file)
@@ -3911,12 +3911,9 @@ bool WebView::onIMENotify(WPARAM, LPARAM, LRESULT*)
     return false;
 }
 
-bool WebView::onIMERequestCharPosition(IMECHARPOSITION* charPos, LRESULT* result)
+bool WebView::onIMERequestCharPosition(Frame* targetFrame, 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);
@@ -3932,14 +3929,41 @@ bool WebView::onIMERequestCharPosition(IMECHARPOSITION* charPos, LRESULT* result
     return true;
 }
 
+bool WebView::onIMERequestReconvertString(Frame* targetFrame, RECONVERTSTRING* reconvertString, LRESULT* result)
+{
+    RefPtr<Range> selectedRange = targetFrame->selectionController()->toRange();
+    String text = selectedRange->text();
+    if (!reconvertString) {
+        *result = sizeof(RECONVERTSTRING) + text.length() * sizeof(UChar);
+        return true;
+    }
+
+    unsigned totalSize = sizeof(RECONVERTSTRING) + text.length() * sizeof(UChar);
+    *result = totalSize;
+    if (totalSize > reconvertString->dwSize) {
+        *result = 0;
+        return false;
+    }
+    reconvertString->dwCompStrLen = text.length();
+    reconvertString->dwStrLen = text.length();
+    reconvertString->dwTargetStrLen = text.length();
+    reconvertString->dwStrOffset = sizeof(RECONVERTSTRING);
+    memcpy(reconvertString + 1, text.characters(), text.length() * sizeof(UChar));
+    return true;
+}
+
 bool WebView::onIMERequest(WPARAM request, LPARAM data, LRESULT* result)
 {
+    Frame* targetFrame = m_page->focusController()->focusedOrMainFrame();
+    if (!targetFrame || !targetFrame->editor()->canEdit())
+        return true;
+
     switch (request) {
         case IMR_RECONVERTSTRING:
-            return false;
+            return onIMERequestReconvertString(targetFrame, (RECONVERTSTRING*)data, result);
 
         case IMR_QUERYCHARPOSITION:
-            return onIMERequestCharPosition((IMECHARPOSITION*)data, result);
+            return onIMERequestCharPosition(targetFrame, (IMECHARPOSITION*)data, result);
     }
     return false;
 }
index d5ee1a2bfcea0e2f13c118f17ee3afbf8c7a8e3e..199089e31ecbeb87420fddc1abdcb26a28fd429c 100644 (file)
@@ -675,7 +675,8 @@ protected:
     void initializeToolTipWindow();
     void prepareCandidateWindow(WebCore::Frame*, HIMC);
     void updateSelectionForIME();
-    bool onIMERequestCharPosition(IMECHARPOSITION*, LRESULT*);
+    bool onIMERequestCharPosition(WebCore::Frame*, IMECHARPOSITION*, LRESULT*);
+    bool onIMERequestReconvertString(WebCore::Frame*, RECONVERTSTRING*, LRESULT*);
     ULONG m_refCount;
     WebCore::String m_groupName;
     HWND m_hostWindow;