WebCore:
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2007 16:59:30 +0000 (16:59 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2007 16:59:30 +0000 (16:59 +0000)
        Reviewed by Darin Adler.

        - better fix for a crash when pressing a key that is not associated
          with a command

        * editing/EditorCommand.cpp:
        (WebCore::Editor::command): Return the empty command if the command name
        is empty.

WebKit/win:

        Reviewed by Darin Adler.

        - revert my earlier crash fix after making WebCore return the empty
          editor command for the empty command name.

        * WebView.cpp:
        (WebView::handleEditingKeyboardEvent):

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

WebCore/ChangeLog
WebCore/editing/EditorCommand.cpp
WebKit/win/ChangeLog
WebKit/win/WebView.cpp

index aee214fbb49a0e1a566014f51d1cb1e3c4004ee4..f0149c56944ee5f218e040fb77ecd306d0bffa5d 100644 (file)
@@ -1,3 +1,14 @@
+2007-12-12  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
+        - better fix for a crash when pressing a key that is not associated
+          with a command
+
+        * editing/EditorCommand.cpp:
+        (WebCore::Editor::command): Return the empty command if the command name
+        is empty.
+
 2007-12-12  Alexey Proskuryakov  <ap@webkit.org>
 
         Reviewed by Darin.
index 3a9c23632f1d0087eb787cb0d888b396be4f83e0..28cc2adba62faf467ab069ada5d914ac33ce3b46 100644 (file)
@@ -1203,6 +1203,9 @@ Editor::Command Editor::command(const String& commandName)
 
 Editor::Command Editor::command(const String& commandName, EditorCommandSource source)
 {
+    if (commandName.isEmpty())
+        return Command();
+
     static const CommandMap& commandMap = createCommandMap();
     const EditorInternalCommand* internalCommand = commandMap.get(commandName);
     return internalCommand ? Command(m_frame, internalCommand, source) : Command();
index c2a9ee626eb829aa7ca069078aec09a03e40557a..51a7d751565b3d97a68df90a6c87e575817fb2f4 100644 (file)
@@ -1,3 +1,13 @@
+2007-12-12  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
+        - revert my earlier crash fix after making WebCore return the empty
+          editor command for the empty command name.
+
+        * WebView.cpp:
+        (WebView::handleEditingKeyboardEvent):
+
 2007-12-12  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Maciej.
index da4456717064c482e04af30b652c0b502d9fbfcc..37dc3ff935bc2bba21171fc0ab512963decf6d21 100644 (file)
@@ -1393,21 +1393,17 @@ 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;
 
-    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);
-        }
+    Editor::Command command = frame->editor()->command(interpretKeyEvent(evt));
 
-         if (command.execute(evt))
-            return true;
-    } else if (keyEvent->type() == PlatformKeyboardEvent::RawKeyDown)
-        return false;
+    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;
 
     // Don't insert null or control characters as they can result in unexpected behaviour
     if (evt->charCode() < ' ')