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

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

Issue 137123009: Add hittest mode for Touch-action which ignore inline elements and svg elements (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase to trunk and Incorporated review comments Created 6 years, 9 months 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
« no previous file with comments | « Source/core/page/EventHandler.h ('k') | Source/core/rendering/HitTestRequest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3660 matching lines...) Expand 10 before | Expand all | Expand 10 after
3671 // Record the originating touch document even if it does not have a touch listener. 3671 // Record the originating touch document even if it does not have a touch listener.
3672 if (freshTouchEvents) { 3672 if (freshTouchEvents) {
3673 m_originatingTouchPointDocument = &doc; 3673 m_originatingTouchPointDocument = &doc;
3674 freshTouchEvents = false; 3674 freshTouchEvents = false;
3675 } 3675 }
3676 if (!doc.hasTouchEventHandlers()) 3676 if (!doc.hasTouchEventHandlers())
3677 continue; 3677 continue;
3678 m_originatingTouchPointTargets.set(touchPointTargetKey, node); 3678 m_originatingTouchPointTargets.set(touchPointTargetKey, node);
3679 touchTarget = node; 3679 touchTarget = node;
3680 3680
3681 // FIXME(rbyers): Should really be doing a second hit test that igno res inline elements - crbug.com/319479. 3681 TouchAction effectiveTouchAction = computeEffectiveTouchAction(pageP oint);
3682 TouchAction effectiveTouchAction = computeEffectiveTouchAction(*node );
3683 if (effectiveTouchAction != TouchActionAuto) 3682 if (effectiveTouchAction != TouchActionAuto)
3684 m_frame->page()->chrome().client().setTouchAction(effectiveTouch Action); 3683 m_frame->page()->chrome().client().setTouchAction(effectiveTouch Action);
3685 3684
3686 } else if (pointState == PlatformTouchPoint::TouchReleased || pointState == PlatformTouchPoint::TouchCancelled) { 3685 } else if (pointState == PlatformTouchPoint::TouchReleased || pointState == PlatformTouchPoint::TouchCancelled) {
3687 // The target should be the original target for this touch, so get i t from the hashmap. As it's a release or cancel 3686 // The target should be the original target for this touch, so get i t from the hashmap. As it's a release or cancel
3688 // we also remove it from the map. 3687 // we also remove it from the map.
3689 touchTarget = m_originatingTouchPointTargets.take(touchPointTargetKe y); 3688 touchTarget = m_originatingTouchPointTargets.take(touchPointTargetKe y);
3690 } else 3689 } else
3691 // No hittest is performed on move or stationary, since the target i s not allowed to change anyway. 3690 // No hittest is performed on move or stationary, since the target i s not allowed to change anyway.
3692 touchTarget = m_originatingTouchPointTargets.get(touchPointTargetKey ); 3691 touchTarget = m_originatingTouchPointTargets.get(touchPointTargetKey );
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
3905 return TouchActionNone; 3904 return TouchActionNone;
3906 if (action1 == TouchActionAuto) 3905 if (action1 == TouchActionAuto)
3907 return action2; 3906 return action2;
3908 if (action2 == TouchActionAuto) 3907 if (action2 == TouchActionAuto)
3909 return action1; 3908 return action1;
3910 if (!(action1 & action2)) 3909 if (!(action1 & action2))
3911 return TouchActionNone; 3910 return TouchActionNone;
3912 return action1 & action2; 3911 return action1 & action2;
3913 } 3912 }
3914 3913
3915 TouchAction EventHandler::computeEffectiveTouchAction(const Node& node) 3914 TouchAction EventHandler::computeEffectiveTouchAction(const LayoutPoint& point)
3916 { 3915 {
3917 // Optimization to minimize risk of this new feature (behavior should be ide ntical 3916 // Optimization to minimize risk of this new feature (behavior should be ide ntical
3918 // since there's no way to get non-default touch-action values). 3917 // since there's no way to get non-default touch-action values).
3919 if (!RuntimeEnabledFeatures::cssTouchActionEnabled()) 3918 if (!RuntimeEnabledFeatures::cssTouchActionEnabled())
3920 return TouchActionAuto; 3919 return TouchActionAuto;
3921 3920
3921 HitTestResult taResult = hitTestResultAtPoint(point, HitTestRequest::TouchEv ent | HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::TouchA ction);
3922 Node* node = taResult.innerNode();
3923 if (!node)
3924 return TouchActionAuto;
3925
3922 // Start by permitting all actions, then walk the block level elements from 3926 // Start by permitting all actions, then walk the block level elements from
3923 // the target node up to the nearest scrollable ancestor and exclude any 3927 // the target node up to the nearest scrollable ancestor and exclude any
3924 // prohibited actions. For now this is trivial, but when we add more types 3928 // prohibited actions. For now this is trivial, but when we add more types
3925 // of actions it'll get a little more complex. 3929 // of actions it'll get a little more complex.
3926 TouchAction effectiveTouchAction = TouchActionAuto; 3930 TouchAction effectiveTouchAction = TouchActionAuto;
3927 for (const Node* curNode = &node; curNode; curNode = NodeRenderingTraversal: :parent(curNode)) { 3931 for (const Node* curNode = node; curNode; curNode = NodeRenderingTraversal:: parent(curNode)) {
3928 // The spec says only block and SVG elements get touch-action. 3932 // The spec says only block and SVG elements get touch-action.
3929 // FIXME(rbyers): Add correct support for SVG, crbug.com/247396. 3933 // FIXME(rbyers): Add correct support for SVG, crbug.com/247396.
3930 if (RenderObject* renderer = curNode->renderer()) { 3934 if (RenderObject* renderer = curNode->renderer()) {
3931 if (renderer->isRenderBlockFlow()) { 3935 if (renderer->isRenderBlockFlow()) {
3932 TouchAction action = renderer->style()->touchAction(); 3936 TouchAction action = renderer->style()->touchAction();
3933 effectiveTouchAction = intersectTouchAction(action, effectiveTou chAction); 3937 effectiveTouchAction = intersectTouchAction(action, effectiveTou chAction);
3934 if (effectiveTouchAction == TouchActionNone) 3938 if (effectiveTouchAction == TouchActionNone)
3935 break; 3939 break;
3936 } 3940 }
3937 3941
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
4021 unsigned EventHandler::accessKeyModifiers() 4025 unsigned EventHandler::accessKeyModifiers()
4022 { 4026 {
4023 #if OS(MACOSX) 4027 #if OS(MACOSX)
4024 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 4028 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
4025 #else 4029 #else
4026 return PlatformEvent::AltKey; 4030 return PlatformEvent::AltKey;
4027 #endif 4031 #endif
4028 } 4032 }
4029 4033
4030 } // namespace WebCore 4034 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/EventHandler.h ('k') | Source/core/rendering/HitTestRequest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698