OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_TEXT_SELECTOR_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_TEXT_SELECTOR_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_TEXT_SELECTOR_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_TEXT_SELECTOR_H_ |
7 | 7 |
8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 virtual void SelectRange(float x1, float y1, float x2, float y2) = 0; | 30 virtual void SelectRange(float x1, float y1, float x2, float y2) = 0; |
31 virtual void LongPress(base::TimeTicks time, float x, float y) = 0; | 31 virtual void LongPress(base::TimeTicks time, float x, float y) = 0; |
32 }; | 32 }; |
33 | 33 |
34 // A class to handle gesture-based text selection, such as when clicking first | 34 // A class to handle gesture-based text selection, such as when clicking first |
35 // button on stylus input. It also generates a synthetic long press gesture on | 35 // button on stylus input. It also generates a synthetic long press gesture on |
36 // tap so that a word can be selected or the contextual menu can be shown. | 36 // tap so that a word can be selected or the contextual menu can be shown. |
37 class CONTENT_EXPORT GestureTextSelector : public ui::SimpleGestureListener { | 37 class CONTENT_EXPORT GestureTextSelector : public ui::SimpleGestureListener { |
38 public: | 38 public: |
39 explicit GestureTextSelector(GestureTextSelectorClient* client); | 39 explicit GestureTextSelector(GestureTextSelectorClient* client); |
40 virtual ~GestureTextSelector(); | 40 ~GestureTextSelector() override; |
41 | 41 |
42 // This should be called before |event| is seen by the platform gesture | 42 // This should be called before |event| is seen by the platform gesture |
43 // detector or forwarded to web content. | 43 // detector or forwarded to web content. |
44 bool OnTouchEvent(const ui::MotionEvent& event); | 44 bool OnTouchEvent(const ui::MotionEvent& event); |
45 | 45 |
46 private: | 46 private: |
47 friend class GestureTextSelectorTest; | 47 friend class GestureTextSelectorTest; |
48 FRIEND_TEST_ALL_PREFIXES(GestureTextSelectorTest, | 48 FRIEND_TEST_ALL_PREFIXES(GestureTextSelectorTest, |
49 ShouldStartTextSelection); | 49 ShouldStartTextSelection); |
50 | 50 |
51 // SimpleGestureListener implementation. | 51 // SimpleGestureListener implementation. |
52 virtual bool OnSingleTapUp(const ui::MotionEvent& e) override; | 52 bool OnSingleTapUp(const ui::MotionEvent& e) override; |
53 virtual bool OnScroll(const ui::MotionEvent& e1, | 53 bool OnScroll(const ui::MotionEvent& e1, |
54 const ui::MotionEvent& e2, | 54 const ui::MotionEvent& e2, |
55 float distance_x, | 55 float distance_x, |
56 float distance_y) override; | 56 float distance_y) override; |
57 | 57 |
58 static bool ShouldStartTextSelection(const ui::MotionEvent& event); | 58 static bool ShouldStartTextSelection(const ui::MotionEvent& event); |
59 | 59 |
60 GestureTextSelectorClient* client_; | 60 GestureTextSelectorClient* client_; |
61 bool text_selection_triggered_; | 61 bool text_selection_triggered_; |
62 bool secondary_button_pressed_; | 62 bool secondary_button_pressed_; |
63 float anchor_x_; | 63 float anchor_x_; |
64 float anchor_y_; | 64 float anchor_y_; |
65 scoped_ptr<ui::GestureDetector> gesture_detector_; | 65 scoped_ptr<ui::GestureDetector> gesture_detector_; |
66 | 66 |
67 DISALLOW_COPY_AND_ASSIGN(GestureTextSelector); | 67 DISALLOW_COPY_AND_ASSIGN(GestureTextSelector); |
68 }; | 68 }; |
69 | 69 |
70 } // namespace content | 70 } // namespace content |
71 | 71 |
72 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_TEXT_SELECTOR_H_ | 72 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_TEXT_SELECTOR_H_ |
OLD | NEW |