WebKit2PlatformKeyboardEvent(const WebKeyboardEvent& webEvent) { // PlatformEvent switch (webEvent.type()) { case WebEvent::KeyDown: m_type = WebCore::PlatformEvent::KeyDown; break; case WebEvent::KeyUp: m_type = WebCore::PlatformEvent::KeyUp; break; case WebEvent::RawKeyDown: m_type = WebCore::PlatformEvent::RawKeyDown; break; case WebEvent::Char: m_type = WebCore::PlatformEvent::Char; 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(); // PlatformKeyboardEvent m_text = webEvent.text(); m_unmodifiedText = webEvent.unmodifiedText(); m_keyIdentifier = webEvent.keyIdentifier(); m_windowsVirtualKeyCode = webEvent.windowsVirtualKeyCode(); m_nativeVirtualKeyCode = webEvent.nativeVirtualKeyCode(); m_macCharCode = webEvent.macCharCode(); #if USE(APPKIT) || PLATFORM(GTK) m_handledByInputMethod = webEvent.handledByInputMethod(); m_commands = webEvent.commands(); #endif m_autoRepeat = webEvent.isAutoRepeat(); m_isKeypad = webEvent.isKeypad(); m_isSystemKey = webEvent.isSystemKey(); }
WebKit2PlatformKeyboardEvent(const WebKeyboardEvent& webEvent) { switch (webEvent.type()) { case WebEvent::KeyDown: m_type = PlatformKeyboardEvent::KeyDown; break; case WebEvent::KeyUp: m_type = PlatformKeyboardEvent::KeyUp; break; case WebEvent::RawKeyDown: m_type = PlatformKeyboardEvent::RawKeyDown; break; case WebEvent::Char: m_type = PlatformKeyboardEvent::Char; break; default: ASSERT_NOT_REACHED(); } m_text = webEvent.text(); m_unmodifiedText = webEvent.unmodifiedText(); m_keyIdentifier = webEvent.keyIdentifier(); m_windowsVirtualKeyCode = webEvent.windowsVirtualKeyCode(); m_nativeVirtualKeyCode = webEvent.nativeVirtualKeyCode(); m_autoRepeat = webEvent.isAutoRepeat(); m_isKeypad = webEvent.isKeypad(); m_shiftKey = webEvent.shiftKey(); m_ctrlKey = webEvent.controlKey(); m_altKey = webEvent.altKey(); m_metaKey = webEvent.metaKey(); #if PLATFORM(WIN) // FIXME: We should make m_isSystemKey available (and false) on all platforms // to avoid this #define. m_isSystemKey = webEvent.isSystemKey(); #endif }
bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboardEvent) { if (keyboardEvent.type() != WebEvent::KeyDown && keyboardEvent.type() != WebEvent::RawKeyDown) return false; switch (keyboardEvent.windowsVirtualKeyCode()) { case VK_BACK: if (keyboardEvent.isSystemKey()) return false; if (keyboardEvent.shiftKey()) m_page->goForward(); else m_page->goBack(); break; case VK_LEFT: if (keyboardEvent.isSystemKey()) m_page->goBack(); else scroll(m_page.get(), ScrollLeft, ScrollByLine); break; case VK_RIGHT: if (keyboardEvent.isSystemKey()) m_page->goForward(); else scroll(m_page.get(), ScrollRight, ScrollByLine); break; case VK_UP: if (keyboardEvent.isSystemKey()) return false; scroll(m_page.get(), ScrollUp, ScrollByLine); break; case VK_DOWN: if (keyboardEvent.isSystemKey()) return false; scroll(m_page.get(), ScrollDown, ScrollByLine); break; case VK_HOME: if (keyboardEvent.isSystemKey()) return false; logicalScroll(m_page.get(), ScrollBlockDirectionBackward, ScrollByDocument); break; case VK_END: if (keyboardEvent.isSystemKey()) return false; logicalScroll(m_page.get(), ScrollBlockDirectionForward, ScrollByDocument); break; case VK_PRIOR: if (keyboardEvent.isSystemKey()) return false; logicalScroll(m_page.get(), ScrollBlockDirectionBackward, ScrollByPage); break; case VK_NEXT: if (keyboardEvent.isSystemKey()) return false; logicalScroll(m_page.get(), ScrollBlockDirectionForward, ScrollByPage); break; default: return false; } return true; }