PlatformMouseEvent::PlatformMouseEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool activatedWebView) : m_position(positionForEvent(hWnd, lParam)) , m_globalPosition(globalPositionForEvent(hWnd, lParam)) , m_clickCount(0) , m_shiftKey(wParam & MK_SHIFT) , m_ctrlKey(wParam & MK_CONTROL) , m_altKey(GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT) , m_metaKey(m_altKey) // FIXME: We'll have to test other browsers , m_activatedWebView(activatedWebView) , m_eventType(messageToEventType(message)) , m_modifierFlags(wParam) { m_timestamp = ::GetTickCount()*0.001; // GetTickCount returns milliseconds switch (message) { case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_LBUTTONDBLCLK: m_button = LeftButton; break; case WM_RBUTTONDOWN: case WM_RBUTTONUP: case WM_RBUTTONDBLCLK: m_button = RightButton; break; case WM_MBUTTONDOWN: case WM_MBUTTONUP: case WM_MBUTTONDBLCLK: m_button = MiddleButton; break; case WM_MOUSEMOVE: #if !OS(WINCE) case WM_MOUSELEAVE: #endif if (wParam & MK_LBUTTON) m_button = LeftButton; else if (wParam & MK_MBUTTON) m_button = MiddleButton; else if (wParam & MK_RBUTTON) m_button = RightButton; else m_button = NoButton; break; default: ASSERT_NOT_REACHED(); } }
PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, WPARAM wParam, LPARAM lParam, bool isMouseHWheel) : PlatformEvent(PlatformEvent::Wheel, wParam & MK_SHIFT, wParam & MK_CONTROL, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, ::GetTickCount() * 0.001) , m_position(positionForEvent(hWnd, lParam)) , m_globalPosition(globalPositionForEvent(hWnd, lParam)) , m_directionInvertedFromDevice(false) { float scaleFactor = deviceScaleFactorForWindow(hWnd); // How many pixels should we scroll per line? Gecko uses the height of the // current line, which means scroll distance changes as you go through the // page or go to different pages. IE 7 is ~50 px/line, although the value // seems to vary slightly by page and zoom level. Since IE 7 has a // smoothing algorithm on scrolling, it can get away with slightly larger // scroll values without feeling jerky. Here we use 100 px per three lines // (the default scroll amount on Windows is three lines per wheel tick). static const float cScrollbarPixelsPerLine = scaleFactor * 100.0f / 3.0f; float delta = GET_WHEEL_DELTA_WPARAM(wParam) / (scaleFactor * static_cast<float>(WHEEL_DELTA)); if (isMouseHWheel) { // Windows is <-- -/+ -->, WebKit wants <-- +/- -->, so we negate // |delta| after saving the original value on the wheel tick member. m_wheelTicksX = delta; m_wheelTicksY = 0; delta = -delta; } else { // Even though we use shift + vertical wheel to scroll horizontally in // WebKit, we still note it as a vertical scroll on the wheel tick // member, so that the DOM event we later construct will match the real // hardware event better. m_wheelTicksX = 0; m_wheelTicksY = delta; } if (isMouseHWheel || shiftKey()) { m_deltaX = delta * static_cast<float>(horizontalScrollChars()) * cScrollbarPixelsPerLine; m_deltaY = 0; m_granularity = ScrollByPixelWheelEvent; } else { m_deltaX = 0; m_deltaY = delta; int verticalMultiplier = verticalScrollLines(); m_granularity = (verticalMultiplier == WHEEL_PAGESCROLL) ? ScrollByPageWheelEvent : ScrollByPixelWheelEvent; if (m_granularity == ScrollByPixelWheelEvent) m_deltaY *= static_cast<float>(verticalMultiplier) * cScrollbarPixelsPerLine; } }
PlatformMouseEvent::PlatformMouseEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool didActivateWebView) : PlatformEvent(messageToEventType(message), wParam & MK_SHIFT, wParam & MK_CONTROL, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, currentTime()) , m_position(positionForEvent(hWnd, lParam)) , m_globalPosition(globalPositionForEvent(hWnd, lParam)) , m_clickCount(0) , m_didActivateWebView(didActivateWebView) , m_modifierFlags(wParam) { switch (message) { case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_LBUTTONDBLCLK: m_button = LeftButton; break; case WM_RBUTTONDOWN: case WM_RBUTTONUP: case WM_RBUTTONDBLCLK: m_button = RightButton; break; case WM_MBUTTONDOWN: case WM_MBUTTONUP: case WM_MBUTTONDBLCLK: m_button = MiddleButton; break; case WM_MOUSEMOVE: #if !OS(WINCE) case WM_MOUSELEAVE: #endif if (wParam & MK_LBUTTON) m_button = LeftButton; else if (wParam & MK_MBUTTON) m_button = MiddleButton; else if (wParam & MK_RBUTTON) m_button = RightButton; else m_button = NoButton; break; default: ASSERT_NOT_REACHED(); } }