Chromium Code Reviews| Index: content/browser/renderer_host/input/gesture_text_selector.h |
| diff --git a/content/browser/renderer_host/input/gesture_text_selector.h b/content/browser/renderer_host/input/gesture_text_selector.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8f4ad87b45708455ba2693ee864f4dba898ec4f8 |
| --- /dev/null |
| +++ b/content/browser/renderer_host/input/gesture_text_selector.h |
| @@ -0,0 +1,62 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// 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_GESTURE_TEXT_SELECTOR_H_ |
| +#define CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_TEXT_SELECTOR_H_ |
| + |
| +#include "base/gtest_prod_util.h" |
| +#include "base/macros.h" |
| +#include "base/memory/scoped_ptr.h" |
|
jdduke (slow)
2014/06/25 14:54:19
Don't think we need scoped_ptr.h anymore.
Changwan Ryu
2014/06/26 00:05:27
Removed.
|
| +#include "content/common/content_export.h" |
| + |
| +namespace ui { |
| +struct GestureEventData; |
| +class MotionEvent; |
| +} |
| + |
| +namespace content { |
| +class GestureTextSelectorTest; |
| + |
| +// Interface with which GestureTextSelector can select, unselect, or show |
| +// selection handles. |
| +class CONTENT_EXPORT GestureTextSelectorClient { |
| + public: |
| + virtual ~GestureTextSelectorClient() {} |
| + |
| + virtual void ShowSelectionHandlesAutomatically() = 0; |
| + virtual void SelectRange(float x1, float y1, float x2, float y2) = 0; |
| + virtual void Unselect() = 0; |
| +}; |
| + |
| +// A class to handle gesture-based text selection, such as when clicking first |
| +// button on stylus input. |
| +class CONTENT_EXPORT GestureTextSelector { |
| + public: |
| + explicit GestureTextSelector(GestureTextSelectorClient* client); |
| + virtual ~GestureTextSelector(); |
| + |
| + // This should be called after gesture detection but before associated |
| + // gestures are dispatched. Returns whether it will consume |event|. |
| + bool OnTouchEvent(const ui::MotionEvent& event); |
| + // Returns whether it will consume the event. |
|
jdduke (slow)
2014/06/25 14:54:19
Nit: Let's add a line break between the two method
Changwan Ryu
2014/06/26 00:05:27
Done.
|
| + bool OnGestureEvent(const ui::GestureEventData& gesture); |
| + |
| + private: |
| + friend class GestureTextSelectorTest; |
| + FRIEND_TEST_ALL_PREFIXES(GestureTextSelectorTest, |
| + ShouldStartTextSelection); |
| + |
| + static bool ShouldStartTextSelection(const ui::MotionEvent& event); |
| + |
| + GestureTextSelectorClient* client_; |
| + bool text_selection_triggered_; |
| + float anchor_x_; |
| + float anchor_y_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(GestureTextSelector); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_TEXT_SELECTOR_H_ |