Source/core/page/EventHandler.cpp
// The return value means 'continue default handling.'
The return value means 'continue default handling.'
The return value means ' continue default handling . '
bool EventHandler::handleMouseFocus(const PlatformMouseEvent& mouseEvent)
{
    if (FrameView* view = m_frame->view()) {
        if (view->scrollbarAtPoint(mouseEvent.position()))
            return true;
    }
    m_frame->document()->updateLayoutIgnorePendingStylesheets();
    Element* element = 0;
    if (m_nodeUnderMouse)
        element = m_nodeUnderMouse->isElementNode() ? toElement(m_nodeUnderMouse) : m_nodeUnderMouse->parentOrShadowHostElement();
    for (; element; element = element->parentOrShadowHostElement()) {
        if (element->isFocusable() && element->focused())
            return true;
        if (element->isMouseFocusable())
            break;
    }
    ASSERT(!element || element->isMouseFocusable());
    if (element
        && m_frame->selection().isRange()
        && m_frame->selection().toNormalizedRange()->compareNode(element, IGNORE_EXCEPTION) == Range::NODE_INSIDE
        && element->isDescendantOf(m_frame->document()->focusedElement()))
        return true;
    if (!element && isInsideScrollbar(mouseEvent.position()))
        return false;
    if (Page* page = m_frame->page()) {
        if (element) {
            if (!page->focusController().setFocusedElement(element, m_frame, FocusTypeMouse))
                return false;
        } else {
            if (!page->focusController().setFocusedElement(0, m_frame))
                return false;
        }
    }
    return true;
}
bool EventHandler :: handleMouseFocus ( const PlatformMouseEvent & mouseEvent ) { if ( FrameView * view = m_frame -> view ( ) ) { if ( view -> scrollbarAtPoint ( mouseEvent . position ( ) ) ) return true ; } m_frame -> document ( ) -> updateLayoutIgnorePendingStylesheets ( ) ; Element * element = 0 ; if ( m_nodeUnderMouse ) element = m_nodeUnderMouse -> isElementNode ( ) ? toElement ( m_nodeUnderMouse ) : m_nodeUnderMouse -> parentOrShadowHostElement ( ) ; for ( ; element ; element = element -> parentOrShadowHostElement ( ) ) { if ( element -> isFocusable ( ) && element -> focused ( ) ) return true ; if ( element -> isMouseFocusable ( ) ) break ; } ASSERT ( ! element || element -> isMouseFocusable ( ) ) ; if ( element && m_frame -> selection ( ) . isRange ( ) && m_frame -> selection ( ) . toNormalizedRange ( ) -> compareNode ( element , IGNORE_EXCEPTION ) == Range :: NODE_INSIDE && element -> isDescendantOf ( m_frame -> document ( ) -> focusedElement ( ) ) ) return true ; if ( ! element && isInsideScrollbar ( mouseEvent . position ( ) ) ) return false ; if ( Page * page = m_frame -> page ( ) ) { if ( element ) { if ( ! page -> focusController ( ) . setFocusedElement ( element , m_frame , FocusTypeMouse ) ) return false ; } else { if ( ! page -> focusController ( ) . setFocusedElement ( 0 , m_frame ) ) return false ; } } return true ; }
The return value means 'continue default handling.'
The return value means ' continue default handling . '
// If clicking on a frame scrollbar, do not mess up with content focus. // The layout needs to be up to date to determine if an element is focusable. // To fix <rdar://problem/4895428> Can't drag selected ToDo, we don't focus // a node on mouse down if it's selected and inside a focused node. It will // be focused if the user does a mouseup over it, however, because the // mouseup will set a selection inside it, which will call // FrameSelection::setFocusedNodeIfNeeded. // Only change the focus when clicking scrollbars if it can transfered to a // mouse focusable node. // If focus shift is blocked, we eat the event. Note we should never // clear swallowEvent if the page already set it (e.g., by canceling // default behavior). // We call setFocusedElement even with !element in order to blur // current focus element when a link is clicked; this is expected by // some sites that rely on onChange handlers running from form // fields before the button click is processed.