Reviewed by Darin.
authorap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 16 Dec 2007 16:16:17 +0000 (16:16 +0000)
committerap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 16 Dec 2007 16:16:17 +0000 (16:16 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=16462
        REGRESSION: access keys broken on Windows

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

WebCore/ChangeLog
WebCore/page/EventHandler.cpp
WebCore/page/EventHandler.h
WebKit/win/ChangeLog
WebKit/win/WebView.cpp
WebKit/wx/ChangeLog
WebKit/wx/WebView.cpp
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/win/EventSender.cpp

index 2598338..8963c06 100644 (file)
@@ -1,3 +1,16 @@
+2007-12-16  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        http://bugs.webkit.org/show_bug.cgi?id=16462
+        REGRESSION: access keys broken on Windows
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleAccessKey):
+        (WebCore::EventHandler::keyEvent):
+        * page/EventHandler.h:
+        Make handleAccessKey a class method; rely on WebKit to call it on Windows and wxWidgets.
+
 2007-12-16  Xan Lopez  <xan@gnome.org>
 
         Reviewed by Alexey Proskuryakov.
index cc77e1b..202f86a 100644 (file)
@@ -1464,7 +1464,7 @@ static EventTargetNode* eventTargetNodeForDocument(Document* doc)
     return EventTargetNodeCast(node);
 }
 
-static bool handleAccessKey(Document* document, const PlatformKeyboardEvent& evt)
+bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt)
 {
 #if PLATFORM(MAC)
     if (evt.ctrlKey())
@@ -1473,7 +1473,7 @@ static bool handleAccessKey(Document* document, const PlatformKeyboardEvent& evt
 #endif
     {
         String key = evt.unmodifiedText();
-        Element* elem = document->getElementByAccessKey(key.lower());
+        Element* elem = m_frame->document()->getElementByAccessKey(key.lower());
         if (elem) {
             elem->accessKeyAction(false);
             return true;
@@ -1502,15 +1502,13 @@ bool EventHandler::keyEvent(const PlatformKeyboardEvent& initialKeyEvent)
     m_frame->loader()->resetMultipleFormSubmissionProtection();
 
     // In IE, access keys are special, they are handled after default keydown processing, but cannot be canceled - this is hard to match.
-    // On Windows, we process them before dispatching keypress event (and rely on WebKit to not drop WM_SYSCHAR events when a keydown representing WM_SYSKEYDOWN is canceled).
-    // On Mac OS X, we process them before dispatching keydown, as the default keydown handler implements Emacs key bindings, which may conflict with access keys.
+    // On Mac OS X, we process them before dispatching keydown, as the default keydown handler implements Emacs key bindings, which may conflict
+    // with access keys. Then we dispatch keydown, but suppress its default handling.
+    // On Windows, WebKit explicitly calls handleAccessKey() instead of dispatching a keypress event for WM_SYSCHAR messages.
     // Other platforms currently match either Mac or Windows behavior, depending on whether they send combined KeyDown events.
     bool matchedAnAccessKey = false;
-    if (initialKeyEvent.type() == PlatformKeyboardEvent::Char) {
-        if (handleAccessKey(m_frame->document(), initialKeyEvent))
-            return true;
-    } else if (initialKeyEvent.type() == PlatformKeyboardEvent::KeyDown)
-        matchedAnAccessKey = handleAccessKey(m_frame->document(), initialKeyEvent);
+    if (initialKeyEvent.type() == PlatformKeyboardEvent::KeyDown)
+        matchedAnAccessKey = handleAccessKey(initialKeyEvent);
 
     // FIXME: it would be fair to let an input method handle KeyUp events before DOM dispatch.
     if (initialKeyEvent.type() == PlatformKeyboardEvent::KeyUp || initialKeyEvent.type() == PlatformKeyboardEvent::Char)
index 919c3c4..e54d427 100644 (file)
@@ -134,6 +134,7 @@ public:
 
     bool needsKeyboardEventDisambiguationQuirks() const;
 
+    bool handleAccessKey(const PlatformKeyboardEvent&);
     bool keyEvent(const PlatformKeyboardEvent&);
     void defaultKeyboardEventHandler(KeyboardEvent*);
 
index 1696f23..4d3c3b9 100644 (file)
@@ -1,3 +1,12 @@
+2007-12-16  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        http://bugs.webkit.org/show_bug.cgi?id=16462
+        REGRESSION: access keys broken on Windows
+
+        * WebView.cpp: (WebView::keyPress): Handle system key presses as access keys.
+
 2007-12-15  Alexey Proskuryakov  <ap@webkit.org>
 
         Reviewed by Maciej.
index b79c260..9f9948d 100644 (file)
@@ -1483,13 +1483,12 @@ bool WebView::keyDown(WPARAM virtualKeyCode, LPARAM keyData, bool systemKeyDown)
 
 bool WebView::keyPress(WPARAM charCode, LPARAM keyData, bool systemKeyDown)
 {
-    // IE does not dispatch keypress event for WM_SYSCHAR.
-    if (systemKeyDown)
-        return false;
-
     Frame* frame = m_page->focusController()->focusedOrMainFrame();
 
     PlatformKeyboardEvent keyEvent(m_viewWindow, charCode, keyData, PlatformKeyboardEvent::Char, systemKeyDown);
+    // IE does not dispatch keypress event for WM_SYSCHAR.
+    if (systemKeyDown)
+        return frame->eventHandler()->handleAccessKey(keyEvent);
     if (frame->eventHandler()->keyEvent(keyEvent))
         return true;
 
index 2d7f590..078d13c 100644 (file)
@@ -1,10 +1,19 @@
+2007-12-16  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        http://bugs.webkit.org/show_bug.cgi?id=16462
+        REGRESSION: access keys broken on Windows
+
+        * WebView.cpp: (wxWebView::OnKeyEvents): Call handleAccessKey() as appropriate.
+
 2007-12-14  Darin Adler  <darin@apple.com>
 
         Reviewed by Alexey.
 
         * WebKitSupport/EditorClientWx.cpp:
         (WebCore::EditorClientWx::handleKeyboardEvent): Switched from Editor::execCommand
-        to Edtor::command.
+        to Editor::command.
 
 2007-12-12  Brady Eidson  <beidson@apple.com>
 
index 92ac055..d2908db 100644 (file)
@@ -499,7 +499,10 @@ void wxWebView::OnKeyEvents(wxKeyEvent& event)
         }
         else {   
             WebCore::PlatformKeyboardEvent wkEvent(event);
-            m_impl->frame->eventHandler()->keyEvent(wkEvent);
+            if (wkEvent.type() == PlatformKeyboardEvent::Char && wkEvent.altKey())
+                m_impl->frame->eventHandler()->handleAccessKey(wkEvent);
+            else
+                m_impl->frame->eventHandler()->keyEvent(wkEvent);
         }
     }
     
index a708be9..703ab52 100644 (file)
@@ -1,3 +1,13 @@
+2007-12-16  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        http://bugs.webkit.org/show_bug.cgi?id=16462
+        REGRESSION: access keys broken on Windows
+
+        * DumpRenderTree/win/EventSender.cpp: (keyDownCallback): Send system key events
+        if Alt is pressed.
+
 2007-12-15  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Mark Rowe.
index bff965a..00ebe45 100644 (file)
@@ -344,7 +344,7 @@ static JSValueRef keyDownCallback(JSContextRef context, JSObjectRef function, JS
         ::SetKeyboardState(newKeyState);
     }
 
-    MSG msg = makeMsg(webViewWindow, WM_KEYDOWN, virtualKeyCode, 0);
+    MSG msg = makeMsg(webViewWindow, (::GetKeyState(VK_MENU) & 0x8000) ? WM_SYSKEYDOWN : WM_KEYDOWN, virtualKeyCode, 0);
     if (virtualKeyCode != 255)
         dispatchMessage(&msg);
     else {
@@ -354,7 +354,7 @@ static JSValueRef keyDownCallback(JSContextRef context, JSObjectRef function, JS
     }
 
     // Tests expect that all messages are processed by the time keyDown() returns.
-    if (::PeekMessage(&msg, webViewWindow, WM_CHAR, WM_CHAR, PM_REMOVE))
+    if (::PeekMessage(&msg, webViewWindow, WM_CHAR, WM_CHAR, PM_REMOVE) || ::PeekMessage(&msg, webViewWindow, WM_SYSCHAR, WM_SYSCHAR, PM_REMOVE))
         ::DispatchMessage(&msg);
 
     MSG msgUp = makeMsg(webViewWindow, WM_KEYUP, virtualKeyCode, 0);