OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 bool swallowEvent = false; | 667 bool swallowEvent = false; |
668 m_mousePressed = true; | 668 m_mousePressed = true; |
669 m_selectionInitiationState = HaveNotStartedSelection; | 669 m_selectionInitiationState = HaveNotStartedSelection; |
670 | 670 |
671 if (event.event().clickCount() == 2) | 671 if (event.event().clickCount() == 2) |
672 swallowEvent = handleMousePressEventDoubleClick(event); | 672 swallowEvent = handleMousePressEventDoubleClick(event); |
673 else if (event.event().clickCount() >= 3) | 673 else if (event.event().clickCount() >= 3) |
674 swallowEvent = handleMousePressEventTripleClick(event); | 674 swallowEvent = handleMousePressEventTripleClick(event); |
675 else | 675 else |
676 swallowEvent = handleMousePressEventSingleClick(event); | 676 swallowEvent = handleMousePressEventSingleClick(event); |
677 | 677 |
678 m_mouseDownMayStartAutoscroll = m_mouseDownMayStartSelect | 678 m_mouseDownMayStartAutoscroll = m_mouseDownMayStartSelect |
679 || (m_mousePressNode && m_mousePressNode->renderBox() && m_mousePressNod
e->renderBox()->canBeProgramaticallyScrolled()); | 679 || (m_mousePressNode && m_mousePressNode->renderBox() && m_mousePressNod
e->renderBox()->canBeProgramaticallyScrolled()); |
680 | 680 |
681 return swallowEvent; | 681 return swallowEvent; |
682 } | 682 } |
683 | 683 |
684 bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e
vent) | 684 bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e
vent) |
685 { | 685 { |
686 if (!m_mousePressed) | 686 if (!m_mousePressed) |
687 return false; | 687 return false; |
688 | 688 |
689 if (handleDrag(event, ShouldCheckDragHysteresis)) | 689 if (handleDrag(event, ShouldCheckDragHysteresis)) |
690 return true; | 690 return true; |
691 | 691 |
692 Node* targetNode = event.targetNode(); | 692 if (event.event().button() != LeftButton || !event.targetNode()) |
693 if (event.event().button() != LeftButton || !targetNode) | |
694 return false; | 693 return false; |
695 | 694 |
696 RenderObject* renderer = targetNode->renderer(); | |
697 if (!renderer) { | |
698 Node* parent = EventPathWalker::parent(targetNode); | |
699 if (!parent) | |
700 return false; | |
701 | |
702 renderer = parent->renderer(); | |
703 if (!renderer || !renderer->isListBox()) | |
704 return false; | |
705 } | |
706 | |
707 m_mouseDownMayStartDrag = false; | 695 m_mouseDownMayStartDrag = false; |
708 | 696 |
709 if (m_mouseDownMayStartAutoscroll && !panScrollInProgress()) { | |
710 m_autoscrollController->startAutoscrollForSelection(renderer); | |
711 m_mouseDownMayStartAutoscroll = false; | |
712 } | |
713 | |
714 if (m_selectionInitiationState != ExtendedSelection) { | 697 if (m_selectionInitiationState != ExtendedSelection) { |
715 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active
| HitTestRequest::DisallowShadowContent); | 698 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active
| HitTestRequest::DisallowShadowContent); |
716 HitTestResult result(m_mouseDownPos); | 699 HitTestResult result(m_mouseDownPos); |
717 m_frame->document()->renderView()->hitTest(request, result); | 700 m_frame->document()->renderView()->hitTest(request, result); |
718 | 701 |
719 updateSelectionForMouseDrag(result); | 702 updateSelectionForMouseDrag(result); |
720 } | 703 } |
721 updateSelectionForMouseDrag(event.hitTestResult()); | 704 updateSelectionForMouseDrag(event.hitTestResult()); |
722 return true; | 705 return true; |
723 } | 706 } |
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1634 return true; | 1617 return true; |
1635 } | 1618 } |
1636 | 1619 |
1637 bool swallowEvent = false; | 1620 bool swallowEvent = false; |
1638 RefPtr<Frame> newSubframe = m_capturingMouseEventsNode.get() ? subframeForTa
rgetNode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev); | 1621 RefPtr<Frame> newSubframe = m_capturingMouseEventsNode.get() ? subframeForTa
rgetNode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev); |
1639 | 1622 |
1640 // We want mouseouts to happen first, from the inside out. First send a mov
e event to the last subframe so that it will fire mouseouts. | 1623 // We want mouseouts to happen first, from the inside out. First send a mov
e event to the last subframe so that it will fire mouseouts. |
1641 if (m_lastMouseMoveEventSubframe && m_lastMouseMoveEventSubframe->tree()->is
DescendantOf(m_frame) && m_lastMouseMoveEventSubframe != newSubframe) | 1624 if (m_lastMouseMoveEventSubframe && m_lastMouseMoveEventSubframe->tree()->is
DescendantOf(m_frame) && m_lastMouseMoveEventSubframe != newSubframe) |
1642 passMouseMoveEventToSubframe(mev, m_lastMouseMoveEventSubframe.get()); | 1625 passMouseMoveEventToSubframe(mev, m_lastMouseMoveEventSubframe.get()); |
1643 | 1626 |
| 1627 Node* targetNode = mev.targetNode(); |
| 1628 |
1644 if (newSubframe) { | 1629 if (newSubframe) { |
1645 // Update over/out state before passing the event to the subframe. | 1630 // Update over/out state before passing the event to the subframe. |
1646 updateMouseEventTargetNode(mev.targetNode(), mouseEvent, true); | 1631 updateMouseEventTargetNode(targetNode, mouseEvent, true); |
1647 | 1632 |
1648 // Event dispatch in updateMouseEventTargetNode may have caused the subf
rame of the target | 1633 // Event dispatch in updateMouseEventTargetNode may have caused the subf
rame of the target |
1649 // node to be detached from its FrameView, in which case the event shoul
d not be passed. | 1634 // node to be detached from its FrameView, in which case the event shoul
d not be passed. |
1650 if (newSubframe->view()) | 1635 if (newSubframe->view()) |
1651 swallowEvent |= passMouseMoveEventToSubframe(mev, newSubframe.get(),
hoveredNode); | 1636 swallowEvent |= passMouseMoveEventToSubframe(mev, newSubframe.get(),
hoveredNode); |
1652 } else { | 1637 } else { |
1653 if (scrollbar && !m_mousePressed) | 1638 if (scrollbar && !m_mousePressed) |
1654 scrollbar->mouseMoved(mouseEvent); // Handle hover effects on platfo
rms that support visual feedback on scrollbar hovering. | 1639 scrollbar->mouseMoved(mouseEvent); // Handle hover effects on platfo
rms that support visual feedback on scrollbar hovering. |
1655 if (FrameView* view = m_frame->view()) { | 1640 if (FrameView* view = m_frame->view()) { |
1656 OptionalCursor optionalCursor = selectCursor(mev, scrollbar); | 1641 OptionalCursor optionalCursor = selectCursor(mev, scrollbar); |
1657 if (optionalCursor.isCursorChange()) { | 1642 if (optionalCursor.isCursorChange()) { |
1658 m_currentMouseCursor = optionalCursor.cursor(); | 1643 m_currentMouseCursor = optionalCursor.cursor(); |
1659 view->setCursor(m_currentMouseCursor); | 1644 view->setCursor(m_currentMouseCursor); |
1660 } | 1645 } |
1661 } | 1646 } |
1662 } | 1647 } |
1663 | 1648 |
1664 m_lastMouseMoveEventSubframe = newSubframe; | 1649 m_lastMouseMoveEventSubframe = newSubframe; |
1665 | 1650 |
1666 if (swallowEvent) | 1651 if (swallowEvent) |
1667 return true; | 1652 return true; |
1668 | 1653 |
1669 swallowEvent = !dispatchMouseEvent(eventNames().mousemoveEvent, mev.targetNo
de(), false, 0, mouseEvent, true); | 1654 swallowEvent = !dispatchMouseEvent(eventNames().mousemoveEvent, targetNode,
false, 0, mouseEvent, true); |
| 1655 |
| 1656 RenderObject* renderer = targetNode ? targetNode->renderer() : 0; |
| 1657 |
| 1658 if (renderer && m_mouseDownMayStartAutoscroll && !panScrollInProgress()) { |
| 1659 m_autoscrollController->startAutoscrollForSelection(renderer); |
| 1660 m_mouseDownMayStartAutoscroll = false; |
| 1661 } |
| 1662 |
1670 if (!swallowEvent) | 1663 if (!swallowEvent) |
1671 swallowEvent = handleMouseDraggedEvent(mev); | 1664 swallowEvent = handleMouseDraggedEvent(mev); |
1672 | 1665 |
1673 return swallowEvent; | 1666 return swallowEvent; |
1674 } | 1667 } |
1675 | 1668 |
1676 void EventHandler::invalidateClick() | 1669 void EventHandler::invalidateClick() |
1677 { | 1670 { |
1678 m_clickCount = 0; | 1671 m_clickCount = 0; |
1679 m_clickNode = 0; | 1672 m_clickNode = 0; |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1991 void EventHandler::setCapturingMouseEventsNode(PassRefPtr<Node> n) | 1984 void EventHandler::setCapturingMouseEventsNode(PassRefPtr<Node> n) |
1992 { | 1985 { |
1993 m_capturingMouseEventsNode = n; | 1986 m_capturingMouseEventsNode = n; |
1994 m_eventHandlerWillResetCapturingMouseEventsNode = false; | 1987 m_eventHandlerWillResetCapturingMouseEventsNode = false; |
1995 } | 1988 } |
1996 | 1989 |
1997 MouseEventWithHitTestResults EventHandler::prepareMouseEvent(const HitTestReques
t& request, const PlatformMouseEvent& mev) | 1990 MouseEventWithHitTestResults EventHandler::prepareMouseEvent(const HitTestReques
t& request, const PlatformMouseEvent& mev) |
1998 { | 1991 { |
1999 ASSERT(m_frame); | 1992 ASSERT(m_frame); |
2000 ASSERT(m_frame->document()); | 1993 ASSERT(m_frame->document()); |
2001 | 1994 |
2002 return m_frame->document()->prepareMouseEvent(request, documentPointForWindo
wPoint(m_frame, mev.position()), mev); | 1995 return m_frame->document()->prepareMouseEvent(request, documentPointForWindo
wPoint(m_frame, mev.position()), mev); |
2003 } | 1996 } |
2004 | 1997 |
2005 #if ENABLE(SVG) | 1998 #if ENABLE(SVG) |
2006 static inline SVGElementInstance* instanceAssociatedWithShadowTreeElement(Node*
referenceNode) | 1999 static inline SVGElementInstance* instanceAssociatedWithShadowTreeElement(Node*
referenceNode) |
2007 { | 2000 { |
2008 if (!referenceNode || !referenceNode->isSVGElement()) | 2001 if (!referenceNode || !referenceNode->isSVGElement()) |
2009 return 0; | 2002 return 0; |
2010 | 2003 |
2011 ShadowRoot* shadowRoot = referenceNode->containingShadowRoot(); | 2004 ShadowRoot* shadowRoot = referenceNode->containingShadowRoot(); |
(...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4000 unsigned EventHandler::accessKeyModifiers() | 3993 unsigned EventHandler::accessKeyModifiers() |
4001 { | 3994 { |
4002 #if OS(DARWIN) | 3995 #if OS(DARWIN) |
4003 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3996 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
4004 #else | 3997 #else |
4005 return PlatformEvent::AltKey; | 3998 return PlatformEvent::AltKey; |
4006 #endif | 3999 #endif |
4007 } | 4000 } |
4008 | 4001 |
4009 } // namespace WebCore | 4002 } // namespace WebCore |
OLD | NEW |