Add ICU message format support
[chromium-blink-merge.git] / content / browser / renderer_host / input / stylus_text_selector.h
blob163a7e966eea44e81dbfceeb60ac1e73addf707e
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_STYLUS_TEXT_SELECTOR_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_STYLUS_TEXT_SELECTOR_H_
8 #include "base/gtest_prod_util.h"
9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/time/time.h"
12 #include "content/common/content_export.h"
13 #include "ui/events/gesture_detection/gesture_listeners.h"
15 namespace ui {
16 class GestureDetector;
17 class MotionEvent;
20 namespace content {
21 class StylusTextSelectorTest;
23 // Interface with which the StylusTextSelector conveys drag and tap gestures
24 // when the activating button is pressed.
25 // selection handles, or long press.
26 class CONTENT_EXPORT StylusTextSelectorClient {
27 public:
28 virtual ~StylusTextSelectorClient() {}
30 // (x0, y0) and (x1, y1) indicate the bounds of the initial selection.
31 virtual void OnStylusSelectBegin(float x0, float y0, float x1, float y1) = 0;
32 virtual void OnStylusSelectUpdate(float x, float y) = 0;
33 virtual void OnStylusSelectEnd() = 0;
34 virtual void OnStylusSelectTap(base::TimeTicks time, float x, float y) = 0;
37 // Provides stylus-based text selection and interaction, including:
38 // * Selection manipulation when an activating stylus button is pressed and
39 // the stylus is dragged.
40 // * Word selection and context menu activation when the when an activating
41 // stylus button is pressed and the stylus is tapped.
42 class CONTENT_EXPORT StylusTextSelector : public ui::SimpleGestureListener {
43 public:
44 explicit StylusTextSelector(StylusTextSelectorClient* client);
45 ~StylusTextSelector() override;
47 // This should be called before |event| is seen by the platform gesture
48 // detector or forwarded to web content.
49 bool OnTouchEvent(const ui::MotionEvent& event);
51 private:
52 friend class StylusTextSelectorTest;
53 FRIEND_TEST_ALL_PREFIXES(StylusTextSelectorTest, ShouldStartTextSelection);
55 // SimpleGestureListener implementation.
56 bool OnSingleTapUp(const ui::MotionEvent& e) override;
57 bool OnScroll(const ui::MotionEvent& e1,
58 const ui::MotionEvent& e2,
59 float distance_x,
60 float distance_y) override;
62 static bool ShouldStartTextSelection(const ui::MotionEvent& event);
64 StylusTextSelectorClient* client_;
65 bool text_selection_triggered_;
66 bool secondary_button_pressed_;
67 bool dragging_;
68 bool dragged_;
69 float anchor_x_;
70 float anchor_y_;
71 scoped_ptr<ui::GestureDetector> gesture_detector_;
73 DISALLOW_COPY_AND_ASSIGN(StylusTextSelector);
76 } // namespace content
78 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_STYLUS_TEXT_SELECTOR_H_