KeyboardEvent* findKeyboardEvent(Event* event) { for (Event* e = event; e; e = e->underlyingEvent()) if (e->isKeyboardEvent()) return toKeyboardEvent(e); return 0; }
void HTMLElement::defaultEventHandler(Event* event) { if (event->type() == EventTypeNames::keypress && event->isKeyboardEvent()) { handleKeypressEvent(toKeyboardEvent(event)); if (event->defaultHandled()) return; } Element::defaultEventHandler(event); }
void HTMLButtonElement::defaultEventHandler(Event* event) { if (event->type() == eventNames().DOMActivateEvent && !isDisabledFormControl()) { if (form() && m_type == SUBMIT) { m_isActivatedSubmit = true; form()->prepareForSubmission(event); event->setDefaultHandled(); m_isActivatedSubmit = false; // Do this in case submission was canceled. } if (form() && m_type == RESET) { form()->reset(); event->setDefaultHandled(); } } if (event->isKeyboardEvent()) { if (event->type() == eventNames().keydownEvent && toKeyboardEvent(event)->keyIdentifier() == "U+0020") { setActive(true, true); // No setDefaultHandled() - IE dispatches a keypress in this case. return; } if (event->type() == eventNames().keypressEvent) { switch (toKeyboardEvent(event)->charCode()) { case '\r': dispatchSimulatedClick(event); event->setDefaultHandled(); return; case ' ': // Prevent scrolling down the page. event->setDefaultHandled(); return; } } if (event->type() == eventNames().keyupEvent && toKeyboardEvent(event)->keyIdentifier() == "U+0020") { if (active()) dispatchSimulatedClick(event); event->setDefaultHandled(); return; } } HTMLFormControlElement::defaultEventHandler(event); }
void HTMLButtonElement::defaultEventHandler(Event* event) { if (event->type() == EventTypeNames::DOMActivate && !isDisabledFormControl()) { if (form() && m_type == SUBMIT) { form()->prepareForSubmission(event, this); event->setDefaultHandled(); } if (form() && m_type == RESET) { form()->reset(); event->setDefaultHandled(); } } if (event->isKeyboardEvent()) { if (event->type() == EventTypeNames::keydown && toKeyboardEvent(event)->key() == " ") { setActive(true); // No setDefaultHandled() - IE dispatches a keypress in this case. return; } if (event->type() == EventTypeNames::keypress) { switch (toKeyboardEvent(event)->charCode()) { case '\r': dispatchSimulatedClick(event); event->setDefaultHandled(); return; case ' ': // Prevent scrolling down the page. event->setDefaultHandled(); return; } } if (event->type() == EventTypeNames::keyup && toKeyboardEvent(event)->key() == " ") { if (isActive()) dispatchSimulatedClick(event); event->setDefaultHandled(); return; } } HTMLFormControlElement::defaultEventHandler(event); }
void HTMLElement::defaultEventHandler(Event* event) { if (event->type() == eventNames().keypressEvent && event->isKeyboardEvent()) { handleKeypressEvent(toKeyboardEvent(event)); if (event->defaultHandled()) return; } StyledElement::defaultEventHandler(event); }
bool isEnterKeyKeydownEvent(Event* event) { return event->type() == eventNames().keydownEvent && event->isKeyboardEvent() && toKeyboardEvent(event)->keyIdentifier() == "Enter"; }
bool InputTypeView::shouldSubmitImplicitly(Event* event) { return event->isKeyboardEvent() && event->type() == EventTypeNames::keypress && toKeyboardEvent(event)->charCode() == '\r'; }
static bool isEnterKeyKeydownEvent(Event* event) { return event->type() == EventTypeNames::keydown && event->isKeyboardEvent() && toKeyboardEvent(event)->keyIdentifier() == "Enter"; }