Source/WebCore/CMakeLists.txt

@@IF (ENABLE_REQUEST_ANIMATION_FRAME)
22042204 )
22052205ENDIF ()
22062206
 2207IF (ENABLE_VIBRATION)
 2208 LIST(APPEND WebCore_SOURCES
 2209 page/Vibrator.cpp
 2210 )
 2211ENDIF ()
 2212
22072213# Modules that the bindings generator scripts may use
22082214SET(SCRIPTS_BINDINGS
22092215 ${WEBCORE_DIR}/bindings/scripts/IDLParser.pm

Source/WebCore/ChangeLog

 12011-12-22 Kihong Kwon <kihong.kwon@samsung.com>
 2
 3 Add a new API for the Vibration API(W3C).
 4 https://bugs.webkit.org/show_bug.cgi?id=72010
 5 http://dev.w3.org/2009/dap/vibration/
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 No new tests. This feature can't make a test case at all.
 10 There is only one method for vibration without return value.
 11
 12 * CMakeLists.txt:
 13 * UseJSC.cmake:
 14 * bindings/js/JSNavigatorCustom.cpp:
 15 (WebCore::JSNavigator::webkitVibrate):
 16 To get an array type parameter.
 17 There is no way to get an array type parameter.
 18 * page/Navigator.cpp:
 19 (WebCore::Navigator::webkitVibrate):
 20 Handling vibrator operation by various parameter type.
 21 Array for pattern, long for time, '0' or "[]" for cancel.
 22 * page/Navigator.h:
 23 * page/Navigator.idl:
 24 * page/Page.cpp:
 25 (WebCore::Page::Page):
 26 (WebCore::Page::PageClients::PageClients):
 27 * page/Page.h:
 28 (WebCore::Page::vibrator):
 29 * page/Vibrator.cpp: Added.
 30 (WebCore::Vibrator::Vibrator):
 31 (WebCore::Vibrator::vibrate):
 32 Transfer and send a vibrate message for each type of vibration.(For array, long and cancel)
 33 (WebCore::Vibrator::cancelVibrate):
 34 (WebCore::Vibrator::isSupport):
 35 (WebCore::Vibrator::timerFired):
 36 * page/Vibrator.h: Added.
 37 (WebCore::Vibrator::~Vibrator):
 38 * page/VibratorClient.h: Added.
 39 (WebCore::VibratorClient::~VibratorClient):
 40
1412011-12-05 Benjamin Poulain <bpoulain@apple.com>
242
343 Upstream the Cursor implementation of iOS

Source/WebCore/UseJSC.cmake

@@IF (ENABLE_WEBGL)
241241 )
242242ENDIF ()
243243
 244IF (ENABLE_VIBRATION)
 245 LIST(APPEND WebCore_SOURCES
 246 bindings/js/JSNavigatorCustom.cpp
 247 )
 248ENDIF ()
 249
244250LIST(APPEND SCRIPTS_BINDINGS
245251 ${WEBCORE_DIR}/bindings/scripts/CodeGenerator.pm
246252)

Source/WebCore/bindings/js/JSNavigatorCustom.cpp

2525
2626#include "CallbackFunction.h"
2727#include "ExceptionCode.h"
 28#if ENABLE(MEDIA_STREAM)
2829#include "JSNavigatorUserMediaErrorCallback.h"
2930#include "JSNavigatorUserMediaSuccessCallback.h"
 31#endif
3032#include "Navigator.h"
3133
3234namespace WebCore {

@@JSValue JSNavigator::webkitGetUserMedia(ExecState* exec)
6062}
6163#endif // ENABLE(MEDIA_STREAM)
6264
 65#if ENABLE(VIBRATION)
 66JSValue JSNavigator::webkitVibrate(ExecState* exec)
 67{
 68 VibrationPattern vibrationArray;
 69 if (!exec->argumentCount())
 70 vibrationArray.append(0);
 71
 72 JSValue value = exec->argument(0);
 73 if (value.isUInt32())
 74 vibrationArray.append(value.asInt32());
 75 else {
 76 unsigned length;
 77 JSObject* object = toJSSequence(exec, value, length);
 78
 79 if (!length)
 80 vibrationArray.append(0);
 81
 82 for (unsigned i = 0; i < length; i++) {
 83 value = object->get(exec, i);
 84 if (exec->hadException())
 85 return jsUndefined();
 86
 87 if (value.isUndefinedOrNull() || !value.isNumber()) {
 88 setDOMException(exec, DATA_CLONE_ERR);
 89 return jsUndefined();
 90 }
 91
 92 if (value.isUInt32())
 93 vibrationArray.append(value.asInt32());
 94 }
 95 }
 96
 97 ExceptionCode ec = 0;
 98 m_impl->webkitVibrate(vibrationArray, ec);
 99
 100 if (ec)
 101 setDOMException(exec, ec);
 102
 103 return jsUndefined();
 104}
 105#endif
 106
63107}

Source/WebCore/page/Navigator.cpp

5656#include "UserMediaRequest.h"
5757#endif
5858
 59#if ENABLE(VIBRATION)
 60#include "Vibrator.h"
 61#endif
 62
5963namespace WebCore {
6064
6165Navigator::Navigator(Frame* frame)

@@GamepadList* Navigator::webkitGamepads()
319323}
320324#endif
321325
 326#if ENABLE(VIBRATION)
 327void Navigator::webkitVibrate(const VibrationPattern& pattern, ExceptionCode& ec)
 328{
 329 if (!pattern.size() || !m_frame->page())
 330 return;
 331
 332#if ENABLE(PAGE_VISIBILITY_API)
 333 if (m_frame->page()->visibilityState() == PageVisibilityStateHidden)
 334 return;
 335#endif
 336
 337 if (!m_frame->page()->vibrator()->isSupport()) {
 338 ec = NOT_SUPPORTED_ERR;
 339 return;
 340 }
 341
 342 ec = 0;
 343 m_frame->page()->vibrator()->vibrate(pattern);
 344}
 345#endif
 346
322347} // namespace WebCore

Source/WebCore/page/Navigator.h

2626#include <wtf/RefCounted.h>
2727#include <wtf/RefPtr.h>
2828
 29#if ENABLE(VIBRATION)
 30#include "Vibrator.h"
 31#endif
 32
2933namespace WebCore {
3034
3135class DOMMimeTypeArray;

@@public:
7983 GamepadList* webkitGamepads();
8084#endif
8185
 86#if ENABLE(VIBRATION)
 87 void webkitVibrate(const VibrationPattern&, ExceptionCode&);
 88#endif
 89
8290private:
8391 Navigator(Frame*);
8492 Frame* m_frame;

Source/WebCore/page/Navigator.idl

@@module window {
6565#if defined(ENABLE_GAMEPAD) && ENABLE_GAMEPAD
6666 readonly attribute [EnabledAtRuntime] GamepadList webkitGamepads;
6767#endif
 68
 69#if defined(ENABLE_VIBRATION) && ENABLE_VIBRATION
 70 [Custom] void webkitVibrate(in Array pattern)
 71 raises(DOMException);
 72#endif
 73
6874 };
6975
7076}

Source/WebCore/page/Page.cpp

8686#include "UserMediaClient.h"
8787#endif
8888
 89#if ENABLE(VIBRATION)
 90#include "Vibrator.h"
 91#endif
 92
8993namespace WebCore {
9094
9195static HashSet<Page*>* allPages;

@@Page::Page(PageClients& pageClients)
178182 , m_visibilityState(PageVisibilityStateVisible)
179183#endif
180184 , m_displayID(0)
 185#if ENABLE(VIBRATION)
 186 , m_vibrator(adoptPtr(new Vibrator(pageClients.vibratorClient)))
 187#endif
181188{
182189 if (!allPages) {
183190 allPages = new HashSet<Page*>;

@@Page::PageClients::PageClients()
10691076 , speechInputClient(0)
10701077 , notificationClient(0)
10711078 , userMediaClient(0)
 1079#if ENABLE(VIBRATION)
 1080 , vibratorClient(0)
 1081#endif
10721082{
10731083}
10741084

Source/WebCore/page/Page.h

@@namespace WebCore {
8989#if ENABLE(NOTIFICATIONS)
9090 class NotificationPresenter;
9191#endif
 92#if ENABLE(VIBRATION)
 93 class Vibrator;
 94 class VibratorClient;
 95#endif
9296
9397 typedef uint64_t LinkHash;
9498

@@namespace WebCore {
121125 SpeechInputClient* speechInputClient;
122126 NotificationPresenter* notificationClient;
123127 UserMediaClient* userMediaClient;
 128#if ENABLE(VIBRATION)
 129 VibratorClient* vibratorClient;
 130#endif
124131 };
125132
126133 Page(PageClients&);

@@namespace WebCore {
343350#endif
344351
345352 PlatformDisplayID displayID() const { return m_displayID; }
346 
 353
 354#if ENABLE(VIBRATION)
 355 Vibrator* vibrator() const { return m_vibrator.get(); }
 356#endif
 357
347358 private:
348359 void initGroup();
349360

@@namespace WebCore {
454465 PageVisibilityState m_visibilityState;
455466#endif
456467 PlatformDisplayID m_displayID;
 468
 469#if ENABLE(VIBRATION)
 470 OwnPtr<Vibrator> m_vibrator;
 471#endif
457472 };
458473
459474} // namespace WebCore

Source/WebCore/page/Vibrator.cpp

 1/*
 2 Copyright (C) 2011 Samsung Electronics
 3
 4 This library is free software; you can redistribute it and/or
 5 modify it under the terms of the GNU Library General Public
 6 License as published by the Free Software Foundation; either
 7 version 2 of the License, or (at your option) any later version.
 8
 9 This library is distributed in the hope that it will be useful,
 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 Library General Public License for more details.
 13
 14 You should have received a copy of the GNU Library General Public License
 15 along with this library; see the file COPYING.LIB. If not, write to
 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17 Boston, MA 02110-1301, USA.
 18*/
 19
 20#include "config.h"
 21#include "Vibrator.h"
 22
 23#if ENABLE(VIBRATION)
 24
 25#include "VibratorClient.h"
 26
 27namespace WebCore {
 28
 29Vibrator::Vibrator(VibratorClient* vibratorClient)
 30 : m_vibratorClient(vibratorClient)
 31 , m_timer(this, &Vibrator::timerFired)
 32 , m_isVibrating(false)
 33{
 34}
 35
 36void Vibrator::vibrate(const VibrationPattern& pattern)
 37{
 38 int length = pattern.size();
 39
 40 if (!length) {
 41 if (m_isVibrating)
 42 cancelVibrate();
 43 return;
 44 }
 45
 46 if (length == 1 && !pattern[0]) {
 47 if (m_isVibrating)
 48 cancelVibrate();
 49 return;
 50 }
 51
 52 if (!m_isVibrating && !m_timer.isActive()) {
 53 m_pattern = pattern;
 54 m_timer.startOneShot(0);
 55 }
 56}
 57
 58void Vibrator::cancelVibrate()
 59{
 60 m_vibratorClient->cancelVibrate();
 61}
 62
 63bool Vibrator::isSupport()
 64{
 65 return m_vibratorClient->isSupport();
 66}
 67
 68void Vibrator::timerFired(Timer<Vibrator>* timer)
 69{
 70 ASSERT_UNUSED(timer, timer == &m_timer);
 71 m_timer.stop();
 72 m_vibratorClient->vibrate(m_pattern[0]);
 73
 74 if (m_pattern.size() <= 2)
 75 return;
 76
 77 m_timer.startOneShot(m_pattern[0] + m_pattern[1]);
 78 m_pattern.remove(0, 2);
 79}
 80
 81}
 82
 83#endif
 84

Source/WebCore/page/Vibrator.h

 1/*
 2 Copyright (C) 2011 Samsung Electronics
 3
 4 This library is free software; you can redistribute it and/or
 5 modify it under the terms of the GNU Library General Public
 6 License as published by the Free Software Foundation; either
 7 version 2 of the License, or (at your option) any later version.
 8
 9 This library is distributed in the hope that it will be useful,
 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 11 Library General Public License for more details.
 12
 13 You should have received a copy of the GNU Library General Public License
 14 along with this library; see the file COPYING.LIB. If not, write to
 15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 16 Boston, MA 02110-1301, USA.
 17*/
 18
 19#ifndef Vibrator_h
 20#define Vibrator_h
 21
 22#include "Timer.h"
 23
 24#include <wtf/Vector.h>
 25
 26namespace WebCore {
 27
 28typedef Vector<long> VibrationPattern;
 29
 30class VibratorClient;
 31
 32class Vibrator {
 33public:
 34 Vibrator(VibratorClient*);
 35 ~Vibrator() { };
 36
 37 void vibrate(const VibrationPattern&);
 38 void cancelVibrate();
 39
 40 bool isSupport();
 41 void timerFired(Timer<Vibrator>*);
 42
 43private:
 44 VibratorClient* m_vibratorClient;
 45 Timer<Vibrator> m_timer;
 46 bool m_isVibrating;
 47 VibrationPattern m_pattern;
 48};
 49
 50} // namespace WebCore
 51
 52#endif // Vibrator_h
 53

Source/WebCore/page/VibratorClient.h

 1/*
 2 Copyright (C) 2011 Samsung Electronics
 3
 4 This library is free software; you can redistribute it and/or
 5 modify it under the terms of the GNU Library General Public
 6 License as published by the Free Software Foundation; either
 7 version 2 of the License, or (at your option) any later version.
 8
 9 This library is distributed in the hope that it will be useful,
 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 Library General Public License for more details.
 13
 14 You should have received a copy of the GNU Library General Public License
 15 along with this library; see the file COPYING.LIB. If not, write to
 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17 Boston, MA 02110-1301, USA.
 18*/
 19
 20
 21#ifndef VibratorClient_h
 22#define VibratorClient_h
 23
 24namespace WebCore {
 25
 26class VibratorClient {
 27public:
 28 virtual void vibrate(const long& time) = 0;
 29 virtual void cancelVibrate() = 0;
 30
 31 virtual bool isSupport() = 0;
 32
 33protected:
 34 virtual ~VibratorClient() { }
 35};
 36
 37} // namespace WebCore
 38
 39#endif // VibratorClientEfl_h
 40

Tools/ChangeLog

 12011-12-22 Kihong Kwon <kihong.kwon@samsung.com>
 2
 3 Add a new API for the Vibration API(W3C).
 4 https://bugs.webkit.org/show_bug.cgi?id=72010
 5 http://dev.w3.org/2009/dap/vibration/
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 No new tests.
 10
 11 * Scripts/build-webkit:
 12
1132011-12-05 Alexander Færøy <alexander.faeroy@nokia.com>
214
315 [Qt] MiniBrowser should default to touch behavior

Tools/Scripts/build-webkit

@@my (
126126 $touchEventsSupport,
127127 $touchIconLoadingSupport,
128128 $videoSupport,
 129 $vibrationSupport,
129130 $webAudioSupport,
130131 $webInspectorSupport,
131132 $webSocketsSupport,

@@my @features = (
318319 { option => "video", desc => "Toggle Video support",
319320 define => "ENABLE_VIDEO", default => (isAppleWebKit() || isGtk() || isBlackBerry()), value => \$videoSupport },
320321
 322 { option => "vibration", desc => "Toggle Vibration support",
 323 define => "ENABLE_VIBRATION", default => 0, value => \$vibrationSupport },
 324
321325 { option => "web-audio", desc => "Toggle Web Audio support",
322326 define => "ENABLE_WEB_AUDIO", default => 0, value=> \$webAudioSupport },
323327