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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include "core/events/ThreadLocalEventNames.h" | 50 #include "core/events/ThreadLocalEventNames.h" |
51 #include "core/events/TouchEvent.h" | 51 #include "core/events/TouchEvent.h" |
52 #include "core/events/WheelEvent.h" | 52 #include "core/events/WheelEvent.h" |
53 #include "core/fetch/ImageResource.h" | 53 #include "core/fetch/ImageResource.h" |
54 #include "core/html/HTMLDialogElement.h" | 54 #include "core/html/HTMLDialogElement.h" |
55 #include "core/html/HTMLFrameElementBase.h" | 55 #include "core/html/HTMLFrameElementBase.h" |
56 #include "core/html/HTMLFrameSetElement.h" | 56 #include "core/html/HTMLFrameSetElement.h" |
57 #include "core/html/HTMLInputElement.h" | 57 #include "core/html/HTMLInputElement.h" |
58 #include "core/loader/FrameLoader.h" | 58 #include "core/loader/FrameLoader.h" |
59 #include "core/loader/FrameLoaderClient.h" | 59 #include "core/loader/FrameLoaderClient.h" |
| 60 #include "core/page/AutoscrollController.h" |
60 #include "core/page/BackForwardClient.h" | 61 #include "core/page/BackForwardClient.h" |
61 #include "core/page/Chrome.h" | 62 #include "core/page/Chrome.h" |
62 #include "core/page/DragController.h" | 63 #include "core/page/DragController.h" |
63 #include "core/page/DragState.h" | 64 #include "core/page/DragState.h" |
64 #include "core/page/EditorClient.h" | 65 #include "core/page/EditorClient.h" |
65 #include "core/page/FocusController.h" | 66 #include "core/page/FocusController.h" |
66 #include "core/frame/Frame.h" | 67 #include "core/frame/Frame.h" |
67 #include "core/page/FrameTree.h" | 68 #include "core/page/FrameTree.h" |
68 #include "core/frame/FrameView.h" | 69 #include "core/frame/FrameView.h" |
69 #include "core/page/MouseEventWithHitTestResults.h" | 70 #include "core/page/MouseEventWithHitTestResults.h" |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 return false; | 696 return false; |
696 | 697 |
697 renderer = parent->renderer(); | 698 renderer = parent->renderer(); |
698 if (!renderer || !renderer->isListBox()) | 699 if (!renderer || !renderer->isListBox()) |
699 return false; | 700 return false; |
700 } | 701 } |
701 | 702 |
702 m_mouseDownMayStartDrag = false; | 703 m_mouseDownMayStartDrag = false; |
703 | 704 |
704 if (m_mouseDownMayStartAutoscroll && !panScrollInProgress()) { | 705 if (m_mouseDownMayStartAutoscroll && !panScrollInProgress()) { |
705 if (Page* page = m_frame->page()) { | 706 if (AutoscrollController* controller = autoscrollController()) { |
706 page->startAutoscrollForSelection(renderer); | 707 controller->startAutoscrollForSelection(renderer); |
707 m_mouseDownMayStartAutoscroll = false; | 708 m_mouseDownMayStartAutoscroll = false; |
708 } | 709 } |
709 } | 710 } |
710 | 711 |
711 if (m_selectionInitiationState != ExtendedSelection) { | 712 if (m_selectionInitiationState != ExtendedSelection) { |
712 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active
| HitTestRequest::DisallowShadowContent); | 713 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active
| HitTestRequest::DisallowShadowContent); |
713 HitTestResult result(m_mouseDownPos); | 714 HitTestResult result(m_mouseDownPos); |
714 m_frame->document()->renderView()->hitTest(request, result); | 715 m_frame->document()->renderView()->hitTest(request, result); |
715 | 716 |
716 updateSelectionForMouseDrag(result); | 717 updateSelectionForMouseDrag(result); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 | 794 |
794 if (m_frame->selection().granularity() != CharacterGranularity) | 795 if (m_frame->selection().granularity() != CharacterGranularity) |
795 newSelection.expandUsingGranularity(m_frame->selection().granularity()); | 796 newSelection.expandUsingGranularity(m_frame->selection().granularity()); |
796 | 797 |
797 m_frame->selection().setNonDirectionalSelectionIfNeeded(newSelection, m_fram
e->selection().granularity(), | 798 m_frame->selection().setNonDirectionalSelectionIfNeeded(newSelection, m_fram
e->selection().granularity(), |
798 FrameSelection::AdjustEndpointsAtBidiBoundary); | 799 FrameSelection::AdjustEndpointsAtBidiBoundary); |
799 } | 800 } |
800 | 801 |
801 bool EventHandler::handleMouseReleaseEvent(const MouseEventWithHitTestResults& e
vent) | 802 bool EventHandler::handleMouseReleaseEvent(const MouseEventWithHitTestResults& e
vent) |
802 { | 803 { |
803 Page* page = m_frame->page(); | 804 AutoscrollController* controller = autoscrollController(); |
804 if (page && page->autoscrollInProgress()) | 805 if (controller && controller->autoscrollInProgress()) |
805 stopAutoscrollTimer(); | 806 stopAutoscroll(); |
806 | 807 |
807 // Used to prevent mouseMoveEvent from initiating a drag before | 808 // Used to prevent mouseMoveEvent from initiating a drag before |
808 // the mouse is pressed again. | 809 // the mouse is pressed again. |
809 m_mousePressed = false; | 810 m_mousePressed = false; |
810 m_capturesDragging = false; | 811 m_capturesDragging = false; |
811 m_mouseDownMayStartDrag = false; | 812 m_mouseDownMayStartDrag = false; |
812 m_mouseDownMayStartSelect = false; | 813 m_mouseDownMayStartSelect = false; |
813 m_mouseDownMayStartAutoscroll = false; | 814 m_mouseDownMayStartAutoscroll = false; |
814 m_mouseDownWasInSubframe = false; | 815 m_mouseDownWasInSubframe = false; |
815 | 816 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 | 848 |
848 return handled; | 849 return handled; |
849 } | 850 } |
850 | 851 |
851 #if OS(WIN) | 852 #if OS(WIN) |
852 | 853 |
853 void EventHandler::startPanScrolling(RenderObject* renderer) | 854 void EventHandler::startPanScrolling(RenderObject* renderer) |
854 { | 855 { |
855 if (!renderer->isBox()) | 856 if (!renderer->isBox()) |
856 return; | 857 return; |
857 Page* page = m_frame->page(); | 858 AutoscrollController* controller = autoscrollController(); |
858 if (!page) | 859 if (!controller) |
859 return; | 860 return; |
860 page->startPanScrolling(toRenderBox(renderer), lastKnownMousePosition()); | 861 controller->startPanScrolling(toRenderBox(renderer), lastKnownMousePosition(
)); |
861 invalidateClick(); | 862 invalidateClick(); |
862 } | 863 } |
863 | 864 |
864 #endif // OS(WIN) | 865 #endif // OS(WIN) |
865 | 866 |
| 867 AutoscrollController* EventHandler::autoscrollController() const |
| 868 { |
| 869 if (Page* page = m_frame->page()) |
| 870 return &page->autoscrollController(); |
| 871 return 0; |
| 872 } |
| 873 |
866 bool EventHandler::panScrollInProgress() const | 874 bool EventHandler::panScrollInProgress() const |
867 { | 875 { |
868 Page* page = m_frame->page(); | 876 return autoscrollController() && autoscrollController()->panScrollInProgress
(); |
869 return page && page->panScrollInProgress(); | |
870 } | 877 } |
871 | 878 |
872 HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe
stRequest::HitTestRequestType hitType, const LayoutSize& padding) | 879 HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe
stRequest::HitTestRequestType hitType, const LayoutSize& padding) |
873 { | 880 { |
874 // We always send hitTestResultAtPoint to the main frame if we have one, | 881 // We always send hitTestResultAtPoint to the main frame if we have one, |
875 // otherwise we might hit areas that are obscured by higher frames. | 882 // otherwise we might hit areas that are obscured by higher frames. |
876 if (Page* page = m_frame->page()) { | 883 if (Page* page = m_frame->page()) { |
877 Frame* mainFrame = page->mainFrame(); | 884 Frame* mainFrame = page->mainFrame(); |
878 if (m_frame != mainFrame) { | 885 if (m_frame != mainFrame) { |
879 FrameView* frameView = m_frame->view(); | 886 FrameView* frameView = m_frame->view(); |
(...skipping 21 matching lines...) Expand all Loading... |
901 m_frame->contentRenderer()->hitTest(request, result); | 908 m_frame->contentRenderer()->hitTest(request, result); |
902 if (!request.readOnly()) | 909 if (!request.readOnly()) |
903 m_frame->document()->updateHoverActiveState(request, result.innerElement
()); | 910 m_frame->document()->updateHoverActiveState(request, result.innerElement
()); |
904 | 911 |
905 if (request.disallowsShadowContent()) | 912 if (request.disallowsShadowContent()) |
906 result.setToNodesInDocumentTreeScope(); | 913 result.setToNodesInDocumentTreeScope(); |
907 | 914 |
908 return result; | 915 return result; |
909 } | 916 } |
910 | 917 |
911 void EventHandler::stopAutoscrollTimer() | 918 void EventHandler::stopAutoscroll() |
912 { | 919 { |
913 Page* page = m_frame->page(); | 920 if (AutoscrollController* controller = autoscrollController()) |
914 if (!page) | 921 controller->stopAutoscroll(); |
915 return; | |
916 page->stopAutoscrollTimer(); | |
917 } | 922 } |
918 | 923 |
919 Node* EventHandler::mousePressNode() const | 924 Node* EventHandler::mousePressNode() const |
920 { | 925 { |
921 return m_mousePressNode.get(); | 926 return m_mousePressNode.get(); |
922 } | 927 } |
923 | 928 |
924 bool EventHandler::scrollOverflow(ScrollDirection direction, ScrollGranularity g
ranularity, Node* startingNode) | 929 bool EventHandler::scrollOverflow(ScrollDirection direction, ScrollGranularity g
ranularity, Node* startingNode) |
925 { | 930 { |
926 Node* node = startingNode; | 931 Node* node = startingNode; |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 m_capturesDragging = subframe->eventHandler().capturesDragging(); | 1352 m_capturesDragging = subframe->eventHandler().capturesDragging(); |
1348 if (m_mousePressed && m_capturesDragging) { | 1353 if (m_mousePressed && m_capturesDragging) { |
1349 m_capturingMouseEventsNode = mev.targetNode(); | 1354 m_capturingMouseEventsNode = mev.targetNode(); |
1350 m_eventHandlerWillResetCapturingMouseEventsNode = true; | 1355 m_eventHandlerWillResetCapturingMouseEventsNode = true; |
1351 } | 1356 } |
1352 invalidateClick(); | 1357 invalidateClick(); |
1353 return true; | 1358 return true; |
1354 } | 1359 } |
1355 | 1360 |
1356 #if OS(WIN) | 1361 #if OS(WIN) |
1357 // We store whether pan scrolling is in progress before calling stopAutoscro
llTimer() | 1362 // We store whether pan scrolling is in progress before calling stopAutoscro
ll() |
1358 // because it will set m_autoscrollType to NoAutoscroll on return. | 1363 // because it will set m_autoscrollType to NoAutoscroll on return. |
1359 bool isPanScrollInProgress = panScrollInProgress(); | 1364 bool isPanScrollInProgress = panScrollInProgress(); |
1360 stopAutoscrollTimer(); | 1365 stopAutoscroll(); |
1361 if (isPanScrollInProgress) { | 1366 if (isPanScrollInProgress) { |
1362 // We invalidate the click when exiting pan scrolling so that we don't i
nadvertently navigate | 1367 // We invalidate the click when exiting pan scrolling so that we don't i
nadvertently navigate |
1363 // away from the current page (e.g. the click was on a hyperlink). See <
rdar://problem/6095023>. | 1368 // away from the current page (e.g. the click was on a hyperlink). See <
rdar://problem/6095023>. |
1364 invalidateClick(); | 1369 invalidateClick(); |
1365 return true; | 1370 return true; |
1366 } | 1371 } |
1367 #endif | 1372 #endif |
1368 | 1373 |
1369 m_clickCount = mouseEvent.clickCount(); | 1374 m_clickCount = mouseEvent.clickCount(); |
1370 m_clickNode = mev.targetNode(); | 1375 m_clickNode = mev.targetNode(); |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1645 | 1650 |
1646 OwnPtr<UserGestureIndicator> gestureIndicator; | 1651 OwnPtr<UserGestureIndicator> gestureIndicator; |
1647 | 1652 |
1648 if (m_frame->tree().top()->eventHandler().m_lastMouseDownUserGestureToken) | 1653 if (m_frame->tree().top()->eventHandler().m_lastMouseDownUserGestureToken) |
1649 gestureIndicator = adoptPtr(new UserGestureIndicator(m_frame->tree().top
()->eventHandler().m_lastMouseDownUserGestureToken.release())); | 1654 gestureIndicator = adoptPtr(new UserGestureIndicator(m_frame->tree().top
()->eventHandler().m_lastMouseDownUserGestureToken.release())); |
1650 else | 1655 else |
1651 gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessin
gUserGesture)); | 1656 gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessin
gUserGesture)); |
1652 | 1657 |
1653 #if OS(WIN) | 1658 #if OS(WIN) |
1654 if (Page* page = m_frame->page()) | 1659 if (Page* page = m_frame->page()) |
1655 page->handleMouseReleaseForPanScrolling(m_frame, mouseEvent); | 1660 page->autoscrollController().handleMouseReleaseForPanScrolling(m_frame,
mouseEvent); |
1656 #endif | 1661 #endif |
1657 | 1662 |
1658 m_mousePressed = false; | 1663 m_mousePressed = false; |
1659 setLastKnownMousePosition(mouseEvent); | 1664 setLastKnownMousePosition(mouseEvent); |
1660 | 1665 |
1661 if (m_svgPan) { | 1666 if (m_svgPan) { |
1662 m_svgPan = false; | 1667 m_svgPan = false; |
1663 toSVGDocument(m_frame->document())->updatePan(m_frame->view()->windowToC
ontents(m_lastKnownMousePosition)); | 1668 toSVGDocument(m_frame->document())->updatePan(m_frame->view()->windowToC
ontents(m_lastKnownMousePosition)); |
1664 return true; | 1669 return true; |
1665 } | 1670 } |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1816 return false; | 1821 return false; |
1817 | 1822 |
1818 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::DisallowSh
adowContent); | 1823 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::DisallowSh
adowContent); |
1819 MouseEventWithHitTestResults mev = prepareMouseEvent(request, event); | 1824 MouseEventWithHitTestResults mev = prepareMouseEvent(request, event); |
1820 | 1825 |
1821 // Drag events should never go to text nodes (following IE, and proper mouse
over/out dispatch) | 1826 // Drag events should never go to text nodes (following IE, and proper mouse
over/out dispatch) |
1822 RefPtr<Node> newTarget = mev.targetNode(); | 1827 RefPtr<Node> newTarget = mev.targetNode(); |
1823 if (newTarget && newTarget->isTextNode()) | 1828 if (newTarget && newTarget->isTextNode()) |
1824 newTarget = EventPath::parent(newTarget.get()); | 1829 newTarget = EventPath::parent(newTarget.get()); |
1825 | 1830 |
1826 if (Page* page = m_frame->page()) | 1831 if (AutoscrollController* controller = autoscrollController()) |
1827 page->updateDragAndDrop(newTarget.get(), event.position(), event.timesta
mp()); | 1832 controller->updateDragAndDrop(newTarget.get(), event.position(), event.t
imestamp()); |
1828 | 1833 |
1829 if (m_dragTarget != newTarget) { | 1834 if (m_dragTarget != newTarget) { |
1830 // FIXME: this ordering was explicitly chosen to match WinIE. However, | 1835 // FIXME: this ordering was explicitly chosen to match WinIE. However, |
1831 // it is sometimes incorrect when dragging within subframes, as seen wit
h | 1836 // it is sometimes incorrect when dragging within subframes, as seen wit
h |
1832 // LayoutTests/fast/events/drag-in-frames.html. | 1837 // LayoutTests/fast/events/drag-in-frames.html. |
1833 // | 1838 // |
1834 // Moreover, this ordering conforms to section 7.9.4 of the HTML 5 spec.
<http://dev.w3.org/html5/spec/Overview.html#drag-and-drop-processing-model>. | 1839 // Moreover, this ordering conforms to section 7.9.4 of the HTML 5 spec.
<http://dev.w3.org/html5/spec/Overview.html#drag-and-drop-processing-model>. |
1835 Frame* targetFrame; | 1840 Frame* targetFrame; |
1836 if (targetIsFrame(newTarget.get(), targetFrame)) { | 1841 if (targetIsFrame(newTarget.get(), targetFrame)) { |
1837 if (targetFrame) | 1842 if (targetFrame) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1902 if (targetFrame) | 1907 if (targetFrame) |
1903 preventedDefault = targetFrame->eventHandler().performDragAndDrop(ev
ent, clipboard); | 1908 preventedDefault = targetFrame->eventHandler().performDragAndDrop(ev
ent, clipboard); |
1904 } else if (m_dragTarget.get()) | 1909 } else if (m_dragTarget.get()) |
1905 preventedDefault = dispatchDragEvent(EventTypeNames::drop, m_dragTarget.
get(), event, clipboard); | 1910 preventedDefault = dispatchDragEvent(EventTypeNames::drop, m_dragTarget.
get(), event, clipboard); |
1906 clearDragState(); | 1911 clearDragState(); |
1907 return preventedDefault; | 1912 return preventedDefault; |
1908 } | 1913 } |
1909 | 1914 |
1910 void EventHandler::clearDragState() | 1915 void EventHandler::clearDragState() |
1911 { | 1916 { |
1912 stopAutoscrollTimer(); | 1917 stopAutoscroll(); |
1913 m_dragTarget = 0; | 1918 m_dragTarget = 0; |
1914 m_capturingMouseEventsNode = 0; | 1919 m_capturingMouseEventsNode = 0; |
1915 m_shouldOnlyFireDragOverEvent = false; | 1920 m_shouldOnlyFireDragOverEvent = false; |
1916 } | 1921 } |
1917 | 1922 |
1918 void EventHandler::setCapturingMouseEventsNode(PassRefPtr<Node> n) | 1923 void EventHandler::setCapturingMouseEventsNode(PassRefPtr<Node> n) |
1919 { | 1924 { |
1920 m_capturingMouseEventsNode = n; | 1925 m_capturingMouseEventsNode = n; |
1921 m_eventHandlerWillResetCapturingMouseEventsNode = false; | 1926 m_eventHandlerWillResetCapturingMouseEventsNode = false; |
1922 } | 1927 } |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3011 return false; | 3016 return false; |
3012 } | 3017 } |
3013 | 3018 |
3014 if (initialKeyEvent.windowsVirtualKeyCode() == VK_CAPITAL) | 3019 if (initialKeyEvent.windowsVirtualKeyCode() == VK_CAPITAL) |
3015 capsLockStateMayHaveChanged(); | 3020 capsLockStateMayHaveChanged(); |
3016 | 3021 |
3017 #if OS(WIN) | 3022 #if OS(WIN) |
3018 if (panScrollInProgress()) { | 3023 if (panScrollInProgress()) { |
3019 // If a key is pressed while the panScroll is in progress then we want t
o stop | 3024 // If a key is pressed while the panScroll is in progress then we want t
o stop |
3020 if (initialKeyEvent.type() == PlatformEvent::KeyDown || initialKeyEvent.
type() == PlatformEvent::RawKeyDown) | 3025 if (initialKeyEvent.type() == PlatformEvent::KeyDown || initialKeyEvent.
type() == PlatformEvent::RawKeyDown) |
3021 stopAutoscrollTimer(); | 3026 stopAutoscroll(); |
3022 | 3027 |
3023 // If we were in panscroll mode, we swallow the key event | 3028 // If we were in panscroll mode, we swallow the key event |
3024 return true; | 3029 return true; |
3025 } | 3030 } |
3026 #endif | 3031 #endif |
3027 | 3032 |
3028 // Check for cases where we are too early for events -- possible unmatched k
ey up | 3033 // Check for cases where we are too early for events -- possible unmatched k
ey up |
3029 // from pressing return in the location bar. | 3034 // from pressing return in the location bar. |
3030 RefPtr<Node> node = eventTargetNodeForDocument(m_frame->document()); | 3035 RefPtr<Node> node = eventTargetNodeForDocument(m_frame->document()); |
3031 if (!node) | 3036 if (!node) |
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3870 unsigned EventHandler::accessKeyModifiers() | 3875 unsigned EventHandler::accessKeyModifiers() |
3871 { | 3876 { |
3872 #if OS(MACOSX) | 3877 #if OS(MACOSX) |
3873 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3878 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
3874 #else | 3879 #else |
3875 return PlatformEvent::AltKey; | 3880 return PlatformEvent::AltKey; |
3876 #endif | 3881 #endif |
3877 } | 3882 } |
3878 | 3883 |
3879 } // namespace WebCore | 3884 } // namespace WebCore |
OLD | NEW |