Reviewed by Dan Bernstein.
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Apr 2011 20:56:20 +0000 (20:56 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Apr 2011 20:56:20 +0000 (20:56 +0000)
        REGRESSION (WebKit2): Caps-Lock indicator sometimes doesn't appear in WebKit2
        https://bugs.webkit.org/show_bug.cgi?id=51230
        <rdar://problem/8780989>

        <rdar://problem/9015250> REGRESSION (WebKit2): Key events not fired for modifier keys

        * UIProcess/API/mac/WKView.mm:
        (-[WKView flagsChanged:]): Ported from WebHTMLView.
        (-[WKView _interpretKeyEvent:withCachedTextInputState:savingCommandsTo:WebCore::]):
        AppKit isn't happy about attempts to interpret NSFlagsChanged, but WK2 lacked the check.

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

16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/EventHandler.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebViewImpl.cpp
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/webkit/webkitwebview.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebHTMLView.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebView.cpp
Source/WebKit/wince/ChangeLog
Source/WebKit/wince/WebView.cpp
Source/WebKit/wx/ChangeLog
Source/WebKit/wx/WebView.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/mac/WKView.mm

index 6052287..5ededef 100644 (file)
@@ -1,3 +1,16 @@
+2011-04-04  Alexey Proskuryakov  <ap@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        REGRESSION (WebKit2): Caps-Lock indicator sometimes doesn't appear in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=51230
+        <rdar://problem/8780989>
+
+        <rdar://problem/9015250> REGRESSION (WebKit2): Key events not fired for modifier keys
+
+        * page/EventHandler.cpp: (WebCore::EventHandler::keyEvent): Moved Caps Lock handling from
+        WebKits to WebCore, because WebKit shouldn't be smart.
+
 2011-04-04  Steve Falkenburg  <sfalken@apple.com>
 
         Fix Windows build warning.
 
         The crash happens because resetting the page scale as part of preparing the WebView for the
         next test triggered layout, which in turn caused a plug-in to make a resource request, and
-        DumpRenderTreeÕs delegate to be dispatched. The delegate doesnÕt expect to be called between
+        DumpRenderTree's delegate to be dispatched. The delegate doesn’t expect to be called between
         tests, and it references the layout test controller, which is null.
 
         * page/Frame.cpp:
-        (WebCore::Frame::scalePage): Avoid an unnecessary layout if the page scale isnÕt changing. This
+        (WebCore::Frame::scalePage): Avoid an unnecessary layout if the page scale isnt changing. This
         is more efficient, and has the side effect of avoiding the crash in DumpRenderTree, although
         DumpRenderTree could still crash when after a test with disabled plug-ins and a non-1 page scale.
         I think there are currently no such tests, so I am not fixing DumpRenderTree.
index 1046c04..dd261d8 100644 (file)
@@ -76,6 +76,7 @@
 #include "UserGestureIndicator.h"
 #include "UserTypingGestureIndicator.h"
 #include "WheelEvent.h"
+#include "WindowsKeyboardCodes.h"
 #include <wtf/CurrentTime.h>
 #include <wtf/StdLibExtras.h>
 
@@ -2379,6 +2380,9 @@ bool EventHandler::keyEvent(const PlatformKeyboardEvent& initialKeyEvent)
 {
     RefPtr<FrameView> protector(m_frame->view()); 
 
+    if (initialKeyEvent.windowsVirtualKeyCode() == VK_CAPITAL)
+        capsLockStateMayHaveChanged();
+
 #if ENABLE(PAN_SCROLLING)
     if (Page* page = m_frame->page()) {
         if (page->mainFrame()->eventHandler()->panScrollInProgress() || m_autoscrollInProgress) {
index 4536355..acf0a35 100644 (file)
@@ -1,3 +1,14 @@
+2011-04-04  Alexey Proskuryakov  <ap@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        REGRESSION (WebKit2): Caps-Lock indicator sometimes doesn't appear in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=51230
+        <rdar://problem/8780989>
+
+        * src/WebViewImpl.cpp: (WebKit::WebViewImpl::keyEvent): Moved Caps Lock handling from
+        WebKits to WebCore, because WebKit shouldn't be smart.
+
 2011-04-01  Adam Barth  <abarth@webkit.org>
 
         Attempt to fix the Chromium build using the great and powerful git.
index 4efa880..0515668 100644 (file)
@@ -620,11 +620,6 @@ bool WebViewImpl::keyEvent(const WebKeyboardEvent& event)
     }
 #endif // OS(WINDOWS) || OS(LINUX) || OS(FREEBSD)
 
-    // It's not clear if we should continue after detecting a capslock keypress.
-    // I'll err on the side of continuing, which is the pre-existing behaviour.
-    if (event.windowsKeyCode == VKEY_CAPITAL)
-        handler->capsLockStateMayHaveChanged();
-
     PlatformKeyboardEventBuilder evt(event);
 
     if (handler->keyEvent(evt)) {
index c6405df..52b406c 100644 (file)
@@ -1,3 +1,14 @@
+2011-04-04  Alexey Proskuryakov  <ap@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        REGRESSION (WebKit2): Caps-Lock indicator sometimes doesn't appear in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=51230
+        <rdar://problem/8780989>
+
+        * webkit/webkitwebview.cpp: (webkit_web_view_key_release_event): Moved Caps Lock handling from
+        WebKits to WebCore, because WebKit shouldn't be smart.
+
 2011-04-04  Martin Robinson  <mrobinson@igalia.com>
 
         Reviewed by Xan Lopez.
index ec95d70..9c1a650 100644 (file)
@@ -749,9 +749,6 @@ static gboolean webkit_web_view_key_release_event(GtkWidget* widget, GdkEventKey
     if (!frame->view())
         return FALSE;
 
-    if (event->keyval == GDK_Caps_Lock)
-        frame->eventHandler()->capsLockStateMayHaveChanged();
-
     PlatformKeyboardEvent keyboardEvent(event);
     if (frame->eventHandler()->keyEvent(keyboardEvent))
         return TRUE;
index 7e4fd4c..73455b7 100644 (file)
@@ -1,3 +1,14 @@
+2011-04-04  Alexey Proskuryakov  <ap@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        REGRESSION (WebKit2): Caps-Lock indicator sometimes doesn't appear in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=51230
+        <rdar://problem/8780989>
+
+        * WebView/WebHTMLView.mm: (-[WebHTMLView flagsChanged:]): Moved Caps Lock handling from
+        WebKits to WebCore, because WebKit shouldn't be smart.
+
 2011-04-01  Alexey Proskuryakov  <ap@apple.com>
 
         Reviewed by Darin Adler.
index afeedb7..a23ec01 100644 (file)
@@ -4163,15 +4163,12 @@ static BOOL isInPasswordField(Frame* coreFrame)
     // the current event prevents that from causing a problem inside WebKit or AppKit code.
     [[event retain] autorelease];
 
-    Frame* coreFrame = core([self _frame]);
-    if (coreFrame)
-        coreFrame->eventHandler()->capsLockStateMayHaveChanged();
-    
     RetainPtr<WebHTMLView> selfProtector = self;
 
+    Frame* coreFrame = core([self _frame]);
     unsigned short keyCode = [event keyCode];
 
-    //Don't make an event from the num lock and function keys
+    // Don't make an event from the num lock and function keys.
     if (coreFrame && keyCode != 0 && keyCode != 10 && keyCode != 63) {
         coreFrame->eventHandler()->keyEvent(PlatformKeyboardEvent(event));
         return;
index a8d8c98..501669a 100644 (file)
@@ -1,3 +1,14 @@
+2011-04-04  Alexey Proskuryakov  <ap@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        REGRESSION (WebKit2): Caps-Lock indicator sometimes doesn't appear in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=51230
+        <rdar://problem/8780989>
+
+        * WebView.cpp: (WebView::keyDown): Moved Caps Lock handling from WebKits to WebCore,
+        because WebKit shouldn't be smart.
+
 2011-04-04  Steve Falkenburg  <sfalken@apple.com>
 
         Reviewed by Adam Roben.
index 2d8209c..41cdf57 100644 (file)
@@ -1935,8 +1935,6 @@ bool WebView::handleEditingKeyboardEvent(KeyboardEvent* evt)
 bool WebView::keyDown(WPARAM virtualKeyCode, LPARAM keyData, bool systemKeyDown)
 {
     Frame* frame = m_page->focusController()->focusedOrMainFrame();
-    if (virtualKeyCode == VK_CAPITAL)
-        frame->eventHandler()->capsLockStateMayHaveChanged();
 
     PlatformKeyboardEvent keyEvent(m_viewWindow, virtualKeyCode, keyData, PlatformKeyboardEvent::RawKeyDown, systemKeyDown);
     bool handled = frame->eventHandler()->keyEvent(keyEvent);
index 489a337..2889b1a 100644 (file)
@@ -1,3 +1,14 @@
+2011-04-04  Alexey Proskuryakov  <ap@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        REGRESSION (WebKit2): Caps-Lock indicator sometimes doesn't appear in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=51230
+        <rdar://problem/8780989>
+
+        * WebView.cpp: (WebView::handleKeyDown): Moved Caps Lock handling from WebKits to WebCore,
+        because WebKit shouldn't be smart.
+
 2011-03-31  Patrick Gansterer  <paroga@webkit.org>
 
         Unreviewed WinCE build fix for r82580.
index c21a7fd..56cbf28 100644 (file)
@@ -347,8 +347,6 @@ bool WebView::handleMouseWheel(HWND hWnd, WPARAM wParam, LPARAM lParam, bool isH
 bool WebView::handleKeyDown(WPARAM virtualKeyCode, LPARAM keyData, bool systemKeyDown)
 {
     Frame* frame = m_page->focusController()->focusedOrMainFrame();
-    if (virtualKeyCode == VK_CAPITAL)
-        frame->eventHandler()->capsLockStateMayHaveChanged();
 
     PlatformKeyboardEvent keyEvent(m_windowHandle, virtualKeyCode, keyData, PlatformKeyboardEvent::RawKeyDown, systemKeyDown);
     bool handled = frame->eventHandler()->keyEvent(keyEvent);
index 1a0a314..0e16727 100644 (file)
@@ -1,3 +1,14 @@
+2011-04-04  Alexey Proskuryakov  <ap@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        REGRESSION (WebKit2): Caps-Lock indicator sometimes doesn't appear in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=51230
+        <rdar://problem/8780989>
+
+        * WebView.cpp: (wxWebView::OnKeyEvents): Moved Caps Lock handling from
+        WebKits to WebCore, because WebKit shouldn't be smart.
+
 2011-03-31  Evan Martin  <evan@chromium.org>
 
         Reviewed by Eric Seidel.
index dab3225..48ec720 100644 (file)
@@ -895,9 +895,6 @@ void wxWebView::OnKeyEvents(wxKeyEvent& event)
     if (!(frame && frame->view()))
         return;
 
-    if (event.GetKeyCode() == WXK_CAPITAL)
-        frame->eventHandler()->capsLockStateMayHaveChanged();
-
     WebCore::PlatformKeyboardEvent wkEvent(event);
 
     if (frame->eventHandler()->keyEvent(wkEvent))
index 5fad09e..503fe50 100644 (file)
@@ -1,3 +1,18 @@
+2011-04-04  Alexey Proskuryakov  <ap@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        REGRESSION (WebKit2): Caps-Lock indicator sometimes doesn't appear in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=51230
+        <rdar://problem/8780989>
+
+        <rdar://problem/9015250> REGRESSION (WebKit2): Key events not fired for modifier keys
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView flagsChanged:]): Ported from WebHTMLView.
+        (-[WKView _interpretKeyEvent:withCachedTextInputState:savingCommandsTo:WebCore::]):
+        AppKit isn't happy about attempts to interpret NSFlagsChanged, but WK2 lacked the check.
+
 2011-04-04  Steve Falkenburg  <sfalken@apple.com>
 
         Reviewed by Adam Roben.
index 7b70f93..f0b3233 100644 (file)
@@ -1165,6 +1165,22 @@ static const short kIOHIDEventTypeScroll = 6;
     _data->_page->handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, self));
 }
 
+- (void)flagsChanged:(NSEvent *)theEvent
+{
+    // There's a chance that responding to this event will run a nested event loop, and
+    // fetching a new event might release the old one. Retaining and then autoreleasing
+    // the current event prevents that from causing a problem inside WebKit or AppKit code.
+    [[theEvent retain] autorelease];
+
+    unsigned short keyCode = [theEvent keyCode];
+
+    // Don't make an event from the num lock and function keys
+    if (!keyCode || keyCode == 10 || keyCode == 63)
+        return;
+
+    _data->_page->handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, self));
+}
+
 - (void)_executeSavedKeypressCommands
 {
     WKViewInterpretKeyEventsParameters* parameters = _data->_interpretKeyEventsParameters;
@@ -1177,7 +1193,6 @@ static const short kIOHIDEventTypeScroll = 6;
     parameters->commands->clear();
 }
 
-
 - (NSTextInputContext *)inputContext
 {
     if (_data->_pluginComplexTextInputIdentifier && !_data->_interpretKeyEventsParameters)
@@ -1846,6 +1861,9 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
     ASSERT(!_data->_interpretKeyEventsParameters);
     ASSERT(commands.isEmpty());
 
+    if ([event type] == NSFlagsChanged)
+        return NO;
+
     WKViewInterpretKeyEventsParameters parameters;
     parameters.cachedTextInputState = cachedTextInputState;
     parameters.eventInterpretationHadSideEffects = false;