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

Unified Diff: content/browser/renderer_host/input/synthetic_touchscreen_pinch_gesture.cc

Issue 2664013002: input: Restrict synthetic touch gesture to view bounds.
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/input/synthetic_gesture_target_base.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/input/synthetic_touchscreen_pinch_gesture.cc
diff --git a/content/browser/renderer_host/input/synthetic_touchscreen_pinch_gesture.cc b/content/browser/renderer_host/input/synthetic_touchscreen_pinch_gesture.cc
index 8daff81a14c7d69fc08b60b5b4263a15425c335d..118003f1dcb7cb25ae4c2b9291b446ec1e95e4db 100644
--- a/content/browser/renderer_host/input/synthetic_touchscreen_pinch_gesture.cc
+++ b/content/browser/renderer_host/input/synthetic_touchscreen_pinch_gesture.cc
@@ -6,6 +6,7 @@
#include <stdint.h>
+#include <algorithm>
#include <cmath>
#include "base/logging.h"
@@ -96,9 +97,11 @@ void SyntheticTouchscreenPinchGesture::MoveTouchPoints(
SyntheticGestureTarget* target,
float delta,
const base::TimeTicks& timestamp) {
+ gfx::Size view_size = target->GetViewSize();
// The two pointers move in opposite directions.
- float current_y_0 = start_y_0_ + delta;
- float current_y_1 = start_y_1_ - delta;
+ float current_y_0 = std::max(start_y_0_ + delta, 0.f);
+ float current_y_1 =
+ std::min(start_y_1_ - delta, static_cast<float>(view_size.height() - 1));
synthetic_pointer_driver_->Move(params_.anchor.x(), current_y_0, 0);
synthetic_pointer_driver_->Move(params_.anchor.x(), current_y_1, 1);
@@ -132,8 +135,10 @@ void SyntheticTouchscreenPinchGesture::SetupCoordinatesAndStopTime(
target->GetTouchSlopInDips();
}
- start_y_0_ = params_.anchor.y() - initial_distance_to_anchor;
- start_y_1_ = params_.anchor.y() + initial_distance_to_anchor;
+ gfx::Size view_size = target->GetViewSize();
+ start_y_0_ = std::max(params_.anchor.y() - initial_distance_to_anchor, 0.f);
+ start_y_1_ = std::min(params_.anchor.y() + initial_distance_to_anchor,
+ static_cast<float>(view_size.height() - 1));
max_pointer_delta_0_ = initial_distance_to_anchor - final_distance_to_anchor;
« no previous file with comments | « content/browser/renderer_host/input/synthetic_gesture_target_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698