Source/Platform/Platform.gypi

5454 'chromium/public/WebCookie.h',
5555 'chromium/public/WebCookieJar.h',
5656 'chromium/public/WebData.h',
 57 'chromium/public/WebDeviceMotionData.h',
 58 'chromium/public/WebDeviceMotionDetector.h',
5759 'chromium/public/WebDelegatedRendererLayer.h',
5860 'chromium/public/WebDragData.h',
5961 'chromium/public/WebExternalTextureLayer.h',

Source/Platform/chromium/public/Platform.h

@@class WebBlobRegistry;
5151class WebClipboard;
5252class WebCompositorSupport;
5353class WebCookieJar;
 54class WebDeviceMotionDetector;
5455class WebFileSystem;
5556class WebFileUtilities;
5657class WebFlingAnimator;

@@public:
437438 virtual void didStartWorkerRunLoop(const WebWorkerRunLoop&) { }
438439 virtual void didStopWorkerRunLoop(const WebWorkerRunLoop&) { }
439440
 441 // DeviceMotion ----------------------------------------------------
 442
 443 virtual WebDeviceMotionDetector* deviceMotionDetector() { return 0; }
 444
440445protected:
441446 virtual ~Platform() { }
442447};

Source/Platform/chromium/public/WebDeviceMotionData.h

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * * Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * * Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef WebDeviceMotionData_h
 27#define WebDeviceMotionData_h
 28
 29#include "WebPrivatePtr.h"
 30
 31namespace WTF { template <typename T> class PassRefPtr; }
 32namespace WebCore { class DeviceMotionData; }
 33
 34namespace WebKit {
 35
 36class WebDeviceMotionData {
 37public:
 38 WebDeviceMotionData() { }
 39 WebDeviceMotionData(const WebDeviceMotionData& other) { assign(other); }
 40 ~WebDeviceMotionData() { reset(); }
 41 WebDeviceMotionData operator=(const WebDeviceMotionData& other)
 42 {
 43 assign(other);
 44 return *this;
 45 }
 46
 47 WEBKIT_EXPORT void reset();
 48 WEBKIT_EXPORT void assign(const WebDeviceMotionData& other);
 49
 50 WEBKIT_EXPORT void initializeAcceleration(bool canProvideAccelerationX, double accelerationX, bool canProvideAccelerationY, double accelerationY, bool canProvideAccelerationZ, double accelerationZ);
 51 WEBKIT_EXPORT void initializeAccelerationIncludingGravity(bool canProvideAccelerationIncludingGravityX, double accelerationIncludingGravityX, bool canProvideAccelerationIncludingGravityY, double accelerationIncludingGravityY, bool canProvideAccelerationIncludingGravityZ, double accelerationIncludingGravityZ);
 52 WEBKIT_EXPORT void initializeRotationRate(bool canProvideRotationRateAlpha, double rotationRateAlpha, bool canProvideRotationRateBeta, double rotationRateBeta, bool canProvideRotationRateGamma, double rotationRateGamma);
 53 WEBKIT_EXPORT void initializeInterval(double interval);
 54
 55 bool isNull() const { return m_private.isNull(); }
 56
 57#if WEBKIT_IMPLEMENTATION
 58 WebDeviceMotionData(const WebCore::DeviceMotionData*);
 59 operator WTF::PassRefPtr<WebCore::DeviceMotionData>() const;
 60#endif
 61
 62private:
 63 WebPrivatePtr<WebCore::DeviceMotionData> m_private;
 64};
 65
 66} // namespace WebKit
 67
 68#endif // WebDeviceMotionData_h

Source/Platform/chromium/public/WebDeviceMotionDetector.h

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * * Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * * Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef DeviceMotionDetector_h
 27#define DeviceMotionDetector_h
 28
 29namespace WebKit {
 30
 31class WebDeviceMotionData;
 32
 33class WebDeviceMotionDetector {
 34public:
 35 virtual void start(void* handle, void (*callback)(void*, const WebDeviceMotionData&)) { WEBKIT_ASSERT_NOT_REACHED(); }
 36 virtual void stop(void* handle) { WEBKIT_ASSERT_NOT_REACHED(); }
 37};
 38
 39} // namespace WebKit
 40
 41#endif // DeviceMotionDetector_h

Source/WebCore/WebCore.gypi

46504650 'platform/chromium/ContextMenuChromium.cpp',
46514651 'platform/chromium/ContextMenuItemChromium.cpp',
46524652 'platform/chromium/CursorChromium.cpp',
 4653 'platform/chromium/DeviceMotionChromium.cpp',
46534654 'platform/chromium/DragDataChromium.cpp',
46544655 'platform/chromium/DragDataRef.h',
46554656 'platform/chromium/DragImageChromiumSkia.cpp',

83738374 'platform/chromium/support/PlatformGestureCurveFactory.h',
83748375 'platform/chromium/support/WebAudioBus.cpp',
83758376 'platform/chromium/support/WebData.cpp',
 8377 'platform/chromium/support/WebDeviceMotionData.cpp',
83768378 'platform/chromium/support/WebFlingAnimatorToGestureCurveAdapter.h',
83778379 'platform/chromium/support/WebHTTPBody.cpp',
83788380 'platform/chromium/support/WebHTTPLoadInfo.cpp',

Source/WebCore/dom/DeviceMotionClient.h

@@public:
4242 virtual void deviceMotionControllerDestroyed() = 0;
4343};
4444
45 void provideDeviceMotionTo(Page*, DeviceMotionClient*);
 45void provideDeviceMotionTo(Page*); // FIXME: This file will be removed, so where should this declaration go?
4646
4747} // namespace WebCore
4848

Source/WebCore/dom/DeviceMotionController.cpp

3232
3333namespace WebCore {
3434
35 DeviceMotionController::DeviceMotionController(DeviceMotionClient* client)
36  : m_client(client)
37  , m_timer(this, &DeviceMotionController::timerFired)
 35DeviceMotionController::DeviceMotionController()
 36 : m_timer(this, &DeviceMotionController::timerFired)
3837{
39  ASSERT(m_client);
40  m_client->setController(this);
4138}
4239
4340DeviceMotionController::~DeviceMotionController()
4441{
45  m_client->deviceMotionControllerDestroyed();
 42 // FIXME: Call stop here?
4643}
4744
48 PassOwnPtr<DeviceMotionController> DeviceMotionController::create(DeviceMotionClient* client)
 45PassOwnPtr<DeviceMotionController> DeviceMotionController::create()
4946{
50  return adoptPtr(new DeviceMotionController(client));
 47 return adoptPtr(new DeviceMotionController());
5148}
5249
5350void DeviceMotionController::timerFired(Timer<DeviceMotionController>* timer)
5451{
5552 ASSERT_UNUSED(timer, timer == &m_timer);
56  ASSERT(m_client->lastMotion());
 53 ASSERT(m_lastMotion);
5754 m_timer.stop();
58 
59  RefPtr<DeviceMotionData> deviceMotionData = m_client->lastMotion();
60  RefPtr<DeviceMotionEvent> event = DeviceMotionEvent::create(eventNames().devicemotionEvent, deviceMotionData.get());
61 
 55
 56 RefPtr<DeviceMotionEvent> event = DeviceMotionEvent::create(eventNames().devicemotionEvent, m_lastMotion.get());
 57
6258 Vector<RefPtr<DOMWindow> > listenersVector;
6359 copyToVector(m_newListeners, listenersVector);
6460 m_newListeners.clear();
6561 for (size_t i = 0; i < listenersVector.size(); ++i)
6662 listenersVector[i]->dispatchEvent(event);
6763}
68 
 64
6965void DeviceMotionController::addListener(DOMWindow* window)
7066{
7167 // If the client already has motion data,
7268 // immediately trigger an asynchronous response.
73  if (m_client->lastMotion()) {
 69 if (m_lastMotion) {
7470 m_newListeners.add(window);
7571 if (!m_timer.isActive())
7672 m_timer.startOneShot(0);
7773 }
78 
 74
7975 bool wasEmpty = m_listeners.isEmpty();
8076 m_listeners.add(window);
8177 if (wasEmpty)
82  m_client->startUpdating();
 78 startDetectingDeviceMotion(this);
8379}
8480
8581void DeviceMotionController::removeListener(DOMWindow* window)

@@void DeviceMotionController::removeListener(DOMWindow* window)
8884 m_suspendedListeners.remove(window);
8985 m_newListeners.remove(window);
9086 if (m_listeners.isEmpty())
91  m_client->stopUpdating();
 87 stopDetectingDeviceMotion(this);
9288}
9389
9490void DeviceMotionController::removeAllListeners(DOMWindow* window)

@@void DeviceMotionController::removeAllListeners(DOMWindow* window)
10197 m_suspendedListeners.removeAll(window);
10298 m_newListeners.remove(window);
10399 if (m_listeners.isEmpty())
104  m_client->stopUpdating();
 100 stopDetectingDeviceMotion(this);
105101}
106102
107103void DeviceMotionController::suspendEventsForAllListeners(DOMWindow* window)

@@void DeviceMotionController::resumeEventsForAllListeners(DOMWindow* window)
126122 addListener(window);
127123}
128124
129 void DeviceMotionController::didChangeDeviceMotion(DeviceMotionData* deviceMotionData)
 125void DeviceMotionController::didDetectDeviceMotion(PassRefPtr<DeviceMotionData> deviceMotionData)
130126{
131  RefPtr<DeviceMotionEvent> event = DeviceMotionEvent::create(eventNames().devicemotionEvent, deviceMotionData);
 127 m_lastMotion = deviceMotionData;
 128 RefPtr<DeviceMotionEvent> event = DeviceMotionEvent::create(eventNames().devicemotionEvent, m_lastMotion.get()); // FIXME: Should this just take a PassRefPtr to the motion data?
132129 Vector<RefPtr<DOMWindow> > listenersVector;
133130 copyToVector(m_listeners, listenersVector);
134131 for (size_t i = 0; i < listenersVector.size(); ++i)

@@bool DeviceMotionController::isActiveAt(Page* page)
148145 return false;
149146}
150147
151 void provideDeviceMotionTo(Page* page, DeviceMotionClient* client)
 148void provideDeviceMotionTo(Page* page)
152149{
153  DeviceMotionController::provideTo(page, DeviceMotionController::supplementName(), DeviceMotionController::create(client));
 150 DeviceMotionController::provideTo(page, DeviceMotionController::supplementName(), DeviceMotionController::create());
154151}
155152
156153} // namespace WebCore

Source/WebCore/dom/DeviceMotionController.h

2626#ifndef DeviceMotionController_h
2727#define DeviceMotionController_h
2828
 29#include "DeviceMotion.h"
2930#include "DOMWindow.h"
3031#include "Page.h"
3132#include "Timer.h"
3233#include <wtf/HashCountedSet.h>
 34#include <wtf/PassRefPtr.h>
3335
3436namespace WebCore {
3537
3638class DeviceMotionData;
37 class DeviceMotionClient;
3839
39 class DeviceMotionController : public Supplement<Page> {
 40class DeviceMotionController : public Supplement<Page>, public DeviceMotionListener {
4041public:
4142 ~DeviceMotionController();
4243
43  static PassOwnPtr<DeviceMotionController> create(DeviceMotionClient*);
 44 static PassOwnPtr<DeviceMotionController> create();
4445
4546 void addListener(DOMWindow*);
4647 void removeListener(DOMWindow*);

@@public:
4950 void suspendEventsForAllListeners(DOMWindow*);
5051 void resumeEventsForAllListeners(DOMWindow*);
5152
52  void didChangeDeviceMotion(DeviceMotionData*);
 53 // DeviceMotionListener:
 54 void didDetectDeviceMotion(PassRefPtr<DeviceMotionData>) OVERRIDE;
5355
5456 bool isActive() { return !m_listeners.isEmpty(); }
5557

@@public:
5860 static bool isActiveAt(Page*);
5961
6062private:
61  explicit DeviceMotionController(DeviceMotionClient*);
 63 DeviceMotionController();
6264
6365 void timerFired(Timer<DeviceMotionController>*);
64 
65  DeviceMotionClient* m_client;
 66
6667 typedef HashCountedSet<RefPtr<DOMWindow> > ListenersCountedSet;
6768 ListenersCountedSet m_listeners;
6869 ListenersCountedSet m_suspendedListeners;
6970 typedef HashSet<RefPtr<DOMWindow> > ListenersSet;
7071 ListenersSet m_newListeners;
7172 Timer<DeviceMotionController> m_timer;
 73 RefPtr<DeviceMotionData> m_lastMotion;
7274};
7375
7476} // namespace WebCore

Source/WebCore/dom/DeviceMotionData.h

@@public:
9292 double interval() const { return m_interval; }
9393 bool canProvideInterval() const { return m_canProvideInterval; }
9494
 95 void initializeAcceleration(PassRefPtr<Acceleration> acceleration)
 96 {
 97 ASSERT(!m_acceleration);
 98 m_acceleration = acceleration;
 99 }
 100 void initializeAccelerationIncludingGravity(PassRefPtr<Acceleration> accelerationIncludingGravity)
 101 {
 102 ASSERT(!m_accelerationIncludingGravity);
 103 m_accelerationIncludingGravity = accelerationIncludingGravity;
 104 }
 105 void initializeRotationRate(PassRefPtr<RotationRate> rotationRate)
 106 {
 107 ASSERT(!m_rotationRate);
 108 m_rotationRate = rotationRate;
 109 }
 110 void initializeInterval(double interval)
 111 {
 112 ASSERT(!m_canProvideInterval);
 113 m_canProvideInterval = true;
 114 m_interval = interval;
 115 }
 116
95117private:
96118 DeviceMotionData();
97119 DeviceMotionData(PassRefPtr<Acceleration> acceleration, PassRefPtr<Acceleration> accelerationIncludingGravity,

Source/WebCore/platform/DeviceMotion.h

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * * Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * * Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef DeviceMotion_h
 27#define DeviceMotion_h
 28
 29#if ENABLE(DEVICE_ORIENTATION)
 30
 31#include <wtf/PassRefPtr.h>
 32
 33namespace WebCore {
 34
 35class DeviceMotionData;
 36
 37class DeviceMotionListener {
 38public:
 39 virtual void didDetectDeviceMotion(PassRefPtr<DeviceMotionData>) = 0;
 40};
 41
 42void startDetectingDeviceMotion(DeviceMotionListener*);
 43void stopDetectingDeviceMotion(DeviceMotionListener*);
 44
 45} // namespace WebCore
 46
 47#endif // ENABLE(DEVICE_ORIENTATION)
 48
 49#endif // DeviceMotion_h

Source/WebCore/platform/chromium/DeviceMotionChromium.cpp

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * * Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * * Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "DeviceMotion.h"
 28
 29#include "DeviceMotionData.h"
 30#include <public/Platform.h>
 31#include <public/WebDeviceMotionData.h>
 32#include <public/WebDeviceMotionDetector.h>
 33
 34#if ENABLE(DEVICE_ORIENTATION)
 35
 36namespace WebCore {
 37
 38// FIXME: Wrap DeviceMotionListener* in a pass-by-value class instead.
 39static void callback(void *handle, const WebKit::WebDeviceMotionData& data)
 40{
 41 DeviceMotionListener* listener = static_cast<DeviceMotionListener*>(handle);
 42 RefPtr<DeviceMotionData> deviceMotionData = PassRefPtr<DeviceMotionData>(data);
 43 listener->didDetectDeviceMotion(deviceMotionData);
 44}
 45
 46void startDetectingDeviceMotion(DeviceMotionListener* listener)
 47{
 48 WebKit::Platform::current()->deviceMotionDetector()->start(listener, callback);
 49}
 50
 51void stopDetectingDeviceMotion(DeviceMotionListener* listener)
 52{
 53 WebKit::Platform::current()->deviceMotionDetector()->stop(listener);
 54}
 55
 56} // namespace WebCore
 57
 58#endif // ENABLE(DEVICE_ORIENTATION)

Source/WebCore/platform/chromium/support/WebDeviceMotionData.cpp

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * * Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * * Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include <public/WebDeviceMotionData.h>
 28
 29#include "DeviceMotionData.h"
 30#include <wtf/PassRefPtr.h>
 31
 32using namespace WebCore;
 33
 34namespace WebKit {
 35
 36void WebDeviceMotionData::reset()
 37{
 38 m_private.reset();
 39}
 40
 41void WebDeviceMotionData::assign(const WebDeviceMotionData& other)
 42{
 43 m_private = other.m_private;
 44}
 45
 46void WebDeviceMotionData::initializeAcceleration(bool canProvideAccelerationX, double accelerationX, bool canProvideAccelerationY, double accelerationY, bool canProvideAccelerationZ, double accelerationZ)
 47{
 48 if (m_private.isNull())
 49 m_private = DeviceMotionData::create();
 50 RefPtr<DeviceMotionData::Acceleration> acceleration = DeviceMotionData::Acceleration::create(canProvideAccelerationX, accelerationX, canProvideAccelerationY, accelerationY, canProvideAccelerationZ, accelerationZ);
 51 m_private->initializeAcceleration(acceleration.release());
 52}
 53
 54void WebDeviceMotionData::initializeAccelerationIncludingGravity(bool canProvideAccelerationIncludingGravityX, double accelerationIncludingGravityX, bool canProvideAccelerationIncludingGravityY, double accelerationIncludingGravityY, bool canProvideAccelerationIncludingGravityZ, double accelerationIncludingGravityZ)
 55{
 56 if (m_private.isNull())
 57 m_private = DeviceMotionData::create();
 58 RefPtr<DeviceMotionData::Acceleration> accelerationIncludingGravity = DeviceMotionData::Acceleration::create(canProvideAccelerationIncludingGravityX, accelerationIncludingGravityX, canProvideAccelerationIncludingGravityY, accelerationIncludingGravityY, canProvideAccelerationIncludingGravityZ, accelerationIncludingGravityZ);
 59 m_private->initializeAccelerationIncludingGravity(accelerationIncludingGravity.release());
 60}
 61
 62void WebDeviceMotionData::initializeRotationRate(bool canProvideRotationRateAlpha, double rotationRateAlpha, bool canProvideRotationRateBeta, double rotationRateBeta, bool canProvideRotationRateGamma, double rotationRateGamma)
 63{
 64 if (m_private.isNull())
 65 m_private = DeviceMotionData::create();
 66 RefPtr<DeviceMotionData::RotationRate> rotationRate = DeviceMotionData::RotationRate::create(canProvideRotationRateAlpha, rotationRateAlpha, canProvideRotationRateBeta, rotationRateBeta, canProvideRotationRateGamma, rotationRateGamma);
 67 m_private->initializeRotationRate(rotationRate.release());
 68}
 69
 70void WebDeviceMotionData::initializeInterval(double interval)
 71{
 72 if (m_private.isNull())
 73 m_private = DeviceMotionData::create();
 74 m_private->initializeInterval(interval);
 75}
 76
 77WebDeviceMotionData::operator PassRefPtr<WebCore::DeviceMotionData>() const
 78{
 79 if (!m_private.get())
 80 return DeviceMotionData::create();
 81 return m_private.get();
 82}
 83
 84} // namespace WebKit

Source/WebCore/platform/mock/DeviceMotionClientMock.cpp

@@void DeviceMotionClientMock::timerFired(Timer<DeviceMotionClientMock>* timer)
6666{
6767 ASSERT_UNUSED(timer, timer == &m_timer);
6868 m_timer.stop();
69  m_controller->didChangeDeviceMotion(m_motion.get());
 69 // FIXME: Need to fix this guy. m_controller->didChangeDeviceMotion(m_motion.get());
7070}
7171
7272} // namespace WebCore

Source/WebKit/chromium/src/WebViewImpl.cpp

4949#include "ContextMenuItem.h"
5050#include "Cursor.h"
5151#include "DOMUtilitiesPrivate.h"
 52#include "DeviceMotionClient.h"
5253#include "DeviceOrientationClientProxy.h"
5354#include "Document.h"
5455#include "DocumentLoader.h"

@@WebViewImpl::WebViewImpl(WebViewClient* client)
473474
474475 provideContextFeaturesTo(m_page.get(), m_featureSwitchClient.get());
475476 provideDeviceOrientationTo(m_page.get(), m_deviceOrientationClientProxy.get());
 477 provideDeviceMotionTo(m_page.get());
476478 provideGeolocationTo(m_page.get(), m_geolocationClientProxy.get());
477479 m_geolocationClientProxy->setController(GeolocationController::from(m_page.get()));
478480