Commit 9c050adc authored by andersca@apple.com's avatar andersca@apple.com

https://bugs.webkit.org/show_bug.cgi?id=29332

<rdar://problem/7231652> 
REGRESSION (r48446): While a <select> popup menu is open, the
rest of the WebView doesn't respond to mouse move events.

Reviewed by Sam Weinig.

* platform/win/PopupMenuWin.cpp:
(WebCore::translatePoint):
New helper function that translates a point between HWND coordinates.
        
(WebCore::PopupMenu::show):
Protect the PopupMenu if someone removes the <select> 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
parent f1b44a6d
2009-09-18 Anders Carlsson <andersca@apple.com>
Reviewed by Sam Weinig.
https://bugs.webkit.org/show_bug.cgi?id=29332
<rdar://problem/7231652>
REGRESSION (r48446): While a <select> popup menu is open, the
rest of the WebView doesn't respond to mouse move events.
* platform/win/PopupMenuWin.cpp:
(WebCore::translatePoint):
New helper function that translates a point between HWND coordinates.
(WebCore::PopupMenu::show):
Protect the PopupMenu if someone removes the <select> 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 <simon.fraser@apple.com>
Reviewed by Dave Hyatt.
......@@ -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<PopupMenu> 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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment