diff options
author | Steve Block <steveblock@google.com> | 2010-08-09 18:30:40 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-08-13 12:42:03 +0100 |
commit | af7a57d40c100e8c29fa6bd758313d0f27d0ac05 (patch) | |
tree | 031aa52b5e04aab89b35496ad18e5c925095a8d1 | |
parent | f2e30ad8bd8c2964e8c3bf9bd88e86f94d0d0a9b (diff) | |
download | external_webkit-af7a57d40c100e8c29fa6bd758313d0f27d0ac05.zip external_webkit-af7a57d40c100e8c29fa6bd758313d0f27d0ac05.tar.gz external_webkit-af7a57d40c100e8c29fa6bd758313d0f27d0ac05.tar.bz2 |
Merge WebKit at r65072 : Implement DeviceMotionClientAndroid
This class acts simply as a proxy to the real or mock client, which is owned by
the WebView. DEVICE_ORIENTATION is enabled on Android, so we must implement this
client before we pull in http://trac.webkit.org/changeset/64845, which calls
DeviceMotionClient::setController() from the Page constructor.
Change-Id: I8cf448f26103df3e55098e70eec80d845725761f
-rw-r--r-- | WebKit/Android.mk | 1 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/DeviceMotionClientAndroid.cpp | 78 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/DeviceMotionClientAndroid.h | 64 | ||||
-rw-r--r-- | WebKit/android/jni/WebCoreFrameBridge.cpp | 4 | ||||
-rw-r--r-- | WebKit/android/jni/WebCoreJniOnLoad.cpp | 4 |
5 files changed, 151 insertions, 0 deletions
diff --git a/WebKit/Android.mk b/WebKit/Android.mk index 884853e..4f16f4c 100644 --- a/WebKit/Android.mk +++ b/WebKit/Android.mk @@ -19,6 +19,7 @@ LOCAL_SRC_FILES := \ android/WebCoreSupport/CachedFramePlatformDataAndroid.cpp \ android/WebCoreSupport/ChromeClientAndroid.cpp \ android/WebCoreSupport/ContextMenuClientAndroid.cpp \ + android/WebCoreSupport/DeviceMotionClientAndroid.cpp \ android/WebCoreSupport/DeviceOrientationClientAndroid.cpp \ android/WebCoreSupport/DragClientAndroid.cpp \ android/WebCoreSupport/EditorClientAndroid.cpp \ diff --git a/WebKit/android/WebCoreSupport/DeviceMotionClientAndroid.cpp b/WebKit/android/WebCoreSupport/DeviceMotionClientAndroid.cpp new file mode 100644 index 0000000..5ca820d --- /dev/null +++ b/WebKit/android/WebCoreSupport/DeviceMotionClientAndroid.cpp @@ -0,0 +1,78 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "DeviceMotionClientAndroid.h" + +#include "WebViewCore.h" + +using namespace WebCore; + +namespace android { + +DeviceMotionClientAndroid::DeviceMotionClientAndroid() + : m_client(0) +{ +} + +void DeviceMotionClientAndroid::setWebViewCore(WebViewCore* webViewCore) +{ + m_webViewCore = webViewCore; + ASSERT(m_webViewCore); +} + +void DeviceMotionClientAndroid::setController(DeviceMotionController* controller) +{ + // This will be called by the Page constructor before the WebViewCore + // has been configured regarding the mock. We cache the controller for + // later use. + m_controller = controller; + ASSERT(m_controller); +} + +void DeviceMotionClientAndroid::startUpdating() +{ + client()->startUpdating(); +} + +void DeviceMotionClientAndroid::stopUpdating() +{ + client()->stopUpdating(); +} + +DeviceMotionData* DeviceMotionClientAndroid::currentDeviceMotion() const +{ + return client()->currentDeviceMotion(); +} + +DeviceMotionClient* DeviceMotionClientAndroid::client() const +{ + if (!m_client) { + // TODO: Get the client from the WebViewCore and set its controller. + } + return m_client; +} + +} // namespace android diff --git a/WebKit/android/WebCoreSupport/DeviceMotionClientAndroid.h b/WebKit/android/WebCoreSupport/DeviceMotionClientAndroid.h new file mode 100644 index 0000000..c38d110 --- /dev/null +++ b/WebKit/android/WebCoreSupport/DeviceMotionClientAndroid.h @@ -0,0 +1,64 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DeviceMotionClientAndroid_h +#define DeviceMotionClientAndroid_h + +#include <DeviceMotionClient.h> + +namespace WebCore { +class DeviceMotionController; +} + +namespace android { + +class WebViewCore; + +// The Android implementation of DeviceMotionClient. Acts as a proxy to +// the real or mock impl, which is owned by the WebViewCore. +class DeviceMotionClientAndroid : public WebCore::DeviceMotionClient { +public: + DeviceMotionClientAndroid(); + + void setWebViewCore(WebViewCore*); + + // DeviceMotionClient methods + virtual void setController(WebCore::DeviceMotionController*); + virtual void startUpdating(); + virtual void stopUpdating(); + virtual WebCore::DeviceMotionData* currentDeviceMotion() const; + +private: + WebCore::DeviceMotionClient* client() const; + + WebViewCore* m_webViewCore; + WebCore::DeviceMotionController* m_controller; + // Lazily obtained cache of the client owned by the WebViewCore. + mutable WebCore::DeviceMotionClient* m_client; +}; + +} // namespace android + +#endif // DeviceMotionClientAndroid_h diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp index 392f931..10c8439 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -35,6 +35,7 @@ #include "Chrome.h" #include "ChromeClientAndroid.h" #include "ContextMenuClientAndroid.h" +#include "DeviceMotionClientAndroid.h" #include "DeviceOrientationClientAndroid.h" #include "Document.h" #include "DocumentLoader.h" @@ -879,6 +880,7 @@ static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAss // Create a new page ChromeClientAndroid* chromeC = new ChromeClientAndroid; EditorClientAndroid* editorC = new EditorClientAndroid; + DeviceMotionClientAndroid* deviceMotionC = new DeviceMotionClientAndroid; DeviceOrientationClientAndroid* deviceOrientationC = new DeviceOrientationClientAndroid; WebCore::Page::PageClients pageClients; @@ -887,6 +889,7 @@ static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAss pageClients.editorClient = editorC; pageClients.dragClient = new DragClientAndroid; pageClients.inspectorClient = new InspectorClientAndroid; + pageClients.deviceMotionClient = deviceMotionC; pageClients.deviceOrientationClient = deviceOrientationC; WebCore::Page* page = new WebCore::Page(pageClients); @@ -926,6 +929,7 @@ static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAss // Set the frame to active to turn on keyboard focus. frame->init(); frame->selection()->setFocused(true); + deviceMotionC->setWebViewCore(webViewCore); deviceOrientationC->setWebViewCore(webViewCore); // Allow local access to file:/// and substitute data diff --git a/WebKit/android/jni/WebCoreJniOnLoad.cpp b/WebKit/android/jni/WebCoreJniOnLoad.cpp index 6253487..57fccac 100644 --- a/WebKit/android/jni/WebCoreJniOnLoad.cpp +++ b/WebKit/android/jni/WebCoreJniOnLoad.cpp @@ -31,6 +31,7 @@ #include "ChromeClientAndroid.h" #include "ContextMenuClientAndroid.h" #include "CookieClient.h" +#include "DeviceMotionClientAndroid.h" #include "DeviceOrientationClientAndroid.h" #include "DragClientAndroid.h" #include "EditorClientAndroid.h" @@ -191,6 +192,7 @@ EXPORT void benchmark(const char* url, int reloadCount, int width, int height) { // Create the page with all the various clients ChromeClientAndroid* chrome = new ChromeClientAndroid; EditorClientAndroid* editor = new EditorClientAndroid; + DeviceMotionClientAndroid* deviceMotion = new DeviceMotionClientAndroid; DeviceOrientationClientAndroid* deviceOrientation = new DeviceOrientationClientAndroid; WebCore::Page::PageClients pageClients; pageClients.chromeClient = chrome; @@ -198,6 +200,7 @@ EXPORT void benchmark(const char* url, int reloadCount, int width, int height) { pageClients.editorClient = editor; pageClients.dragClient = new DragClientAndroid; pageClients.inspectorClient = new InspectorClientAndroid; + pageClients.deviceMotionClient = deviceMotion; pageClients.deviceOrientationClient = deviceOrientation; WebCore::Page* page = new WebCore::Page(pageClients); editor->setPage(page); @@ -231,6 +234,7 @@ EXPORT void benchmark(const char* url, int reloadCount, int width, int height) { frame->init(); frame->selection()->setFocused(true); + deviceMotion->setWebViewCore(webViewCore); deviceOrientation->setWebViewCore(webViewCore); // Set all the default settings the Browser normally uses. |