Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(636)

Side by Side Diff: Source/core/page/EventHandler.cpp

Issue 16507017: Initial touch-action main thread implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Don't add delay param to public API just yet Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/AutoscrollController.h"
61 #include "core/page/BackForwardClient.h" 61 #include "core/page/BackForwardClient.h"
62 #include "core/page/Chrome.h" 62 #include "core/page/Chrome.h"
63 #include "core/page/ChromeClient.h"
63 #include "core/page/DragController.h" 64 #include "core/page/DragController.h"
64 #include "core/page/DragState.h" 65 #include "core/page/DragState.h"
65 #include "core/page/EditorClient.h" 66 #include "core/page/EditorClient.h"
66 #include "core/page/FocusController.h" 67 #include "core/page/FocusController.h"
67 #include "core/frame/Frame.h" 68 #include "core/frame/Frame.h"
68 #include "core/page/FrameTree.h" 69 #include "core/page/FrameTree.h"
69 #include "core/frame/FrameView.h" 70 #include "core/frame/FrameView.h"
70 #include "core/inspector/InspectorController.h" 71 #include "core/inspector/InspectorController.h"
71 #include "core/page/MouseEventWithHitTestResults.h" 72 #include "core/page/MouseEventWithHitTestResults.h"
72 #include "core/page/Page.h" 73 #include "core/page/Page.h"
73 #include "core/page/Settings.h" 74 #include "core/page/Settings.h"
74 #include "core/page/SpatialNavigation.h" 75 #include "core/page/SpatialNavigation.h"
75 #include "core/page/TouchAdjustment.h" 76 #include "core/page/TouchAdjustment.h"
76 #include "core/platform/Cursor.h" 77 #include "core/platform/Cursor.h"
77 #include "core/platform/ScrollAnimator.h" 78 #include "core/platform/ScrollAnimator.h"
78 #include "core/platform/Scrollbar.h" 79 #include "core/platform/Scrollbar.h"
79 #include "core/platform/chromium/ChromiumDataObject.h" 80 #include "core/platform/chromium/ChromiumDataObject.h"
80 #include "core/platform/graphics/Image.h" 81 #include "core/platform/graphics/Image.h"
81 #include "core/rendering/HitTestRequest.h" 82 #include "core/rendering/HitTestRequest.h"
82 #include "core/rendering/HitTestResult.h" 83 #include "core/rendering/HitTestResult.h"
83 #include "core/rendering/RenderLayer.h" 84 #include "core/rendering/RenderLayer.h"
84 #include "core/rendering/RenderTextControlSingleLine.h" 85 #include "core/rendering/RenderTextControlSingleLine.h"
85 #include "core/rendering/RenderView.h" 86 #include "core/rendering/RenderView.h"
86 #include "core/rendering/RenderWidget.h" 87 #include "core/rendering/RenderWidget.h"
87 #include "core/rendering/style/CursorList.h" 88 #include "core/rendering/style/CursorList.h"
89 #include "core/rendering/style/RenderStyle.h"
88 #include "core/svg/SVGDocument.h" 90 #include "core/svg/SVGDocument.h"
89 #include "core/svg/SVGElementInstance.h" 91 #include "core/svg/SVGElementInstance.h"
90 #include "core/svg/SVGUseElement.h" 92 #include "core/svg/SVGUseElement.h"
91 #include "platform/PlatformGestureEvent.h" 93 #include "platform/PlatformGestureEvent.h"
92 #include "platform/PlatformKeyboardEvent.h" 94 #include "platform/PlatformKeyboardEvent.h"
93 #include "platform/PlatformTouchEvent.h" 95 #include "platform/PlatformTouchEvent.h"
94 #include "platform/PlatformWheelEvent.h" 96 #include "platform/PlatformWheelEvent.h"
95 #include "platform/WindowsKeyboardCodes.h" 97 #include "platform/WindowsKeyboardCodes.h"
96 #include "platform/geometry/FloatPoint.h" 98 #include "platform/geometry/FloatPoint.h"
97 #include "wtf/Assertions.h" 99 #include "wtf/Assertions.h"
(...skipping 3524 matching lines...) Expand 10 before | Expand all | Expand 10 after
3622 Document& doc = node->document(); 3624 Document& doc = node->document();
3623 // Record the originating touch document even if it does not have a touch listener. 3625 // Record the originating touch document even if it does not have a touch listener.
3624 if (freshTouchEvents) { 3626 if (freshTouchEvents) {
3625 m_originatingTouchPointDocument = &doc; 3627 m_originatingTouchPointDocument = &doc;
3626 freshTouchEvents = false; 3628 freshTouchEvents = false;
3627 } 3629 }
3628 if (!doc.hasTouchEventHandlers()) 3630 if (!doc.hasTouchEventHandlers())
3629 continue; 3631 continue;
3630 m_originatingTouchPointTargets.set(touchPointTargetKey, node); 3632 m_originatingTouchPointTargets.set(touchPointTargetKey, node);
3631 touchTarget = node; 3633 touchTarget = node;
3634
3635 // FIXME(rbyers): Should really be doing a second hit test that igno res inline elements - crbug.com/319479.
3636 TouchAction effectiveTouchAction = computeEffectiveTouchAction(node) ;
3637 if (effectiveTouchAction != TouchActionAuto) {
3638 m_frame->page()->chrome().client().setTouchAction(point.id(), ef fectiveTouchAction);
3639 }
abarth-chromium 2013/11/18 21:16:59 No need for { }
Rick Byers 2013/11/19 21:24:21 Done.
3640
3632 } else if (pointState == PlatformTouchPoint::TouchReleased || pointState == PlatformTouchPoint::TouchCancelled) { 3641 } else if (pointState == PlatformTouchPoint::TouchReleased || pointState == PlatformTouchPoint::TouchCancelled) {
3633 // The target should be the original target for this touch, so get i t from the hashmap. As it's a release or cancel 3642 // The target should be the original target for this touch, so get i t from the hashmap. As it's a release or cancel
3634 // we also remove it from the map. 3643 // we also remove it from the map.
3635 touchTarget = m_originatingTouchPointTargets.take(touchPointTargetKe y); 3644 touchTarget = m_originatingTouchPointTargets.take(touchPointTargetKe y);
3636 } else 3645 } else
3637 // No hittest is performed on move or stationary, since the target i s not allowed to change anyway. 3646 // No hittest is performed on move or stationary, since the target i s not allowed to change anyway.
3638 touchTarget = m_originatingTouchPointTargets.get(touchPointTargetKey ); 3647 touchTarget = m_originatingTouchPointTargets.get(touchPointTargetKey );
3639 3648
3640 if (!touchTarget.get()) 3649 if (!touchTarget.get())
3641 continue; 3650 continue;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
3833 3842
3834 float magnifyDelta = exp(event.deltaY() * 0.002f); 3843 float magnifyDelta = exp(event.deltaY() * 0.002f);
3835 float newPageScaleFactor = pageScaleFactor * magnifyDelta; 3844 float newPageScaleFactor = pageScaleFactor * magnifyDelta;
3836 3845
3837 IntPoint anchorAfterCss(anchorBeforeDip); 3846 IntPoint anchorAfterCss(anchorBeforeDip);
3838 anchorAfterCss.scale(1.f / newPageScaleFactor, 1.f / newPageScaleFactor); 3847 anchorAfterCss.scale(1.f / newPageScaleFactor, 1.f / newPageScaleFactor);
3839 page->inspectorController().requestPageScaleFactor(newPageScaleFactor, ancho rBeforeCss - toIntSize(anchorAfterCss)); 3848 page->inspectorController().requestPageScaleFactor(newPageScaleFactor, ancho rBeforeCss - toIntSize(anchorAfterCss));
3840 return true; 3849 return true;
3841 } 3850 }
3842 3851
3852 TouchAction EventHandler::computeEffectiveTouchAction(Node* node)
3853 {
3854 // Optimization to minimize risk of this new feature (behavior should be ide ntical
3855 // since there's no way to get non-default touch-action values).
3856 if (!RuntimeEnabledFeatures::cssTouchActionEnabled())
3857 return TouchActionAuto;
3858
3859 // Start by permitting all actions, then walk the block level elements from
3860 // the target node up to the nearest scrollable ancestor and exclude any
3861 // prohibited actions. For now this is trivial, but when we add more types
3862 // of actions it'll get a little more complex.
3863 TouchAction effectiveTouchAction = TouchActionAuto;
3864
3865 while (node) {
3866 // The spec says only block and SVG elements get touch-action.
3867 // FIXME(rbyers): Add correct support for SVG, crbug.com/247396.
3868 if (node->isBlockFlowElement()) {
3869 RenderObject* renderer = node->renderer();
3870 if (renderer) {
abarth-chromium 2013/11/18 21:16:59 You can combine this line with the previous one.
Rick Byers 2013/11/19 21:24:21 Done.
3871 TouchAction action = renderer->style()->touchAction();
3872 if (action == TouchActionNone)
3873 effectiveTouchAction = action;
3874 }
3875 }
3876
3877 // If we've reached an ancestor that supports a touch action, search no further.
3878 if (node->renderBox() && node->renderBox()->scrollsOverflow())
3879 break;
abarth-chromium 2013/11/18 21:16:59 I'm not sure if poking the render tree in this way
Rick Byers 2013/11/19 21:24:21 I think this is similar to what scrollNode (here i
3880
3881 node = node->parentNode();
3882 }
3883 return effectiveTouchAction;
3884 }
3885
3843 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) 3886 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event)
3844 { 3887 {
3845 m_mousePositionIsUnknown = false; 3888 m_mousePositionIsUnknown = false;
3846 m_lastKnownMousePosition = event.position(); 3889 m_lastKnownMousePosition = event.position();
3847 m_lastKnownMouseGlobalPosition = event.globalPosition(); 3890 m_lastKnownMouseGlobalPosition = event.globalPosition();
3848 } 3891 }
3849 3892
3850 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m ev, Frame* subframe) 3893 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m ev, Frame* subframe)
3851 { 3894 {
3852 // If we're clicking into a frame that is selected, the frame will appear 3895 // 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
3918 unsigned EventHandler::accessKeyModifiers() 3961 unsigned EventHandler::accessKeyModifiers()
3919 { 3962 {
3920 #if OS(MACOSX) 3963 #if OS(MACOSX)
3921 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3964 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3922 #else 3965 #else
3923 return PlatformEvent::AltKey; 3966 return PlatformEvent::AltKey;
3924 #endif 3967 #endif
3925 } 3968 }
3926 3969
3927 } // namespace WebCore 3970 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698