Chromium Code Reviews| 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 51% |
| 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..cee8c13ac2280b066e51c049223ce48c12e4bfb3 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,18 +18,29 @@ |
| 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 { |
|
Sami
2015/02/19 11:59:06
Please add unit tests for this and SyntheticDragGe
ssid
2015/02/20 10:58:55
I have added unittests that I can think of, please
|
| public: |
| - explicit SyntheticSmoothScrollGesture( |
| - const SyntheticSmoothScrollGestureParams& params); |
| - ~SyntheticSmoothScrollGesture() override; |
| + enum InputType { |
| + TOUCH_INPUT, |
|
Sami
2015/02/19 11:59:06
nit: either have INPUT in all of the entries or no
ssid
2015/02/20 10:58:55
Done.
|
| + MOUSE_CLICK, |
|
Sami
2015/02/19 11:59:06
Maybe MOUSE_MOVE would be a better match for what
ssid
2015/02/20 10:58:55
Made it drag, because it involves clicks too.
|
| + MOUSE_WHEEL |
| + }; |
| + |
| + SyntheticSmoothMoveGesture( |
| + InputType gesture_source_type, |
| + gfx::PointF start_point, |
| + std::vector<gfx::Vector2d> distances, |
| + int speed_in_pixels_s, |
| + bool prevent_fling); |
| + ~SyntheticSmoothMoveGesture() override; |
| SyntheticGesture::Result ForwardInputEvents( |
|
Sami
2015/02/19 11:59:05
Please add: // SyntheticGesture implementation:
ssid
2015/02/20 10:58:55
added in header.
|
| const base::TimeTicks& timestamp, |
| @@ -45,7 +57,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 +76,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 gesture_source_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::Vector2d> 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_ |