Example #1
0
bool HTMLElement::supportsSpatialNavigationFocus() const
{
    // This function checks whether the element satisfies the extended criteria
    // for the element to be focusable, introduced by spatial navigation feature,
    // i.e. checks if click or keyboard event handler is specified.
    // This is the way to make it possible to navigate to (focus) elements
    // which web designer meant for being active (made them respond to click events).

    if (!document().settings() || !document().settings()->spatialNavigationEnabled())
        return false;
    EventTarget* target = const_cast<HTMLElement*>(this);
    return target->hasEventListeners(eventNames().clickEvent)
        || target->hasEventListeners(eventNames().keydownEvent)
        || target->hasEventListeners(eventNames().keypressEvent)
        || target->hasEventListeners(eventNames().keyupEvent);
}
void EventHandlerRegistry::updateAllEventHandlers(ChangeOperation op, EventTarget& target)
{
    if (!target.hasEventListeners())
        return;

    Vector<AtomicString> eventTypes = target.eventTypes();
    for (size_t i = 0; i < eventTypes.size(); ++i) {
        EventHandlerClass handlerClass;
        if (!eventTypeToClass(eventTypes[i], &handlerClass))
            continue;
        if (op == RemoveAll) {
            updateEventHandlerInternal(op, handlerClass, &target);
            continue;
        }
        for (unsigned count = target.getEventListeners(eventTypes[i]).size(); count > 0; --count)
            updateEventHandlerInternal(op, handlerClass, &target);
    }
}