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

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: incoporated review comments Created 6 years, 10 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
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 3650 matching lines...) Expand 10 before | Expand all | Expand 10 after
3661 // Record the originating touch document even if it does not have a touch listener. 3661 // Record the originating touch document even if it does not have a touch listener.
3662 if (freshTouchEvents) { 3662 if (freshTouchEvents) {
3663 m_originatingTouchPointDocument = &doc; 3663 m_originatingTouchPointDocument = &doc;
3664 freshTouchEvents = false; 3664 freshTouchEvents = false;
3665 } 3665 }
3666 if (!doc.hasTouchEventHandlers()) 3666 if (!doc.hasTouchEventHandlers())
3667 continue; 3667 continue;
3668 m_originatingTouchPointTargets.set(touchPointTargetKey, node); 3668 m_originatingTouchPointTargets.set(touchPointTargetKey, node);
3669 touchTarget = node; 3669 touchTarget = node;
3670 3670
3671 // FIXME(rbyers): Should really be doing a second hit test that igno res inline elements - crbug.com/319479. 3671 TouchAction effectiveTouchAction = computeEffectiveTouchAction(pageP oint);
3672 TouchAction effectiveTouchAction = computeEffectiveTouchAction(*node );
3673 if (effectiveTouchAction != TouchActionAuto) 3672 if (effectiveTouchAction != TouchActionAuto)
3674 m_frame->page()->chrome().client().setTouchAction(effectiveTouch Action); 3673 m_frame->page()->chrome().client().setTouchAction(effectiveTouch Action);
3675 3674
3676 } else if (pointState == PlatformTouchPoint::TouchReleased || pointState == PlatformTouchPoint::TouchCancelled) { 3675 } else if (pointState == PlatformTouchPoint::TouchReleased || pointState == PlatformTouchPoint::TouchCancelled) {
3677 // The target should be the original target for this touch, so get i t from the hashmap. As it's a release or cancel 3676 // The target should be the original target for this touch, so get i t from the hashmap. As it's a release or cancel
3678 // we also remove it from the map. 3677 // we also remove it from the map.
3679 touchTarget = m_originatingTouchPointTargets.take(touchPointTargetKe y); 3678 touchTarget = m_originatingTouchPointTargets.take(touchPointTargetKe y);
3680 } else 3679 } else
3681 // No hittest is performed on move or stationary, since the target i s not allowed to change anyway. 3680 // No hittest is performed on move or stationary, since the target i s not allowed to change anyway.
3682 touchTarget = m_originatingTouchPointTargets.get(touchPointTargetKey ); 3681 touchTarget = m_originatingTouchPointTargets.get(touchPointTargetKey );
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
3895 return TouchActionNone; 3894 return TouchActionNone;
3896 if (action1 == TouchActionAuto) 3895 if (action1 == TouchActionAuto)
3897 return action2; 3896 return action2;
3898 if (action2 == TouchActionAuto) 3897 if (action2 == TouchActionAuto)
3899 return action1; 3898 return action1;
3900 if (!(action1 & action2)) 3899 if (!(action1 & action2))
3901 return TouchActionNone; 3900 return TouchActionNone;
3902 return action1 & action2; 3901 return action1 & action2;
3903 } 3902 }
3904 3903
3905 TouchAction EventHandler::computeEffectiveTouchAction(const Node& node) 3904 TouchAction EventHandler::computeEffectiveTouchAction(const LayoutPoint& point)
3906 { 3905 {
3907 // Optimization to minimize risk of this new feature (behavior should be ide ntical 3906 // Optimization to minimize risk of this new feature (behavior should be ide ntical
3908 // since there's no way to get non-default touch-action values). 3907 // since there's no way to get non-default touch-action values).
3909 if (!RuntimeEnabledFeatures::cssTouchActionEnabled()) 3908 if (!RuntimeEnabledFeatures::cssTouchActionEnabled())
3910 return TouchActionAuto; 3909 return TouchActionAuto;
3911 3910
3911 HitTestResult taResult = hitTestResultAtPoint(point, HitTestRequest::TouchEv ent | HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::TouchA ction);
3912 Node* node = taResult.innerNode();
3913 if (!node)
3914 return TouchActionAuto;
3915
3912 // Start by permitting all actions, then walk the block level elements from 3916 // Start by permitting all actions, then walk the block level elements from
3913 // the target node up to the nearest scrollable ancestor and exclude any 3917 // the target node up to the nearest scrollable ancestor and exclude any
3914 // prohibited actions. For now this is trivial, but when we add more types 3918 // prohibited actions. For now this is trivial, but when we add more types
3915 // of actions it'll get a little more complex. 3919 // of actions it'll get a little more complex.
3916 TouchAction effectiveTouchAction = TouchActionAuto; 3920 TouchAction effectiveTouchAction = TouchActionAuto;
3917 for (const Node* curNode = &node; curNode; curNode = NodeRenderingTraversal: :parent(curNode)) { 3921 for (const Node* curNode = node; curNode; curNode = NodeRenderingTraversal:: parent(curNode)) {
3918 // The spec says only block and SVG elements get touch-action. 3922 // The spec says only block and SVG elements get touch-action.
3919 // FIXME(rbyers): Add correct support for SVG, crbug.com/247396. 3923 // FIXME(rbyers): Add correct support for SVG, crbug.com/247396.
3920 if (RenderObject* renderer = curNode->renderer()) { 3924 if (RenderObject* renderer = curNode->renderer()) {
3921 if (renderer->isRenderBlockFlow()) { 3925 if (renderer->isRenderBlockFlow()) {
3922 TouchAction action = renderer->style()->touchAction(); 3926 TouchAction action = renderer->style()->touchAction();
3923 effectiveTouchAction = intersectTouchAction(action, effectiveTou chAction); 3927 effectiveTouchAction = intersectTouchAction(action, effectiveTou chAction);
3924 if (effectiveTouchAction == TouchActionNone) 3928 if (effectiveTouchAction == TouchActionNone)
3925 break; 3929 break;
3926 } 3930 }
3927 3931
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
4011 unsigned EventHandler::accessKeyModifiers() 4015 unsigned EventHandler::accessKeyModifiers()
4012 { 4016 {
4013 #if OS(MACOSX) 4017 #if OS(MACOSX)
4014 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 4018 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
4015 #else 4019 #else
4016 return PlatformEvent::AltKey; 4020 return PlatformEvent::AltKey;
4017 #endif 4021 #endif
4018 } 4022 }
4019 4023
4020 } // namespace WebCore 4024 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698