Fix <rdar://5485108> Type-select while a <select> menu is open doesn't work
authoraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Nov 2007 23:42:41 +0000 (23:42 +0000)
committeraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Nov 2007 23:42:41 +0000 (23:42 +0000)
         There were two things broken here:
            - WebView now requires a WM_CHAR message to be sent before it will
              create a keyboard event with a charCode, but we were only sending
              a WM_KEYDOWN event.
            - The popup menu was not updating its focused index when the
              <select> element's selectedIndex changed.

         Reviewed by Adele.

         * platform/win/PopupMenuWin.cpp:
         (WebCore::PopupMenu::updateFromElement): Update the focused index from
         the client's selected index.
         (WebCore::PopupWndProc): When we receive a WM_CHAR message for a
         printable character, manufacture a WM_KEYDOWN message for it and post
         both that and the current WM_CHAR message to the WebView.

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

WebCore/ChangeLog
WebCore/platform/win/PopupMenuWin.cpp

index 856dd89..e668391 100644 (file)
@@ -1,3 +1,23 @@
+2007-11-15  Adam Roben  <aroben@apple.com>
+
+        Fix <rdar://5485108> Type-select while a <select> menu is open doesn't work
+
+        There were two things broken here:
+           - WebView now requires a WM_CHAR message to be sent before it will
+             create a keyboard event with a charCode, but we were only sending
+             a WM_KEYDOWN event.
+           - The popup menu was not updating its focused index when the
+             <select> element's selectedIndex changed.
+
+        Reviewed by Adele.
+
+        * platform/win/PopupMenuWin.cpp:
+        (WebCore::PopupMenu::updateFromElement): Update the focused index from
+        the client's selected index.
+        (WebCore::PopupWndProc): When we receive a WM_CHAR message for a
+        printable character, manufacture a WM_KEYDOWN message for it and post
+        both that and the current WM_CHAR message to the WebView.
+
 2007-11-15  Brady Eidson  <beidson@apple.com>
 
         Build fix
index d9ac000..3bdf59b 100644 (file)
@@ -412,6 +412,8 @@ void PopupMenu::updateFromElement()
     if (!m_popup)
         return;
 
+    m_focusedIndex = client()->selectedIndex();
+
     ::InvalidateRect(m_popup, 0, TRUE);
     if (!scrollToRevealSelection())
         ::UpdateWindow(m_popup);
@@ -679,11 +681,7 @@ static LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT message, WPARAM wParam, LPA
                         popup->client()->hidePopup();
                         break;
                     default:
-                        if (isASCIIPrintable(::MapVirtualKey(LOWORD(wParam), 2)))
-                            // Send the keydown to the WebView so it can be used for type-ahead find
-                            ::SendMessage(popup->client()->clientDocument()->view()->containingWindow(), message, wParam, lParam);
-                        else
-                            lResult = 1;
+                        lResult = 1;
                         break;
                 }
             }
@@ -706,7 +704,14 @@ static LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT message, WPARAM wParam, LPA
                     case 0x08:   // Backspace
                     case 0x0A:   // Linefeed
                     default:     // Character
-                        lResult = 1;
+                        if (isASCIIPrintable(wParam)) {
+                            // Send a WM_KEYDOWN event and the current WM_CHAR event to the WebView
+                            // so that it can perform type-to-select.
+                            HWND webView = popup->client()->clientDocument()->view()->containingWindow();
+                            ::PostMessage(webView, WM_KEYDOWN, LOWORD(wParam), lParam);
+                            ::PostMessage(webView, message, wParam, lParam);
+                        } else
+                            lResult = 1;
                         break;
                 }
             }