Fix wrong computation of scroll velocity.
authorTomasz Czekala <t.czekala@samsung.com>
Mon, 28 Dec 2015 08:50:31 +0000 (09:50 +0100)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 07:55:23 +0000 (07:55 +0000)
Currently timestamp for touch event (ui::TouchEvent) is using
function ecore_time_get() which gives time in seconds. This makes
difficult to distinguish touch events occurring in sequence as time
comes almost same in seconds. This further breaks gesture event
handing as timestamp resolution is too low.

This patch adds current time in microseconds which is high enough
to distinguish two consecutive touch events distinctly.

This improves touch smoothness in all gestures quite a lot.

This patch sends the timestamp of event actually occurred in platform.
When browser process is busy, system may not be able to deliver the
events in time, so we may get events delayed. Actual events occurred
in platform are equi-spaced in time.

This solves the incorrect fling occurring in small scrolls due to
wrong velocity computation. This also solves now the smoothness with
all gestures and removes jitters from fling events.

This is a port of the following patches:
http://165.213.202.130/gerrit/#/c/100329/
http://165.213.202.130/gerrit/#/c/100453/

Reviewed by: a1.gomes, djmix.kim, prashant.n

Change-Id: I6669f167deb61dc004856985785daf62b39b8f61
Signed-off-by: Tomasz Czekala <t.czekala@samsung.com>
tizen_src/chromium_impl/content/browser/renderer_host/render_widget_host_view_efl.cc
tizen_src/chromium_impl/content/browser/renderer_host/render_widget_host_view_efl.h
tizen_src/chromium_impl/content/browser/renderer_host/web_event_factory_efl.cc
tizen_src/chromium_impl/content/browser/renderer_host/web_event_factory_efl.h

index 8e2ff73..98dcc95 100755 (executable)
@@ -278,11 +278,11 @@ void RenderWidgetHostViewEfl::InitAsChild(gfx::NativeView parent_view) {
       OnKeyUp, this);
 
   evas_object_event_callback_add(content_image_, EVAS_CALLBACK_MULTI_DOWN,
-      OnMultiTouchEvent, this);
+      OnMultiTouchDownEvent, this);
   evas_object_event_callback_add(content_image_, EVAS_CALLBACK_MULTI_MOVE,
-      OnMultiTouchEvent, this);
+      OnMultiTouchMoveEvent, this);
   evas_object_event_callback_add(content_image_, EVAS_CALLBACK_MULTI_UP,
-      OnMultiTouchEvent, this);
+      OnMultiTouchUpEvent, this);
 
 #if defined(OS_TIZEN_MOBILE)
   eext_object_event_callback_add(content_image_, EEXT_CALLBACK_BACK,
@@ -341,11 +341,11 @@ RenderWidgetHostViewEfl::~RenderWidgetHostViewEfl() {
       OnKeyUp);
 
   evas_object_event_callback_del(content_image_, EVAS_CALLBACK_MULTI_DOWN,
-      OnMultiTouchEvent);
+      OnMultiTouchDownEvent);
   evas_object_event_callback_del(content_image_, EVAS_CALLBACK_MULTI_MOVE,
-      OnMultiTouchEvent);
+      OnMultiTouchMoveEvent);
   evas_object_event_callback_del(content_image_, EVAS_CALLBACK_MULTI_UP,
-      OnMultiTouchEvent);
+      OnMultiTouchUpEvent);
 
   evas_object_del(content_image_elm_host_);
   content_image_elm_host_ = NULL;
@@ -1419,7 +1419,8 @@ void RenderWidgetHostViewEfl::OnMouseDown(
         static_cast<Evas_Event_Mouse_Down*>(event_info));
     rwhv->host_->ForwardMouseEvent(event);
   } else {
-    rwhv->ProcessTouchEvents();
+    rwhv->ProcessTouchEvents(
+        static_cast<Evas_Event_Mouse_Down*>(event_info)->timestamp);
   }
 }
 
@@ -1436,7 +1437,8 @@ void RenderWidgetHostViewEfl::OnMouseUp(
         static_cast<Evas_Event_Mouse_Up*>(event_info));
     rwhv->host_->ForwardMouseEvent(event);
   } else {
-    rwhv->ProcessTouchEvents();
+    rwhv->ProcessTouchEvents(
+        static_cast<Evas_Event_Mouse_Up*>(event_info)->timestamp);
   }
 }
 
@@ -1452,15 +1454,33 @@ void RenderWidgetHostViewEfl::OnMouseMove(
         static_cast<Evas_Event_Mouse_Move*>(event_info));
     rwhv->host_->ForwardMouseEvent(event);
   } else {
-    rwhv->ProcessTouchEvents();
+    rwhv->ProcessTouchEvents(
+        static_cast<Evas_Event_Mouse_Move*>(event_info)->timestamp);
   }
 }
 
-void RenderWidgetHostViewEfl::OnMultiTouchEvent(
+void RenderWidgetHostViewEfl::OnMultiTouchDownEvent(
     void* data, Evas* evas, Evas_Object* obj, void* event_info) {
   RenderWidgetHostViewEfl* rwhv = static_cast<RenderWidgetHostViewEfl*>(data);
   CHECK(rwhv->touch_events_enabled_);
-  rwhv->ProcessTouchEvents();
+  rwhv->ProcessTouchEvents(
+      static_cast<Evas_Event_Multi_Down*>(event_info)->timestamp);
+}
+
+void RenderWidgetHostViewEfl::OnMultiTouchMoveEvent(
+    void* data, Evas* evas, Evas_Object* obj, void* event_info) {
+  RenderWidgetHostViewEfl* rwhv = static_cast<RenderWidgetHostViewEfl*>(data);
+  CHECK(rwhv->touch_events_enabled_);
+  rwhv->ProcessTouchEvents(
+      static_cast<Evas_Event_Multi_Move*>(event_info)->timestamp);
+}
+
+void RenderWidgetHostViewEfl::OnMultiTouchUpEvent(
+    void* data, Evas* evas, Evas_Object* obj, void* event_info) {
+  RenderWidgetHostViewEfl* rwhv = static_cast<RenderWidgetHostViewEfl*>(data);
+  CHECK(rwhv->touch_events_enabled_);
+  rwhv->ProcessTouchEvents(
+      static_cast<Evas_Event_Multi_Up*>(event_info)->timestamp);
 }
 
 void RenderWidgetHostViewEfl::OnKeyDown(
@@ -1544,7 +1564,7 @@ void RenderWidgetHostViewEfl::OnMouseWheel(
   }
 }
 
-void RenderWidgetHostViewEfl::ProcessTouchEvents() {
+void RenderWidgetHostViewEfl::ProcessTouchEvents(unsigned int timestamp) {
   // These constants are used to map multi touch's touch id(s).
   // The poorly-written Tizen API document says:
   //  "0 for Mouse Event and device id for Multi Event."
@@ -1605,7 +1625,8 @@ void RenderWidgetHostViewEfl::ProcessTouchEvents() {
       }
     }
 
-    ui::TouchEvent touch_event = MakeTouchEvent(pt, state, id, content_image_);
+    ui::TouchEvent touch_event =
+        MakeTouchEvent(pt, state, id, content_image_, timestamp);
     HandleTouchEvent(&touch_event);
   }
 }
index a5a65a9..cf36250 100755 (executable)
@@ -292,7 +292,9 @@ class CONTENT_EXPORT RenderWidgetHostViewEfl
   static void OnMotionMove(void* data, Evas_Object*, void*);
   static void OnMotionZoom(void* data, Evas_Object*, void*);
 
-  static void OnMultiTouchEvent(void* data, Evas*, Evas_Object*, void*);
+  static void OnMultiTouchDownEvent(void* data, Evas*, Evas_Object*, void*);
+  static void OnMultiTouchMoveEvent(void* data, Evas*, Evas_Object*, void*);
+  static void OnMultiTouchUpEvent(void* data, Evas*, Evas_Object*, void*);
 
   static void OnMouseDown(void* data, Evas*, Evas_Object*, void*);
   static void OnMouseUp(void* data, Evas*, Evas_Object*, void*);
@@ -304,7 +306,7 @@ class CONTENT_EXPORT RenderWidgetHostViewEfl
   static void OnHWBackEvent(void*, Evas_Object*, void*);
 #endif
 
-  void ProcessTouchEvents();
+  void ProcessTouchEvents(unsigned int timestamp);
   void SetDoubleTapSupportEnabled(bool enabled);
 
   void OnOrientationChangeEvent(int);
index 5e247fd..4e62ecd 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "base/time/time.h"
 #include "base/strings/utf_string_conversions.h"
+#include "ui/events/event_utils.h"
 #include "ui/events/keycodes/keyboard_codes.h"
 #include "ui/events/keycodes/keyboard_code_conversion_x.h"
 #include "ui/gfx/screen.h"
@@ -526,12 +527,17 @@ bool IsHardwareBackKey(const Evas_Event_Key_Down* event) {
 }
 
 ui::TouchEvent MakeTouchEvent(Evas_Coord_Point pt,
-    Evas_Touch_Point_State state, int id, Evas_Object* view) {
+                              Evas_Touch_Point_State state,
+                              int id, Evas_Object* view,
+                              unsigned int timestamp) {
   TranslateEvasCoordToWebKitCoord(view, pt.x, pt.y);
   const float scale = GetDeviceScaleFactor();
+  base::TimeDelta event_timestamp =
+      base::TimeDelta::FromMilliseconds(timestamp);
+  if (timestamp == 0)
+    event_timestamp = ui::EventTimeForNow();
   return ui::TouchEvent(EvasTouchEventTypeToUI(state),
-      gfx::Point(pt.x / scale, pt.y / scale),
-      id, base::TimeDelta::FromMilliseconds(ecore_time_get() * 1000));
+      gfx::Point(pt.x / scale, pt.y / scale), id, event_timestamp);
 }
 
 }
index 3e3ba1b..5f3a2f8 100644 (file)
@@ -30,8 +30,11 @@ NativeWebKeyboardEvent MakeWebKeyboardEvent(bool pressed, const EVT*);
 bool IsHardwareBackKey(const Evas_Event_Key_Down* event);
 
 // Touch
+// TODO(prashant.n): Make timestamp explicit argument.
 CONTENT_EXPORT ui::TouchEvent MakeTouchEvent(Evas_Coord_Point pt,
-    Evas_Touch_Point_State state, int id, Evas_Object* view);
+                                             Evas_Touch_Point_State state,
+                                             int id, Evas_Object* view,
+                                             unsigned int timestamp = 0);
 
 } // namespace content