Reviewed by Alexey Proskuryakov.
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2007 08:07:27 +0000 (08:07 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2007 08:07:27 +0000 (08:07 +0000)
        - fix a crash when pressing a key that is not associated with a command

        * WebView.cpp:
        (WebView::handleEditingKeyboardEvent): Check if the result of
        interpretKeyEvent() is empty.

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

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

index a53db84b7c847d75840be4e67cfc8e96e61ba209..7f46740bf9afa6c6fa118280882b929f27f6d623 100644 (file)
@@ -1,3 +1,13 @@
+2007-12-12  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Alexey Proskuryakov.
+
+        - fix a crash when pressing a key that is not associated with a command
+
+        * WebView.cpp:
+        (WebView::handleEditingKeyboardEvent): Check if the result of
+        interpretKeyEvent() is empty.
+
 2007-12-11  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Darin Adler.
index 2449e6a16dd6314782caed09a05770eab4e5a638..b18584b90b7629133f3ca023e3d79b6d7cc4f90b 100644 (file)
@@ -1371,17 +1371,21 @@ bool WebView::handleEditingKeyboardEvent(KeyboardEvent* evt)
     if (!keyEvent || keyEvent->isSystemKey())  // do not treat this as text input if it's a system key event
         return false;
 
-    Editor::Command command = frame->editor()->command(interpretKeyEvent(evt));
-
-    if (keyEvent->type() == PlatformKeyboardEvent::RawKeyDown) {
-        // WebKit doesn't have enough information about mode to decide how commands that just insert text if executed via Editor should be treated,
-        // so we leave it upon WebCore to either handle them immediately (e.g. Tab that changes focus) or let a keypress event be generated
-        // (e.g. Tab that inserts a Tab character, or Enter).
-        return !command.isTextInsertion() && command.execute(evt);
-    }
+    String commandName = interpretKeyEvent(evt);
+    if (!commandName.isEmpty()) {
+        Editor::Command command = frame->editor()->command(commandName);
+
+        if (keyEvent->type() == PlatformKeyboardEvent::RawKeyDown) {
+            // WebKit doesn't have enough information about mode to decide how commands that just insert text if executed via Editor should be treated,
+            // so we leave it upon WebCore to either handle them immediately (e.g. Tab that changes focus) or let a keypress event be generated
+            // (e.g. Tab that inserts a Tab character, or Enter).
+            return !command.isTextInsertion() && command.execute(evt);
+        }
 
-     if (command.execute(evt))
-        return true;
+         if (command.execute(evt))
+            return true;
+    } else if (keyEvent->type() == PlatformKeyboardEvent::RawKeyDown)
+        return false;
 
     // Don't insert null or control characters as they can result in unexpected behaviour
     if (evt->charCode() < ' ')