Title: [129765] trunk/Source/WebKit2
Revision
129765
Author
commit-qu...@webkit.org
Date
2012-09-27 08:08:14 -0700 (Thu, 27 Sep 2012)

Log Message

[EFL][WK2] Process touch events using mouse and multi events of Evas.
https://bugs.webkit.org/show_bug.cgi?id=96906

Patch by Eunmi Lee <eunmi15....@samsung.com> on 2012-09-27
Reviewed by Kenneth Rohde Christiansen.

Provide default behavior for processing touch events in the ewk_view if
application wants to use it.
We can to process touch events using mouse and multi events because the
Evas creates mouse events for first touch and multi events for second and
third touch. It can be modified when Evas starts to support event type
for touch events.

* UIProcess/API/efl/ewk_view.cpp:
(_Ewk_View_Private_Data):
(_Ewk_View_Private_Data::_Ewk_View_Private_Data):
(_ewk_view_feed_touch_event_using_touch_point_list_of_evas):
(_ewk_view_on_touch_down):
(_ewk_view_on_touch_up):
(_ewk_view_on_touch_move):
(ewk_view_touch_events_enabled_set):
(ewk_view_touch_events_enabled_get):
* UIProcess/API/efl/ewk_view.h:
* UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp:
(EWK2UnitTest::EWK2UnitTestBase::mouseDown):
(EWK2UnitTest):
(EWK2UnitTest::EWK2UnitTestBase::mouseUp):
(EWK2UnitTest::EWK2UnitTestBase::mouseMove):
(EWK2UnitTest::EWK2UnitTestBase::multiDown):
(EWK2UnitTest::EWK2UnitTestBase::multiUp):
(EWK2UnitTest::EWK2UnitTestBase::multiMove):
* UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h:
(EWK2UnitTestBase):
* UIProcess/API/efl/tests/test_ewk2_view.cpp:
(TEST_F):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (129764 => 129765)


--- trunk/Source/WebKit2/ChangeLog	2012-09-27 14:56:53 UTC (rev 129764)
+++ trunk/Source/WebKit2/ChangeLog	2012-09-27 15:08:14 UTC (rev 129765)
@@ -1,3 +1,40 @@
+2012-09-27  Eunmi Lee  <eunmi15....@samsung.com>
+
+        [EFL][WK2] Process touch events using mouse and multi events of Evas.
+        https://bugs.webkit.org/show_bug.cgi?id=96906
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Provide default behavior for processing touch events in the ewk_view if
+        application wants to use it.
+        We can to process touch events using mouse and multi events because the
+        Evas creates mouse events for first touch and multi events for second and
+        third touch. It can be modified when Evas starts to support event type
+        for touch events.
+
+        * UIProcess/API/efl/ewk_view.cpp:
+        (_Ewk_View_Private_Data):
+        (_Ewk_View_Private_Data::_Ewk_View_Private_Data):
+        (_ewk_view_feed_touch_event_using_touch_point_list_of_evas):
+        (_ewk_view_on_touch_down):
+        (_ewk_view_on_touch_up):
+        (_ewk_view_on_touch_move):
+        (ewk_view_touch_events_enabled_set):
+        (ewk_view_touch_events_enabled_get):
+        * UIProcess/API/efl/ewk_view.h:
+        * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp:
+        (EWK2UnitTest::EWK2UnitTestBase::mouseDown):
+        (EWK2UnitTest):
+        (EWK2UnitTest::EWK2UnitTestBase::mouseUp):
+        (EWK2UnitTest::EWK2UnitTestBase::mouseMove):
+        (EWK2UnitTest::EWK2UnitTestBase::multiDown):
+        (EWK2UnitTest::EWK2UnitTestBase::multiUp):
+        (EWK2UnitTest::EWK2UnitTestBase::multiMove):
+        * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h:
+        (EWK2UnitTestBase):
+        * UIProcess/API/efl/tests/test_ewk2_view.cpp:
+        (TEST_F):
+
 2012-09-27  Jinwoo Song  <jinwoo7.s...@samsung.com>
 
         [EFL][WK2] Add callback functions for WKPageFindClient

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp (129764 => 129765)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp	2012-09-27 14:56:53 UTC (rev 129764)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp	2012-09-27 15:08:14 UTC (rev 129765)
@@ -101,6 +101,9 @@
     bool areMouseEventsEnabled;
     WKColorPickerResultListenerRef colorPickerResultListener;
     Ewk_Context* context;
+#if ENABLE(TOUCH_EVENTS)
+    bool areTouchEventsEnabled;
+#endif
 
     WebPopupMenuProxyEfl* popupMenuProxy;
     Eina_List* popupMenuItems;
@@ -121,6 +124,9 @@
         , areMouseEventsEnabled(false)
         , colorPickerResultListener(0)
         , context(0)
+#if ENABLE(TOUCH_EVENTS)
+        , areTouchEventsEnabled(false)
+#endif
         , popupMenuProxy(0)
         , popupMenuItems(0)
 #ifdef HAVE_ECORE_X
@@ -356,6 +362,47 @@
     smartData->api->key_up(smartData, upEvent);
 }
 
+#if ENABLE(TOUCH_EVENTS)
+static inline void _ewk_view_feed_touch_event_using_touch_point_list_of_evas(Evas_Object* ewkView, Ewk_Touch_Event_Type type)
+{
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+
+    unsigned count = evas_touch_point_list_count(smartData->base.evas);
+    if (!count)
+        return;
+
+    Eina_List* points = 0;
+    for (unsigned i = 0; i < count; ++i) {
+        Ewk_Touch_Point* point = new Ewk_Touch_Point;
+        point->id = evas_touch_point_list_nth_id_get(smartData->base.evas, i);
+        evas_touch_point_list_nth_xy_get(smartData->base.evas, i, &point->x, &point->y);
+        point->state = evas_touch_point_list_nth_state_get(smartData->base.evas, i);
+        points = eina_list_append(points, point);
+    }
+
+    ewk_view_feed_touch_event(ewkView, type, points, evas_key_modifier_get(smartData->base.evas));
+
+    void* data;
+    EINA_LIST_FREE(points, data)
+        delete data;
+}
+
+static void _ewk_view_on_touch_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
+{
+    _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_START);
+}
+
+static void _ewk_view_on_touch_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
+{
+    _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_END);
+}
+
+static void _ewk_view_on_touch_move(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
+{
+    _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_MOVE);
+}
+#endif
+
 static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL;
 
 static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData)
@@ -1778,3 +1825,53 @@
     return false;
 #endif
 }
+
+Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
+{
+#if ENABLE(TOUCH_EVENTS)
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
+    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
+
+    enabled = !!enabled;
+    if (priv->areTouchEventsEnabled == enabled)
+        return true;
+
+    priv->areTouchEventsEnabled = enabled;
+    if (enabled) {
+        // FIXME: We have to connect touch callbacks with mouse and multi events
+        // because the Evas creates mouse events for first touch and multi events
+        // for second and third touches. Below codes should be fixed when the Evas
+        // supports the touch events.
+        // See https://bugs.webkit.org/show_bug.cgi?id=97785 for details.
+        evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down, smartData);
+        evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up, smartData);
+        evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move, smartData);
+        evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down, smartData);
+        evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up, smartData);
+        evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move, smartData);
+    } else {
+        evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down);
+        evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up);
+        evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move);
+        evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down);
+        evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up);
+        evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move);
+    }
+
+    return true;
+#else
+    return false;
+#endif
+}
+
+Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object* ewkView)
+{
+#if ENABLE(TOUCH_EVENTS)
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
+    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
+
+    return priv->areTouchEventsEnabled;
+#else
+    return false;
+#endif
+}

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h (129764 => 129765)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h	2012-09-27 14:56:53 UTC (rev 129764)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h	2012-09-27 15:08:14 UTC (rev 129765)
@@ -708,6 +708,28 @@
  */
 EAPI Eina_Bool ewk_view_feed_touch_event(Evas_Object *o, Ewk_Touch_Event_Type type, const Eina_List *points, const Evas_Modifier *modifiers);
 
+/**
+ * Sets whether the ewk_view supports the touch events or not.
+ *
+ * The ewk_view will support the touch events if @c EINA_TRUE or not support the
+ * touch events otherwise. The default value is @c EINA_FALSE.
+ *
+ * @param o view object to enable/disable the touch events
+ * @param enabled a state to set
+ *
+ * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
+ */
+EAPI Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object *o, Eina_Bool enabled);
+
+/**
+ * Queries if the ewk_view supports the touch events.
+ *
+ * @param o view object to query if the touch events are enabled
+ *
+ * @return @c EINA_TRUE if the touch events are enabled or @c EINA_FALSE otherwise
+ */
+EAPI Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object *o);
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp (129764 => 129765)


--- trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp	2012-09-27 14:56:53 UTC (rev 129764)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp	2012-09-27 15:08:14 UTC (rev 129765)
@@ -239,4 +239,38 @@
     evas_event_feed_mouse_up(evas, /* Left */ 1, EVAS_BUTTON_NONE, 0, 0);
 }
 
+void EWK2UnitTestBase::mouseDown(int x, int y)
+{
+    Evas* evas = evas_object_evas_get(m_webView);
+    evas_event_feed_mouse_move(evas, x, y, 0, 0);
+    evas_event_feed_mouse_down(evas, /* Left */ 1, EVAS_BUTTON_NONE, 0, 0);
+}
+
+void EWK2UnitTestBase::mouseUp(int x, int y)
+{
+    Evas* evas = evas_object_evas_get(m_webView);
+    evas_event_feed_mouse_move(evas, x, y, 0, 0);
+    evas_event_feed_mouse_up(evas, /* Left */ 1, EVAS_BUTTON_NONE, 0, 0);
+}
+
+void EWK2UnitTestBase::mouseMove(int x, int y)
+{
+    evas_event_feed_mouse_move(evas_object_evas_get(m_webView), x, y, 0, 0);
+}
+
+void EWK2UnitTestBase::multiDown(int id, int x, int y)
+{
+    evas_event_feed_multi_down(evas_object_evas_get(m_webView), id, x, y, 0, 0, 0, 0, 0, 0, 0, EVAS_BUTTON_NONE, 0, 0);
+}
+
+void EWK2UnitTestBase::multiUp(int id, int x, int y)
+{
+    evas_event_feed_multi_up(evas_object_evas_get(m_webView), id, x, y, 0, 0, 0, 0, 0, 0, 0, EVAS_BUTTON_NONE, 0, 0);
+}
+
+void EWK2UnitTestBase::multiMove(int id, int x, int y)
+{
+    evas_event_feed_multi_move(evas_object_evas_get(m_webView), id, x, y, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+}
+
 } // namespace EWK2UnitTest

Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h (129764 => 129765)


--- trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h	2012-09-27 14:56:53 UTC (rev 129764)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h	2012-09-27 15:08:14 UTC (rev 129765)
@@ -48,6 +48,12 @@
     bool waitUntilURIChangedTo(const char* expectedURI, double timeoutSeconds = defaultTimeoutSeconds);
 
     void mouseClick(int x, int y);
+    void mouseDown(int x, int y);
+    void mouseUp(int x, int y);
+    void mouseMove(int x, int y);
+    void multiDown(int id, int x, int y);
+    void multiUp(int id, int x, int y);
+    void multiMove(int id, int x, int y);
 
 private:
     Evas_Object* m_webView;

Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp (129764 => 129765)


--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp	2012-09-27 14:56:53 UTC (rev 129764)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp	2012-09-27 15:08:14 UTC (rev 129765)
@@ -824,3 +824,45 @@
 
     evas_object_smart_callback_del(webView(), "text,found", onTextFound);
 }
+
+TEST_F(EWK2UnitTestBase, ewk_view_touch_events_enabled)
+{
+    ASSERT_FALSE(ewk_view_touch_events_enabled_get(webView()));
+
+    ASSERT_TRUE(ewk_view_touch_events_enabled_set(webView(), true));
+    ASSERT_TRUE(ewk_view_touch_events_enabled_get(webView()));
+
+    ASSERT_TRUE(ewk_view_touch_events_enabled_set(webView(), 2));
+    ASSERT_TRUE(ewk_view_touch_events_enabled_get(webView()));
+
+    const char* touchHTML =
+        "<!doctype html><body><div style=\"width:100px; height:100px;\" "
+        "_ontouchstart_=\"document.title='touchstarted' + event.touches.length;\" "
+        "_ontouchmove_=\"document.title='touchmoved' + event.touches.length;\" "
+        "_ontouchend_=\"document.title='touchended' + event.touches.length;\">"
+        "</div></body>";
+
+    ewk_view_html_string_load(webView(), touchHTML, "file:///", 0);
+    ASSERT_TRUE(waitUntilLoadFinished());
+
+    mouseDown(10, 10);
+    ASSERT_TRUE(waitUntilTitleChangedTo("touchstarted1"));
+
+    multiDown(1, 30, 30);
+    ASSERT_TRUE(waitUntilTitleChangedTo("touchstarted2"));
+
+    multiMove(1, 40, 40);
+    ASSERT_TRUE(waitUntilTitleChangedTo("touchmoved2"));
+
+    multiUp(1, 40, 40);
+    ASSERT_TRUE(waitUntilTitleChangedTo("touchended1"));
+
+    mouseMove(20, 20);
+    ASSERT_TRUE(waitUntilTitleChangedTo("touchmoved1"));
+
+    mouseUp(20, 20);
+    ASSERT_TRUE(waitUntilTitleChangedTo("touchended0"));
+
+    ASSERT_TRUE(ewk_view_touch_events_enabled_set(webView(), false));
+    ASSERT_FALSE(ewk_view_touch_events_enabled_get(webView()));
+}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to