Title: [108272] trunk
Revision
108272
Author
[email protected]
Date
2012-02-20 17:05:11 -0800 (Mon, 20 Feb 2012)

Log Message

.: Add a new API for the Vibration API(W3C).
https://bugs.webkit.org/show_bug.cgi?id=72010

Patch by Kihong Kwon <[email protected]> on 2012-02-20
Reviewed by Hajime Morita.

Add Implementation for the Vibration API to the WebKit-EFL port.
http://dev.w3.org/2009/dap/vibration/

* Source/cmake/OptionsEfl.cmake: Add ENABLE_VIBRATION feature.
* Source/cmakeconfig.h.cmake:

Source/WebCore: Add a new API for the Vibration API(W3C).
https://bugs.webkit.org/show_bug.cgi?id=72010

http://dev.w3.org/2009/dap/vibration/
This patch implements navigator.webkitvibrate() API.
This API operates differently depending upon a given parameter:
1. It cancels vibration when given 0 or [].
2. It gives a vibration duration in milliseconds when given as a single integer value.
3. It gives a vibration pattern when given as an integer array. For instance, [1000 300 1000] generates a vibration of 1000ms followed by 300ms of idle time, and then creates another vibration of 1000ms.

Patch by Kihong Kwon <[email protected]> on 2012-02-20
Reviewed by Hajime Morita.

Test: fast/dom/navigator-vibration.html

* CMakeLists.txt:
* Modules/vibration/NavigatorVibration.cpp: Added.
(WebCore):
(WebCore::NavigatorVibration::NavigatorVibration):
(WebCore::NavigatorVibration::~NavigatorVibration):
(WebCore::NavigatorVibration::webkitVibrate):
Add webkitVibrate method to get an array or single integer parameter for vibrating.
They check vibration is activated in the platform, and then call vibrate() in the Vibration class.
* Modules/vibration/NavigatorVibration.h: Added.
(WebCore):
(NavigatorVibration):
* Modules/vibration/NavigatorVibration.idl: Added.
* Modules/vibration/Vibration.cpp: Added.
This class implements the entire vibration logic.
(WebCore):
(WebCore::Vibration::Vibration):
(WebCore::Vibration::~Vibration):
(WebCore::Vibration::create):
(WebCore::Vibration::vibrate):
(WebCore::Vibration::cancelVibration):
(WebCore::Vibration::suspendVibration):
(WebCore::Vibration::resumeVibration):
(WebCore::Vibration::timerStartFired):
(WebCore::Vibration::timerStopFired):
(WebCore::Vibration::supplementName):
(WebCore::Vibration::isActive):
(WebCore::provideVibrationTo):
* Modules/vibration/Vibration.h: Added.
(WebCore):
(Vibration):
(WebCore::Vibration::from):
* Modules/vibration/VibrationClient.h: Added.
vibrate() and cancelVibrate() need to be implemented in the VibrationClient.
(WebCore):
(VibrationClient):
(WebCore::VibrationClient::~VibrationClient):

Source/WebKit/efl: Add a new API for the Vibration API(W3C).
https://bugs.webkit.org/show_bug.cgi?id=72010

Patch by Kihong Kwon <[email protected]> on 2012-02-20
Reviewed by Hajime Morita.

Implementation for the Vibration API feature to the EFL-port layer.
http://dev.w3.org/2009/dap/vibration/
There are two methods for vibration API.
- vibrate : Vibrate device for receiving as a parameter.
- cancelVibrate : Cancel current vibration.

* CMakeListsEfl.txt:
* WebCoreSupport/VibrationClientEfl.cpp: Added.
(WebCore):
(WebCore::VibrationClientEfl::VibrationClientEfl):
(WebCore::VibrationClientEfl::vibrate):
(WebCore::VibrationClientEfl::cancelVibration):
(WebCore::VibrationClientEfl::vibrationDestroyed):
* WebCoreSupport/VibrationClientEfl.h: Added.
(WebCore):
(VibrationClientEfl):
(WebCore::VibrationClientEfl::~VibrationClientEfl):
* ewk/ewk_view.cpp:
(_Ewk_View_Private_Data):
(_ewk_view_priv_new):

Tools: Add a new API for the Vibration API(W3C).
https://bugs.webkit.org/show_bug.cgi?id=72010

Patch by Kihong Kwon <[email protected]> on 2012-02-20
Reviewed by Hajime Morita.

* Scripts/build-webkit: Enable ENABLE_VIBRATION feature.

LayoutTests: Add a new test case for the Vibration API.
https://bugs.webkit.org/show_bug.cgi?id=72010

Patch by Kihong Kwon <[email protected]> on 2012-02-20
Reviewed by Hajime Morita.

* fast/dom/navigator-vibration-expected.txt: Added.
* fast/dom/navigator-vibration.html: Added.
* platform/chromium/test_expectations.txt:
* platform/gtk/Skipped:
* platform/mac/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
* platform/wincairo/Skipped:

Modified Paths

Added Paths

Diff

Modified: trunk/ChangeLog (108271 => 108272)


--- trunk/ChangeLog	2012-02-21 00:57:20 UTC (rev 108271)
+++ trunk/ChangeLog	2012-02-21 01:05:11 UTC (rev 108272)
@@ -1,3 +1,16 @@
+2012-02-20  Kihong Kwon  <[email protected]>
+
+        Add a new API for the Vibration API(W3C).
+        https://bugs.webkit.org/show_bug.cgi?id=72010
+
+        Reviewed by Hajime Morita.
+
+        Add Implementation for the Vibration API to the WebKit-EFL port.
+        http://dev.w3.org/2009/dap/vibration/
+
+        * Source/cmake/OptionsEfl.cmake: Add ENABLE_VIBRATION feature.
+        * Source/cmakeconfig.h.cmake:
+
 2012-02-19  Ryosuke Niwa  <[email protected]>
 
         Move more logic from handler classes to model classes and add unit tests

Modified: trunk/LayoutTests/ChangeLog (108271 => 108272)


--- trunk/LayoutTests/ChangeLog	2012-02-21 00:57:20 UTC (rev 108271)
+++ trunk/LayoutTests/ChangeLog	2012-02-21 01:05:11 UTC (rev 108272)
@@ -1,3 +1,19 @@
+2012-02-20  Kihong Kwon  <[email protected]>
+
+        Add a new test case for the Vibration API.
+        https://bugs.webkit.org/show_bug.cgi?id=72010
+
+        Reviewed by Hajime Morita.
+
+        * fast/dom/navigator-vibration-expected.txt: Added.
+        * fast/dom/navigator-vibration.html: Added.
+        * platform/chromium/test_expectations.txt:
+        * platform/gtk/Skipped:
+        * platform/mac/Skipped:
+        * platform/qt/Skipped:
+        * platform/win/Skipped:
+        * platform/wincairo/Skipped:
+
 2012-02-20  David Barton  <[email protected]>
 
         RenderMathMLRow::baselinePosition() only if linePositionMode == PositionOnContainingLine

Added: trunk/LayoutTests/fast/dom/navigator-vibration-expected.txt (0 => 108272)


--- trunk/LayoutTests/fast/dom/navigator-vibration-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/navigator-vibration-expected.txt	2012-02-21 01:05:11 UTC (rev 108272)
@@ -0,0 +1,15 @@
+Test for the Vibration API.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS navigator.webkitVibrate(0); is undefined
+PASS navigator.webkitVibrate([]); is undefined
+PASS navigator.webkitVibrate(1000); is undefined
+PASS navigator.webkitVibrate([1000, 300, 500]); is undefined
+PASS navigator.webkitVibrate(4294967295); is undefined
+PASS navigator.webkitVibrate(); threw exception TypeError: Type error.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/navigator-vibration.html (0 => 108272)


--- trunk/LayoutTests/fast/dom/navigator-vibration.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/navigator-vibration.html	2012-02-21 01:05:11 UTC (rev 108272)
@@ -0,0 +1,18 @@
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+description('Test for the Vibration API.');
+
+shouldBe("navigator.webkitVibrate(0);", "undefined");
+shouldBe("navigator.webkitVibrate([]);", "undefined");
+shouldBe("navigator.webkitVibrate(1000);", "undefined");
+shouldBe("navigator.webkitVibrate([1000, 300, 500]);", "undefined");
+shouldBe("navigator.webkitVibrate(4294967295);", "undefined");
+shouldThrow("navigator.webkitVibrate();");
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (108271 => 108272)


--- trunk/LayoutTests/platform/chromium/test_expectations.txt	2012-02-21 00:57:20 UTC (rev 108271)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt	2012-02-21 01:05:11 UTC (rev 108272)
@@ -112,6 +112,9 @@
 // New test, needs baselines.
 
 
+// Vibration API is not supported yet in the chromium port.
+BUGWK72010 SKIP : fast/dom/navigator-vibration.html = FAIL
+
 // -----------------------------------------------------------------
 // WONTFIX TESTS
 // -----------------------------------------------------------------

Modified: trunk/LayoutTests/platform/gtk/Skipped (108271 => 108272)


--- trunk/LayoutTests/platform/gtk/Skipped	2012-02-21 00:57:20 UTC (rev 108271)
+++ trunk/LayoutTests/platform/gtk/Skipped	2012-02-21 01:05:11 UTC (rev 108272)
@@ -396,6 +396,9 @@
 http/tests/security/webgl-remote-read-remote-image-blocked-no-crossorigin.html
 http/tests/security/webgl-remote-read-remote-image-allowed-with-credentials.html
 
+#Vibration API support not yet. http://webkit.org/b/72010
+fast/dom/navigator-vibration.html
+
 ###############################################################################
 # TESTS FAILING
 ###############################################################################

Modified: trunk/LayoutTests/platform/mac/Skipped (108271 => 108272)


--- trunk/LayoutTests/platform/mac/Skipped	2012-02-21 00:57:20 UTC (rev 108271)
+++ trunk/LayoutTests/platform/mac/Skipped	2012-02-21 01:05:11 UTC (rev 108272)
@@ -553,3 +553,7 @@
 # Fails because MutationObservers are not notified at end-of-task
 # https://bugs.webkit.org/show_bug.cgi?id=78290
 fast/mutation/end-of-task-delivery.html
+
+# https://bugs.webkit.org/show_bug.cgi?id=72010
+# Needs PageClients::vibrationClient() implementation.
+fast/dom/navigator-vibration.html

Modified: trunk/LayoutTests/platform/qt/Skipped (108271 => 108272)


--- trunk/LayoutTests/platform/qt/Skipped	2012-02-21 00:57:20 UTC (rev 108271)
+++ trunk/LayoutTests/platform/qt/Skipped	2012-02-21 01:05:11 UTC (rev 108272)
@@ -331,6 +331,9 @@
 # https://bugs.webkit.org/show_bug.cgi?id=72363
 fast/dom/Window/window-postmessage-arrays.html
 
+#Vibration API is not implemented.
+fast/dom/navigator-vibration.html
+
 # =========================================================================== #
 #       Drag and Drop Support in DRT.                                         #
 # =========================================================================== #

Modified: trunk/LayoutTests/platform/win/Skipped (108271 => 108272)


--- trunk/LayoutTests/platform/win/Skipped	2012-02-21 00:57:20 UTC (rev 108271)
+++ trunk/LayoutTests/platform/win/Skipped	2012-02-21 01:05:11 UTC (rev 108272)
@@ -1651,3 +1651,6 @@
 fast/inline/continuation-outlines-with-layers-2.html
 fast/inline/continuation-outlines-with-layers.html
 fast/repaint/transform-absolute-in-positioned-container.html
+
+#Vibration API is not implemented.
+fast/dom/navigator-vibration.html

Modified: trunk/LayoutTests/platform/wincairo/Skipped (108271 => 108272)


--- trunk/LayoutTests/platform/wincairo/Skipped	2012-02-21 00:57:20 UTC (rev 108271)
+++ trunk/LayoutTests/platform/wincairo/Skipped	2012-02-21 01:05:11 UTC (rev 108272)
@@ -2048,3 +2048,6 @@
 # Fails because MutationObservers are not notified at end-of-task
 # https://bugs.webkit.org/show_bug.cgi?id=78290
 fast/mutation/end-of-task-delivery.html
+
+#Vibration API is not implemented.
+fast/dom/navigator-vibration.html

Modified: trunk/Source/WebCore/CMakeLists.txt (108271 => 108272)


--- trunk/Source/WebCore/CMakeLists.txt	2012-02-21 00:57:20 UTC (rev 108271)
+++ trunk/Source/WebCore/CMakeLists.txt	2012-02-21 01:05:11 UTC (rev 108272)
@@ -2252,6 +2252,19 @@
     )
 ENDIF ()
 
+IF (ENABLE_VIBRATION)
+    LIST(APPEND WebCore_INCLUDE_DIRECTORIES
+        ${WEBCORE_DIR}/Modules/vibration
+    )
+    LIST(APPEND WebCore_IDL_FILES
+        Modules/vibration/NavigatorVibration.idl
+    )
+    LIST(APPEND WebCore_SOURCES
+        Modules/vibration/NavigatorVibration.cpp
+        Modules/vibration/Vibration.cpp
+    )
+ENDIF ()
+
 # Modules that the bindings generator scripts may use
 SET(SCRIPTS_RESOLVE_SUPPLEMENTAL
     ${WEBCORE_DIR}/bindings/scripts/IDLParser.pm

Modified: trunk/Source/WebCore/ChangeLog (108271 => 108272)


--- trunk/Source/WebCore/ChangeLog	2012-02-21 00:57:20 UTC (rev 108271)
+++ trunk/Source/WebCore/ChangeLog	2012-02-21 01:05:11 UTC (rev 108272)
@@ -1,3 +1,56 @@
+2012-02-20  Kihong Kwon  <[email protected]>
+
+        Add a new API for the Vibration API(W3C).
+        https://bugs.webkit.org/show_bug.cgi?id=72010
+
+        http://dev.w3.org/2009/dap/vibration/
+        This patch implements navigator.webkitvibrate() API.
+        This API operates differently depending upon a given parameter:
+        1. It cancels vibration when given 0 or [].
+        2. It gives a vibration duration in milliseconds when given as a single integer value.
+        3. It gives a vibration pattern when given as an integer array. For instance, [1000 300 1000] generates a vibration of 1000ms followed by 300ms of idle time, and then creates another vibration of 1000ms.
+
+        Reviewed by Hajime Morita.
+
+        Test: fast/dom/navigator-vibration.html
+
+        * CMakeLists.txt:
+        * Modules/vibration/NavigatorVibration.cpp: Added.
+        (WebCore):
+        (WebCore::NavigatorVibration::NavigatorVibration):
+        (WebCore::NavigatorVibration::~NavigatorVibration):
+        (WebCore::NavigatorVibration::webkitVibrate):
+        Add webkitVibrate method to get an array or single integer parameter for vibrating.
+        They check vibration is activated in the platform, and then call vibrate() in the Vibration class.
+        * Modules/vibration/NavigatorVibration.h: Added.
+        (WebCore):
+        (NavigatorVibration):
+        * Modules/vibration/NavigatorVibration.idl: Added.
+        * Modules/vibration/Vibration.cpp: Added.
+        This class implements the entire vibration logic.
+        (WebCore):
+        (WebCore::Vibration::Vibration):
+        (WebCore::Vibration::~Vibration):
+        (WebCore::Vibration::create):
+        (WebCore::Vibration::vibrate):
+        (WebCore::Vibration::cancelVibration):
+        (WebCore::Vibration::suspendVibration):
+        (WebCore::Vibration::resumeVibration):
+        (WebCore::Vibration::timerStartFired):
+        (WebCore::Vibration::timerStopFired):
+        (WebCore::Vibration::supplementName):
+        (WebCore::Vibration::isActive):
+        (WebCore::provideVibrationTo):
+        * Modules/vibration/Vibration.h: Added.
+        (WebCore):
+        (Vibration):
+        (WebCore::Vibration::from):
+        * Modules/vibration/VibrationClient.h: Added.
+        vibrate() and cancelVibrate() need to be implemented in the VibrationClient.
+        (WebCore):
+        (VibrationClient):
+        (WebCore::VibrationClient::~VibrationClient):
+
 2012-02-20  Yuta Kitamura  <[email protected]>
 
         Unreviewed, rolling out r108263.

Added: trunk/Source/WebCore/Modules/vibration/NavigatorVibration.cpp (0 => 108272)


--- trunk/Source/WebCore/Modules/vibration/NavigatorVibration.cpp	                        (rev 0)
+++ trunk/Source/WebCore/Modules/vibration/NavigatorVibration.cpp	2012-02-21 01:05:11 UTC (rev 108272)
@@ -0,0 +1,81 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "NavigatorVibration.h"
+
+#if ENABLE(VIBRATION)
+
+#include "ExceptionCode.h"
+#include "Frame.h"
+#include "Navigator.h"
+#include "Page.h"
+#include "Vibration.h"
+#include <wtf/Uint32Array.h>
+
+namespace WebCore {
+
+NavigatorVibration::NavigatorVibration()
+{
+}
+
+NavigatorVibration::~NavigatorVibration()
+{
+}
+
+void NavigatorVibration::webkitVibrate(Navigator* navigator, unsigned long time, ExceptionCode& ec)
+{
+    if (!navigator->frame()->page())
+        return;
+
+#if ENABLE(PAGE_VISIBILITY_API)
+    if (navigator->frame()->page()->visibilityState() == PageVisibilityStateHidden)
+        return;
+#endif
+
+    if (!Vibration::isActive(navigator->frame()->page())) {
+        ec = NOT_SUPPORTED_ERR;
+        return;
+    }
+
+    Vibration::from(navigator->frame()->page())->vibrate(time);
+}
+
+void NavigatorVibration::webkitVibrate(Navigator* navigator, const VibrationPattern& pattern, ExceptionCode& ec)
+{
+    if (!navigator->frame()->page())
+        return;
+
+#if ENABLE(PAGE_VISIBILITY_API)
+    if (navigator->frame()->page()->visibilityState() == PageVisibilityStateHidden)
+        return;
+#endif
+
+    if (!Vibration::isActive(navigator->frame()->page())) {
+        ec = NOT_SUPPORTED_ERR;
+        return;
+    }
+
+    Vibration::from(navigator->frame()->page())->vibrate(pattern);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(VIBRATION)
+

Added: trunk/Source/WebCore/Modules/vibration/NavigatorVibration.h (0 => 108272)


--- trunk/Source/WebCore/Modules/vibration/NavigatorVibration.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/vibration/NavigatorVibration.h	2012-02-21 01:05:11 UTC (rev 108272)
@@ -0,0 +1,50 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef NavigatorVibration_h
+#define NavigatorVibration_h
+
+#if ENABLE(VIBRATION)
+
+#include "ExceptionCode.h"
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class Navigator;
+class Uint32Array;
+
+class NavigatorVibration {
+public:
+    typedef Vector<unsigned long> VibrationPattern;
+
+    static void webkitVibrate(Navigator*, unsigned long time, ExceptionCode&);
+    static void webkitVibrate(Navigator*, const VibrationPattern&, ExceptionCode&);
+
+private:
+    NavigatorVibration();
+    ~NavigatorVibration();
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(VIBRATION)
+
+#endif // NavigatorVibration_h
+

Added: trunk/Source/WebCore/Modules/vibration/NavigatorVibration.idl (0 => 108272)


--- trunk/Source/WebCore/Modules/vibration/NavigatorVibration.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/vibration/NavigatorVibration.idl	2012-02-21 01:05:11 UTC (rev 108272)
@@ -0,0 +1,30 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+module window {
+
+    interface [
+        Conditional=VIBRATION,
+        Supplemental=Navigator
+    ] NavigatorVibration {
+        void webkitVibrate(in unsigned long[] pattern) raises(DOMException);
+        void webkitVibrate(in unsigned long time) raises(DOMException);
+    };
+
+}

Added: trunk/Source/WebCore/Modules/vibration/Vibration.cpp (0 => 108272)


--- trunk/Source/WebCore/Modules/vibration/Vibration.cpp	                        (rev 0)
+++ trunk/Source/WebCore/Modules/vibration/Vibration.cpp	2012-02-21 01:05:11 UTC (rev 108272)
@@ -0,0 +1,144 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "Vibration.h"
+
+#if ENABLE(VIBRATION)
+
+#include "VibrationClient.h"
+
+namespace WebCore {
+
+Vibration::Vibration(VibrationClient* client)
+    : m_vibrationClient(client)
+    , m_timerStart(this, &Vibration::timerStartFired)
+    , m_timerStop(this, &Vibration::timerStopFired)
+    , m_isVibrating(false)
+{
+}
+
+Vibration::~Vibration()
+{
+    m_vibrationClient->vibrationDestroyed();
+}
+
+PassOwnPtr<Vibration> Vibration::create(VibrationClient* client)
+{
+    return adoptPtr(new Vibration(client));
+}
+
+void Vibration::vibrate(const unsigned long& time)
+{
+    if (!time) {
+        cancelVibration();
+        return;
+    }
+    m_pattern.append(time);
+    m_timerStart.startOneShot(0);
+}
+
+void Vibration::vibrate(const VibrationPattern& pattern)
+{
+    int length = pattern.size();
+
+    if (m_isVibrating)
+        cancelVibration();
+
+    if (!length || (length == 1 && !pattern[0]))
+        return;
+
+    if (m_timerStart.isActive())
+        m_timerStart.stop();
+
+    m_pattern = pattern;
+    m_timerStart.startOneShot(0);
+}
+
+void Vibration::cancelVibration()
+{
+    if (m_isVibrating) {
+        m_vibrationClient->cancelVibration();
+        m_isVibrating = false;
+        m_timerStop.stop();
+    }
+}
+
+void Vibration::suspendVibration()
+{
+    if (!m_isVibrating)
+        return;
+
+    m_pattern.insert(0, m_timerStop.nextFireInterval());
+    m_timerStop.stop();
+    cancelVibration();
+}
+
+void Vibration::resumeVibration()
+{
+    m_timerStart.startOneShot(0);
+}
+
+void Vibration::timerStartFired(Timer<Vibration>* timer)
+{
+    ASSERT_UNUSED(timer, timer == &m_timerStart);
+
+    m_timerStart.stop();
+
+    if (m_pattern.size()) {
+        m_isVibrating = true;
+        m_vibrationClient->vibrate(m_pattern[0]);
+        m_timerStop.startOneShot(m_pattern[0] / 1000.0);
+        m_pattern.remove(0);
+    }
+}
+
+void Vibration::timerStopFired(Timer<Vibration>* timer)
+{
+    ASSERT_UNUSED(timer, timer == &m_timerStop);
+
+    m_timerStop.stop();
+    m_isVibrating = false;
+
+    if (m_pattern.size()) {
+        m_timerStart.startOneShot(m_pattern[0] / 1000.0);
+        m_pattern.remove(0);
+    }
+}
+
+const AtomicString& Vibration::supplementName()
+{
+    DEFINE_STATIC_LOCAL(AtomicString, name, ("vibration"));
+    return name;
+}
+
+bool Vibration::isActive(Page* page)
+{
+    return static_cast<bool>(Vibration::from(page));
+}
+
+void provideVibrationTo(Page* page, VibrationClient* client)
+{
+    PageSupplement::provideTo(page, Vibration::supplementName(), Vibration::create(client));
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(VIBRATION)
+

Added: trunk/Source/WebCore/Modules/vibration/Vibration.h (0 => 108272)


--- trunk/Source/WebCore/Modules/vibration/Vibration.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/vibration/Vibration.h	2012-02-21 01:05:11 UTC (rev 108272)
@@ -0,0 +1,71 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef Vibration_h
+#define Vibration_h
+
+#if ENABLE(VIBRATION)
+
+#include "PageSupplement.h"
+#include "Timer.h"
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+
+class Navigator;
+class Page;
+class VibrationClient;
+
+class Vibration : public PageSupplement {
+public:
+    typedef Vector<unsigned long> VibrationPattern;
+
+    Vibration(VibrationClient*);
+    ~Vibration();
+
+    static PassOwnPtr<Vibration> create(VibrationClient*);
+
+    void vibrate(const unsigned long& time);
+    void vibrate(const VibrationPattern&);
+    void cancelVibration();
+
+    // FIXME : Add suspendVibration() and resumeVibration() to the page visibility feature, when the document.hidden attribute is changed.
+    void suspendVibration();
+    void resumeVibration();
+    void timerStartFired(Timer<Vibration>*);
+    void timerStopFired(Timer<Vibration>*);
+
+    static const AtomicString& supplementName();
+    static Vibration* from(Page* page) { return static_cast<Vibration*>(PageSupplement::from(page, supplementName())); }
+    static bool isActive(Page*);
+
+private:
+    VibrationClient* m_vibrationClient;
+    Timer<Vibration> m_timerStart;
+    Timer<Vibration> m_timerStop;
+    bool m_isVibrating;
+    VibrationPattern m_pattern;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(VIBRATION)
+
+#endif // Vibration_h
+

Added: trunk/Source/WebCore/Modules/vibration/VibrationClient.h (0 => 108272)


--- trunk/Source/WebCore/Modules/vibration/VibrationClient.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/vibration/VibrationClient.h	2012-02-21 01:05:11 UTC (rev 108272)
@@ -0,0 +1,42 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef VibrationClient_h
+#define VibrationClient_h
+
+namespace WebCore {
+
+class Page;
+
+class VibrationClient {
+public:
+    virtual ~VibrationClient() { }
+
+    virtual void vibrate(const unsigned long& time) = 0;
+    virtual void cancelVibration() = 0;
+
+    virtual void vibrationDestroyed() = 0;
+};
+
+void provideVibrationTo(Page*, VibrationClient*);
+
+} // namespace WebCore
+
+#endif // VibrationClient_h
+

Modified: trunk/Source/WebKit/efl/CMakeListsEfl.txt (108271 => 108272)


--- trunk/Source/WebKit/efl/CMakeListsEfl.txt	2012-02-21 00:57:20 UTC (rev 108271)
+++ trunk/Source/WebKit/efl/CMakeListsEfl.txt	2012-02-21 01:05:11 UTC (rev 108272)
@@ -115,6 +115,16 @@
     ${LIBSOUP24_LIBRARIES}
 )
 
+IF (ENABLE_VIBRATION)
+    LIST(APPEND WebKit_INCLUDE_DIRECTORIES
+        ${WEBCORE_DIR}/Modules/vibration
+    )
+    LIST(APPEND WebKit_SOURCES
+        efl/WebCoreSupport/VibrationClientEfl.cpp
+    )
+ENDIF ()
+
+
 SET(WebKit_THEME_DEFINITION "")
 IF (ENABLE_PROGRESS_TAG)
   LIST(APPEND WebKit_THEME_DEFINITION "-DENABLE_PROGRESS_TAG")

Modified: trunk/Source/WebKit/efl/ChangeLog (108271 => 108272)


--- trunk/Source/WebKit/efl/ChangeLog	2012-02-21 00:57:20 UTC (rev 108271)
+++ trunk/Source/WebKit/efl/ChangeLog	2012-02-21 01:05:11 UTC (rev 108272)
@@ -1,3 +1,31 @@
+2012-02-20  Kihong Kwon  <[email protected]>
+
+        Add a new API for the Vibration API(W3C).
+        https://bugs.webkit.org/show_bug.cgi?id=72010
+
+        Reviewed by Hajime Morita.
+
+        Implementation for the Vibration API feature to the EFL-port layer.
+        http://dev.w3.org/2009/dap/vibration/
+        There are two methods for vibration API.
+        - vibrate : Vibrate device for receiving as a parameter.
+        - cancelVibrate : Cancel current vibration.
+
+        * CMakeListsEfl.txt:
+        * WebCoreSupport/VibrationClientEfl.cpp: Added.
+        (WebCore):
+        (WebCore::VibrationClientEfl::VibrationClientEfl):
+        (WebCore::VibrationClientEfl::vibrate):
+        (WebCore::VibrationClientEfl::cancelVibration):
+        (WebCore::VibrationClientEfl::vibrationDestroyed):
+        * WebCoreSupport/VibrationClientEfl.h: Added.
+        (WebCore):
+        (VibrationClientEfl):
+        (WebCore::VibrationClientEfl::~VibrationClientEfl):
+        * ewk/ewk_view.cpp:
+        (_Ewk_View_Private_Data):
+        (_ewk_view_priv_new):
+
 2012-02-17  Raphael Kubo da Costa  <[email protected]>
 
         [EFL] Unreviewed, adapt to the changes introduced in r107973.

Added: trunk/Source/WebKit/efl/WebCoreSupport/VibrationClientEfl.cpp (0 => 108272)


--- trunk/Source/WebKit/efl/WebCoreSupport/VibrationClientEfl.cpp	                        (rev 0)
+++ trunk/Source/WebKit/efl/WebCoreSupport/VibrationClientEfl.cpp	2012-02-21 01:05:11 UTC (rev 108272)
@@ -0,0 +1,50 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "VibrationClientEfl.h"
+
+#if ENABLE(VIBRATION)
+
+namespace WebCore {
+
+VibrationClientEfl::VibrationClientEfl(Evas_Object* view)
+    : m_view(view)
+{
+}
+
+void VibrationClientEfl::vibrate(const unsigned long& time)
+{
+    evas_object_smart_callback_call(m_view, "vibration,vibrate", (void*)&time);
+}
+
+void VibrationClientEfl::cancelVibration()
+{
+    evas_object_smart_callback_call(m_view, "vibration,cancel", 0);
+}
+
+void VibrationClientEfl::vibrationDestroyed()
+{
+    delete this;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(VIBRATION)
+

Added: trunk/Source/WebKit/efl/WebCoreSupport/VibrationClientEfl.h (0 => 108272)


--- trunk/Source/WebKit/efl/WebCoreSupport/VibrationClientEfl.h	                        (rev 0)
+++ trunk/Source/WebKit/efl/WebCoreSupport/VibrationClientEfl.h	2012-02-21 01:05:11 UTC (rev 108272)
@@ -0,0 +1,45 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef VibrationClientEfl_h
+#define VibrationClientEfl_h
+
+#include "VibrationClient.h"
+#include <Evas.h>
+
+namespace WebCore {
+
+class VibrationClientEfl : public VibrationClient {
+public:
+    VibrationClientEfl(Evas_Object* view);
+    virtual ~VibrationClientEfl() { }
+
+    virtual void vibrate(const unsigned long& time);
+    virtual void cancelVibration();
+
+    virtual void vibrationDestroyed();
+
+private:
+    Evas_Object* m_view;
+};
+
+} // namespace WebCore
+
+#endif // VibrationClientEfl_h
+

Modified: trunk/Source/WebKit/efl/ewk/ewk_view.cpp (108271 => 108272)


--- trunk/Source/WebKit/efl/ewk/ewk_view.cpp	2012-02-21 00:57:20 UTC (rev 108271)
+++ trunk/Source/WebKit/efl/ewk/ewk_view.cpp	2012-02-21 01:05:11 UTC (rev 108272)
@@ -1,6 +1,6 @@
 /*
     Copyright (C) 2009-2010 ProFUSION embedded systems
-    Copyright (C) 2009-2011 Samsung Electronics
+    Copyright (C) 2009-2012 Samsung Electronics
 
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Library General Public
@@ -70,6 +70,10 @@
 #include "DeviceOrientationClientEfl.h"
 #endif
 
+#if ENABLE(VIBRATION)
+#include "VibrationClientEfl.h"
+#endif
+
 static const float zoomMinimum = 0.05;
 static const float zoomMaximum = 4.0;
 
@@ -617,6 +621,10 @@
     WebCore::provideDeviceOrientationTo(priv->page, new WebCore::DeviceOrientationClientEfl);
 #endif
 
+#if ENABLE(VIBRATION)
+    WebCore::provideVibrationTo(priv->page, new WebCore::VibrationClientEfl(smartData->self));
+#endif
+
     priv->pageSettings = priv->page->settings();
     if (!priv->pageSettings) {
         CRITICAL("Could not get page settings.");

Modified: trunk/Source/cmake/OptionsEfl.cmake (108271 => 108272)


--- trunk/Source/cmake/OptionsEfl.cmake	2012-02-21 00:57:20 UTC (rev 108271)
+++ trunk/Source/cmake/OptionsEfl.cmake	2012-02-21 01:05:11 UTC (rev 108272)
@@ -95,6 +95,7 @@
 WEBKIT_FEATURE(ENABLE_SVG_FONTS "Enable SVG fonts" DEFAULT ON)
 WEBKIT_FEATURE(ENABLE_TOUCH_EVENTS "Enable Touch Events" DEFAULT OFF)
 WEBKIT_FEATURE(ENABLE_TOUCH_ICON_LOADING "Enable Touch Icon Loading" DEFAULT OFF)
+WEBKIT_FEATURE(ENABLE_VIBRATION "Enable vibration" DEFAULT ON)
 WEBKIT_FEATURE(ENABLE_VIDEO "Enable video" DEFAULT ON)
 WEBKIT_FEATURE(ENABLE_WEB_SOCKETS "Enable web sockets" DEFAULT ON)
 WEBKIT_FEATURE(ENABLE_WEBGL "Enable WebGL" DEFAULT OFF)

Modified: trunk/Source/cmakeconfig.h.cmake (108271 => 108272)


--- trunk/Source/cmakeconfig.h.cmake	2012-02-21 00:57:20 UTC (rev 108271)
+++ trunk/Source/cmakeconfig.h.cmake	2012-02-21 01:05:11 UTC (rev 108272)
@@ -39,6 +39,7 @@
 #cmakedefine01 ENABLE_SVG_FONTS
 #cmakedefine01 ENABLE_TOUCH_EVENTS
 #cmakedefine01 ENABLE_TOUCH_ICON_LOADING
+#cmakedefine01 ENABLE_VIBRATION
 #cmakedefine01 ENABLE_VIDEO
 #cmakedefine01 ENABLE_WEBGL
 #cmakedefine01 ENABLE_WEB_SOCKETS

Modified: trunk/Tools/ChangeLog (108271 => 108272)


--- trunk/Tools/ChangeLog	2012-02-21 00:57:20 UTC (rev 108271)
+++ trunk/Tools/ChangeLog	2012-02-21 01:05:11 UTC (rev 108272)
@@ -1,3 +1,12 @@
+2012-02-20  Kihong Kwon  <[email protected]>
+
+        Add a new API for the Vibration API(W3C).
+        https://bugs.webkit.org/show_bug.cgi?id=72010
+
+        Reviewed by Hajime Morita.
+
+        * Scripts/build-webkit: Enable ENABLE_VIBRATION feature.
+
 2012-02-20  János Badics  <[email protected]>
 
         [Qt] run-qtwebkit-tests doesn't consider timeouts as failures

Modified: trunk/Tools/Scripts/build-webkit (108271 => 108272)


--- trunk/Tools/Scripts/build-webkit	2012-02-21 00:57:20 UTC (rev 108271)
+++ trunk/Tools/Scripts/build-webkit	2012-02-21 01:05:11 UTC (rev 108272)
@@ -128,6 +128,7 @@
     $tiledBackingStoreSupport,
     $touchEventsSupport,
     $touchIconLoadingSupport,
+    $vibrationSupport,
     $videoSupport,
     $videoTrackSupport,
     $webAudioSupport,
@@ -329,6 +330,9 @@
     { option => "touch-icon-loading", desc => "Toggle Touch Icon Loading Support",
       define => "ENABLE_TOUCH_ICON_LOADING", default => 0, value => \$touchIconLoadingSupport },
 
+    { option => "vibration", desc => "Toggle Video support",
+      define => "ENABLE_VIBRATION", default => isEfl(), value => \$vibrationSupport },
+
     { option => "video", desc => "Toggle Video support",
       define => "ENABLE_VIDEO", default => (isAppleWebKit() || isGtk() || isBlackBerry() || isEfl()), value => \$videoSupport },
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to