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

Unified Diff: content/browser/android/content_view_core_impl.cc

Issue 342633003: [Android] Select text when stylus first button is pressed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 6 years, 6 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/android/content_view_core_impl.cc
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index 4b6a7b16b27be88a8b7fbb25baa82ef6ea940c3a..2577720b1e1b88db69edc5d6a24d6c1f70b23b17 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -58,6 +58,7 @@
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "ui/base/android/view_android.h"
#include "ui/base/android/window_android.h"
+#include "ui/events/gesture_detection/motion_event.h"
#include "ui/gfx/android/java_bitmap.h"
#include "ui/gfx/screen.h"
#include "ui/gfx/size_conversions.h"
@@ -225,7 +226,9 @@ ContentViewCoreImpl::ContentViewCoreImpl(
view_android_(view_android),
window_android_(window_android),
device_orientation_(0),
- accessibility_enabled_(false) {
+ accessibility_enabled_(false),
+ mouse_drag_start_x_(0),
+ mouse_drag_start_y_(0) {
CHECK(web_contents) <<
"A ContentViewCoreImpl should be created with a valid WebContents.";
@@ -977,6 +980,29 @@ jboolean ContentViewCoreImpl::OnTouchEvent(JNIEnv* env,
android_tool_type_1,
android_button_state);
+ // Select text and show handles if necessary.
+ if (rwhv->ShouldTriggerOrUntriggerTextSelection(event)) {
+ Java_ContentViewCore_showSelectionHandlesAutomatically(env, obj);
+ switch (event.GetAction()) {
+ case ui::MotionEvent::ACTION_DOWN:
+ web_contents_->Unselect();
+ mouse_drag_start_x_ = pos_x_0;
jdduke (slow) 2014/06/23 15:09:59 All of this logic should live close to where we de
jdduke (slow) 2014/06/23 15:24:50 Hmm, it appears |GetWebContents()| is a proper pub
Changwan Ryu 2014/06/24 09:29:48 Done
+ mouse_drag_start_y_ = pos_y_0;
+ break;
+ case ui::MotionEvent::ACTION_MOVE:
+ case ui::MotionEvent::ACTION_UP:
+ if (rwhv->IsGestureTextSelectionTriggered()) {
+ SelectBetweenCoordinates(env, obj, mouse_drag_start_x_,
+ mouse_drag_start_y_, pos_x_0, pos_y_0);
+ }
+ break;
+ case ui::MotionEvent::ACTION_CANCEL:
+ web_contents_->Unselect();
+ break;
+ default:
+ break;
+ }
+ }
return rwhv->OnTouchEvent(event);
}

Powered by Google App Engine
This is Rietveld 408576698