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

Unified Diff: Source/core/page/EventHandler.cpp

Issue 103823003: Implement touch-action pan-x/pan-y handling on the main thread (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@issue1
Patch Set: incorporated review comments Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/page/EventHandler.h ('k') | Source/web/tests/TouchActionTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/EventHandler.cpp
diff --git a/Source/core/page/EventHandler.cpp b/Source/core/page/EventHandler.cpp
old mode 100644
new mode 100755
index 24b02a8368b3bdeed6d7d9d685d4feb0c5e91130..239ca708021b564f0f7419377919a48c50ef902c
--- a/Source/core/page/EventHandler.cpp
+++ b/Source/core/page/EventHandler.cpp
@@ -3903,6 +3903,19 @@ bool EventHandler::handleWheelEventAsEmulatedGesture(const PlatformWheelEvent& e
return true;
}
+TouchAction EventHandler::intersectTouchAction(TouchAction action1, TouchAction action2)
+{
+ if (action1 == TouchActionNone || action2 == TouchActionNone)
+ return TouchActionNone;
+ if (action1 == TouchActionAuto)
+ return action2;
+ if (action2 == TouchActionAuto)
+ return action1;
+ if (!(action1 & action2))
+ return TouchActionNone;
+ return action1 & action2;
+}
+
TouchAction EventHandler::computeEffectiveTouchAction(const Node& node)
{
// Optimization to minimize risk of this new feature (behavior should be identical
@@ -3914,13 +3927,16 @@ TouchAction EventHandler::computeEffectiveTouchAction(const Node& node)
// the target node up to the nearest scrollable ancestor and exclude any
// prohibited actions. For now this is trivial, but when we add more types
// of actions it'll get a little more complex.
+ TouchAction effectiveTouchAction = TouchActionAuto;
for (const Node* curNode = &node; curNode; curNode = NodeRenderingTraversal::parent(curNode)) {
// The spec says only block and SVG elements get touch-action.
// FIXME(rbyers): Add correct support for SVG, crbug.com/247396.
if (RenderObject* renderer = curNode->renderer()) {
if (renderer->isRenderBlockFlow()) {
- if (renderer->style()->touchAction() == TouchActionNone)
- return TouchActionNone;
+ TouchAction action = renderer->style()->touchAction();
+ effectiveTouchAction = intersectTouchAction(action, effectiveTouchAction);
+ if (effectiveTouchAction == TouchActionNone)
+ break;
}
// If we've reached an ancestor that supports a touch action, search no further.
@@ -3928,7 +3944,7 @@ TouchAction EventHandler::computeEffectiveTouchAction(const Node& node)
break;
}
}
- return TouchActionAuto;
+ return effectiveTouchAction;
}
void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event)
« no previous file with comments | « Source/core/page/EventHandler.h ('k') | Source/web/tests/TouchActionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698