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

Unified Diff: content/browser/renderer_host/input/synthetic_smooth_move_gesture.h

Issue 929333002: Adding synthetic touch/mouse drag [Part1] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed nits. Created 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/synthetic_smooth_move_gesture.h
diff --git a/content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h b/content/browser/renderer_host/input/synthetic_smooth_move_gesture.h
similarity index 50%
copy from content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h
copy to content/browser/renderer_host/input/synthetic_smooth_move_gesture.h
index da3e39e210410ffdc618d88f3962c27764db442e..0d2e99218d43cad6768874e3653046af4271c95e 100644
--- a/content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h
+++ b/content/browser/renderer_host/input/synthetic_smooth_move_gesture.h
@@ -2,14 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_SMOOTH_SCROLL_GESTURE_H_
-#define CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_SMOOTH_SCROLL_GESTURE_H_
+#ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_SMOOTH_MOVE_GESTURE_H_
+#define CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_SMOOTH_MOVE_GESTURE_H_
+
+#include <vector>
#include "base/time/time.h"
#include "content/browser/renderer_host/input/synthetic_gesture.h"
#include "content/browser/renderer_host/input/synthetic_gesture_target.h"
#include "content/common/content_export.h"
-#include "content/common/input/synthetic_smooth_scroll_gesture_params.h"
#include "content/common/input/synthetic_web_input_event_builders.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "ui/gfx/geometry/vector2d.h"
@@ -17,19 +18,32 @@
namespace content {
-// Simulates scrolling given a sequence of scroll distances as a continuous
-// gestures (i.e. when synthesizing touch events, the touch pointer is not
-// lifted when changing scroll direction).
+// This class is used as helper class for simulation of scroll and drag.
+// Simulates scrolling/dragging given a sequence of distances as a continuous
+// gestures (i.e. when synthesizing touch or mouse drag events, the pointer is
+// not lifted when changing scroll direction).
// If no distance is provided or the first one is 0, no touch events are
// generated.
-// When synthesizing touch events, the first distance is extended to compensate
-// for the touch slop.
-class CONTENT_EXPORT SyntheticSmoothScrollGesture : public SyntheticGesture {
+// When synthesizing touch events for scrolling, the first distance is extended
+// to compensate for the touch slop.
+class CONTENT_EXPORT SyntheticSmoothMoveGesture : public SyntheticGesture {
public:
- explicit SyntheticSmoothScrollGesture(
- const SyntheticSmoothScrollGestureParams& params);
- ~SyntheticSmoothScrollGesture() override;
+ enum InputType {
+ MOUSE_DRAG_INPUT,
+ MOUSE_WHEEL_INPUT,
+ TOUCH_DRAG_INPUT,
Sami 2015/02/20 17:57:07 What's the difference between TOUCH_DRAG and TOUCH
+ TOUCH_SCROLL_INPUT
+ };
+
+ SyntheticSmoothMoveGesture(
+ InputType input_type,
+ gfx::PointF start_point,
+ std::vector<gfx::Vector2dF> distances,
+ int speed_in_pixels_s,
+ bool prevent_fling);
+ ~SyntheticSmoothMoveGesture() override;
+ // SyntheticGesture implementation:
SyntheticGesture::Result ForwardInputEvents(
const base::TimeTicks& timestamp,
SyntheticGestureTarget* target) override;
@@ -45,7 +59,9 @@ class CONTENT_EXPORT SyntheticSmoothScrollGesture : public SyntheticGesture {
void ForwardTouchInputEvents(
const base::TimeTicks& timestamp, SyntheticGestureTarget* target);
- void ForwardMouseInputEvents(
+ void ForwardMouseWheelInputEvents(
+ const base::TimeTicks& timestamp, SyntheticGestureTarget* target);
+ void ForwardMouseClickInputEvents(
const base::TimeTicks& timestamp, SyntheticGestureTarget* target);
void ForwardTouchEvent(SyntheticGestureTarget* target,
@@ -62,30 +78,39 @@ class CONTENT_EXPORT SyntheticSmoothScrollGesture : public SyntheticGesture {
void ReleaseTouchPoint(SyntheticGestureTarget* target,
const base::TimeTicks& timestamp);
+ void PressMousePoint(SyntheticGestureTarget* target,
+ const base::TimeTicks& timestamp);
+ void ReleaseMousePoint(SyntheticGestureTarget* target,
+ const base::TimeTicks& timestamp);
+ void MoveMousePoint(SyntheticGestureTarget* target,
+ const gfx::Vector2dF& delta,
+ const base::TimeTicks& timestamp);
+
void AddTouchSlopToFirstDistance(SyntheticGestureTarget* target);
- gfx::Vector2dF GetPositionDeltaAtTime(const base::TimeTicks& timestamp)
- const;
- void ComputeNextScrollSegment();
+ gfx::Vector2dF GetPositionDeltaAtTime(const base::TimeTicks& timestamp) const;
+ void ComputeNextMoveSegment();
base::TimeTicks ClampTimestamp(const base::TimeTicks& timestamp) const;
- bool FinishedCurrentScrollSegment(const base::TimeTicks& timestamp) const;
- bool IsLastScrollSegment() const;
- bool ScrollIsNoOp() const;
+ bool FinishedCurrentMoveSegment(const base::TimeTicks& timestamp) const;
+ bool IsLastMoveSegment() const;
+ bool MoveIsNoOp() const;
- SyntheticSmoothScrollGestureParams params_;
// Used for mouse input.
- gfx::Vector2d current_scroll_segment_total_delta_discrete_;
+ gfx::Vector2d current_move_segment_total_delta_discrete_;
// Used for touch input.
- gfx::Point current_scroll_segment_start_position_;
+ gfx::PointF current_move_segment_start_position_;
SyntheticWebTouchEvent touch_event_;
- SyntheticGestureParams::GestureSourceType gesture_source_type_;
+ InputType input_type_;
GestureState state_;
- int current_scroll_segment_;
- base::TimeTicks current_scroll_segment_start_time_;
- base::TimeTicks current_scroll_segment_stop_time_;
+ int current_move_segment_;
+ base::TimeTicks current_move_segment_start_time_;
+ base::TimeTicks current_move_segment_stop_time_;
+ std::vector<gfx::Vector2dF> move_distances_;
+ int speed_in_pixels_s_;
+ bool prevent_fling_;
- DISALLOW_COPY_AND_ASSIGN(SyntheticSmoothScrollGesture);
+ DISALLOW_COPY_AND_ASSIGN(SyntheticSmoothMoveGesture);
};
} // namespace content
-#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_SMOOTH_SCROLL_GESTURE_H_
+#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_SMOOTH_MOVE_GESTURE_H_

Powered by Google App Engine
This is Rietveld 408576698