<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[20030] trunk</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/20030">20030</a></dd>
<dt>Author</dt> <dd>adele</dd>
<dt>Date</dt> <dd>2007-03-07 14:49:48 -0800 (Wed, 07 Mar 2007)</dd>
</dl>

<h3>Log Message</h3>
<pre>WebCore:

        Reviewed by Darin.

        WebCore part of fix for:
        http://bugs.webkit.org/show_bug.cgi?id=10871
        http://bugs.webkit.org/show_bug.cgi?id=12677
        &lt;rdar://problem/4823129&gt; REGRESSION: IME key events different in nightly
        &lt;rdar://problem/4759563&gt; REGRESSION: Return key is always sent when you confirm a clause in kotoeri

        * page/EventHandler.cpp: (WebCore::EventHandler::defaultKeyboardEventHandler): Call handleInputMethodKeypress before actually dispatching the keypress event
          so that input methods have a chance to handle the event.  
          If the input method handles the event (by marking or unmarking text), then we don't need to send the keypress event.
          If an input method doesn't handle the event, then we'll save the data we need to perform the correct action (like what text to insert or what selector to use) 
          when we dispatch the keypress event.

        * dom/KeyboardEvent.h: Added Mac-specific KeypressCommand struct, so we can store command info during handleInputMethodKeypress, and use it during handleKeypress.
        (WebCore::KeyboardEvent::keypressCommand):
        (WebCore::KeyboardEvent::setKeypressCommand):

        * bridge/EditorClient.h:
        * editing/Editor.cpp:
        (WebCore::Editor::handleKeypress): Changed handleKeyPress to handleKeypress.
        (WebCore::Editor::handleInputMethodKeypress): Added.
        * editing/Editor.h:

        * platform/graphics/svg/SVGImageEmptyClients.h:
        (WebCore::SVGEmptyEditorClient::handleKeypress): Changed handleKeyPress to handleKeypress.
        (WebCore::SVGEmptyEditorClient::handleInputMethodKeypress): Added.

WebKit:

        Reviewed by Darin.

        WebKit part of fix for:
        http://bugs.webkit.org/show_bug.cgi?id=10871
        http://bugs.webkit.org/show_bug.cgi?id=12677
        &lt;rdar://problem/4823129&gt; REGRESSION: IME key events different in nightly
        &lt;rdar://problem/4759563&gt; REGRESSION: Return key is always sent when you confirm a clause in kotoeri

        * WebView/WebHTMLView.mm:
        (-[WebHTMLView _interceptEditingKeyEvent: shouldSaveCommand:]): Added shouldSaveCommand field to WebHTMLViewInterpretKeyEventsParameters.
          When shouldSaveCommand is true, we call interpretKeyEvents and in doCommandBySelector and insertText, we just save the information without performing any action.
          When shouldSaveCommand is false, we used the saved information and call doCommandBySelector and insertText directly.
          If there's no saved command data in the KeyboardEvent, call interpretKeyEvents, and honor the shouldSaveCommand argument.  This allows repeating keypress events
          to function normally.
        (-[WebHTMLView doCommandBySelector:]): If the WebHTMLViewInterpretKeyEventsParameters shouldSaveCommand field is set, then
          just save the selector information in the KeyboardEvent, and don't perform the action.
        (-[WebHTMLView insertText:]): ditto. 
          insertText can be called from an input method or from normal key event processing
          If its from an input method, then we should go ahead and insert the text now.  
          The only way we know if its from an input method is to check hasMarkedText.  There might be a better way to do this.

        * WebView/WebHTMLViewInternal.h: Added shouldSaveCommand argument.
        * WebView/WebViewInternal.h: ditto.

        * WebCoreSupport/WebEditorClient.h:
        * WebCoreSupport/WebEditorClient.mm:
        (WebEditorClient::handleKeypress): Changed handleKeyPress to handleKeypress.  Call _interceptEditingKeyEvent with shouldSaveCommand:NO.
        (WebEditorClient::handleInputMethodKeypress):  Call _interceptEditingKeyEvent with shouldSaveCommand:YES.

WebKitQt:

        Reviewed by Darin.

        WebKitQT part of fix for:
        http://bugs.webkit.org/show_bug.cgi?id=10871
        http://bugs.webkit.org/show_bug.cgi?id=12677
        &lt;rdar://problem/4823129&gt; REGRESSION: IME key events different in nightly
        &lt;rdar://problem/4759563&gt; REGRESSION: Return key is always sent when you confirm a clause in kotoeri

        * WebCoreSupport/EditorClientQt.cpp:
        (WebCore::EditorClientQt::handleKeypress): Changed handleKeyPress to handleKeypress.
        (WebCore::EditorClientQt::handleInputMethodKeypress): Added.
        * WebCoreSupport/EditorClientQt.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCorebridgeEditorClienth">trunk/WebCore/bridge/EditorClient.h</a></li>
<li><a href="#trunkWebCoredomKeyboardEventh">trunk/WebCore/dom/KeyboardEvent.h</a></li>
<li><a href="#trunkWebCoreeditingEditorcpp">trunk/WebCore/editing/Editor.cpp</a></li>
<li><a href="#trunkWebCoreeditingEditorh">trunk/WebCore/editing/Editor.h</a></li>
<li><a href="#trunkWebCorepageEventHandlercpp">trunk/WebCore/page/EventHandler.cpp</a></li>
<li><a href="#trunkWebCoreplatformgraphicssvgSVGImageEmptyClientsh">trunk/WebCore/platform/graphics/svg/SVGImageEmptyClients.h</a></li>
<li><a href="#trunkWebKitChangeLog">trunk/WebKit/ChangeLog</a></li>
<li><a href="#trunkWebKitWebCoreSupportWebEditorClienth">trunk/WebKit/WebCoreSupport/WebEditorClient.h</a></li>
<li><a href="#trunkWebKitWebCoreSupportWebEditorClientmm">trunk/WebKit/WebCoreSupport/WebEditorClient.mm</a></li>
<li><a href="#trunkWebKitWebViewWebHTMLViewmm">trunk/WebKit/WebView/WebHTMLView.mm</a></li>
<li><a href="#trunkWebKitWebViewWebHTMLViewInternalh">trunk/WebKit/WebView/WebHTMLViewInternal.h</a></li>
<li><a href="#trunkWebKitWebViewWebViewInternalh">trunk/WebKit/WebView/WebViewInternal.h</a></li>
<li><a href="#trunkWebKitQtChangeLog">trunk/WebKitQt/ChangeLog</a></li>
<li><a href="#trunkWebKitQtWebCoreSupportEditorClientQtcpp">trunk/WebKitQt/WebCoreSupport/EditorClientQt.cpp</a></li>
<li><a href="#trunkWebKitQtWebCoreSupportEditorClientQth">trunk/WebKitQt/WebCoreSupport/EditorClientQt.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (20029 => 20030)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2007-03-07 22:30:43 UTC (rev 20029)
+++ trunk/WebCore/ChangeLog        2007-03-07 22:49:48 UTC (rev 20030)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2007-03-07  Adele Peterson  &lt;adele@apple.com&gt;
+
+        Reviewed by Darin.
+
+        WebCore part of fix for:
+        http://bugs.webkit.org/show_bug.cgi?id=10871
+        http://bugs.webkit.org/show_bug.cgi?id=12677
+        &lt;rdar://problem/4823129&gt; REGRESSION: IME key events different in nightly
+        &lt;rdar://problem/4759563&gt; REGRESSION: Return key is always sent when you confirm a clause in kotoeri
+
+        * page/EventHandler.cpp: (WebCore::EventHandler::defaultKeyboardEventHandler): Call handleInputMethodKeypress before actually dispatching the keypress event
+          so that input methods have a chance to handle the event.  
+          If the input method handles the event (by marking or unmarking text), then we don't need to send the keypress event.
+          If an input method doesn't handle the event, then we'll save the data we need to perform the correct action (like what text to insert or what selector to use) 
+          when we dispatch the keypress event.
+
+        * dom/KeyboardEvent.h: Added Mac-specific KeypressCommand struct, so we can store command info during handleInputMethodKeypress, and use it during handleKeypress.
+        (WebCore::KeyboardEvent::keypressCommand):
+        (WebCore::KeyboardEvent::setKeypressCommand):
+
+        * bridge/EditorClient.h:
+        * editing/Editor.cpp:
+        (WebCore::Editor::handleKeypress): Changed handleKeyPress to handleKeypress.
+        (WebCore::Editor::handleInputMethodKeypress): Added.
+        * editing/Editor.h:
+
+        * platform/graphics/svg/SVGImageEmptyClients.h:
+        (WebCore::SVGEmptyEditorClient::handleKeypress): Changed handleKeyPress to handleKeypress.
+        (WebCore::SVGEmptyEditorClient::handleInputMethodKeypress): Added.
+
</ins><span class="cx"> 2007-03-07  Anders Carlsson  &lt;acarlsson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Brady.
</span><span class="lines">@@ -436,7 +466,6 @@
</span><span class="cx">          keygen element when selecting different items. Also removed m_typedString(String()) from the constructor
</span><span class="cx">          initialization because this is not needed.
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> 2007-03-06  Kevin McCullough  &lt;kmccullough@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Darin.
</span></span></pre></div>
<a id="trunkWebCorebridgeEditorClienth"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/bridge/EditorClient.h (20029 => 20030)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/bridge/EditorClient.h        2007-03-07 22:30:43 UTC (rev 20029)
+++ trunk/WebCore/bridge/EditorClient.h        2007-03-07 22:49:48 UTC (rev 20030)
</span><span class="lines">@@ -96,7 +96,8 @@
</span><span class="cx">     virtual void undo() = 0;
</span><span class="cx">     virtual void redo() = 0;
</span><span class="cx"> 
</span><del>-    virtual void handleKeyPress(KeyboardEvent*) = 0;
</del><ins>+    virtual void handleKeypress(KeyboardEvent*) = 0;
+    virtual void handleInputMethodKeypress(KeyboardEvent*) = 0;
</ins><span class="cx">     
</span><span class="cx">     virtual void textFieldDidBeginEditing(Element*) = 0;
</span><span class="cx">     virtual void textFieldDidEndEditing(Element*) = 0;
</span></span></pre></div>
<a id="trunkWebCoredomKeyboardEventh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/dom/KeyboardEvent.h (20029 => 20030)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/dom/KeyboardEvent.h        2007-03-07 22:30:43 UTC (rev 20029)
+++ trunk/WebCore/dom/KeyboardEvent.h        2007-03-07 22:49:48 UTC (rev 20030)
</span><span class="lines">@@ -32,6 +32,13 @@
</span><span class="cx"> 
</span><span class="cx">     class PlatformKeyboardEvent;
</span><span class="cx"> 
</span><ins>+#if PLATFORM(MAC)
+    struct KeypressCommand {
+        String name;
+        String text;
+    };
+#endif
+    
</ins><span class="cx">     // Introduced in DOM Level 3
</span><span class="cx">     class KeyboardEvent : public UIEventWithKeyState {
</span><span class="cx">     public:
</span><span class="lines">@@ -68,11 +75,21 @@
</span><span class="cx">         virtual bool isKeyboardEvent() const;
</span><span class="cx">         virtual int which() const;
</span><span class="cx"> 
</span><ins>+#if PLATFORM(MAC)
+        // We only have this need to store keypress command info on the Mac.
+        KeypressCommand keypressCommand() { return m_keypressCommand; }
+        void setKeypressCommand(const KeypressCommand&amp; command) { m_keypressCommand = command; }        
+#endif
+
</ins><span class="cx">     private:
</span><span class="cx">         PlatformKeyboardEvent* m_keyEvent;
</span><span class="cx">         String m_keyIdentifier;
</span><span class="cx">         unsigned m_keyLocation;
</span><span class="cx">         bool m_altGraphKey : 1;
</span><ins>+
+#if PLATFORM(MAC)        
+        KeypressCommand m_keypressCommand;
+#endif
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     KeyboardEvent* findKeyboardEvent(Event*);
</span></span></pre></div>
<a id="trunkWebCoreeditingEditorcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/editing/Editor.cpp (20029 => 20030)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/editing/Editor.cpp        2007-03-07 22:30:43 UTC (rev 20029)
+++ trunk/WebCore/editing/Editor.cpp        2007-03-07 22:49:48 UTC (rev 20030)
</span><span class="lines">@@ -101,13 +101,20 @@
</span><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Editor::handleKeyPress(KeyboardEvent* event)
</del><ins>+void Editor::handleKeypress(KeyboardEvent* event)
</ins><span class="cx"> {
</span><span class="cx">     if (EditorClient* c = client())
</span><span class="cx">         if (selectionForEvent(m_frame, event).isContentEditable())
</span><del>-            c-&gt;handleKeyPress(event);
</del><ins>+            c-&gt;handleKeypress(event);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Editor::handleInputMethodKeypress(KeyboardEvent* event)
+{
+    if (EditorClient* c = client())
+        if (selectionForEvent(m_frame, event).isContentEditable())
+            c-&gt;handleInputMethodKeypress(event);
+}
+
</ins><span class="cx"> bool Editor::canEdit() const
</span><span class="cx"> {
</span><span class="cx">     return m_frame-&gt;selectionController()-&gt;isContentEditable();
</span></span></pre></div>
<a id="trunkWebCoreeditingEditorh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/editing/Editor.h (20029 => 20030)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/editing/Editor.h        2007-03-07 22:30:43 UTC (rev 20029)
+++ trunk/WebCore/editing/Editor.h        2007-03-07 22:49:48 UTC (rev 20030)
</span><span class="lines">@@ -66,7 +66,8 @@
</span><span class="cx">     DeleteButtonController* deleteButtonController() const { return m_deleteButtonController.get(); }
</span><span class="cx">     EditCommand* lastEditCommand() { return m_lastEditCommand.get(); }
</span><span class="cx"> 
</span><del>-    void handleKeyPress(KeyboardEvent*);
</del><ins>+    void handleKeypress(KeyboardEvent*);
+    void handleInputMethodKeypress(KeyboardEvent*);
</ins><span class="cx"> 
</span><span class="cx">     bool canEdit() const;
</span><span class="cx">     bool canEditRichly() const;
</span></span></pre></div>
<a id="trunkWebCorepageEventHandlercpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/page/EventHandler.cpp (20029 => 20030)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/page/EventHandler.cpp        2007-03-07 22:30:43 UTC (rev 20029)
+++ trunk/WebCore/page/EventHandler.cpp        2007-03-07 22:49:48 UTC (rev 20030)
</span><span class="lines">@@ -1282,15 +1282,24 @@
</span><span class="cx">                                             event-&gt;ctrlKey(), event-&gt;altKey(), event-&gt;shiftKey(), event-&gt;metaKey(), event-&gt;altGraphKey());
</span><span class="cx">             }
</span><span class="cx">             keypress-&gt;setUnderlyingEvent(event);   
</span><del>-        
-            // Dispatch the new keypress event
-            ExceptionCode ec;
-            node-&gt;dispatchEvent(keypress, ec, true);
</del><ins>+            keypress-&gt;setTarget(node);
+            
+            // Call handleInputMethodKeypress so that input methods have a chance to handle the event.
+            // If that happens, then we don't need to send the keypress event.  If an input method doesn't handle the event, 
+            // then we'll save the data we need to perform the correct action (like inserting text) 
+            // when we call handleKeypress.
+            m_frame-&gt;editor()-&gt;handleInputMethodKeypress(keypress.get());
+            
+            if (!keypress-&gt;defaultHandled()) {
+                // Dispatch the new keypress event
+                ExceptionCode ec;
+                node-&gt;dispatchEvent(keypress, ec, true);
+            }
</ins><span class="cx">             if (keypress-&gt;defaultHandled())
</span><span class="cx">                 event-&gt;setDefaultHandled();
</span><span class="cx">         }
</span><span class="cx">     } else if (event-&gt;type() == keypressEvent) {
</span><del>-        m_frame-&gt;editor()-&gt;handleKeyPress(event);
</del><ins>+        m_frame-&gt;editor()-&gt;handleKeypress(event);
</ins><span class="cx">         if (event-&gt;defaultHandled())
</span><span class="cx">             return;
</span><span class="cx">         if (event-&gt;keyIdentifier() == &quot;U+000009&quot;)
</span></span></pre></div>
<a id="trunkWebCoreplatformgraphicssvgSVGImageEmptyClientsh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/graphics/svg/SVGImageEmptyClients.h (20029 => 20030)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/svg/SVGImageEmptyClients.h        2007-03-07 22:30:43 UTC (rev 20029)
+++ trunk/WebCore/platform/graphics/svg/SVGImageEmptyClients.h        2007-03-07 22:49:48 UTC (rev 20030)
</span><span class="lines">@@ -316,7 +316,8 @@
</span><span class="cx">     virtual void undo() { }
</span><span class="cx">     virtual void redo() { }
</span><span class="cx"> 
</span><del>-    virtual void handleKeyPress(KeyboardEvent*) { }
</del><ins>+    virtual void handleKeypress(KeyboardEvent*) { }
+    virtual void handleInputMethodKeypress(KeyboardEvent*) { }
</ins><span class="cx"> 
</span><span class="cx">     virtual void textFieldDidBeginEditing(Element*) { }
</span><span class="cx">     virtual void textFieldDidEndEditing(Element*) { }
</span></span></pre></div>
<a id="trunkWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/ChangeLog (20029 => 20030)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/ChangeLog        2007-03-07 22:30:43 UTC (rev 20029)
+++ trunk/WebKit/ChangeLog        2007-03-07 22:49:48 UTC (rev 20030)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2007-03-07  Adele Peterson  &lt;adele@apple.com&gt;
+
+        Reviewed by Darin.
+
+        WebKit part of fix for:
+        http://bugs.webkit.org/show_bug.cgi?id=10871
+        http://bugs.webkit.org/show_bug.cgi?id=12677
+        &lt;rdar://problem/4823129&gt; REGRESSION: IME key events different in nightly
+        &lt;rdar://problem/4759563&gt; REGRESSION: Return key is always sent when you confirm a clause in kotoeri
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView _interceptEditingKeyEvent: shouldSaveCommand:]): Added shouldSaveCommand field to WebHTMLViewInterpretKeyEventsParameters.
+          When shouldSaveCommand is true, we call interpretKeyEvents and in doCommandBySelector and insertText, we just save the information without performing any action.
+          When shouldSaveCommand is false, we used the saved information and call doCommandBySelector and insertText directly.
+          If there's no saved command data in the KeyboardEvent, call interpretKeyEvents, and honor the shouldSaveCommand argument.  This allows repeating keypress events
+          to function normally.
+        (-[WebHTMLView doCommandBySelector:]): If the WebHTMLViewInterpretKeyEventsParameters shouldSaveCommand field is set, then
+          just save the selector information in the KeyboardEvent, and don't perform the action.
+        (-[WebHTMLView insertText:]): ditto. 
+          insertText can be called from an input method or from normal key event processing
+          If its from an input method, then we should go ahead and insert the text now.  
+          The only way we know if its from an input method is to check hasMarkedText.  There might be a better way to do this.
+
+        * WebView/WebHTMLViewInternal.h: Added shouldSaveCommand argument.
+        * WebView/WebViewInternal.h: ditto.
+
+        * WebCoreSupport/WebEditorClient.h:
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::handleKeypress): Changed handleKeyPress to handleKeypress.  Call _interceptEditingKeyEvent with shouldSaveCommand:NO.
+        (WebEditorClient::handleInputMethodKeypress):  Call _interceptEditingKeyEvent with shouldSaveCommand:YES.
+
</ins><span class="cx"> 2007-03-07  Anders Carlsson  &lt;acarlsson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Brady.
</span></span></pre></div>
<a id="trunkWebKitWebCoreSupportWebEditorClienth"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/WebCoreSupport/WebEditorClient.h (20029 => 20030)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/WebCoreSupport/WebEditorClient.h        2007-03-07 22:30:43 UTC (rev 20029)
+++ trunk/WebKit/WebCoreSupport/WebEditorClient.h        2007-03-07 22:49:48 UTC (rev 20030)
</span><span class="lines">@@ -84,7 +84,8 @@
</span><span class="cx">     virtual void undo();
</span><span class="cx">     virtual void redo();
</span><span class="cx">     
</span><del>-    virtual void handleKeyPress(WebCore::KeyboardEvent*);
</del><ins>+    virtual void handleKeypress(WebCore::KeyboardEvent*);
+    virtual void handleInputMethodKeypress(WebCore::KeyboardEvent*);
</ins><span class="cx"> 
</span><span class="cx">     virtual void markedTextAbandoned(WebCore::Frame*);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebKitWebCoreSupportWebEditorClientmm"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/WebCoreSupport/WebEditorClient.mm (20029 => 20030)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/WebCoreSupport/WebEditorClient.mm        2007-03-07 22:30:43 UTC (rev 20029)
+++ trunk/WebKit/WebCoreSupport/WebEditorClient.mm        2007-03-07 22:49:48 UTC (rev 20030)
</span><span class="lines">@@ -408,14 +408,22 @@
</span><span class="cx">         [[m_webView undoManager] redo];    
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebEditorClient::handleKeyPress(KeyboardEvent* event)
</del><ins>+void WebEditorClient::handleKeypress(KeyboardEvent* event)
</ins><span class="cx"> {
</span><span class="cx">     Frame* frame = event-&gt;target()-&gt;toNode()-&gt;document()-&gt;frame();
</span><span class="cx">     WebHTMLView *webHTMLView = [[kit(frame) frameView] documentView];
</span><del>-    if ([webHTMLView _interceptEditingKeyEvent:event])
</del><ins>+    if ([webHTMLView _interceptEditingKeyEvent:event shouldSaveCommand:NO])
</ins><span class="cx">         event-&gt;setDefaultHandled();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebEditorClient::handleInputMethodKeypress(KeyboardEvent* event)
+{
+    Frame* frame = event-&gt;target()-&gt;toNode()-&gt;document()-&gt;frame();
+    WebHTMLView *webHTMLView = [[kit(frame) frameView] documentView];
+    if ([webHTMLView _interceptEditingKeyEvent:event shouldSaveCommand:YES])
+        event-&gt;setDefaultHandled();
+}
+
</ins><span class="cx"> void WebEditorClient::markedTextAbandoned(Frame* frame)
</span><span class="cx"> {
</span><span class="cx">     WebHTMLView *webHTMLView = [[kit(frame) frameView] documentView];
</span></span></pre></div>
<a id="trunkWebKitWebViewWebHTMLViewmm"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/WebView/WebHTMLView.mm (20029 => 20030)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/WebView/WebHTMLView.mm        2007-03-07 22:30:43 UTC (rev 20029)
+++ trunk/WebKit/WebView/WebHTMLView.mm        2007-03-07 22:49:48 UTC (rev 20030)
</span><span class="lines">@@ -287,6 +287,7 @@
</span><span class="cx"> struct WebHTMLViewInterpretKeyEventsParameters {
</span><span class="cx">     KeyboardEvent* event;
</span><span class="cx">     BOOL eventWasHandled;
</span><ins>+    BOOL shouldSaveCommand;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> @implementation WebHTMLViewPrivate
</span><span class="lines">@@ -5246,18 +5247,30 @@
</span><span class="cx">     [self _updateMouseoverWithFakeEvent];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (BOOL)_interceptEditingKeyEvent:(KeyboardEvent *)event
</del><ins>+- (BOOL)_interceptEditingKeyEvent:(KeyboardEvent*)event shouldSaveCommand:(BOOL)shouldSave
</ins><span class="cx"> {
</span><span class="cx">     // Ask AppKit to process the key event -- it will call back with either insertText or doCommandBySelector.
</span><span class="cx">     WebHTMLViewInterpretKeyEventsParameters parameters;
</span><span class="cx">     parameters.eventWasHandled = false;
</span><ins>+    parameters.shouldSaveCommand = shouldSave;
+        
</ins><span class="cx">     if (const PlatformKeyboardEvent* platformEvent = event-&gt;keyEvent()) {
</span><span class="cx">         NSEvent *macEvent = platformEvent-&gt;macEvent();
</span><span class="cx">         if ([macEvent type] == NSKeyDown &amp;&amp; [_private-&gt;compController filterKeyDown:macEvent])
</span><span class="cx">             return true;
</span><span class="cx">         parameters.event = event;
</span><span class="cx">         _private-&gt;interpretKeyEventsParameters = &amp;parameters;
</span><del>-        [self interpretKeyEvents:[NSArray arrayWithObject:macEvent]];
</del><ins>+        KeypressCommand command = event-&gt;keypressCommand();
+        bool hasKeypressCommand = !command.name.isEmpty() || !command.text.isEmpty();
+
+        if (parameters.shouldSaveCommand || !hasKeypressCommand)
+            [self interpretKeyEvents:[NSArray arrayWithObject:macEvent]];
+        else {
+            if (!command.text.isEmpty())
+                [self insertText:command.text];
+            else
+                [self doCommandBySelector:NSSelectorFromString(command.name)];
+        }
</ins><span class="cx">         _private-&gt;interpretKeyEventsParameters = 0;
</span><span class="cx">     }
</span><span class="cx">     return parameters.eventWasHandled;
</span><span class="lines">@@ -5476,11 +5489,19 @@
</span><span class="cx">     // Use pointer to get parameters passed to us by the caller of interpretKeyEvents.
</span><span class="cx">     WebHTMLViewInterpretKeyEventsParameters* parameters = _private-&gt;interpretKeyEventsParameters;
</span><span class="cx">     _private-&gt;interpretKeyEventsParameters = 0;
</span><del>-
</del><ins>+    KeyboardEvent* event = parameters ? parameters-&gt;event : 0;
+    
+    bool shouldSaveCommand = parameters &amp;&amp; parameters-&gt;shouldSaveCommand;
+    if (event &amp;&amp; shouldSaveCommand) {
+        KeypressCommand command;
+        command.name = NSStringFromSelector(aSelector);
+        event-&gt;setKeypressCommand(command);
+        return;
+    }
+    
</ins><span class="cx">     if (aSelector == @selector(noop:))
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    KeyboardEvent* event = parameters ? parameters-&gt;event : 0;
</del><span class="cx">     bool eventWasHandled = true;
</span><span class="cx"> 
</span><span class="cx">     WebView *webView = [self _webView];
</span><span class="lines">@@ -5516,8 +5537,24 @@
</span><span class="cx"> 
</span><span class="cx">     bool eventHandled = false;
</span><span class="cx">     if ([text length]) {
</span><ins>+        KeyboardEvent* event = parameters ? parameters-&gt;event : 0;
+
+        // insertText can be called from an input method or from normal key event processing
+        // If its from normal key event processing, we may need to save the action to perform it later.
+        // If its from an input method, then we should go ahead and insert the text now.  
+        // We assume it's from the input method if we have marked text.
+        // FIXME: In theory, this could be wrong for some input methods, so we should try to find
+        // another way to determine if the call is from the input method
+        bool shouldSaveCommand = parameters &amp;&amp; parameters-&gt;shouldSaveCommand;
+        bool isFromInputMethod = [self hasMarkedText];
+        if (event &amp;&amp; shouldSaveCommand &amp;&amp; !isFromInputMethod) {
+            KeypressCommand command;
+            command.text = text;
+            event-&gt;setKeypressCommand(command);
+            return;
+        }
+        
</ins><span class="cx">         Frame* coreFrame = core([self _frame]);
</span><del>-        KeyboardEvent* event = parameters ? parameters-&gt;event : 0;
</del><span class="cx">         String eventText = text;
</span><span class="cx">         eventText.replace(NSBackTabCharacter, NSTabCharacter); // same thing is done in KeyEventMac.mm in WebCore
</span><span class="cx">         eventHandled = coreFrame &amp;&amp; coreFrame-&gt;eventHandler()-&gt;handleTextInputEvent(eventText, event);
</span></span></pre></div>
<a id="trunkWebKitWebViewWebHTMLViewInternalh"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/WebView/WebHTMLViewInternal.h (20029 => 20030)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/WebView/WebHTMLViewInternal.h        2007-03-07 22:30:43 UTC (rev 20029)
+++ trunk/WebKit/WebView/WebHTMLViewInternal.h        2007-03-07 22:49:48 UTC (rev 20030)
</span><span class="lines">@@ -110,7 +110,7 @@
</span><span class="cx"> - (void)closeIfNotCurrentView;
</span><span class="cx"> - (void)_lookUpInDictionaryFromMenu:(id)sender;
</span><span class="cx"> - (void)_hoverFeedbackSuspendedChanged;
</span><del>-- (BOOL)_interceptEditingKeyEvent:(WebCore::KeyboardEvent *)event;
</del><ins>+- (BOOL)_interceptEditingKeyEvent:(WebCore::KeyboardEvent *)event shouldSaveCommand:(BOOL)shouldSave;
</ins><span class="cx"> - (DOMDocumentFragment*)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard;
</span><span class="cx"> - (NSEvent *)_mouseDownEvent;
</span><span class="cx"> #ifndef BUILDING_ON_TIGER
</span></span></pre></div>
<a id="trunkWebKitWebViewWebViewInternalh"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/WebView/WebViewInternal.h (20029 => 20030)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/WebView/WebViewInternal.h        2007-03-07 22:30:43 UTC (rev 20029)
+++ trunk/WebKit/WebView/WebViewInternal.h        2007-03-07 22:49:48 UTC (rev 20030)
</span><span class="lines">@@ -47,7 +47,7 @@
</span><span class="cx"> @class WebBasePluginPackage;
</span><span class="cx"> 
</span><span class="cx"> @interface WebView (WebViewEditingExtras)
</span><del>-- (BOOL)_interceptEditingKeyEvent:(WebCoreKeyboardEvent *)event;
</del><ins>+- (BOOL)_interceptEditingKeyEvent:(WebCoreKeyboardEvent *)event shouldSaveCommand:(BOOL)shouldSave;
</ins><span class="cx"> - (BOOL)_shouldChangeSelectedDOMRange:(DOMRange *)currentRange toDOMRange:(DOMRange *)proposedRange affinity:(NSSelectionAffinity)selectionAffinity stillSelecting:(BOOL)flag;
</span><span class="cx"> @end
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebKitQtChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebKitQt/ChangeLog (20029 => 20030)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKitQt/ChangeLog        2007-03-07 22:30:43 UTC (rev 20029)
+++ trunk/WebKitQt/ChangeLog        2007-03-07 22:49:48 UTC (rev 20030)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2007-03-07  Adele Peterson  &lt;adele@apple.com&gt;
+
+        Reviewed by Darin.
+
+        WebKitQT part of fix for:
+        http://bugs.webkit.org/show_bug.cgi?id=10871
+        http://bugs.webkit.org/show_bug.cgi?id=12677
+        &lt;rdar://problem/4823129&gt; REGRESSION: IME key events different in nightly
+        &lt;rdar://problem/4759563&gt; REGRESSION: Return key is always sent when you confirm a clause in kotoeri
+
+        * WebCoreSupport/EditorClientQt.cpp:
+        (WebCore::EditorClientQt::handleKeypress): Changed handleKeyPress to handleKeypress.
+        (WebCore::EditorClientQt::handleInputMethodKeypress): Added.
+        * WebCoreSupport/EditorClientQt.h:
+
</ins><span class="cx"> 2007-03-07  Darin Adler  &lt;darin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         * WebCoreSupport/FrameLoaderClientQt.h: Oops, forgot the header.
</span></span></pre></div>
<a id="trunkWebKitQtWebCoreSupportEditorClientQtcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebKitQt/WebCoreSupport/EditorClientQt.cpp (20029 => 20030)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKitQt/WebCoreSupport/EditorClientQt.cpp        2007-03-07 22:30:43 UTC (rev 20029)
+++ trunk/WebKitQt/WebCoreSupport/EditorClientQt.cpp        2007-03-07 22:49:48 UTC (rev 20030)
</span><span class="lines">@@ -209,7 +209,7 @@
</span><span class="cx">     notImplemented();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void EditorClientQt::handleKeyPress(KeyboardEvent* event)
</del><ins>+void EditorClientQt::handleKeypress(KeyboardEvent* event)
</ins><span class="cx"> {
</span><span class="cx">     Frame* frame = m_page-&gt;d-&gt;page-&gt;focusController()-&gt;focusedOrMainFrame();
</span><span class="cx">     if (!frame)
</span><span class="lines">@@ -260,6 +260,10 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void EditorClientQt::handleInputMethodKeypress(KeyboardEvent*)
+{
+}
+
</ins><span class="cx"> EditorClientQt::EditorClientQt(QWebPage* page)
</span><span class="cx">     : m_page(page), m_editing(false), m_inUndoRedo(false)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkWebKitQtWebCoreSupportEditorClientQth"></a>
<div class="modfile"><h4>Modified: trunk/WebKitQt/WebCoreSupport/EditorClientQt.h (20029 => 20030)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKitQt/WebCoreSupport/EditorClientQt.h        2007-03-07 22:30:43 UTC (rev 20029)
+++ trunk/WebKitQt/WebCoreSupport/EditorClientQt.h        2007-03-07 22:49:48 UTC (rev 20030)
</span><span class="lines">@@ -81,7 +81,8 @@
</span><span class="cx">     virtual void undo();
</span><span class="cx">     virtual void redo();
</span><span class="cx"> 
</span><del>-    virtual void handleKeyPress(KeyboardEvent*);
</del><ins>+    virtual void handleKeypress(KeyboardEvent*);
+    virtual void handleInputMethodKeypress(KeyboardEvent*);
</ins><span class="cx"> 
</span><span class="cx">     virtual void textFieldDidBeginEditing(Element*);
</span><span class="cx">     virtual void textFieldDidEndEditing(Element*);
</span></span></pre>
</div>
</div>

</body>
</html>