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

Unified Diff: services/native_viewport/platform_viewport_android.cc

Issue 801443008: PlatformViewportAndroid shouldn't crash on second touch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: more blank lines Created 5 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/native_viewport/platform_viewport_android.cc
diff --git a/services/native_viewport/platform_viewport_android.cc b/services/native_viewport/platform_viewport_android.cc
index ff70db34e95235c81758ad8faa80ea29c88d2ec0..3986be5d477c764768e8997208bcf41106246e58 100644
--- a/services/native_viewport/platform_viewport_android.cc
+++ b/services/native_viewport/platform_viewport_android.cc
@@ -13,21 +13,33 @@
#include "ui/gfx/point.h"
namespace native_viewport {
+namespace {
ui::EventType MotionEventActionToEventType(jint action) {
switch (action) {
case AMOTION_EVENT_ACTION_DOWN:
return ui::ET_TOUCH_PRESSED;
- case AMOTION_EVENT_ACTION_MOVE:
- return ui::ET_TOUCH_MOVED;
case AMOTION_EVENT_ACTION_UP:
return ui::ET_TOUCH_RELEASED;
+ case AMOTION_EVENT_ACTION_MOVE:
+ return ui::ET_TOUCH_MOVED;
+ case AMOTION_EVENT_ACTION_CANCEL:
+ return ui::ET_TOUCH_CANCELLED;
+ // case AMOTION_EVENT_ACTION_OUTSIDE:
+ // case AMOTION_EVENT_ACTION_POINTER_DOWN:
+ // case AMOTION_EVENT_ACTION_POINTER_UP:
+ // case AMOTION_EVENT_ACTION_HOVER_MOVE:
+ // case AMOTION_EVENT_ACTION_SCROLL:
+ // case AMOTION_EVENT_ACTION_HOVER_ENTER:
+ // case AMOTION_EVENT_ACTION_HOVER_EXIT:
default:
- NOTREACHED();
+ NOTIMPLEMENTED() << "Unimplemented motion action: " << action;
}
return ui::ET_UNKNOWN;
}
+}
+
////////////////////////////////////////////////////////////////////////////////
// PlatformViewportAndroid, public:
@@ -79,16 +91,17 @@ void PlatformViewportAndroid::SurfaceSetSize(JNIEnv* env, jobject obj,
bool PlatformViewportAndroid::TouchEvent(JNIEnv* env, jobject obj,
jint pointer_id,
- jint action,
+ jint action_and_index,
jfloat x, jfloat y,
jlong time_ms) {
gfx::Point location(static_cast<int>(x), static_cast<int>(y));
+ jint action = action_and_index & AMOTION_EVENT_ACTION_MASK;
ui::TouchEvent event(MotionEventActionToEventType(action), location,
id_generator_.GetGeneratedID(pointer_id),
base::TimeDelta::FromMilliseconds(time_ms));
// TODO(beng): handle multiple touch-points.
delegate_->OnEvent(&event);
- if (action == ui::ET_TOUCH_RELEASED)
+ if (action == ui::ET_TOUCH_RELEASED || action == ui::ET_TOUCH_CANCELLED)
id_generator_.ReleaseNumber(pointer_id);
return true;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698