Reviewed by Darin.
authorap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 16 Dec 2007 17:37:42 +0000 (17:37 +0000)
committerap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 16 Dec 2007 17:37:42 +0000 (17:37 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=14140
        <rdar://problem/5270958> REGRESSION: Complex system KeyBindings don't work properly

WebCore:
        * dom/KeyboardEvent.h:
        (WebCore::KeypressCommand::KeypressCommand):
        (WebCore::KeyboardEvent::keypressCommands):
        Change stored command class to preserve complete information about commands.

        * editing/EditorCommand.cpp: (WebCore::CommandEntry::): Mark InsertText as a text insertion
        command, which it is. Previously, we couldn't do it because WebKit didn't really treat insertText:
        as a command.

        * page/EventHandler.cpp: (WebCore::EventHandler::keyEvent): Copy commands saved while interpreting
        a keydown event into keypress, to avoid losing state when running interpretKeyEvents: again.

WebKit:
        * WebView/WebHTMLView.mm:
        (-[WebHTMLView _interceptEditingKeyEvent:shouldSaveCommand:]): Made command replaying work
        when handling keypress, too.
        (-[WebHTMLView doCommandBySelector:]): Adapted for the new way to store commands in events.
        (-[WebHTMLView insertText:]): Append a command, not replace the whole existing vector. Also,
        restore the state for additional commands to be saved correctly.

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

WebCore/ChangeLog
WebCore/dom/KeyboardEvent.h
WebCore/editing/EditorCommand.cpp
WebCore/page/EventHandler.cpp
WebKit/mac/ChangeLog
WebKit/mac/WebView/WebHTMLView.mm

index 8963c06710eb1490f7c75d2befe0a2be462b937a..879fbdf78ee57fb7fb27ff4791ad95f72c12c4a3 100644 (file)
@@ -1,3 +1,22 @@
+2007-12-16  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        http://bugs.webkit.org/show_bug.cgi?id=14140
+        <rdar://problem/5270958> REGRESSION: Complex system KeyBindings don't work properly
+
+        * dom/KeyboardEvent.h:
+        (WebCore::KeypressCommand::KeypressCommand):
+        (WebCore::KeyboardEvent::keypressCommands):
+        Change stored command class to preserve complete information about commands.
+
+        * editing/EditorCommand.cpp: (WebCore::CommandEntry::): Mark InsertText as a text insertion
+        command, which it is. Previously, we couldn't do it because WebKit didn't really treat insertText:
+        as a command.
+
+        * page/EventHandler.cpp: (WebCore::EventHandler::keyEvent): Copy commands saved while interpreting
+        a keydown event into keypress, to avoid losing state when running interpretKeyEvents: again.
+
 2007-12-16  Alexey Proskuryakov  <ap@webkit.org>
 
         Reviewed by Darin.
index 086739729d9a7c299769c233bfbf429f26eba4ca..c77d3d0eb119e016da533c6721325a512457a181 100644 (file)
@@ -33,10 +33,11 @@ namespace WebCore {
 
 #if PLATFORM(MAC)
     struct KeypressCommand {
-        Vector<String> commandNames;
+        KeypressCommand(const String& commandName) : commandName(commandName) {}
+        KeypressCommand(const String& commandName, const String& text) : commandName(commandName), text(text) { ASSERT(commandName == "insertText:"); }
+
+        String commandName;
         String text;
-        
-        bool isEmpty() const { return text.isEmpty() && commandNames.isEmpty(); }
     };
 #endif
     
@@ -78,8 +79,7 @@ namespace WebCore {
 
 #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& command) { m_keypressCommand = command; }        
+        Vector<KeypressCommand>& keypressCommands() { return m_keypressCommands; }
 #endif
 
     private:
@@ -89,7 +89,7 @@ namespace WebCore {
         bool m_altGraphKey : 1;
 
 #if PLATFORM(MAC)        
-        KeypressCommand m_keypressCommand;
+        Vector<KeypressCommand> m_keypressCommands;
 #endif
     };
 
index d2857db6af452ef4c4d37e2e26fd18eb18bec3ad..12c6e5d9b1cc712c3979e38e84b8c5a89c376b24 100644 (file)
@@ -1169,7 +1169,7 @@ static const CommandMap& createCommandMap()
         { "InsertOrderedList", { executeInsertOrderedList, supported, enabledInRichlyEditableText, stateOrderedList, valueNull, notTextInsertion } },
         { "InsertParagraph", { executeInsertParagraph, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
         { "InsertTab", { executeInsertTab, supported, enabledInEditableText, stateNone, valueNull, isTextInsertion } },
-        { "InsertText", { executeInsertText, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
+        { "InsertText", { executeInsertText, supported, enabledInEditableText, stateNone, valueNull, isTextInsertion } },
         { "InsertUnorderedList", { executeInsertUnorderedList, supported, enabledInRichlyEditableText, stateUnorderedList, valueNull, notTextInsertion } },
         { "Italic", { executeToggleItalic, supported, enabledInRichlyEditableText, stateItalic, valueNull, notTextInsertion } },
         { "JustifyCenter", { executeJustifyCenter, supported, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion } },
index 202f86ad0fc7d895fe5adf4512f347050234f419..56ede27e4af51eb0705801558f0e609fecbe3877 100644 (file)
@@ -1565,6 +1565,9 @@ bool EventHandler::keyEvent(const PlatformKeyboardEvent& initialKeyEvent)
     keypress->setTarget(node);
     if (keydownResult)
         keypress->setDefaultPrevented(true);
+#if PLATFORM(MAC)
+    keypress->keypressCommands() = keydown->keypressCommands();
+#endif
     node->dispatchEvent(keypress, ec, true);
 
     return keydownResult || keypress->defaultPrevented() || keypress->defaultHandled();
index bf0cb681e749b632c910119455504a90f5edbddd..10746f3725af9f50c688f7cd51918c0b4eabb5ff 100644 (file)
@@ -1,3 +1,17 @@
+2007-12-16  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        http://bugs.webkit.org/show_bug.cgi?id=14140
+        <rdar://problem/5270958> REGRESSION: Complex system KeyBindings don't work properly
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView _interceptEditingKeyEvent:shouldSaveCommand:]): Made command replaying work
+        when handling keypress, too.
+        (-[WebHTMLView doCommandBySelector:]): Adapted for the new way to store commands in events.
+        (-[WebHTMLView insertText:]): Append a command, not replace the whole existing vector. Also,
+        restore the state for additional commands to be saved correctly.
+
 2007-12-14  David D. Kilzer  <ddkilzer@apple.com>
 
         <rdar://problem/5647272> Remove user agent string hack for flickr.com
index 92a095996216551863d0cb911ff2b0e9331adb4f..50a4612b88b44660d351f0a382cf6170cedc411e 100644 (file)
@@ -4700,8 +4700,8 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point)
         parameters.event = event;
         _private->interpretKeyEventsParameters = &parameters;
         _private->receivedNOOP = NO;
-        KeypressCommand command = event->keypressCommand();
-        bool hasKeypressCommand = !command.commandNames.isEmpty() || !command.text.isEmpty();
+        const Vector<KeypressCommand>& commands = event->keypressCommands();
+        bool hasKeypressCommand = !commands.isEmpty();
 
         // FIXME: interpretKeyEvents doesn't match application key equivalents (such as Cmd+A),
         // and sends noop: for those. As a result, we don't handle those from within WebCore,
@@ -4709,20 +4709,22 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point)
         if (parameters.shouldSaveCommand || !hasKeypressCommand)
             [self interpretKeyEvents:[NSArray arrayWithObject:macEvent]];
         else {
-            ASSERT(platformEvent->type() == PlatformKeyboardEvent::RawKeyDown);
-            size_t size = command.commandNames.size();
+            size_t size = commands.size();
             // Are there commands that would just cause text insertion if executed via Editor?
             // WebKit doesn't have enough information about mode to decide how they 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).
             bool haveTextInsertionCommands = false;
             for (size_t i = 0; i < size; ++i) {
-                if ([self coreCommandBySelector:NSSelectorFromString(command.commandNames[i])].isTextInsertion())
+                if ([self coreCommandBySelector:NSSelectorFromString(commands[i].commandName)].isTextInsertion())
                     haveTextInsertionCommands = true;
             }
-            if (!haveTextInsertionCommands)
+            if (!haveTextInsertionCommands || platformEvent->type() == PlatformKeyboardEvent::Char)
                 for (size_t i = 0; i < size; ++i)
-                    [self doCommandBySelector:NSSelectorFromString(command.commandNames[i])];
+                    if (commands[i].commandName == "insertText:")
+                        [self insertText:commands[i].text];
+                    else
+                        [self doCommandBySelector:NSSelectorFromString(commands[i].commandName)];
         }
         _private->interpretKeyEventsParameters = 0;
     }
@@ -5047,11 +5049,9 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
     KeyboardEvent* event = parameters ? parameters->event : 0;
     bool shouldSaveCommand = parameters && parameters->shouldSaveCommand;
 
-    if (event && shouldSaveCommand) {
-        KeypressCommand command = event->keypressCommand();
-        command.commandNames.append(NSStringFromSelector(selector));
-        event->setKeypressCommand(command);
-    } else {
+    if (event && shouldSaveCommand)
+        event->keypressCommands().append(KeypressCommand(NSStringFromSelector(selector)));
+    else {
         // Make sure that only direct calls to doCommandBySelector: see the parameters by setting to 0.
         _private->interpretKeyEventsParameters = 0;
 
@@ -5121,9 +5121,8 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
         // another way to determine if the call is from the input method
         bool shouldSaveCommand = parameters && parameters->shouldSaveCommand;
         if (event && shouldSaveCommand && !isFromInputMethod) {
-            KeypressCommand command;
-            command.text = text;
-            event->setKeypressCommand(command);
+            event->keypressCommands().append(KeypressCommand("insertText:", text));
+            _private->interpretKeyEventsParameters = parameters;
             return;
         }