.: Add a new API for the Vibration API(W3C).
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Feb 2012 01:05:11 +0000 (01:05 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Feb 2012 01:05:11 +0000 (01:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=72010

Patch by Kihong Kwon <kihong.kwon@samsung.com> 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 <kihong.kwon@samsung.com> 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 <kihong.kwon@samsung.com> 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 <kihong.kwon@samsung.com> 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 <kihong.kwon@samsung.com> 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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108272 268f45cc-cd09-0410-ab3c-d52691b4dbfc

27 files changed:
ChangeLog
LayoutTests/ChangeLog
LayoutTests/fast/dom/navigator-vibration-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/navigator-vibration.html [new file with mode: 0644]
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/gtk/Skipped
LayoutTests/platform/mac/Skipped
LayoutTests/platform/qt/Skipped
LayoutTests/platform/win/Skipped
LayoutTests/platform/wincairo/Skipped
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/vibration/NavigatorVibration.cpp [new file with mode: 0644]
Source/WebCore/Modules/vibration/NavigatorVibration.h [new file with mode: 0644]
Source/WebCore/Modules/vibration/NavigatorVibration.idl [new file with mode: 0644]
Source/WebCore/Modules/vibration/Vibration.cpp [new file with mode: 0644]
Source/WebCore/Modules/vibration/Vibration.h [new file with mode: 0644]
Source/WebCore/Modules/vibration/VibrationClient.h [new file with mode: 0644]
Source/WebKit/efl/CMakeListsEfl.txt
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/WebCoreSupport/VibrationClientEfl.cpp [new file with mode: 0644]
Source/WebKit/efl/WebCoreSupport/VibrationClientEfl.h [new file with mode: 0644]
Source/WebKit/efl/ewk/ewk_view.cpp
Source/cmake/OptionsEfl.cmake
Source/cmakeconfig.h.cmake
Tools/ChangeLog
Tools/Scripts/build-webkit

index 2150509b3a00136dcfecf1887494e7de76d484c0..b3fdb20b3d383da50c33b0cefd36476d19bb136f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2012-02-20  Kihong Kwon  <kihong.kwon@samsung.com>
+
+        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  <rniwa@webkit.org>
 
         Move more logic from handler classes to model classes and add unit tests
index f0ec4be076ec94f6c69a41009ffd2dddb8f9d7ef..45c289be3bbe8864a00217a8d5e4ade9dccd15e4 100644 (file)
@@ -1,3 +1,19 @@
+2012-02-20  Kihong Kwon  <kihong.kwon@samsung.com>
+
+        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  <dbarton@mathscribe.com>
 
         RenderMathMLRow::baselinePosition() only if linePositionMode == PositionOnContainingLine
diff --git a/LayoutTests/fast/dom/navigator-vibration-expected.txt b/LayoutTests/fast/dom/navigator-vibration-expected.txt
new file mode 100644 (file)
index 0000000..c70bc8e
--- /dev/null
@@ -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
+
diff --git a/LayoutTests/fast/dom/navigator-vibration.html b/LayoutTests/fast/dom/navigator-vibration.html
new file mode 100644 (file)
index 0000000..a04fddd
--- /dev/null
@@ -0,0 +1,18 @@
+<html>
+<head>
+<script src="../js/resources/js-test-pre.js"></script>
+</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="../js/resources/js-test-post.js"></script>
+</body>
+</html>
index d0227dcd71eb00c731d6f8b4162efa8b215330d5..0157d5602394eff9c057831d7171cb05988f5609 100644 (file)
@@ -112,6 +112,9 @@ BUGNOEL : svg/carto.net/selectionlist.svg = IMAGE+TEXT IMAGE
 // New test, needs baselines.
 
 
+// Vibration API is not supported yet in the chromium port.
+BUGWK72010 SKIP : fast/dom/navigator-vibration.html = FAIL
+
 // -----------------------------------------------------------------
 // WONTFIX TESTS
 // -----------------------------------------------------------------
index 48851322dd47b1595a92cbe5f3e8be96970226c2..98ac288afe49779558d2fac3565ad8ed2fff225e 100644 (file)
@@ -396,6 +396,9 @@ http/tests/security/webgl-remote-read-remote-image-allowed.html
 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
 ###############################################################################
index 3bb6248fac190fcaa847d32e87ece0f34f0ab686..e286761c46844fc76788a673b096cc33751978c8 100644 (file)
@@ -553,3 +553,7 @@ media/W3C/video/canPlayType/canPlayType_two_implies_one_6.html
 # 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
index f1c5c3cd3ed62931ca940afddad1d4f2566ff486..e9c852a449e576e3794e8219be0f574f45605620 100644 (file)
@@ -331,6 +331,9 @@ fast/parser/pre-html5-parser-quirks.html
 # 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.                                         #
 # =========================================================================== #
index 808e3f423fe24c3d17143ce201c1b8f03fe08dd2..abee90cd891ca64a959c46e557c5aedccd61bc30 100644 (file)
@@ -1651,3 +1651,6 @@ fast/encoding/utf-16-little-endian.html
 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
index 8db177f17c17c72acd3c63f2083e2818bd25f0df..e6ed879ee09f140421e7ff6743448eee5e6ebb4f 100644 (file)
@@ -2048,3 +2048,6 @@ fast/canvas/webgl/arraybuffer-transfer-of-control.html
 # 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
index 56f104b049e24d62e738ca893a5adae05962ddae..479d3877e026e7456cbae8809bc33de447b84298 100644 (file)
@@ -2252,6 +2252,19 @@ IF (ENABLE_REQUEST_ANIMATION_FRAME)
     )
 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
index 1186f1524b3a3fd3e832821465c7d2855117f144..9d19c89cb55ea9cd65c01277c9af0dceb92e6c2b 100644 (file)
@@ -1,3 +1,56 @@
+2012-02-20  Kihong Kwon  <kihong.kwon@samsung.com>
+
+        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  <yutak@chromium.org>
 
         Unreviewed, rolling out r108263.
diff --git a/Source/WebCore/Modules/vibration/NavigatorVibration.cpp b/Source/WebCore/Modules/vibration/NavigatorVibration.cpp
new file mode 100644 (file)
index 0000000..ae46bff
--- /dev/null
@@ -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)
+
diff --git a/Source/WebCore/Modules/vibration/NavigatorVibration.h b/Source/WebCore/Modules/vibration/NavigatorVibration.h
new file mode 100644 (file)
index 0000000..098f6ad
--- /dev/null
@@ -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
+
diff --git a/Source/WebCore/Modules/vibration/NavigatorVibration.idl b/Source/WebCore/Modules/vibration/NavigatorVibration.idl
new file mode 100644 (file)
index 0000000..624845d
--- /dev/null
@@ -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);
+    };
+
+}
diff --git a/Source/WebCore/Modules/vibration/Vibration.cpp b/Source/WebCore/Modules/vibration/Vibration.cpp
new file mode 100644 (file)
index 0000000..9e52c3d
--- /dev/null
@@ -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)
+
diff --git a/Source/WebCore/Modules/vibration/Vibration.h b/Source/WebCore/Modules/vibration/Vibration.h
new file mode 100644 (file)
index 0000000..27e0736
--- /dev/null
@@ -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
+
diff --git a/Source/WebCore/Modules/vibration/VibrationClient.h b/Source/WebCore/Modules/vibration/VibrationClient.h
new file mode 100644 (file)
index 0000000..ebe6889
--- /dev/null
@@ -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
+
index aefdb9804a715c011d97d1d07233d159e6382f60..daf22876ea3760c60c036cd174eb82a4cdc57ba1 100644 (file)
@@ -115,6 +115,16 @@ LIST(APPEND WebKit_LIBRARIES
     ${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")
index 53dc3569ca8cbaa5b21d37d3f1092d3c110c78aa..861c2cf0ed846a85ece87eb1db3efb8362ec742f 100644 (file)
@@ -1,3 +1,31 @@
+2012-02-20  Kihong Kwon  <kihong.kwon@samsung.com>
+
+        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  <kubo@profusion.mobi>
 
         [EFL] Unreviewed, adapt to the changes introduced in r107973.
diff --git a/Source/WebKit/efl/WebCoreSupport/VibrationClientEfl.cpp b/Source/WebKit/efl/WebCoreSupport/VibrationClientEfl.cpp
new file mode 100644 (file)
index 0000000..2365b72
--- /dev/null
@@ -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)
+
diff --git a/Source/WebKit/efl/WebCoreSupport/VibrationClientEfl.h b/Source/WebKit/efl/WebCoreSupport/VibrationClientEfl.h
new file mode 100644 (file)
index 0000000..e7b0d92
--- /dev/null
@@ -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
+
index 3d4324114c5f809a75a351de8adec880876bb768..8a96740227b188bf64e3e72e9ff8004d0d538c86 100644 (file)
@@ -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
 #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 @@ static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData)
     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.");
index 7df444298820cb34f7eab280eacd6c61527d03fc..42d28b84726fd6cff9f5d12d1308e13b2244ea83 100644 (file)
@@ -95,6 +95,7 @@ WEBKIT_FEATURE(ENABLE_SVG "Enable SVG" DEFAULT ON)
 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)
index 6d3f837947293c1d2530ddb41888e94d65e1b4b8..b632fcc303c3152ef50df144aac81cced8ef9902 100644 (file)
@@ -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
index 2b19f4a5b5336cee90a92f2b27e0d885b8308774..8329f03fab6873aa048596795e7f5d70ea3a8d15 100644 (file)
@@ -1,3 +1,12 @@
+2012-02-20  Kihong Kwon  <kihong.kwon@samsung.com>
+
+        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  <dicska@gmail.com>
 
         [Qt] run-qtwebkit-tests doesn't consider timeouts as failures
index cdf62a07add78e457112eb74573c5a0a6028f0c1..64c478149cdc6aa8a338cba276285e3231d7a7f2 100755 (executable)
@@ -128,6 +128,7 @@ my (
     $tiledBackingStoreSupport,
     $touchEventsSupport,
     $touchIconLoadingSupport,
+    $vibrationSupport,
     $videoSupport,
     $videoTrackSupport,
     $webAudioSupport,
@@ -329,6 +330,9 @@ my @features = (
     { 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 },