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 18 matching lines...) Expand all Loading... |
29 #include "core/page/EventHandler.h" | 29 #include "core/page/EventHandler.h" |
30 | 30 |
31 #include "HTMLNames.h" | 31 #include "HTMLNames.h" |
32 #include "RuntimeEnabledFeatures.h" | 32 #include "RuntimeEnabledFeatures.h" |
33 #include "SVGNames.h" | 33 #include "SVGNames.h" |
34 #include "bindings/v8/ExceptionStatePlaceholder.h" | 34 #include "bindings/v8/ExceptionStatePlaceholder.h" |
35 #include "core/dom/Clipboard.h" | 35 #include "core/dom/Clipboard.h" |
36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
37 #include "core/dom/DocumentMarkerController.h" | 37 #include "core/dom/DocumentMarkerController.h" |
38 #include "core/dom/FullscreenElementStack.h" | 38 #include "core/dom/FullscreenElementStack.h" |
| 39 #include "core/dom/NodeRenderingTraversal.h" |
39 #include "core/dom/TouchList.h" | 40 #include "core/dom/TouchList.h" |
40 #include "core/dom/shadow/ShadowRoot.h" | 41 #include "core/dom/shadow/ShadowRoot.h" |
41 #include "core/editing/Editor.h" | 42 #include "core/editing/Editor.h" |
42 #include "core/editing/FrameSelection.h" | 43 #include "core/editing/FrameSelection.h" |
43 #include "core/editing/TextIterator.h" | 44 #include "core/editing/TextIterator.h" |
44 #include "core/editing/htmlediting.h" | 45 #include "core/editing/htmlediting.h" |
45 #include "core/events/DOMWindowEventQueue.h" | 46 #include "core/events/DOMWindowEventQueue.h" |
46 #include "core/events/EventPath.h" | 47 #include "core/events/EventPath.h" |
47 #include "core/events/KeyboardEvent.h" | 48 #include "core/events/KeyboardEvent.h" |
48 #include "core/events/MouseEvent.h" | 49 #include "core/events/MouseEvent.h" |
49 #include "core/events/TextEvent.h" | 50 #include "core/events/TextEvent.h" |
50 #include "core/events/ThreadLocalEventNames.h" | 51 #include "core/events/ThreadLocalEventNames.h" |
51 #include "core/events/TouchEvent.h" | 52 #include "core/events/TouchEvent.h" |
52 #include "core/events/WheelEvent.h" | 53 #include "core/events/WheelEvent.h" |
53 #include "core/fetch/ImageResource.h" | 54 #include "core/fetch/ImageResource.h" |
54 #include "core/html/HTMLDialogElement.h" | 55 #include "core/html/HTMLDialogElement.h" |
55 #include "core/html/HTMLFrameElementBase.h" | 56 #include "core/html/HTMLFrameElementBase.h" |
56 #include "core/html/HTMLFrameSetElement.h" | 57 #include "core/html/HTMLFrameSetElement.h" |
57 #include "core/html/HTMLInputElement.h" | 58 #include "core/html/HTMLInputElement.h" |
58 #include "core/loader/FrameLoader.h" | 59 #include "core/loader/FrameLoader.h" |
59 #include "core/loader/FrameLoaderClient.h" | 60 #include "core/loader/FrameLoaderClient.h" |
60 #include "core/page/AutoscrollController.h" | 61 #include "core/page/AutoscrollController.h" |
61 #include "core/page/BackForwardClient.h" | 62 #include "core/page/BackForwardClient.h" |
62 #include "core/page/Chrome.h" | 63 #include "core/page/Chrome.h" |
| 64 #include "core/page/ChromeClient.h" |
63 #include "core/page/DragController.h" | 65 #include "core/page/DragController.h" |
64 #include "core/page/DragState.h" | 66 #include "core/page/DragState.h" |
65 #include "core/page/EditorClient.h" | 67 #include "core/page/EditorClient.h" |
66 #include "core/page/FocusController.h" | 68 #include "core/page/FocusController.h" |
67 #include "core/frame/Frame.h" | 69 #include "core/frame/Frame.h" |
68 #include "core/page/FrameTree.h" | 70 #include "core/page/FrameTree.h" |
69 #include "core/frame/FrameView.h" | 71 #include "core/frame/FrameView.h" |
70 #include "core/inspector/InspectorController.h" | 72 #include "core/inspector/InspectorController.h" |
71 #include "core/page/MouseEventWithHitTestResults.h" | 73 #include "core/page/MouseEventWithHitTestResults.h" |
72 #include "core/page/Page.h" | 74 #include "core/page/Page.h" |
73 #include "core/page/Settings.h" | 75 #include "core/page/Settings.h" |
74 #include "core/page/SpatialNavigation.h" | 76 #include "core/page/SpatialNavigation.h" |
75 #include "core/page/TouchAdjustment.h" | 77 #include "core/page/TouchAdjustment.h" |
76 #include "core/platform/ScrollAnimator.h" | 78 #include "core/platform/ScrollAnimator.h" |
77 #include "core/platform/Scrollbar.h" | 79 #include "core/platform/Scrollbar.h" |
78 #include "core/platform/chromium/ChromiumDataObject.h" | 80 #include "core/platform/chromium/ChromiumDataObject.h" |
79 #include "core/platform/graphics/Image.h" | 81 #include "core/platform/graphics/Image.h" |
80 #include "core/rendering/HitTestResult.h" | 82 #include "core/rendering/HitTestResult.h" |
81 #include "core/rendering/RenderLayer.h" | 83 #include "core/rendering/RenderLayer.h" |
82 #include "core/rendering/RenderTextControlSingleLine.h" | 84 #include "core/rendering/RenderTextControlSingleLine.h" |
83 #include "core/rendering/RenderView.h" | 85 #include "core/rendering/RenderView.h" |
84 #include "core/rendering/RenderWidget.h" | 86 #include "core/rendering/RenderWidget.h" |
85 #include "core/rendering/style/CursorList.h" | 87 #include "core/rendering/style/CursorList.h" |
| 88 #include "core/rendering/style/RenderStyle.h" |
86 #include "core/svg/SVGDocument.h" | 89 #include "core/svg/SVGDocument.h" |
87 #include "core/svg/SVGElementInstance.h" | 90 #include "core/svg/SVGElementInstance.h" |
88 #include "core/svg/SVGUseElement.h" | 91 #include "core/svg/SVGUseElement.h" |
89 #include "platform/PlatformGestureEvent.h" | 92 #include "platform/PlatformGestureEvent.h" |
90 #include "platform/PlatformKeyboardEvent.h" | 93 #include "platform/PlatformKeyboardEvent.h" |
91 #include "platform/PlatformTouchEvent.h" | 94 #include "platform/PlatformTouchEvent.h" |
92 #include "platform/PlatformWheelEvent.h" | 95 #include "platform/PlatformWheelEvent.h" |
93 #include "platform/WindowsKeyboardCodes.h" | 96 #include "platform/WindowsKeyboardCodes.h" |
94 #include "platform/geometry/FloatPoint.h" | 97 #include "platform/geometry/FloatPoint.h" |
95 #include "wtf/Assertions.h" | 98 #include "wtf/Assertions.h" |
(...skipping 3581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3677 Document& doc = node->document(); | 3680 Document& doc = node->document(); |
3678 // Record the originating touch document even if it does not have a
touch listener. | 3681 // Record the originating touch document even if it does not have a
touch listener. |
3679 if (freshTouchEvents) { | 3682 if (freshTouchEvents) { |
3680 m_originatingTouchPointDocument = &doc; | 3683 m_originatingTouchPointDocument = &doc; |
3681 freshTouchEvents = false; | 3684 freshTouchEvents = false; |
3682 } | 3685 } |
3683 if (!doc.hasTouchEventHandlers()) | 3686 if (!doc.hasTouchEventHandlers()) |
3684 continue; | 3687 continue; |
3685 m_originatingTouchPointTargets.set(touchPointTargetKey, node); | 3688 m_originatingTouchPointTargets.set(touchPointTargetKey, node); |
3686 touchTarget = node; | 3689 touchTarget = node; |
| 3690 |
| 3691 // FIXME(rbyers): Should really be doing a second hit test that igno
res inline elements - crbug.com/319479. |
| 3692 TouchAction effectiveTouchAction = computeEffectiveTouchAction(*node
); |
| 3693 if (effectiveTouchAction != TouchActionAuto) |
| 3694 m_frame->page()->chrome().client().setTouchAction(effectiveTouch
Action); |
| 3695 |
3687 } else if (pointState == PlatformTouchPoint::TouchReleased || pointState
== PlatformTouchPoint::TouchCancelled) { | 3696 } else if (pointState == PlatformTouchPoint::TouchReleased || pointState
== PlatformTouchPoint::TouchCancelled) { |
3688 // The target should be the original target for this touch, so get i
t from the hashmap. As it's a release or cancel | 3697 // The target should be the original target for this touch, so get i
t from the hashmap. As it's a release or cancel |
3689 // we also remove it from the map. | 3698 // we also remove it from the map. |
3690 touchTarget = m_originatingTouchPointTargets.take(touchPointTargetKe
y); | 3699 touchTarget = m_originatingTouchPointTargets.take(touchPointTargetKe
y); |
3691 } else | 3700 } else |
3692 // No hittest is performed on move or stationary, since the target i
s not allowed to change anyway. | 3701 // No hittest is performed on move or stationary, since the target i
s not allowed to change anyway. |
3693 touchTarget = m_originatingTouchPointTargets.get(touchPointTargetKey
); | 3702 touchTarget = m_originatingTouchPointTargets.get(touchPointTargetKey
); |
3694 | 3703 |
3695 if (!touchTarget.get()) | 3704 if (!touchTarget.get()) |
3696 continue; | 3705 continue; |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3888 | 3897 |
3889 float magnifyDelta = exp(event.deltaY() * 0.002f); | 3898 float magnifyDelta = exp(event.deltaY() * 0.002f); |
3890 float newPageScaleFactor = pageScaleFactor * magnifyDelta; | 3899 float newPageScaleFactor = pageScaleFactor * magnifyDelta; |
3891 | 3900 |
3892 IntPoint anchorAfterCss(anchorBeforeDip); | 3901 IntPoint anchorAfterCss(anchorBeforeDip); |
3893 anchorAfterCss.scale(1.f / newPageScaleFactor, 1.f / newPageScaleFactor); | 3902 anchorAfterCss.scale(1.f / newPageScaleFactor, 1.f / newPageScaleFactor); |
3894 page->inspectorController().requestPageScaleFactor(newPageScaleFactor, ancho
rBeforeCss - toIntSize(anchorAfterCss)); | 3903 page->inspectorController().requestPageScaleFactor(newPageScaleFactor, ancho
rBeforeCss - toIntSize(anchorAfterCss)); |
3895 return true; | 3904 return true; |
3896 } | 3905 } |
3897 | 3906 |
| 3907 TouchAction EventHandler::computeEffectiveTouchAction(const Node& node) |
| 3908 { |
| 3909 // Optimization to minimize risk of this new feature (behavior should be ide
ntical |
| 3910 // since there's no way to get non-default touch-action values). |
| 3911 if (!RuntimeEnabledFeatures::cssTouchActionEnabled()) |
| 3912 return TouchActionAuto; |
| 3913 |
| 3914 // Start by permitting all actions, then walk the block level elements from |
| 3915 // the target node up to the nearest scrollable ancestor and exclude any |
| 3916 // prohibited actions. For now this is trivial, but when we add more types |
| 3917 // of actions it'll get a little more complex. |
| 3918 for (const Node* curNode = &node; curNode; curNode = NodeRenderingTraversal:
:parent(curNode)) { |
| 3919 // The spec says only block and SVG elements get touch-action. |
| 3920 // FIXME(rbyers): Add correct support for SVG, crbug.com/247396. |
| 3921 if (RenderObject* renderer = curNode->renderer()) { |
| 3922 if (renderer->isRenderBlockFlow()) { |
| 3923 if (renderer->style()->touchAction() == TouchActionNone) |
| 3924 return TouchActionNone; |
| 3925 } |
| 3926 |
| 3927 // If we've reached an ancestor that supports a touch action, search
no further. |
| 3928 if (renderer->isBox() && toRenderBox(renderer)->scrollsOverflow()) |
| 3929 break; |
| 3930 } |
| 3931 } |
| 3932 return TouchActionAuto; |
| 3933 } |
| 3934 |
3898 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) | 3935 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) |
3899 { | 3936 { |
3900 m_mousePositionIsUnknown = false; | 3937 m_mousePositionIsUnknown = false; |
3901 m_lastKnownMousePosition = event.position(); | 3938 m_lastKnownMousePosition = event.position(); |
3902 m_lastKnownMouseGlobalPosition = event.globalPosition(); | 3939 m_lastKnownMouseGlobalPosition = event.globalPosition(); |
3903 } | 3940 } |
3904 | 3941 |
3905 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m
ev, Frame* subframe) | 3942 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m
ev, Frame* subframe) |
3906 { | 3943 { |
3907 // If we're clicking into a frame that is selected, the frame will appear | 3944 // If we're clicking into a frame that is selected, the frame will appear |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3973 unsigned EventHandler::accessKeyModifiers() | 4010 unsigned EventHandler::accessKeyModifiers() |
3974 { | 4011 { |
3975 #if OS(MACOSX) | 4012 #if OS(MACOSX) |
3976 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4013 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
3977 #else | 4014 #else |
3978 return PlatformEvent::AltKey; | 4015 return PlatformEvent::AltKey; |
3979 #endif | 4016 #endif |
3980 } | 4017 } |
3981 | 4018 |
3982 } // namespace WebCore | 4019 } // namespace WebCore |
OLD | NEW |