KeyboardEvent::KeyboardEvent(const PlatformKeyboardEvent& key, DOMWindow* view) : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type()) , true, true, key.timestamp(), view, 0, key.ctrlKey(), key.altKey(), key.shiftKey() , key.metaKey(), false, key.modifiers().contains(PlatformEvent::Modifier::CapsLockKey)) , m_keyEvent(std::make_unique<PlatformKeyboardEvent>(key)) #if ENABLE(KEYBOARD_KEY_ATTRIBUTE) , m_key(key.key()) #endif #if ENABLE(KEYBOARD_CODE_ATTRIBUTE) , m_code(key.code()) #endif , m_keyIdentifier(key.keyIdentifier()) , m_location(keyLocationCode(key)) , m_repeat(key.isAutoRepeat()) , m_isComposing(view && view->frame() && view->frame()->editor().hasComposition()) #if PLATFORM(COCOA) #if USE(APPKIT) , m_handledByInputMethod(key.handledByInputMethod()) , m_keypressCommands(key.commands()) #else , m_handledByInputMethod(false) #endif #endif { }
KeyboardEvent::KeyboardEvent(const PlatformKeyboardEvent& key, AbstractView* view) : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type()), true, true, view, 0, key.ctrlKey(), key.altKey(), key.shiftKey(), key.metaKey()) , m_keyEvent(adoptPtr(new PlatformKeyboardEvent(key))) , m_keyIdentifier(key.keyIdentifier()) , m_keyLocation(key.isKeypad() ? DOM_KEY_LOCATION_NUMPAD : DOM_KEY_LOCATION_STANDARD) // FIXME: differentiate right/left, too , m_altGraphKey(false) { }
KeyboardEvent::KeyboardEvent(const PlatformKeyboardEvent& key, AbstractView* view) : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type()), true, true, view, 0, key.ctrlKey(), key.altKey(), key.shiftKey(), key.metaKey()) , m_keyEvent(adoptPtr(new PlatformKeyboardEvent(key))) , m_keyIdentifier(key.keyIdentifier()) , m_location(keyLocationCode(key)) , m_altGraphKey(false) , m_isAutoRepeat(key.isAutoRepeat()) { ScriptWrappable::init(this); }
KeyboardEvent::KeyboardEvent(const PlatformKeyboardEvent& key, AbstractView* view) : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type()), true, true, key.timestamp(), view, 0, key.ctrlKey(), key.altKey(), key.shiftKey(), key.metaKey()) , m_keyEvent(std::make_unique<PlatformKeyboardEvent>(key)) , m_keyIdentifier(key.keyIdentifier()) , m_location(keyLocationCode(key)) , m_altGraphKey(false) #if PLATFORM(COCOA) #if USE(APPKIT) , m_handledByInputMethod(key.handledByInputMethod()) , m_keypressCommands(key.commands()) #else , m_handledByInputMethod(false) #endif #endif { }
static void handleKeyPress(Frame& frame, KeyboardEvent& event, const PlatformKeyboardEvent& platformEvent) { String commandName = interpretKeyEvent(event); if (!commandName.isEmpty()) { frame.editor().command(commandName).execute(); event.setDefaultHandled(); return; } // Don't insert null or control characters as they can result in unexpected behaviour if (event.charCode() < ' ') return; // Don't insert anything if a modifier is pressed and it has not been handled yet if (platformEvent.ctrlKey() || platformEvent.altKey()) return; if (frame.editor().insertText(platformEvent.text(), &event)) event.setDefaultHandled(); }
bool PopupListBox::handleKeyEvent(const PlatformKeyboardEvent& event) { if (event.type() == PlatformEvent::KeyUp) return true; if (!numItems() && event.windowsVirtualKeyCode() != VKEY_ESCAPE) return true; switch (event.windowsVirtualKeyCode()) { case VKEY_ESCAPE: abandon(); // may delete this return true; case VKEY_RETURN: if (m_selectedIndex == -1) { hidePopup(); // Don't eat the enter if nothing is selected. return false; } acceptIndex(m_selectedIndex); // may delete this return true; case VKEY_UP: case VKEY_DOWN: // We have to forward only shift + up combination to focused node when // autofill popup. Because all characters from the cursor to the start // of the text area should selected when you press shift + up arrow. // shift + down should be the similar way to shift + up. if (event.modifiers() && m_popupClient->menuStyle().menuType() == PopupMenuStyle::AutofillPopup) m_focusedElement->dispatchKeyEvent(event); else if (event.windowsVirtualKeyCode() == VKEY_UP) selectPreviousRow(); else selectNextRow(); break; case VKEY_PRIOR: adjustSelectedIndex(-m_visibleRows); break; case VKEY_NEXT: adjustSelectedIndex(m_visibleRows); break; case VKEY_HOME: adjustSelectedIndex(-m_selectedIndex); break; case VKEY_END: adjustSelectedIndex(m_items.size()); break; default: if (!event.ctrlKey() && !event.altKey() && !event.metaKey() && isPrintableChar(event.windowsVirtualKeyCode()) && isCharacterTypeEvent(event)) typeAheadFind(event); break; } if (m_originalIndex != m_selectedIndex) { // Keyboard events should update the selection immediately (but we don't // want to fire the onchange event until the popup is closed, to match // IE). We change the original index so we revert to that when the // popup is closed. if (m_settings.acceptOnAbandon) m_acceptedIndexOnAbandon = m_selectedIndex; setOriginalIndex(m_selectedIndex); if (m_settings.setTextOnIndexChange) m_popupClient->setTextFromItem(m_selectedIndex); } if (event.windowsVirtualKeyCode() == VKEY_TAB) { // TAB is a special case as it should select the current item if any and // advance focus. if (m_selectedIndex >= 0) { acceptIndex(m_selectedIndex); // May delete us. // Return false so the TAB key event is propagated to the page. return false; } // Call abandon() so we honor m_acceptedIndexOnAbandon if set. abandon(); // Return false so the TAB key event is propagated to the page. return false; } return true; }
KeyboardEvent::KeyboardEvent(const PlatformKeyboardEvent& key, AbstractView* view) : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type()), true, true, view, 0, key.ctrlKey(), key.altKey(), key.shiftKey(), key.metaKey(), InputDevice::doesntFireTouchEventsInputDevice()) , m_keyEvent(adoptPtr(new PlatformKeyboardEvent(key))) , m_keyIdentifier(key.keyIdentifier()) , m_code(key.code()) , m_key(key.key()) , m_location(keyLocationCode(key)) , m_isAutoRepeat(key.isAutoRepeat()) , m_bbIsNumLock(key.bbIsNumLock()) { setUICreateTime(key.timestamp()); }