summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--LayoutTests/platform/android/test_expectations.txt1
-rw-r--r--WebKit/Android.mk1
-rw-r--r--WebKit/android/WebCoreSupport/DeviceOrientationClientAndroid.cpp5
-rw-r--r--WebKit/android/jni/DeviceOrientationManager.cpp96
-rw-r--r--WebKit/android/jni/DeviceOrientationManager.h58
-rw-r--r--WebKit/android/jni/WebCoreJniOnLoad.cpp2
-rw-r--r--WebKit/android/jni/WebViewCore.h5
7 files changed, 166 insertions, 2 deletions
diff --git a/LayoutTests/platform/android/test_expectations.txt b/LayoutTests/platform/android/test_expectations.txt
index 959a3f0..6d01fd9 100644
--- a/LayoutTests/platform/android/test_expectations.txt
+++ b/LayoutTests/platform/android/test_expectations.txt
@@ -17,7 +17,6 @@
// SLOW - marks the test as being slow to run
editing/selection/move-left-right.html SKIP // Causes DumpRenderTree to hang
-fast/dom/DeviceOrientation/basic-operation.html SKIP // Will cause crash until mock DeviceOrientationClient is hooked up.
fast/js/excessive-comma-usage.html SKIP // Tests huge initializer list, causes OOM.
fast/js/regexp-charclass-crash.html SKIP // RegExp is too large, causing OOM
fast/regex/test1.html SKIP // Causes DumpRenderTree to hang with V8
diff --git a/WebKit/Android.mk b/WebKit/Android.mk
index 032b71a..884853e 100644
--- a/WebKit/Android.mk
+++ b/WebKit/Android.mk
@@ -54,6 +54,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
\
android/icu/unicode/ucnv.cpp \
\
+ android/jni/DeviceOrientationManager.cpp \
android/jni/GeolocationPermissionsBridge.cpp \
android/jni/JavaBridge.cpp \
android/jni/JavaSharedClient.cpp \
diff --git a/WebKit/android/WebCoreSupport/DeviceOrientationClientAndroid.cpp b/WebKit/android/WebCoreSupport/DeviceOrientationClientAndroid.cpp
index 52923fd..d6c8cd6 100644
--- a/WebKit/android/WebCoreSupport/DeviceOrientationClientAndroid.cpp
+++ b/WebKit/android/WebCoreSupport/DeviceOrientationClientAndroid.cpp
@@ -26,6 +26,8 @@
#include "config.h"
#include "DeviceOrientationClientAndroid.h"
+#include "WebViewCore.h"
+
using namespace WebCore;
namespace android {
@@ -68,7 +70,8 @@ DeviceOrientation* DeviceOrientationClientAndroid::lastOrientation() const
DeviceOrientationClient* DeviceOrientationClientAndroid::client() const
{
if (!m_client) {
- // TODO: Get the client from the WebViewCore and set its controller.
+ m_client = m_webViewCore->deviceOrientationManager()->client();
+ m_client->setController(m_controller);
}
return m_client;
}
diff --git a/WebKit/android/jni/DeviceOrientationManager.cpp b/WebKit/android/jni/DeviceOrientationManager.cpp
new file mode 100644
index 0000000..8a48ce8
--- /dev/null
+++ b/WebKit/android/jni/DeviceOrientationManager.cpp
@@ -0,0 +1,96 @@
+/*
+ * 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 "DeviceOrientationManager.h"
+
+#include "WebViewCore.h"
+#include <DeviceOrientationClientMock.h>
+#include <JNIHelp.h>
+
+using namespace WebCore;
+
+namespace android {
+
+DeviceOrientationManager::DeviceOrientationManager()
+ : m_useMock(false)
+{
+}
+
+void DeviceOrientationManager::useMock()
+{
+ m_useMock = true;
+}
+
+void DeviceOrientationManager::setMockOrientation(PassRefPtr<DeviceOrientation> orientation)
+{
+ if (!m_useMock)
+ return;
+ static_cast<DeviceOrientationClientMock*>(client())->setOrientation(orientation);
+};
+
+DeviceOrientationClient* DeviceOrientationManager::client()
+{
+ // FIXME: Implement real client.
+ if (!m_client)
+ m_client.set(m_useMock ? new DeviceOrientationClientMock() : 0);
+ ASSERT(m_client);
+ return m_client.get();
+}
+
+// JNI for android.webkit.MockDeviceOrientation
+static const char* javaDeviceOrientationManagerClass = "android/webkit/DeviceOrientationManager";
+
+static WebViewCore* getWebViewCore(JNIEnv* env, jobject webViewCoreObject)
+{
+ jclass webViewCoreClass = env->FindClass("android/webkit/WebViewCore");
+ jfieldID nativeClassField = env->GetFieldID(webViewCoreClass, "mNativeClass", "I");
+ return reinterpret_cast<WebViewCore*>(env->GetIntField(webViewCoreObject, nativeClassField));
+}
+
+static void useMock(JNIEnv* env, jobject, jobject webViewCoreObject)
+{
+ getWebViewCore(env, webViewCoreObject)->deviceOrientationManager()->useMock();
+}
+
+static void setMockOrientation(JNIEnv* env, jobject, jobject webViewCoreObject, bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma)
+{
+ RefPtr<DeviceOrientation> orientation = DeviceOrientation::create(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma);
+ getWebViewCore(env, webViewCoreObject)->deviceOrientationManager()->setMockOrientation(orientation.release());
+}
+
+static JNINativeMethod gDeviceOrientationManagerMethods[] = {
+ { "nativeUseMock", "(Landroid/webkit/WebViewCore;)V", (void*) useMock },
+ { "nativeSetMockOrientation", "(Landroid/webkit/WebViewCore;ZDZDZD)V", (void*) setMockOrientation }
+};
+
+int register_device_orientation_manager(JNIEnv* env)
+{
+ jclass deviceOrientationManager = env->FindClass(javaDeviceOrientationManagerClass);
+ LOG_ASSERT(deviceOrientationManager, "Unable to find class");
+ return jniRegisterNativeMethods(env, javaDeviceOrientationManagerClass, gDeviceOrientationManagerMethods, NELEM(gDeviceOrientationManagerMethods));
+}
+
+} // namespace android
diff --git a/WebKit/android/jni/DeviceOrientationManager.h b/WebKit/android/jni/DeviceOrientationManager.h
new file mode 100644
index 0000000..0e43c18
--- /dev/null
+++ b/WebKit/android/jni/DeviceOrientationManager.h
@@ -0,0 +1,58 @@
+/*
+ * 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 DeviceOrientationManager_h
+#define DeviceOrientationManager_h
+
+#include <DeviceOrientationClient.h>
+#include <PassRefPtr.h>
+#include <OwnPtr.h>
+
+namespace WebCore {
+class DeviceOrientation;
+}
+
+namespace android {
+
+// This class handles providing a client for DeviceOrientation. This is
+// non-trivial because of the need to be able to use and configure a mock
+// client. This class is owned by WebViewCore and exists to keep cruft out of
+// that class.
+class DeviceOrientationManager {
+public:
+ DeviceOrientationManager();
+
+ void useMock();
+ void setMockOrientation(PassRefPtr<WebCore::DeviceOrientation>);
+ WebCore::DeviceOrientationClient* client();
+
+private:
+ bool m_useMock;
+ OwnPtr<WebCore::DeviceOrientationClient> m_client;
+};
+
+} // namespace android
+
+#endif // DeviceOrientationManager_h
diff --git a/WebKit/android/jni/WebCoreJniOnLoad.cpp b/WebKit/android/jni/WebCoreJniOnLoad.cpp
index 8d51f02..28f20a6 100644
--- a/WebKit/android/jni/WebCoreJniOnLoad.cpp
+++ b/WebKit/android/jni/WebCoreJniOnLoad.cpp
@@ -85,6 +85,7 @@ extern int register_mock_geolocation(JNIEnv*);
extern int register_mediaplayer_audio(JNIEnv*);
extern int register_mediaplayer_video(JNIEnv*);
#endif
+extern int register_device_orientation_manager(JNIEnv*);
}
@@ -111,6 +112,7 @@ static RegistrationMethod gWebCoreRegMethods[] = {
{ "HTML5Audio", android::register_mediaplayer_audio },
{ "HTML5VideoViewProxy", android::register_mediaplayer_video },
#endif
+ { "DeviceOrientationManager", android::register_device_orientation_manager },
};
EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index 99f02e9..d66f2fa 100644
--- a/WebKit/android/jni/WebViewCore.h
+++ b/WebKit/android/jni/WebViewCore.h
@@ -30,6 +30,7 @@
#include "FileChooser.h"
#include "CacheBuilder.h"
#include "CachedHistory.h"
+#include "DeviceOrientationManager.h"
#include "PictureSet.h"
#include "PlatformGraphicsContext.h"
#include "SkColor.h"
@@ -467,6 +468,8 @@ namespace android {
void notifyWebAppCanBeInstalled();
+ DeviceOrientationManager* deviceOrientationManager() { return &m_deviceOrientationManager; }
+
// these members are shared with webview.cpp
static Mutex gFrameCacheMutex;
CachedRoot* m_frameCacheKit; // nav data being built by webcore
@@ -568,6 +571,8 @@ namespace android {
uint32_t m_now;
#endif
+ DeviceOrientationManager m_deviceOrientationManager;
+
private:
// called from constructor, to add this to a global list
static void addInstance(WebViewCore*);