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

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: merge with trunk - no changes 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 3511 matching lines...) Expand 10 before | Expand all | Expand 10 after
3609 Document& doc = node->document(); 3611 Document& doc = node->document();
3610 // Record the originating touch document even if it does not have a touch listener. 3612 // Record the originating touch document even if it does not have a touch listener.
3611 if (freshTouchEvents) { 3613 if (freshTouchEvents) {
3612 m_originatingTouchPointDocument = &doc; 3614 m_originatingTouchPointDocument = &doc;
3613 freshTouchEvents = false; 3615 freshTouchEvents = false;
3614 } 3616 }
3615 if (!doc.hasTouchEventHandlers()) 3617 if (!doc.hasTouchEventHandlers())
3616 continue; 3618 continue;
3617 m_originatingTouchPointTargets.set(touchPointTargetKey, node); 3619 m_originatingTouchPointTargets.set(touchPointTargetKey, node);
3618 touchTarget = node; 3620 touchTarget = node;
3621
3622 // FIXME(rbyers): Should really be doing a second hit test that igno res inline elements - crbug.com/319479.
3623 TouchAction effectiveTouchAction = computeEffectiveTouchAction(node) ;
3624 if (effectiveTouchAction != TouchActionAuto)
3625 m_frame->page()->chrome().client().setTouchAction(effectiveTouch Action);
3626
3619 } else if (pointState == PlatformTouchPoint::TouchReleased || pointState == PlatformTouchPoint::TouchCancelled) { 3627 } else if (pointState == PlatformTouchPoint::TouchReleased || pointState == PlatformTouchPoint::TouchCancelled) {
3620 // The target should be the original target for this touch, so get i t from the hashmap. As it's a release or cancel 3628 // The target should be the original target for this touch, so get i t from the hashmap. As it's a release or cancel
3621 // we also remove it from the map. 3629 // we also remove it from the map.
3622 touchTarget = m_originatingTouchPointTargets.take(touchPointTargetKe y); 3630 touchTarget = m_originatingTouchPointTargets.take(touchPointTargetKe y);
3623 } else 3631 } else
3624 // No hittest is performed on move or stationary, since the target i s not allowed to change anyway. 3632 // No hittest is performed on move or stationary, since the target i s not allowed to change anyway.
3625 touchTarget = m_originatingTouchPointTargets.get(touchPointTargetKey ); 3633 touchTarget = m_originatingTouchPointTargets.get(touchPointTargetKey );
3626 3634
3627 if (!touchTarget.get()) 3635 if (!touchTarget.get())
3628 continue; 3636 continue;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
3820 3828
3821 float magnifyDelta = exp(event.deltaY() * 0.002f); 3829 float magnifyDelta = exp(event.deltaY() * 0.002f);
3822 float newPageScaleFactor = pageScaleFactor * magnifyDelta; 3830 float newPageScaleFactor = pageScaleFactor * magnifyDelta;
3823 3831
3824 IntPoint anchorAfterCss(anchorBeforeDip); 3832 IntPoint anchorAfterCss(anchorBeforeDip);
3825 anchorAfterCss.scale(1.f / newPageScaleFactor, 1.f / newPageScaleFactor); 3833 anchorAfterCss.scale(1.f / newPageScaleFactor, 1.f / newPageScaleFactor);
3826 page->inspectorController().requestPageScaleFactor(newPageScaleFactor, ancho rBeforeCss - toIntSize(anchorAfterCss)); 3834 page->inspectorController().requestPageScaleFactor(newPageScaleFactor, ancho rBeforeCss - toIntSize(anchorAfterCss));
3827 return true; 3835 return true;
3828 } 3836 }
3829 3837
3838 TouchAction EventHandler::computeEffectiveTouchAction(Node* node)
3839 {
3840 // Optimization to minimize risk of this new feature (behavior should be ide ntical
3841 // since there's no way to get non-default touch-action values).
3842 if (!RuntimeEnabledFeatures::cssTouchActionEnabled())
3843 return TouchActionAuto;
3844
3845 // Start by permitting all actions, then walk the block level elements from
3846 // the target node up to the nearest scrollable ancestor and exclude any
3847 // prohibited actions. For now this is trivial, but when we add more types
3848 // of actions it'll get a little more complex.
3849 TouchAction effectiveTouchAction = TouchActionAuto;
3850
3851 while (node) {
3852 // The spec says only block and SVG elements get touch-action.
3853 // FIXME(rbyers): Add correct support for SVG, crbug.com/247396.
3854 if (node->isBlockFlowElement()) {
3855 if (RenderObject* renderer = node->renderer()) {
esprehn 2013/11/21 16:26:29 This loop checks for renderer() repeatedly (isBloc
Rick Byers 2013/11/21 22:09:29 Thanks. I could have sworn I've seen situations w
3856 TouchAction action = renderer->style()->touchAction();
3857 if (action == TouchActionNone)
3858 effectiveTouchAction = action;
3859 }
3860 }
3861
3862 // If we've reached an ancestor that supports a touch action, search no further.
3863 if (node->renderBox() && node->renderBox()->scrollsOverflow())
3864 break;
3865
3866 node = node->parentNode();
esprehn 2013/11/21 16:26:29 This doesn't appear correct, Shadow DOM means pare
Rick Byers 2013/11/21 22:09:29 Yes, thank you! I've fixed this to traverse up th
3867 }
3868 return effectiveTouchAction;
3869 }
3870
3830 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) 3871 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event)
3831 { 3872 {
3832 m_mousePositionIsUnknown = false; 3873 m_mousePositionIsUnknown = false;
3833 m_lastKnownMousePosition = event.position(); 3874 m_lastKnownMousePosition = event.position();
3834 m_lastKnownMouseGlobalPosition = event.globalPosition(); 3875 m_lastKnownMouseGlobalPosition = event.globalPosition();
3835 } 3876 }
3836 3877
3837 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m ev, Frame* subframe) 3878 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m ev, Frame* subframe)
3838 { 3879 {
3839 // If we're clicking into a frame that is selected, the frame will appear 3880 // 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
3905 unsigned EventHandler::accessKeyModifiers() 3946 unsigned EventHandler::accessKeyModifiers()
3906 { 3947 {
3907 #if OS(MACOSX) 3948 #if OS(MACOSX)
3908 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3949 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3909 #else 3950 #else
3910 return PlatformEvent::AltKey; 3951 return PlatformEvent::AltKey;
3911 #endif 3952 #endif
3912 } 3953 }
3913 3954
3914 } // namespace WebCore 3955 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698