2010-12-27 Martin Robinson <mrobinson@igalia.com>
authormrobinson@webkit.org <mrobinson@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Dec 2010 22:48:21 +0000 (22:48 +0000)
committermrobinson@webkit.org <mrobinson@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Dec 2010 22:48:21 +0000 (22:48 +0000)
        Reviewed by Ryosuke Niwa.

        [GTK] EditorClient::generateEditorCommands queues up "null string" commands
        https://bugs.webkit.org/show_bug.cgi?id=51569

        Prevent adding "null string" editor commands by first checking whether or not
        the command string is null in generateEditorCommands before appending it to the
        list of pending editor command strings.

        * WebCoreSupport/EditorClientGtk.cpp:
        (WebKit::EditorClient::generateEditorCommands): Check for the null string (no
        command for this key combination) before appending a command string to the list of
        pending editor commands.
        (WebKit::EditorClient::executePendingEditorCommands): Add an ASSERT which detects
        null command strings.

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

WebKit/gtk/ChangeLog
WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp

index 889f18e..d5efd82 100644 (file)
@@ -1,3 +1,21 @@
+2010-12-27  Martin Robinson  <mrobinson@igalia.com>
+
+        Reviewed by Ryosuke Niwa.
+
+        [GTK] EditorClient::generateEditorCommands queues up "null string" commands
+        https://bugs.webkit.org/show_bug.cgi?id=51569
+
+        Prevent adding "null string" editor commands by first checking whether or not
+        the command string is null in generateEditorCommands before appending it to the
+        list of pending editor command strings.
+
+        * WebCoreSupport/EditorClientGtk.cpp:
+        (WebKit::EditorClient::generateEditorCommands): Check for the null string (no
+        command for this key combination) before appending a command string to the list of
+        pending editor commands.
+        (WebKit::EditorClient::executePendingEditorCommands): Add an ASSERT which detects
+        null command strings.
+
 2010-12-27  Xan Lopez  <xlopez@igalia.com>
 
         Reviewed by Martin Robinson.
 2010-12-27  Xan Lopez  <xlopez@igalia.com>
 
         Reviewed by Martin Robinson.
index 0522f87..3f55cca 100644 (file)
@@ -652,24 +652,23 @@ void EditorClient::generateEditorCommands(const KeyboardEvent* event)
     if (event->ctrlKey())
         modifiers |= CtrlKey;
 
     if (event->ctrlKey())
         modifiers |= CtrlKey;
 
-
-    if (event->type() == eventNames().keydownEvent) {
-        int mapKey = modifiers << 16 | event->keyCode();
-        if (mapKey)
-            m_pendingEditorCommands.append(keyDownCommandsMap.get(mapKey));
+    // For keypress events, we want charCode(), but keyCode() does that.
+    int mapKey = modifiers << 16 | event->keyCode();
+    if (!mapKey)
         return;
         return;
-    }
-
-    int mapKey = modifiers << 16 | event->charCode();
-    if (mapKey)
-        m_pendingEditorCommands.append(keyPressCommandsMap.get(mapKey));
+    HashMap<int, const char*>* commandMap = event->type() == eventNames().keydownEvent ?
+        &keyDownCommandsMap : &keyPressCommandsMap;
+    if (const char* commandString = commandMap->get(mapKey))
+        m_pendingEditorCommands.append(commandString);
 }
 
 bool EditorClient::executePendingEditorCommands(Frame* frame, bool allowTextInsertion)
 {
     Vector<Editor::Command> commands;
     for (size_t i = 0; i < m_pendingEditorCommands.size(); i++) {
 }
 
 bool EditorClient::executePendingEditorCommands(Frame* frame, bool allowTextInsertion)
 {
     Vector<Editor::Command> commands;
     for (size_t i = 0; i < m_pendingEditorCommands.size(); i++) {
-        Editor::Command command = frame->editor()->command(m_pendingEditorCommands.at(i));
+        const char* commandString = m_pendingEditorCommands.at(i);
+        ASSERT(commandString);
+        Editor::Command command = frame->editor()->command(commandString);
         if (command.isTextInsertion() && !allowTextInsertion)
             return false;
 
         if (command.isTextInsertion() && !allowTextInsertion)
             return false;