Title: [123482] trunk/Source/WebKit2
Revision
123482
Author
commit-qu...@webkit.org
Date
2012-07-24 08:40:05 -0700 (Tue, 24 Jul 2012)

Log Message

[EFL][WK2] Add vibration client
https://bugs.webkit.org/show_bug.cgi?id=91371

Patch by Sudarsana Nagineni <sudarsana.nagin...@linux.intel.com> on 2012-07-24
Reviewed by Antonio Gomes.

Implement Vibration provider for WebKit2 EFL and add an API to set
vibration client callbacks by application to handle the tactile
feedback in the application when the page content ask for vibration.

* CMakeLists.txt: Add WebCore/Modules/vibration to include path.
* PlatformEfl.cmake: Add VibrationProvider.cpp file to the build
system.
* UIProcess/API/efl/VibrationProvider.cpp: Added.
(_Ewk_Vibration_Client): Structure contains the vibration client
callbacks.
(_Ewk_Vibration_Client::_Ewk_Vibration_Client):
(toVibrationProvider): Helper function to cast the clientinfo to
VibrationProvider.
(vibrateCallback):
(cancelVibrationCallback):
(VibrationProvider::create):
(VibrationProvider::VibrationProvider):
(VibrationProvider::~VibrationProvider):
(VibrationProvider::vibrate):
(VibrationProvider::cancelVibration):
(VibrationProvider::setVibrationClientCallbacks):
* UIProcess/API/efl/VibrationProvider.h: Added.
(VibrationProvider):
* UIProcess/API/efl/ewk_context.cpp:
(_Ewk_Context):
(createDefaultEwkContext):
(ewk_context_vibration_client_callbacks_set): API to set vibration
client callbacks.
* UIProcess/API/efl/ewk_context.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/CMakeLists.txt (123481 => 123482)


--- trunk/Source/WebKit2/CMakeLists.txt	2012-07-24 15:38:10 UTC (rev 123481)
+++ trunk/Source/WebKit2/CMakeLists.txt	2012-07-24 15:40:05 UTC (rev 123482)
@@ -45,6 +45,7 @@
     "${WEBCORE_DIR}"
     "${WEBCORE_DIR}/Modules/battery"
     "${WEBCORE_DIR}/Modules/intents"
+    "${WEBCORE_DIR}/Modules/vibration"
     "${WEBCORE_DIR}/accessibility"
     "${WEBCORE_DIR}/bindings/js"
     "${WEBCORE_DIR}/bindings"

Modified: trunk/Source/WebKit2/ChangeLog (123481 => 123482)


--- trunk/Source/WebKit2/ChangeLog	2012-07-24 15:38:10 UTC (rev 123481)
+++ trunk/Source/WebKit2/ChangeLog	2012-07-24 15:40:05 UTC (rev 123482)
@@ -1,3 +1,40 @@
+2012-07-24  Sudarsana Nagineni  <sudarsana.nagin...@linux.intel.com>
+
+        [EFL][WK2] Add vibration client
+        https://bugs.webkit.org/show_bug.cgi?id=91371
+
+        Reviewed by Antonio Gomes.
+
+        Implement Vibration provider for WebKit2 EFL and add an API to set
+        vibration client callbacks by application to handle the tactile
+        feedback in the application when the page content ask for vibration.
+
+        * CMakeLists.txt: Add WebCore/Modules/vibration to include path.
+        * PlatformEfl.cmake: Add VibrationProvider.cpp file to the build
+        system.
+        * UIProcess/API/efl/VibrationProvider.cpp: Added.
+        (_Ewk_Vibration_Client): Structure contains the vibration client
+        callbacks.
+        (_Ewk_Vibration_Client::_Ewk_Vibration_Client):
+        (toVibrationProvider): Helper function to cast the clientinfo to
+        VibrationProvider.
+        (vibrateCallback):
+        (cancelVibrationCallback):
+        (VibrationProvider::create):
+        (VibrationProvider::VibrationProvider):
+        (VibrationProvider::~VibrationProvider):
+        (VibrationProvider::vibrate):
+        (VibrationProvider::cancelVibration):
+        (VibrationProvider::setVibrationClientCallbacks):
+        * UIProcess/API/efl/VibrationProvider.h: Added.
+        (VibrationProvider):
+        * UIProcess/API/efl/ewk_context.cpp:
+        (_Ewk_Context):
+        (createDefaultEwkContext):
+        (ewk_context_vibration_client_callbacks_set): API to set vibration
+        client callbacks.
+        * UIProcess/API/efl/ewk_context.h:
+
 2012-07-24  Simon Hausmann  <simon.hausm...@nokia.com>
 
         [Qt] Fix compilation after QtQuick API changes

Modified: trunk/Source/WebKit2/PlatformEfl.cmake (123481 => 123482)


--- trunk/Source/WebKit2/PlatformEfl.cmake	2012-07-24 15:38:10 UTC (rev 123481)
+++ trunk/Source/WebKit2/PlatformEfl.cmake	2012-07-24 15:40:05 UTC (rev 123482)
@@ -38,6 +38,7 @@
 
     UIProcess/API/efl/BatteryProvider.cpp
     UIProcess/API/efl/PageClientImpl.cpp
+    UIProcess/API/efl/VibrationProvider.cpp
     UIProcess/API/efl/ewk_context.cpp
     UIProcess/API/efl/ewk_context_request_manager_client.cpp
     UIProcess/API/efl/ewk_cookie_manager.cpp

Added: trunk/Source/WebKit2/UIProcess/API/efl/VibrationProvider.cpp (0 => 123482)


--- trunk/Source/WebKit2/UIProcess/API/efl/VibrationProvider.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/VibrationProvider.cpp	2012-07-24 15:40:05 UTC (rev 123482)
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "VibrationProvider.h"
+
+#if ENABLE(VIBRATION)
+
+#include "WKAPICast.h"
+#include "WKVibration.h"
+#include <Evas.h>
+
+using namespace WebCore;
+
+/**
+ * \struct  _Ewk_Vibration_Client
+ * @brief   Contains the vibration client callbacks.
+ */
+struct _Ewk_Vibration_Client {
+    Ewk_Vibration_Client_Vibrate_Cb vibrate;
+    Ewk_Vibration_Client_Vibration_Cancel_Cb cancelVibration;
+    void* userData;
+
+    _Ewk_Vibration_Client(Ewk_Vibration_Client_Vibrate_Cb vibrate, Ewk_Vibration_Client_Vibration_Cancel_Cb cancelVibration, void* userData)
+        : vibrate(vibrate)
+        , cancelVibration(cancelVibration)
+        , userData(userData)
+    { }
+};
+
+static inline VibrationProvider* toVibrationProvider(const void* clientInfo)
+{
+    return static_cast<VibrationProvider*>(const_cast<void*>(clientInfo));
+}
+
+static void vibrateCallback(WKVibrationRef vibrationRef, uint64_t vibrationTime, const void* clientInfo)
+{
+    toVibrationProvider(clientInfo)->vibrate(vibrationTime);
+}
+
+static void cancelVibrationCallback(WKVibrationRef vibrationRef, const void* clientInfo)
+{
+    toVibrationProvider(clientInfo)->cancelVibration();
+}
+
+PassRefPtr<VibrationProvider> VibrationProvider::create(WKVibrationRef wkVibrationRef)
+{
+    return adoptRef(new VibrationProvider(wkVibrationRef));
+}
+
+VibrationProvider::VibrationProvider(WKVibrationRef wkVibrationRef)
+    : m_wkVibrationRef(wkVibrationRef)
+{
+    ASSERT(wkVibrationRef);
+
+    WKVibrationProvider wkVibrationProvider = {
+        kWKVibrationProviderCurrentVersion,
+        this, // clientInfo
+        vibrateCallback,
+        cancelVibrationCallback
+    };
+    WKVibrationSetProvider(m_wkVibrationRef.get(), &wkVibrationProvider);
+}
+
+VibrationProvider::~VibrationProvider()
+{
+}
+
+void VibrationProvider::vibrate(uint64_t vibrationTime)
+{
+    if (m_vibrationClient && m_vibrationClient->vibrate)
+        m_vibrationClient->vibrate(vibrationTime, m_vibrationClient->userData);
+}
+
+void VibrationProvider::cancelVibration()
+{
+    if (m_vibrationClient && m_vibrationClient->cancelVibration)
+        m_vibrationClient->cancelVibration(m_vibrationClient->userData);
+}
+
+void VibrationProvider::setVibrationClientCallbacks(Ewk_Vibration_Client_Vibrate_Cb vibrate, Ewk_Vibration_Client_Vibration_Cancel_Cb cancelVibration, void* data)
+{
+    m_vibrationClient = adoptPtr(new Ewk_Vibration_Client(vibrate, cancelVibration, data));
+}
+
+#endif // ENABLE(VIBRATION)

Added: trunk/Source/WebKit2/UIProcess/API/efl/VibrationProvider.h (0 => 123482)


--- trunk/Source/WebKit2/UIProcess/API/efl/VibrationProvider.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/VibrationProvider.h	2012-07-24 15:40:05 UTC (rev 123482)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef VibrationProvider_h
+#define VibrationProvider_h
+
+#if ENABLE(VIBRATION)
+
+#include "WKRetainPtr.h"
+#include "ewk_context.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+typedef struct _Ewk_Vibration_Client Ewk_Vibration_Client;
+
+class VibrationProvider : public RefCounted<VibrationProvider> {
+public:
+    static PassRefPtr<VibrationProvider> create(WKVibrationRef);
+    virtual ~VibrationProvider();
+
+    void vibrate(uint64_t vibrationTime);
+    void cancelVibration();
+    void setVibrationClientCallbacks(Ewk_Vibration_Client_Vibrate_Cb, Ewk_Vibration_Client_Vibration_Cancel_Cb, void*);
+
+private:
+    explicit VibrationProvider(WKVibrationRef);
+
+    WKRetainPtr<WKVibrationRef> m_wkVibrationRef;
+    OwnPtr<Ewk_Vibration_Client> m_vibrationClient;
+};
+
+#endif // ENABLE(VIBRATION)
+
+#endif // VibrationProvider_h

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp (123481 => 123482)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp	2012-07-24 15:38:10 UTC (rev 123481)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp	2012-07-24 15:40:05 UTC (rev 123482)
@@ -22,6 +22,7 @@
 #include "ewk_context.h"
 
 #include "BatteryProvider.h"
+#include "VibrationProvider.h"
 #include "WKAPICast.h"
 #include "WKContextSoup.h"
 #include "WKRetainPtr.h"
@@ -58,6 +59,9 @@
 #if ENABLE(BATTERY_STATUS)
     RefPtr<BatteryProvider> batteryProvider;
 #endif
+#if ENABLE(VIBRATION)
+    RefPtr<VibrationProvider> vibrationProvider;
+#endif
 
     WKRetainPtr<WKSoupRequestManagerRef> requestManager;
     URLSchemeHandlerMap urlSchemeHandlers;
@@ -72,6 +76,11 @@
         batteryProvider = BatteryProvider::create(wkBatteryManager);
 #endif
 
+#if ENABLE(VIBRATION)
+        WKVibrationRef wkVibrationRef = WKContextGetVibration(contextRef);
+        vibrationProvider = VibrationProvider::create(wkVibrationRef);
+#endif
+
         ewk_context_request_manager_client_attach(this);
     }
 
@@ -151,3 +160,12 @@
 
     return true;
 }
+
+void ewk_context_vibration_client_callbacks_set(Ewk_Context* ewkContext, Ewk_Vibration_Client_Vibrate_Cb vibrate, Ewk_Vibration_Client_Vibration_Cancel_Cb cancel, void* data)
+{
+    EINA_SAFETY_ON_NULL_RETURN(ewkContext);
+
+#if ENABLE(VIBRATION)
+    ewkContext->vibrationProvider->setVibrationClientCallbacks(vibrate, cancel, data);
+#endif
+}

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.h (123481 => 123482)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.h	2012-07-24 15:38:10 UTC (rev 123481)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.h	2012-07-24 15:40:05 UTC (rev 123482)
@@ -47,6 +47,20 @@
 typedef void (*Ewk_Url_Scheme_Request_Cb) (Ewk_Url_Scheme_Request *request, void *user_data);
 
 /**
+ * @typedef Ewk_Vibration_Client_Vibrate_Cb Ewk_Vibration_Client_Vibrate_Cb
+ * @brief Type definition for a function that will be called back when vibrate
+ * request receiveed from the vibration controller.
+ */
+typedef void (*Ewk_Vibration_Client_Vibrate_Cb)(uint64_t vibration_time, void *user_data);
+
+/**
+ * @typedef Ewk_Vibration_Client_Vibration_Cancel_Cb Ewk_Vibration_Client_Vibration_Cancel_Cb
+ * @brief Type definition for a function that will be called back when cancel
+ * vibration request receiveed from the vibration controller.
+ */
+typedef void (*Ewk_Vibration_Client_Vibration_Cancel_Cb)(void *user_data);
+
+/**
  * Gets default Ewk_Context instance.
  *
  * @return Ewk_Context object.
@@ -105,6 +119,22 @@
  */
 EAPI Eina_Bool ewk_context_uri_scheme_register(Ewk_Context *context, const char *scheme, Ewk_Url_Scheme_Request_Cb callback, void *user_data);
 
+/**
+ * Sets vibration client callbacks to handle the tactile feedback in the form of
+ * vibration in the client application when the content asks for vibration.
+ *
+ * To stop listening for vibration events, you may call this function with @c
+ * NULL for the callbacks.
+ *
+ * @param context context object to set vibration client callbacks.
+ * @param vibrate The function to call when the vibrate request received from the
+ *        controller (may be @c NULL).
+ * @param cancel The function to call when the cancel vibration request received
+ *        from the controller (may be @c NULL).
+ * @param data User data (may be @c NULL).
+ */
+EAPI void ewk_context_vibration_client_callbacks_set(Ewk_Context *context, Ewk_Vibration_Client_Vibrate_Cb vibrate, Ewk_Vibration_Client_Vibration_Cancel_Cb cancel, void *data);
+
 #ifdef __cplusplus
 }
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to