Diff
Modified: trunk/Source/WebKit/ChangeLog (106975 => 106976)
--- trunk/Source/WebKit/ChangeLog 2012-02-07 20:28:57 UTC (rev 106975)
+++ trunk/Source/WebKit/ChangeLog 2012-02-07 20:40:08 UTC (rev 106976)
@@ -1,3 +1,17 @@
+2012-02-07 Jacky Jiang <zhaji...@rim.com>
+
+ [BlackBerry] Upstream BlackBerry WebCoreSupport DeviceOrientationClientBlackBerry and DeviceMotionClientBlackBerry classes
+ https://bugs.webkit.org/show_bug.cgi?id=77993
+
+ Reviewed by Rob Buis.
+
+ Initial upstream, no new tests.
+
+ * blackberry/WebCoreSupport/DeviceMotionClientBlackBerry.cpp: Added.
+ * blackberry/WebCoreSupport/DeviceMotionClientBlackBerry.h: Added.
+ * blackberry/WebCoreSupport/DeviceOrientationClientBlackBerry.cpp: Added.
+ * blackberry/WebCoreSupport/DeviceOrientationClientBlackBerry.h: Added.
+
2012-02-06 Leo Yang <leo.y...@torchmobile.com.cn>
[BlackBerry] Use WebPagePrivate instead of WebPage in GeolocationControllerClientBlackBerry
Added: trunk/Source/WebKit/blackberry/WebCoreSupport/DeviceMotionClientBlackBerry.cpp (0 => 106976)
--- trunk/Source/WebKit/blackberry/WebCoreSupport/DeviceMotionClientBlackBerry.cpp (rev 0)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/DeviceMotionClientBlackBerry.cpp 2012-02-07 20:40:08 UTC (rev 106976)
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "DeviceMotionClientBlackBerry.h"
+
+#include "DeviceMotionController.h"
+#include "DeviceMotionData.h"
+#include "WebPage_p.h"
+#include <BlackBerryPlatformDeviceMotionTracker.h>
+
+using namespace WebCore;
+
+DeviceMotionClientBlackBerry::DeviceMotionClientBlackBerry(BlackBerry::WebKit::WebPagePrivate* webPagePrivate)
+ : m_webPagePrivate(webPagePrivate)
+ , m_tracker(0)
+ , m_controller(0)
+ , m_lastEventTime(0)
+{
+}
+
+DeviceMotionClientBlackBerry::~DeviceMotionClientBlackBerry()
+{
+ if (m_tracker)
+ m_tracker->destroy();
+}
+
+void DeviceMotionClientBlackBerry::setController(DeviceMotionController* controller)
+{
+ m_controller = controller;
+}
+
+void DeviceMotionClientBlackBerry::deviceMotionControllerDestroyed()
+{
+ delete this;
+}
+
+void DeviceMotionClientBlackBerry::startUpdating()
+{
+ if (m_tracker)
+ m_tracker->resume();
+ else
+ m_tracker = BlackBerry::Platform::DeviceMotionTracker::create(this);
+}
+
+void DeviceMotionClientBlackBerry::stopUpdating()
+{
+ if (m_tracker)
+ m_tracker->suspend();
+}
+
+DeviceMotionData* DeviceMotionClientBlackBerry::currentDeviceMotion() const
+{
+ return m_currentMotion.get();
+}
+
+void DeviceMotionClientBlackBerry::onMotion(const BlackBerry::Platform::DeviceMotionEvent* event)
+{
+ RefPtr<DeviceMotionData::Acceleration> accel = DeviceMotionData::Acceleration::create(
+ true, event->x, true, event->y, true, event->z);
+
+ double now = WTF::currentTimeMS();
+ m_currentMotion = DeviceMotionData::create(0, accel, 0, m_lastEventTime, m_lastEventTime - now);
+ m_lastEventTime = now;
+
+ if (!m_controller)
+ return;
+
+ m_controller->didChangeDeviceMotion(currentDeviceMotion());
+}
Added: trunk/Source/WebKit/blackberry/WebCoreSupport/DeviceMotionClientBlackBerry.h (0 => 106976)
--- trunk/Source/WebKit/blackberry/WebCoreSupport/DeviceMotionClientBlackBerry.h (rev 0)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/DeviceMotionClientBlackBerry.h 2012-02-07 20:40:08 UTC (rev 106976)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef DeviceMotionClientBlackBerry_h
+#define DeviceMotionClientBlackBerry_h
+
+#include "DeviceMotionClient.h"
+#include "DeviceMotionData.h"
+
+#include <BlackBerryPlatformDeviceMotionTrackerListener.h>
+
+namespace BlackBerry {
+namespace WebKit {
+class WebPagePrivate;
+}
+}
+
+namespace BlackBerry {
+namespace Platform {
+class DeviceMotionTracker;
+}
+}
+
+namespace WebCore {
+
+class DeviceMotionClientBlackBerry : public DeviceMotionClient, public BlackBerry::Platform::DeviceMotionTrackerListener {
+public:
+ DeviceMotionClientBlackBerry(BlackBerry::WebKit::WebPagePrivate*);
+ ~DeviceMotionClientBlackBerry();
+
+ virtual void setController(DeviceMotionController*);
+ virtual void startUpdating();
+ virtual void stopUpdating();
+ virtual DeviceMotionData* currentDeviceMotion() const;
+ virtual void deviceMotionControllerDestroyed();
+ virtual void onMotion(const BlackBerry::Platform::DeviceMotionEvent*);
+
+private:
+ BlackBerry::WebKit::WebPagePrivate* m_webPagePrivate;
+ BlackBerry::Platform::DeviceMotionTracker* m_tracker;
+ DeviceMotionController* m_controller;
+ RefPtr<DeviceMotionData> m_currentMotion;
+ double m_lastEventTime;
+};
+}
+
+#endif // DeviceMotionClientBlackBerry_h
Added: trunk/Source/WebKit/blackberry/WebCoreSupport/DeviceOrientationClientBlackBerry.cpp (0 => 106976)
--- trunk/Source/WebKit/blackberry/WebCoreSupport/DeviceOrientationClientBlackBerry.cpp (rev 0)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/DeviceOrientationClientBlackBerry.cpp 2012-02-07 20:40:08 UTC (rev 106976)
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "DeviceOrientationClientBlackBerry.h"
+
+#include "DeviceOrientationController.h"
+#include "WebPage_p.h"
+#include <BlackBerryPlatformDeviceOrientationTracker.h>
+
+using namespace WebCore;
+
+DeviceOrientationClientBlackBerry::DeviceOrientationClientBlackBerry(BlackBerry::WebKit::WebPagePrivate* webPagePrivate)
+ : m_webPagePrivate(webPagePrivate)
+ , m_tracker(0)
+ , m_controller(0)
+{
+}
+
+DeviceOrientationClientBlackBerry::~DeviceOrientationClientBlackBerry()
+{
+ if (m_tracker)
+ m_tracker->destroy();
+}
+
+void DeviceOrientationClientBlackBerry::setController(DeviceOrientationController* controller)
+{
+ m_controller = controller;
+}
+
+void DeviceOrientationClientBlackBerry::deviceOrientationControllerDestroyed()
+{
+ delete this;
+}
+
+void DeviceOrientationClientBlackBerry::startUpdating()
+{
+ if (m_tracker)
+ m_tracker->resume();
+ else
+ m_tracker = BlackBerry::Platform::DeviceOrientationTracker::create(this);
+}
+
+void DeviceOrientationClientBlackBerry::stopUpdating()
+{
+ if (m_tracker)
+ m_tracker->suspend();
+}
+
+DeviceOrientation* DeviceOrientationClientBlackBerry::lastOrientation() const
+{
+ return m_currentOrientation.get();
+}
+
+void DeviceOrientationClientBlackBerry::onOrientation(const BlackBerry::Platform::DeviceOrientationEvent* event)
+{
+ m_currentOrientation = DeviceOrientation::create(true, event->alpha, true, event->beta, true, event->gamma);
+ if (!m_controller)
+ return;
+
+ m_controller->didChangeDeviceOrientation(lastOrientation());
+}
Added: trunk/Source/WebKit/blackberry/WebCoreSupport/DeviceOrientationClientBlackBerry.h (0 => 106976)
--- trunk/Source/WebKit/blackberry/WebCoreSupport/DeviceOrientationClientBlackBerry.h (rev 0)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/DeviceOrientationClientBlackBerry.h 2012-02-07 20:40:08 UTC (rev 106976)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef DeviceOrientationClientBlackBerry_h
+#define DeviceOrientationClientBlackBerry_h
+
+#include "DeviceOrientation.h"
+#include "DeviceOrientationClient.h"
+
+#include <BlackBerryPlatformDeviceOrientationTrackerListener.h>
+#include <wtf/RefPtr.h>
+
+namespace BlackBerry {
+namespace WebKit {
+class WebPagePrivate;
+}
+}
+
+namespace BlackBerry {
+namespace Platform {
+class DeviceOrientationTracker;
+}
+}
+
+namespace WebCore {
+
+class DeviceOrientationClientBlackBerry : public DeviceOrientationClient, public BlackBerry::Platform::DeviceOrientationTrackerListener {
+public:
+ DeviceOrientationClientBlackBerry(BlackBerry::WebKit::WebPagePrivate*);
+ virtual ~DeviceOrientationClientBlackBerry();
+
+ virtual void setController(DeviceOrientationController*);
+ virtual void startUpdating();
+ virtual void stopUpdating();
+ virtual DeviceOrientation* lastOrientation() const;
+ virtual void deviceOrientationControllerDestroyed();
+ virtual void onOrientation(const BlackBerry::Platform::DeviceOrientationEvent*);
+
+private:
+ BlackBerry::WebKit::WebPagePrivate* m_webPagePrivate;
+ BlackBerry::Platform::DeviceOrientationTracker* m_tracker;
+ DeviceOrientationController* m_controller;
+ RefPtr<DeviceOrientation> m_currentOrientation;
+};
+}
+
+#endif // DeviceOrientationClientBlackBerry_h