WebKit2PlatformMouseEvent(const WebMouseEvent& webEvent) { switch (webEvent.type()) { case WebEvent::MouseDown: m_eventType = WebCore::MouseEventPressed; break; case WebEvent::MouseUp: m_eventType = WebCore::MouseEventReleased; break; case WebEvent::MouseMove: m_eventType = WebCore::MouseEventMoved; break; default: ASSERT_NOT_REACHED(); } switch (webEvent.button()) { case WebMouseEvent::NoButton: m_button = WebCore::NoButton; break; case WebMouseEvent::LeftButton: m_button = WebCore::LeftButton; break; case WebMouseEvent::MiddleButton: m_button = WebCore::MiddleButton; break; case WebMouseEvent::RightButton: m_button = WebCore::RightButton; break; default: ASSERT_NOT_REACHED(); } m_position = WebCore::IntPoint(webEvent.positionX(), webEvent.positionY()); m_globalPosition = WebCore::IntPoint(webEvent.globalPositionX(), webEvent.globalPositionY()); m_clickCount = webEvent.clickCount(); m_timestamp = webEvent.timestamp(); m_shiftKey = webEvent.shiftKey(); m_ctrlKey = webEvent.controlKey(); m_altKey = webEvent.altKey(); m_metaKey = webEvent.metaKey(); m_modifierFlags = 0; if (m_shiftKey) m_modifierFlags |= WebEvent::ShiftKey; if (m_ctrlKey) m_modifierFlags |= WebEvent::ControlKey; if (m_altKey) m_modifierFlags |= WebEvent::AltKey; if (m_metaKey) m_modifierFlags |= WebEvent::MetaKey; }
WebKit2PlatformMouseEvent(const WebMouseEvent& webEvent) { // PlatformEvent switch (webEvent.type()) { case WebEvent::MouseDown: m_type = WebCore::PlatformEvent::MousePressed; m_force = WebCore::ForceAtClick; break; case WebEvent::MouseUp: m_type = WebCore::PlatformEvent::MouseReleased; m_force = WebCore::ForceAtClick; break; case WebEvent::MouseMove: m_type = WebCore::PlatformEvent::MouseMoved; m_force = webEvent.force(); break; case WebEvent::MouseForceChanged: m_type = WebCore::PlatformEvent::MouseForceChanged; m_force = webEvent.force(); break; case WebEvent::MouseForceDown: m_type = WebCore::PlatformEvent::MouseForceDown; m_force = WebCore::ForceAtForceClick; break; case WebEvent::MouseForceUp: m_type = WebCore::PlatformEvent::MouseForceUp; m_force = WebCore::ForceAtForceClick; break; default: ASSERT_NOT_REACHED(); } m_modifiers = 0; if (webEvent.shiftKey()) m_modifiers |= ShiftKey; if (webEvent.controlKey()) m_modifiers |= CtrlKey; if (webEvent.altKey()) m_modifiers |= AltKey; if (webEvent.metaKey()) m_modifiers |= MetaKey; m_timestamp = webEvent.timestamp(); // PlatformMouseEvent switch (webEvent.button()) { case WebMouseEvent::NoButton: m_button = WebCore::NoButton; break; case WebMouseEvent::LeftButton: m_button = WebCore::LeftButton; break; case WebMouseEvent::MiddleButton: m_button = WebCore::MiddleButton; break; case WebMouseEvent::RightButton: m_button = WebCore::RightButton; break; default: ASSERT_NOT_REACHED(); } m_position = webEvent.position(); m_globalPosition = webEvent.globalPosition(); m_clickCount = webEvent.clickCount(); #if PLATFORM(MAC) m_eventNumber = webEvent.eventNumber(); m_menuTypeForEvent = webEvent.menuTypeForEvent(); #endif m_modifierFlags = 0; if (webEvent.shiftKey()) m_modifierFlags |= WebEvent::ShiftKey; if (webEvent.controlKey()) m_modifierFlags |= WebEvent::ControlKey; if (webEvent.altKey()) m_modifierFlags |= WebEvent::AltKey; if (webEvent.metaKey()) m_modifierFlags |= WebEvent::MetaKey; }
WebKit2PlatformMouseEvent(const WebMouseEvent& webEvent) { // PlatformEvent switch (webEvent.type()) { case WebEvent::MouseDown: m_type = WebCore::PlatformEvent::MousePressed; break; case WebEvent::MouseUp: m_type = WebCore::PlatformEvent::MouseReleased; break; case WebEvent::MouseMove: m_type = WebCore::PlatformEvent::MouseMoved; break; default: ASSERT_NOT_REACHED(); } m_modifiers = 0; if (webEvent.shiftKey()) m_modifiers |= ShiftKey; if (webEvent.controlKey()) m_modifiers |= CtrlKey; if (webEvent.altKey()) m_modifiers |= AltKey; if (webEvent.metaKey()) m_modifiers |= MetaKey; m_timestamp = webEvent.timestamp(); // PlatformMouseEvent switch (webEvent.button()) { case WebMouseEvent::NoButton: m_button = WebCore::NoButton; break; case WebMouseEvent::LeftButton: m_button = WebCore::LeftButton; break; case WebMouseEvent::MiddleButton: m_button = WebCore::MiddleButton; break; case WebMouseEvent::RightButton: m_button = WebCore::RightButton; break; default: ASSERT_NOT_REACHED(); } m_position = webEvent.position(); m_globalPosition = webEvent.globalPosition(); m_clickCount = webEvent.clickCount(); m_modifierFlags = 0; if (webEvent.shiftKey()) m_modifierFlags |= WebEvent::ShiftKey; if (webEvent.controlKey()) m_modifierFlags |= WebEvent::ControlKey; if (webEvent.altKey()) m_modifierFlags |= WebEvent::AltKey; if (webEvent.metaKey()) m_modifierFlags |= WebEvent::MetaKey; #if PLATFORM(WIN) m_didActivateWebView = webEvent.didActivateWebView(); #endif }
NPEvent toNP(const WebMouseEvent& event) { NPEvent npEvent; npEvent.wParam = 0; if (event.controlKey()) npEvent.wParam |= MK_CONTROL; if (event.shiftKey()) npEvent.wParam |= MK_SHIFT; npEvent.lParam = MAKELPARAM(event.position().x(), event.position().y()); switch (event.type()) { case WebEvent::MouseMove: npEvent.event = WM_MOUSEMOVE; switch (event.button()) { case WebMouseEvent::LeftButton: npEvent.wParam |= MK_LBUTTON; break; case WebMouseEvent::MiddleButton: npEvent.wParam |= MK_MBUTTON; break; case WebMouseEvent::RightButton: npEvent.wParam |= MK_RBUTTON; break; case WebMouseEvent::NoButton: break; } break; case WebEvent::MouseDown: switch (event.button()) { case WebMouseEvent::LeftButton: npEvent.event = WM_LBUTTONDOWN; break; case WebMouseEvent::MiddleButton: npEvent.event = WM_MBUTTONDOWN; break; case WebMouseEvent::RightButton: npEvent.event = WM_RBUTTONDOWN; break; case WebMouseEvent::NoButton: ASSERT_NOT_REACHED(); break; } break; case WebEvent::MouseUp: switch (event.button()) { case WebMouseEvent::LeftButton: npEvent.event = WM_LBUTTONUP; break; case WebMouseEvent::MiddleButton: npEvent.event = WM_MBUTTONUP; break; case WebMouseEvent::RightButton: npEvent.event = WM_RBUTTONUP; break; case WebMouseEvent::NoButton: ASSERT_NOT_REACHED(); break; } break; default: ASSERT_NOT_REACHED(); break; } return npEvent; }