From 9c050adc591c12be5aee59f86b51d81414a7687c Mon Sep 17 00:00:00 2001 From: "andersca@apple.com" Date: Fri, 18 Sep 2009 20:52:01 +0000 Subject: [PATCH] https://bugs.webkit.org/show_bug.cgi?id=29332 REGRESSION (r48446): While a in response to a mouse event. Handle WM_HOST_WINDOW_MOUSEMOVE events. (WebCore::PopupMenu::wndProc): in the WM_MOUSEMOVE handler, if the mouse is not over the popup, post a WM_HOST_WINDOW_MOUSEMOVE event so that the host window (the WebView) gets the mouse move event. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48529 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebCore/ChangeLog | 22 +++++++++++++ WebCore/platform/win/PopupMenuWin.cpp | 45 +++++++++++++++++++++------ 2 files changed, 58 insertions(+), 9 deletions(-) diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index dd0308d78bd..44c7f7ebd3c 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,25 @@ +2009-09-18 Anders Carlsson + + Reviewed by Sam Weinig. + + https://bugs.webkit.org/show_bug.cgi?id=29332 + + REGRESSION (r48446): While a in response to a mouse + event. Handle WM_HOST_WINDOW_MOUSEMOVE events. + + (WebCore::PopupMenu::wndProc): + in the WM_MOUSEMOVE handler, if the mouse is not over the popup, post a + WM_HOST_WINDOW_MOUSEMOVE event so that the host window (the WebView) gets the + mouse move event. + 2009-09-18 Simon Fraser Reviewed by Dave Hyatt. diff --git a/WebCore/platform/win/PopupMenuWin.cpp b/WebCore/platform/win/PopupMenuWin.cpp index 735b252a247..a6e205d8568 100644 --- a/WebCore/platform/win/PopupMenuWin.cpp +++ b/WebCore/platform/win/PopupMenuWin.cpp @@ -62,9 +62,11 @@ const int popupWindowBorderWidth = 1; static LPCTSTR kPopupWindowClassName = _T("PopupWindowClass"); // This is used from within our custom message pump when we want to send a -// WM_CHAR message to the web view and not have our message stolen and sent to +// message to the web view and not have our message stolen and sent to // the popup window. -static const UINT WM_HOST_WINDOW_CHAR = WM_USER; +static const UINT WM_HOST_WINDOW_FIRST = WM_USER; +static const UINT WM_HOST_WINDOW_CHAR = WM_USER + WM_CHAR; +static const UINT WM_HOST_WINDOW_MOUSEMOVE = WM_USER + WM_MOUSEMOVE; // FIXME: Remove this as soon as practical. static inline bool isASCIIPrintable(unsigned c) @@ -72,6 +74,15 @@ static inline bool isASCIIPrintable(unsigned c) return c >= 0x20 && c <= 0x7E; } +static void translatePoint(LPARAM& lParam, HWND from, HWND to) +{ + POINT pt; + pt.x = (short)GET_X_LPARAM(lParam); + pt.y = (short)GET_Y_LPARAM(lParam); + ::MapWindowPoints(from, to, &pt, 1); + lParam = MAKELPARAM(pt.x, pt.y); +} + PopupMenu::PopupMenu(PopupMenuClient* client) : m_popupClient(client) , m_scrollbar(0) @@ -165,6 +176,9 @@ void PopupMenu::show(const IntRect& r, FrameView* view, int index) m_showPopup = true; + // Protect the popup menu in case its owner is destroyed while we're running the message pump. + RefPtr protect(this); + ::SetCapture(hostWindow); MSG msg; @@ -172,11 +186,12 @@ void PopupMenu::show(const IntRect& r, FrameView* view, int index) while (::GetMessage(&msg, 0, 0, 0)) { switch (msg.message) { + case WM_HOST_WINDOW_MOUSEMOVE: case WM_HOST_WINDOW_CHAR: if (msg.hwnd == m_popup) { - // This message should be sent to the host window as a WM_CHAR. + // This message should be sent to the host window. msg.hwnd = hostWindow; - msg.message = WM_CHAR; + msg.message -= WM_HOST_WINDOW_FIRST; } break; @@ -206,11 +221,9 @@ void PopupMenu::show(const IntRect& r, FrameView* view, int index) case WM_MBUTTONDOWN: case WM_MBUTTONUP: case WM_MBUTTONDBLCLK: { - POINT pt; - pt.x = (short)LOWORD(msg.lParam); - pt.y = (short)HIWORD(msg.lParam); - ::MapWindowPoints(msg.hwnd, m_popup, &pt, 1); - msg.lParam = MAKELPARAM(pt.x, pt.y); + // Translate the coordinate. + translatePoint(msg.lParam, msg.hwnd, m_popup); + msg.hwnd = m_popup; break; } @@ -230,6 +243,9 @@ void PopupMenu::show(const IntRect& r, FrameView* view, int index) ::TranslateMessage(&msg); ::DispatchMessage(&msg); + if (!m_popupClient) + break; + if (!m_showPopup) break; activeWindow = ::GetActiveWindow(); @@ -880,6 +896,17 @@ LRESULT PopupMenu::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam RECT bounds; GetClientRect(popupHandle(), &bounds); + if (!::PtInRect(&bounds, mousePoint) && !(wParam & MK_LBUTTON) && client()) { + // When the mouse is not inside the popup menu and the left button isn't down, just + // repost the message to the web view. + + // Translate the coordinate. + translatePoint(lParam, m_popup, client()->hostWindow()->platformWindow()); + + ::PostMessage(m_popup, WM_HOST_WINDOW_MOUSEMOVE, wParam, lParam); + break; + } + if ((shouldHotTrack || wParam & MK_LBUTTON) && ::PtInRect(&bounds, mousePoint)) setFocusedIndex(listIndexAtPoint(mousePoint), true); -- GitLab