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 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 m_frame->selection().selectFrameElementInParentIfFullySelected(); | 857 m_frame->selection().selectFrameElementInParentIfFullySelected(); |
858 | 858 |
859 if (event.event().button() == MiddleButton && !event.isOverLink()) { | 859 if (event.event().button() == MiddleButton && !event.isOverLink()) { |
860 // Ignore handled, since we want to paste to where the caret was placed
anyway. | 860 // Ignore handled, since we want to paste to where the caret was placed
anyway. |
861 handled = handlePasteGlobalSelection(event.event()) || handled; | 861 handled = handlePasteGlobalSelection(event.event()) || handled; |
862 } | 862 } |
863 | 863 |
864 return handled; | 864 return handled; |
865 } | 865 } |
866 | 866 |
867 #if OS(WINDOWS) | 867 #if OS(WIN) |
868 | 868 |
869 void EventHandler::startPanScrolling(RenderObject* renderer) | 869 void EventHandler::startPanScrolling(RenderObject* renderer) |
870 { | 870 { |
871 if (!renderer->isBox()) | 871 if (!renderer->isBox()) |
872 return; | 872 return; |
873 Page* page = m_frame->page(); | 873 Page* page = m_frame->page(); |
874 if (!page) | 874 if (!page) |
875 return; | 875 return; |
876 page->startPanScrolling(toRenderBox(renderer), lastKnownMousePosition()); | 876 page->startPanScrolling(toRenderBox(renderer), lastKnownMousePosition()); |
877 invalidateClick(); | 877 invalidateClick(); |
878 } | 878 } |
879 | 879 |
880 #endif // OS(WINDOWS) | 880 #endif // OS(WIN) |
881 | 881 |
882 bool EventHandler::panScrollInProgress() const | 882 bool EventHandler::panScrollInProgress() const |
883 { | 883 { |
884 Page* page = m_frame->page(); | 884 Page* page = m_frame->page(); |
885 return page && page->panScrollInProgress(); | 885 return page && page->panScrollInProgress(); |
886 } | 886 } |
887 | 887 |
888 HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe
stRequest::HitTestRequestType hitType, const LayoutSize& padding) | 888 HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe
stRequest::HitTestRequestType hitType, const LayoutSize& padding) |
889 { | 889 { |
890 // We always send hitTestResultAtPoint to the main frame if we have one, | 890 // We always send hitTestResultAtPoint to the main frame if we have one, |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 } | 1100 } |
1101 | 1101 |
1102 OptionalCursor EventHandler::selectCursor(const MouseEventWithHitTestResults& ev
ent, Scrollbar* scrollbar) | 1102 OptionalCursor EventHandler::selectCursor(const MouseEventWithHitTestResults& ev
ent, Scrollbar* scrollbar) |
1103 { | 1103 { |
1104 if (m_resizeLayer && m_resizeLayer->inResizeMode()) | 1104 if (m_resizeLayer && m_resizeLayer->inResizeMode()) |
1105 return NoCursorChange; | 1105 return NoCursorChange; |
1106 | 1106 |
1107 Page* page = m_frame->page(); | 1107 Page* page = m_frame->page(); |
1108 if (!page) | 1108 if (!page) |
1109 return NoCursorChange; | 1109 return NoCursorChange; |
1110 #if OS(WINDOWS) | 1110 #if OS(WIN) |
1111 if (panScrollInProgress()) | 1111 if (panScrollInProgress()) |
1112 return NoCursorChange; | 1112 return NoCursorChange; |
1113 #endif | 1113 #endif |
1114 | 1114 |
1115 Node* node = event.targetNode(); | 1115 Node* node = event.targetNode(); |
1116 RenderObject* renderer = node ? node->renderer() : 0; | 1116 RenderObject* renderer = node ? node->renderer() : 0; |
1117 RenderStyle* style = renderer ? renderer->style() : 0; | 1117 RenderStyle* style = renderer ? renderer->style() : 0; |
1118 bool horizontalText = !style || style->isHorizontalWritingMode(); | 1118 bool horizontalText = !style || style->isHorizontalWritingMode(); |
1119 const Cursor& iBeam = horizontalText ? iBeamCursor() : verticalTextCursor(); | 1119 const Cursor& iBeam = horizontalText ? iBeamCursor() : verticalTextCursor(); |
1120 | 1120 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1315 // the m_mousePressed flag, which may happen if an AppKit widget entered
a modal event loop. | 1315 // the m_mousePressed flag, which may happen if an AppKit widget entered
a modal event loop. |
1316 m_capturesDragging = subframe->eventHandler()->capturesDragging(); | 1316 m_capturesDragging = subframe->eventHandler()->capturesDragging(); |
1317 if (m_mousePressed && m_capturesDragging) { | 1317 if (m_mousePressed && m_capturesDragging) { |
1318 m_capturingMouseEventsNode = mev.targetNode(); | 1318 m_capturingMouseEventsNode = mev.targetNode(); |
1319 m_eventHandlerWillResetCapturingMouseEventsNode = true; | 1319 m_eventHandlerWillResetCapturingMouseEventsNode = true; |
1320 } | 1320 } |
1321 invalidateClick(); | 1321 invalidateClick(); |
1322 return true; | 1322 return true; |
1323 } | 1323 } |
1324 | 1324 |
1325 #if OS(WINDOWS) | 1325 #if OS(WIN) |
1326 // We store whether pan scrolling is in progress before calling stopAutoscro
llTimer() | 1326 // We store whether pan scrolling is in progress before calling stopAutoscro
llTimer() |
1327 // because it will set m_autoscrollType to NoAutoscroll on return. | 1327 // because it will set m_autoscrollType to NoAutoscroll on return. |
1328 bool isPanScrollInProgress = panScrollInProgress(); | 1328 bool isPanScrollInProgress = panScrollInProgress(); |
1329 stopAutoscrollTimer(); | 1329 stopAutoscrollTimer(); |
1330 if (isPanScrollInProgress) { | 1330 if (isPanScrollInProgress) { |
1331 // We invalidate the click when exiting pan scrolling so that we don't i
nadvertently navigate | 1331 // We invalidate the click when exiting pan scrolling so that we don't i
nadvertently navigate |
1332 // away from the current page (e.g. the click was on a hyperlink). See <
rdar://problem/6095023>. | 1332 // away from the current page (e.g. the click was on a hyperlink). See <
rdar://problem/6095023>. |
1333 invalidateClick(); | 1333 invalidateClick(); |
1334 return true; | 1334 return true; |
1335 } | 1335 } |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1610 if (defaultPrevented) | 1610 if (defaultPrevented) |
1611 return true; | 1611 return true; |
1612 | 1612 |
1613 OwnPtr<UserGestureIndicator> gestureIndicator; | 1613 OwnPtr<UserGestureIndicator> gestureIndicator; |
1614 | 1614 |
1615 if (m_lastMouseDownUserGestureToken) | 1615 if (m_lastMouseDownUserGestureToken) |
1616 gestureIndicator = adoptPtr(new UserGestureIndicator(m_lastMouseDownUser
GestureToken.release())); | 1616 gestureIndicator = adoptPtr(new UserGestureIndicator(m_lastMouseDownUser
GestureToken.release())); |
1617 else | 1617 else |
1618 gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessin
gUserGesture)); | 1618 gestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessin
gUserGesture)); |
1619 | 1619 |
1620 #if OS(WINDOWS) | 1620 #if OS(WIN) |
1621 if (Page* page = m_frame->page()) | 1621 if (Page* page = m_frame->page()) |
1622 page->handleMouseReleaseForPanScrolling(m_frame, mouseEvent); | 1622 page->handleMouseReleaseForPanScrolling(m_frame, mouseEvent); |
1623 #endif | 1623 #endif |
1624 | 1624 |
1625 m_mousePressed = false; | 1625 m_mousePressed = false; |
1626 setLastKnownMousePosition(mouseEvent); | 1626 setLastKnownMousePosition(mouseEvent); |
1627 | 1627 |
1628 if (m_svgPan) { | 1628 if (m_svgPan) { |
1629 m_svgPan = false; | 1629 m_svgPan = false; |
1630 toSVGDocument(m_frame->document())->updatePan(m_frame->view()->windowToC
ontents(m_lastKnownMousePosition)); | 1630 toSVGDocument(m_frame->document())->updatePan(m_frame->view()->windowToC
ontents(m_lastKnownMousePosition)); |
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2725 | 2725 |
2726 Document* doc = m_frame->document(); | 2726 Document* doc = m_frame->document(); |
2727 if (!doc) | 2727 if (!doc) |
2728 return false; | 2728 return false; |
2729 | 2729 |
2730 // Clear mouse press state to avoid initiating a drag while context menu is
up. | 2730 // Clear mouse press state to avoid initiating a drag while context menu is
up. |
2731 m_mousePressed = false; | 2731 m_mousePressed = false; |
2732 | 2732 |
2733 static const int kContextMenuMargin = 1; | 2733 static const int kContextMenuMargin = 1; |
2734 | 2734 |
2735 #if OS(WINDOWS) | 2735 #if OS(WIN) |
2736 int rightAligned = ::GetSystemMetrics(SM_MENUDROPALIGNMENT); | 2736 int rightAligned = ::GetSystemMetrics(SM_MENUDROPALIGNMENT); |
2737 #else | 2737 #else |
2738 int rightAligned = 0; | 2738 int rightAligned = 0; |
2739 #endif | 2739 #endif |
2740 IntPoint location; | 2740 IntPoint location; |
2741 | 2741 |
2742 Element* focusedElement = doc->focusedElement(); | 2742 Element* focusedElement = doc->focusedElement(); |
2743 FrameSelection& selection = m_frame->selection(); | 2743 FrameSelection& selection = m_frame->selection(); |
2744 Position start = selection.selection().start(); | 2744 Position start = selection.selection().start(); |
2745 | 2745 |
(...skipping 27 matching lines...) Expand all Loading... |
2773 targetNode = doc; | 2773 targetNode = doc; |
2774 | 2774 |
2775 // Use the focused node as the target for hover and active. | 2775 // Use the focused node as the target for hover and active. |
2776 HitTestResult result(position); | 2776 HitTestResult result(position); |
2777 result.setInnerNode(targetNode); | 2777 result.setInnerNode(targetNode); |
2778 doc->updateHoverActiveState(HitTestRequest::Active | HitTestRequest::Disallo
wShadowContent, result.innerElement()); | 2778 doc->updateHoverActiveState(HitTestRequest::Active | HitTestRequest::Disallo
wShadowContent, result.innerElement()); |
2779 | 2779 |
2780 // The contextmenu event is a mouse event even when invoked using the keyboa
rd. | 2780 // The contextmenu event is a mouse event even when invoked using the keyboa
rd. |
2781 // This is required for web compatibility. | 2781 // This is required for web compatibility. |
2782 | 2782 |
2783 #if OS(WINDOWS) | 2783 #if OS(WIN) |
2784 PlatformEvent::Type eventType = PlatformEvent::MouseReleased; | 2784 PlatformEvent::Type eventType = PlatformEvent::MouseReleased; |
2785 #else | 2785 #else |
2786 PlatformEvent::Type eventType = PlatformEvent::MousePressed; | 2786 PlatformEvent::Type eventType = PlatformEvent::MousePressed; |
2787 #endif | 2787 #endif |
2788 | 2788 |
2789 PlatformMouseEvent mouseEvent(position, globalPosition, RightButton, eventTy
pe, 1, false, false, false, false, WTF::currentTime()); | 2789 PlatformMouseEvent mouseEvent(position, globalPosition, RightButton, eventTy
pe, 1, false, false, false, false, WTF::currentTime()); |
2790 | 2790 |
2791 return !dispatchMouseEvent(eventNames().contextmenuEvent, targetNode, true,
0, mouseEvent, false); | 2791 return !dispatchMouseEvent(eventNames().contextmenuEvent, targetNode, true,
0, mouseEvent, false); |
2792 } | 2792 } |
2793 | 2793 |
2794 bool EventHandler::sendContextMenuEventForGesture(const PlatformGestureEvent& ev
ent) | 2794 bool EventHandler::sendContextMenuEventForGesture(const PlatformGestureEvent& ev
ent) |
2795 { | 2795 { |
2796 #if OS(WINDOWS) | 2796 #if OS(WIN) |
2797 PlatformEvent::Type eventType = PlatformEvent::MouseReleased; | 2797 PlatformEvent::Type eventType = PlatformEvent::MouseReleased; |
2798 #else | 2798 #else |
2799 PlatformEvent::Type eventType = PlatformEvent::MousePressed; | 2799 PlatformEvent::Type eventType = PlatformEvent::MousePressed; |
2800 #endif | 2800 #endif |
2801 | 2801 |
2802 IntPoint adjustedPoint = event.position(); | 2802 IntPoint adjustedPoint = event.position(); |
2803 adjustGesturePosition(event, adjustedPoint); | 2803 adjustGesturePosition(event, adjustedPoint); |
2804 PlatformMouseEvent mouseEvent(adjustedPoint, event.globalPosition(), RightBu
tton, eventType, 1, false, false, false, false, WTF::currentTime()); | 2804 PlatformMouseEvent mouseEvent(adjustedPoint, event.globalPosition(), RightBu
tton, eventType, 1, false, false, false, false, WTF::currentTime()); |
2805 // To simulate right-click behavior, we send a right mouse down and then | 2805 // To simulate right-click behavior, we send a right mouse down and then |
2806 // context menu event. | 2806 // context menu event. |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2962 RefPtr<FrameView> protector(m_frame->view()); | 2962 RefPtr<FrameView> protector(m_frame->view()); |
2963 | 2963 |
2964 if (FullscreenElementStack* fullscreen = FullscreenElementStack::fromIfExist
s(m_frame->document())) { | 2964 if (FullscreenElementStack* fullscreen = FullscreenElementStack::fromIfExist
s(m_frame->document())) { |
2965 if (fullscreen->webkitIsFullScreen() && !isKeyEventAllowedInFullScreen(f
ullscreen, initialKeyEvent)) | 2965 if (fullscreen->webkitIsFullScreen() && !isKeyEventAllowedInFullScreen(f
ullscreen, initialKeyEvent)) |
2966 return false; | 2966 return false; |
2967 } | 2967 } |
2968 | 2968 |
2969 if (initialKeyEvent.windowsVirtualKeyCode() == VK_CAPITAL) | 2969 if (initialKeyEvent.windowsVirtualKeyCode() == VK_CAPITAL) |
2970 capsLockStateMayHaveChanged(); | 2970 capsLockStateMayHaveChanged(); |
2971 | 2971 |
2972 #if OS(WINDOWS) | 2972 #if OS(WIN) |
2973 if (panScrollInProgress()) { | 2973 if (panScrollInProgress()) { |
2974 // If a key is pressed while the panScroll is in progress then we want t
o stop | 2974 // If a key is pressed while the panScroll is in progress then we want t
o stop |
2975 if (initialKeyEvent.type() == PlatformEvent::KeyDown || initialKeyEvent.
type() == PlatformEvent::RawKeyDown) | 2975 if (initialKeyEvent.type() == PlatformEvent::KeyDown || initialKeyEvent.
type() == PlatformEvent::RawKeyDown) |
2976 stopAutoscrollTimer(); | 2976 stopAutoscrollTimer(); |
2977 | 2977 |
2978 // If we were in panscroll mode, we swallow the key event | 2978 // If we were in panscroll mode, we swallow the key event |
2979 return true; | 2979 return true; |
2980 } | 2980 } |
2981 #endif | 2981 #endif |
2982 | 2982 |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3847 unsigned EventHandler::accessKeyModifiers() | 3847 unsigned EventHandler::accessKeyModifiers() |
3848 { | 3848 { |
3849 #if OS(MACOSX) | 3849 #if OS(MACOSX) |
3850 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3850 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
3851 #else | 3851 #else |
3852 return PlatformEvent::AltKey; | 3852 return PlatformEvent::AltKey; |
3853 #endif | 3853 #endif |
3854 } | 3854 } |
3855 | 3855 |
3856 } // namespace WebCore | 3856 } // namespace WebCore |
OLD | NEW |