diff options
181 files changed, 4443 insertions, 2723 deletions
@@ -62,94 +62,6 @@ WEBKIT_SRC_FILES := # We have to use bison 2.3 include $(BASE_PATH)/bison_check.mk -ifeq ($(JAVASCRIPT_ENGINE),v8) -# Include WTF source file. -d := JavaScriptCore -LOCAL_PATH := $(BASE_PATH)/$d -intermediates := $(base_intermediates)/$d -include $(LOCAL_PATH)/Android.v8.wtf.mk -WEBKIT_SRC_FILES += $(addprefix $d/,$(LOCAL_SRC_FILES)) -endif # JAVASCRIPT_ENGINE == v8 - -# Include source files for WebCore -d := WebCore -LOCAL_PATH := $(BASE_PATH)/$d -JAVASCRIPTCORE_PATH := $(BASE_PATH)/JavaScriptCore -intermediates := $(base_intermediates)/$d -include $(LOCAL_PATH)/Android.mk -ifeq ($(JAVASCRIPT_ENGINE),jsc) -include $(LOCAL_PATH)/Android.jscbindings.mk -endif -ifeq ($(JAVASCRIPT_ENGINE),v8) -include $(LOCAL_PATH)/Android.v8bindings.mk -# TODO: We should use the WebCore JNI code instead. -JNI_PATH := V8Binding/jni -# bridge/jni path must be listed after V8Bindings, so files are preferentially -# included from V8bindings. -BINDING_C_INCLUDES += \ - $(BASE_PATH)/$(JNI_PATH) \ - $(LOCAL_PATH)/bridge/jni \ - $(LOCAL_PATH)/bridge/jni/v8 -JNI_SRC_FILES := \ - jni_class.cpp \ - jni_instance.cpp \ - jni_npobject.cpp \ - jni_runtime.cpp -WEBKIT_SRC_FILES += $(addprefix $(JNI_PATH)/,$(JNI_SRC_FILES)) -endif -WEBKIT_SRC_FILES += $(addprefix $d/,$(LOCAL_SRC_FILES)) -LOCAL_C_INCLUDES := $(BINDING_C_INCLUDES) - -# Include the derived source files for WebCore. Uses the same path as -# WebCore -include $(LOCAL_PATH)/Android.derived.mk -ifeq ($(JAVASCRIPT_ENGINE),jsc) -include $(LOCAL_PATH)/Android.derived.jscbindings.mk -endif -ifeq ($(JAVASCRIPT_ENGINE),v8) -include $(LOCAL_PATH)/Android.derived.v8bindings.mk -endif - -# Include source files for android WebKit port -d := WebKit -LOCAL_PATH := $(BASE_PATH)/$d -intermediates := $(base_intermediates)/$d -include $(LOCAL_PATH)/Android.mk -WEBKIT_SRC_FILES += $(addprefix $d/,$(LOCAL_SRC_FILES)) - -# Redefine LOCAL_PATH here so the build system is not confused -LOCAL_PATH := $(BASE_PATH) - -# Define our compiler flags -LOCAL_CFLAGS += -Wno-endif-labels -Wno-import -Wno-format -LOCAL_CFLAGS += -fno-strict-aliasing -LOCAL_CFLAGS += -include "WebCorePrefix.h" -LOCAL_CFLAGS += -fvisibility=hidden -LOCAL_CFLAGS += -D__SGI_STL_INTERNAL_PAIR_H - -ifeq ($(TARGET_ARCH),arm) -LOCAL_CFLAGS += -Darm -# remove this warning: "note: the mangling of 'va_list' has changed in GCC 4.4" -LOCAL_CFLAGS += -Wno-psabi -endif - -ifeq ($(ENABLE_SVG),true) -LOCAL_CFLAGS += -DENABLE_SVG=1 -endif - -# Temporary disable SVG_ANIMATION. -ifeq ($(ENABLE_SVG_ANIMATION),true) -LOCAL_CFLAGS += -DENABLE_SVG_ANIMATION=1 -endif - -ifeq ($(WEBCORE_INSTRUMENTATION),true) -LOCAL_CFLAGS += -DANDROID_INSTRUMENT -endif - -# LOCAL_LDLIBS is used in simulator builds only and simulator builds are only -# valid on Linux -LOCAL_LDLIBS += -lpthread -ldl - # Build our list of include paths. We include WebKit/android/icu first so that # any files that include <unicode/ucnv.h> will include our ucnv.h first. We # also add external/ as an include directory so that we can specify the real @@ -157,7 +69,7 @@ LOCAL_LDLIBS += -lpthread -ldl # # Note that JavasCriptCore/ must be included after WebCore/, so that we pick up # the right config.h. -LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \ +LOCAL_C_INCLUDES := \ $(JNI_H_INCLUDE) \ $(LOCAL_PATH)/WebKit/android/icu \ bionic/ \ @@ -244,6 +156,91 @@ LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \ $(base_intermediates)/WebCore/svg endif +ifeq ($(JAVASCRIPT_ENGINE),v8) +# Include WTF source file. +d := JavaScriptCore +LOCAL_PATH := $(BASE_PATH)/$d +intermediates := $(base_intermediates)/$d +include $(LOCAL_PATH)/Android.v8.wtf.mk +WEBKIT_SRC_FILES += $(addprefix $d/,$(LOCAL_SRC_FILES)) +endif # JAVASCRIPT_ENGINE == v8 + +# Include source files for WebCore +d := WebCore +LOCAL_PATH := $(BASE_PATH)/$d +JAVASCRIPTCORE_PATH := $(BASE_PATH)/JavaScriptCore +intermediates := $(base_intermediates)/$d +include $(LOCAL_PATH)/Android.mk +ifeq ($(JAVASCRIPT_ENGINE),jsc) +include $(LOCAL_PATH)/Android.jscbindings.mk +endif +ifeq ($(JAVASCRIPT_ENGINE),v8) +include $(LOCAL_PATH)/Android.v8bindings.mk +# TODO: We should use the WebCore JNI code instead. +JNI_PATH := V8Binding/jni +# bridge/jni path must be listed after V8Bindings, so files are preferentially +# included from V8bindings. +BINDING_C_INCLUDES += \ + $(BASE_PATH)/$(JNI_PATH) \ + $(LOCAL_PATH)/bridge/jni \ + $(LOCAL_PATH)/bridge/jni/v8 +JNI_SRC_FILES := \ + jni_runtime.cpp +WEBKIT_SRC_FILES += $(addprefix $(JNI_PATH)/,$(JNI_SRC_FILES)) +endif +WEBKIT_SRC_FILES += $(addprefix $d/,$(LOCAL_SRC_FILES)) +LOCAL_C_INCLUDES += $(BINDING_C_INCLUDES) + +# Include the derived source files for WebCore. Uses the same path as +# WebCore +include $(LOCAL_PATH)/Android.derived.mk +ifeq ($(JAVASCRIPT_ENGINE),jsc) +include $(LOCAL_PATH)/Android.derived.jscbindings.mk +endif +ifeq ($(JAVASCRIPT_ENGINE),v8) +include $(LOCAL_PATH)/Android.derived.v8bindings.mk +endif + +# Include source files for android WebKit port +d := WebKit +LOCAL_PATH := $(BASE_PATH)/$d +intermediates := $(base_intermediates)/$d +include $(LOCAL_PATH)/Android.mk +WEBKIT_SRC_FILES += $(addprefix $d/,$(LOCAL_SRC_FILES)) + +# Redefine LOCAL_PATH here so the build system is not confused +LOCAL_PATH := $(BASE_PATH) + +# Define our compiler flags +LOCAL_CFLAGS += -Wno-endif-labels -Wno-import -Wno-format +LOCAL_CFLAGS += -fno-strict-aliasing +LOCAL_CFLAGS += -include "WebCorePrefix.h" +LOCAL_CFLAGS += -fvisibility=hidden +LOCAL_CFLAGS += -D__SGI_STL_INTERNAL_PAIR_H + +ifeq ($(TARGET_ARCH),arm) +LOCAL_CFLAGS += -Darm +# remove this warning: "note: the mangling of 'va_list' has changed in GCC 4.4" +LOCAL_CFLAGS += -Wno-psabi +endif + +ifeq ($(ENABLE_SVG),true) +LOCAL_CFLAGS += -DENABLE_SVG=1 +endif + +# Temporary disable SVG_ANIMATION. +ifeq ($(ENABLE_SVG_ANIMATION),true) +LOCAL_CFLAGS += -DENABLE_SVG_ANIMATION=1 +endif + +ifeq ($(WEBCORE_INSTRUMENTATION),true) +LOCAL_CFLAGS += -DANDROID_INSTRUMENT +endif + +# LOCAL_LDLIBS is used in simulator builds only and simulator builds are only +# valid on Linux +LOCAL_LDLIBS += -lpthread -ldl + # Build the list of shared libraries LOCAL_SHARED_LIBRARIES := \ libandroid_runtime \ diff --git a/JavaScriptCore/wtf/ThreadingPthreads.cpp b/JavaScriptCore/wtf/ThreadingPthreads.cpp index fe7b26a..f5cba5d 100644 --- a/JavaScriptCore/wtf/ThreadingPthreads.cpp +++ b/JavaScriptCore/wtf/ThreadingPthreads.cpp @@ -46,7 +46,7 @@ #endif #if PLATFORM(ANDROID) -#include "jni_utility.h" +#include "JNIUtility.h" #endif namespace WTF { diff --git a/V8Binding/jni/jni_runtime.cpp b/V8Binding/jni/jni_runtime.cpp index 2fbcc5d..6428bf2 100644 --- a/V8Binding/jni/jni_runtime.cpp +++ b/V8Binding/jni/jni_runtime.cpp @@ -1,6 +1,5 @@ /* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * Copyright 2009, The Android Open Source Project + * 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 @@ -21,84 +20,81 @@ * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" - #include "jni_runtime.h" -#include "jni_utility.h" + +#include "JNIUtility.h" using namespace JSC::Bindings; -JavaParameter::JavaParameter (JNIEnv *env, jstring type) +JavaParameter::JavaParameter(JNIEnv* env, jstring type) { - _type = JavaString (env, type); - _JNIType = JNITypeFromClassName (_type.UTF8String()); + m_type = JavaString(env, type); + m_JNIType = JNITypeFromClassName(m_type.UTF8String()); } - -JavaField::JavaField (JNIEnv *env, jobject aField) +JavaField::JavaField(JNIEnv* env, jobject aField) { // Get field type jobject fieldType = callJNIMethod<jobject>(aField, "getType", "()Ljava/lang/Class;"); - jstring fieldTypeName = (jstring)callJNIMethod<jobject>(fieldType, "getName", "()Ljava/lang/String;"); - _type = JavaString(env, fieldTypeName); - _JNIType = JNITypeFromClassName (_type.UTF8String()); + jstring fieldTypeName = static_cast<jstring>(callJNIMethod<jobject>(fieldType, "getName", "()Ljava/lang/String;")); + m_type = JavaString(env, fieldTypeName); + m_JNIType = JNITypeFromClassName(m_type.UTF8String()); // Get field name - jstring fieldName = (jstring)callJNIMethod<jobject>(aField, "getName", "()Ljava/lang/String;"); - _name = JavaString(env, fieldName); + jstring fieldName = static_cast<jstring>(callJNIMethod<jobject>(aField, "getName", "()Ljava/lang/String;")); + m_name = JavaString(env, fieldName); - _field = new JObjectWrapper(aField); + m_field = new JObjectWrapper(aField); } - -JavaMethod::JavaMethod (JNIEnv *env, jobject aMethod) +JavaMethod::JavaMethod(JNIEnv* env, jobject aMethod) { // Get return type jobject returnType = callJNIMethod<jobject>(aMethod, "getReturnType", "()Ljava/lang/Class;"); - jstring returnTypeName = (jstring)callJNIMethod<jobject>(returnType, "getName", "()Ljava/lang/String;"); - _returnType =JavaString (env, returnTypeName); - _JNIReturnType = JNITypeFromClassName (_returnType.UTF8String()); - env->DeleteLocalRef (returnType); - env->DeleteLocalRef (returnTypeName); + jstring returnTypeName = static_cast<jstring>(callJNIMethod<jobject>(returnType, "getName", "()Ljava/lang/String;")); + m_returnType = JavaString(env, returnTypeName); + m_JNIReturnType = JNITypeFromClassName(m_returnType.UTF8String()); + env->DeleteLocalRef(returnType); + env->DeleteLocalRef(returnTypeName); // Get method name - jstring methodName = (jstring)callJNIMethod<jobject>(aMethod, "getName", "()Ljava/lang/String;"); - _name = JavaString (env, methodName); - env->DeleteLocalRef (methodName); + jstring methodName = static_cast<jstring>(callJNIMethod<jobject>(aMethod, "getName", "()Ljava/lang/String;")); + m_name = JavaString(env, methodName); + env->DeleteLocalRef(methodName); // Get parameters - jarray jparameters = (jarray)callJNIMethod<jobject>(aMethod, "getParameterTypes", "()[Ljava/lang/Class;"); - _numParameters = env->GetArrayLength (jparameters); - _parameters = new JavaParameter[_numParameters]; - - int i; - for (i = 0; i < _numParameters; i++) { - jobject aParameter = env->GetObjectArrayElement ((jobjectArray)jparameters, i); - jstring parameterName = (jstring)callJNIMethod<jobject>(aParameter, "getName", "()Ljava/lang/String;"); - _parameters[i] = JavaParameter(env, parameterName); - env->DeleteLocalRef (aParameter); - env->DeleteLocalRef (parameterName); + jarray jparameters = static_cast<jarray>(callJNIMethod<jobject>(aMethod, "getParameterTypes", "()[Ljava/lang/Class;")); + m_numParameters = env->GetArrayLength(jparameters); + m_parameters = new JavaParameter[m_numParameters]; + + for (int i = 0; i < m_numParameters; i++) { + jobject aParameter = env->GetObjectArrayElement(static_cast<jobjectArray>(jparameters), i); + jstring parameterName = static_cast<jstring>(callJNIMethod<jobject>(aParameter, "getName", "()Ljava/lang/String;")); + m_parameters[i] = JavaParameter(env, parameterName); + env->DeleteLocalRef(aParameter); + env->DeleteLocalRef(parameterName); } - env->DeleteLocalRef (jparameters); + env->DeleteLocalRef(jparameters); // Created lazily. - _signature = 0; - _methodID = 0; - + m_signature = 0; + m_methodID = 0; + jclass modifierClass = env->FindClass("java/lang/reflect/Modifier"); int modifiers = callJNIMethod<jint>(aMethod, "getModifiers", "()I"); - _isStatic = (bool)callJNIStaticMethod<jboolean>(modifierClass, "isStatic", "(I)Z", modifiers); + m_isStatic = static_cast<bool>(callJNIStaticMethod<jboolean>(modifierClass, "isStatic", "(I)Z", modifiers)); env->DeleteLocalRef(modifierClass); } -JavaMethod::~JavaMethod() +JavaMethod::~JavaMethod() { - if (_signature) - free(_signature); - delete [] _parameters; + if (m_signature) + free(m_signature); + delete[] m_parameters; }; @@ -107,20 +103,20 @@ public: explicit SignatureBuilder(int init_size) { if (init_size <= 0) init_size = 16; - size_ = init_size; - length_ = 0; - storage_ = (char*)malloc(size_ * sizeof(char)); + m_size = init_size; + m_length = 0; + m_storage = (char*)malloc(m_size * sizeof(char)); } ~SignatureBuilder() { - free(storage_); + free(m_storage); } void append(const char* s) { int l = strlen(s); expandIfNeeded(l); - memcpy(storage_ + length_, s, l); - length_ += l; + memcpy(m_storage + m_length, s, l); + m_length += l; } // JNI method signatures use '/' between components of a class name, but @@ -129,9 +125,9 @@ public: int l = strlen(className); expandIfNeeded(l); - char* sp = storage_ + length_; + char* sp = m_storage + m_length; const char* cp = className; - + while (*cp) { if (*cp == '.') *sp = '/'; @@ -142,86 +138,83 @@ public: sp++; } - length_ += l; + m_length += l; } // make a duplicated copy of the content. char* ascii() { - if (length_ == 0) + if (m_length == 0) return NULL; - storage_[length_] = '\0'; - return strndup(storage_, length_); + m_storage[m_length] = '\0'; + return strndup(m_storage, m_length); } private: void expandIfNeeded(int l) { // expand storage if needed - if (l + length_ >= size_) { - int new_size = 2 * size_; - if (l + length_ >= new_size) - new_size = l + length_ + 1; + if (l + m_length >= m_size) { + int new_size = 2 * m_size; + if (l + m_length >= new_size) + new_size = l + m_length + 1; char* new_storage = (char*)malloc(new_size * sizeof(char)); - memcpy(new_storage, storage_, length_); - size_ = new_size; - free(storage_); - storage_ = new_storage; + memcpy(new_storage, m_storage, m_length); + m_size = new_size; + free(m_storage); + m_storage = new_storage; } } - int size_; - int length_; - char* storage_; + int m_size; + int m_length; + char* m_storage; }; -const char *JavaMethod::signature() const +const char* JavaMethod::signature() const { - if (!_signature) { + if (!m_signature) { SignatureBuilder signatureBuilder(64); signatureBuilder.append("("); - for (int i = 0; i < _numParameters; i++) { + for (int i = 0; i < m_numParameters; i++) { JavaParameter* aParameter = parameterAt(i); - JNIType _JNIType = aParameter->getJNIType(); - if (_JNIType == array_type) + JNIType type = aParameter->getJNIType(); + if (type == array_type) signatureBuilder.appendClassName(aParameter->type()); else { - signatureBuilder.append(signatureFromPrimitiveType(_JNIType)); - if (_JNIType == object_type) { + signatureBuilder.append(signatureFromPrimitiveType(type)); + if (type == object_type) { signatureBuilder.appendClassName(aParameter->type()); signatureBuilder.append(";"); } } } signatureBuilder.append(")"); - - const char *returnType = _returnType.UTF8String(); - if (_JNIReturnType == array_type) { + + const char* returnType = m_returnType.UTF8String(); + if (m_JNIReturnType == array_type) signatureBuilder.appendClassName(returnType); - } else { - signatureBuilder.append(signatureFromPrimitiveType(_JNIReturnType)); - if (_JNIReturnType == object_type) { + else { + signatureBuilder.append(signatureFromPrimitiveType(m_JNIReturnType)); + if (m_JNIReturnType == object_type) { signatureBuilder.appendClassName(returnType); signatureBuilder.append(";"); } } - - _signature = signatureBuilder.ascii(); + + m_signature = signatureBuilder.ascii(); } - - return _signature; + + return m_signature; } JNIType JavaMethod::JNIReturnType() const { - return _JNIReturnType; + return m_JNIReturnType; } -jmethodID JavaMethod::methodID (jobject obj) const +jmethodID JavaMethod::methodID(jobject obj) const { - if (_methodID == 0) { - _methodID = getMethodID (obj, _name.UTF8String(), signature()); - } - return _methodID; + if (!m_methodID) + m_methodID = getMethodID(obj, m_name.UTF8String(), signature()); + return m_methodID; } - - diff --git a/V8Binding/jni/jni_runtime.h b/V8Binding/jni/jni_runtime.h index 0e3f98f..735e2c2 100644 --- a/V8Binding/jni/jni_runtime.h +++ b/V8Binding/jni/jni_runtime.h @@ -1,6 +1,5 @@ /* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * Copyright 2009, The Android Open Source Project + * 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 @@ -21,124 +20,110 @@ * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _JNI_RUNTIME_H_ -#define _JNI_RUNTIME_H_ +#ifndef jni_runtime_h +#define jni_runtime_h -#include "jni_utility.h" -#include "jni_instance.h" +#include "JNIUtility.h" +#include "JavaInstanceV8.h" -#include "CString.h" +#if USE(V8) +#include "JavaStringV8.h" +#endif -namespace JSC -{ +namespace JSC { -namespace Bindings -{ +namespace Bindings { -class JavaString -{ +class JavaString { public: - JavaString() { } - - void _commonInit (JNIEnv *e, jstring s) + JavaString() { - int size = e->GetStringLength(s); - const char* cs = getCharactersFromJStringInEnv(e, s); - { - _utf8String = WebCore::CString(cs, size); - } - releaseCharactersForJStringInEnv (e, s, cs); - } - - JavaString (JNIEnv *e, jstring s) { - _commonInit (e, s); + m_impl.init(); } - - JavaString (jstring s) { - _commonInit (getJNIEnv(), s); + + JavaString(JNIEnv* e, jstring s) + { + m_impl.init(e, s); } - - ~JavaString() { } - - int length() const { return _utf8String.length(); } - - const char* UTF8String() const { - return _utf8String.data(); + + JavaString(jstring s) + { + m_impl.init(getJNIEnv(), s); } + const char* UTF8String() const { return m_impl.UTF8String(); } + const jchar* uchars() const { return m_impl.uchars(); } + int length() const { return m_impl.length(); } + private: - WebCore::CString _utf8String; + JavaStringImpl m_impl; }; - -class JavaParameter -{ +class JavaParameter { public: - JavaParameter () : _JNIType(invalid_type) {}; - JavaParameter (JNIEnv *env, jstring type); + JavaParameter() : m_JNIType(invalid_type) { } + JavaParameter(JNIEnv*, jstring type); virtual ~JavaParameter() { } - const char* type() const { return _type.UTF8String(); } - JNIType getJNIType() const { return _JNIType; } - + const char* type() const { return m_type.UTF8String(); } + JNIType getJNIType() const { return m_JNIType; } + private: - JavaString _type; - JNIType _JNIType; + JavaString m_type; + JNIType m_JNIType; }; -class JavaField -{ +class JavaField { public: - JavaField (JNIEnv *env, jobject aField); + JavaField(JNIEnv*, jobject aField); - const char* name() const { return _name.UTF8String(); } - const char* type() const { return _type.UTF8String(); } + const JavaString& name() const { return m_name; } + const char* type() const { return m_type.UTF8String(); } + + JNIType getJNIType() const { return m_JNIType; } - JNIType getJNIType() const { return _JNIType; } - private: - JavaString _name; - JavaString _type; - JNIType _JNIType; - RefPtr<JObjectWrapper> _field; + JavaString m_name; + JavaString m_type; + JNIType m_JNIType; + RefPtr<JObjectWrapper> m_field; }; -class JavaMethod -{ +class JavaMethod { public: - JavaMethod(JNIEnv* env, jobject aMethod); + JavaMethod(JNIEnv*, jobject aMethod); ~JavaMethod(); - const char* name() const { return _name.UTF8String(); } - const char* returnType() const { return _returnType.UTF8String(); }; - JavaParameter* parameterAt(int i) const { return &_parameters[i]; }; - int numParameters() const { return _numParameters; }; - - const char *signature() const; + const JavaString& name() const { return m_name; } + const char* returnType() const { return m_returnType.UTF8String(); } + JavaParameter* parameterAt(int i) const { return &m_parameters[i]; } + int numParameters() const { return m_numParameters; } + + const char* signature() const; JNIType JNIReturnType() const; - jmethodID methodID (jobject obj) const; - - bool isStatic() const { return _isStatic; } + jmethodID methodID(jobject obj) const; + + bool isStatic() const { return m_isStatic; } private: - JavaParameter* _parameters; - int _numParameters; - JavaString _name; - mutable char* _signature; - JavaString _returnType; - JNIType _JNIReturnType; - mutable jmethodID _methodID; - bool _isStatic; + JavaParameter* m_parameters; + int m_numParameters; + JavaString m_name; + mutable char* m_signature; + JavaString m_returnType; + JNIType m_JNIReturnType; + mutable jmethodID m_methodID; + bool m_isStatic; }; } // namespace Bindings } // namespace JSC -#endif // _JNI_RUNTIME_H_ +#endif // jni_runtime_h diff --git a/WebCore/Android.derived.jscbindings.mk b/WebCore/Android.derived.jscbindings.mk index d7ca0a4..cc7ba28 100644 --- a/WebCore/Android.derived.jscbindings.mk +++ b/WebCore/Android.derived.jscbindings.mk @@ -289,6 +289,7 @@ $(patsubst %.h,%.cpp,$(GEN)): $(intermediates)/loader/appcache/%.cpp : $(interme # page GEN := \ $(intermediates)/page/JSBarInfo.h \ + $(intermediates)/page/JSConnection.h \ $(intermediates)/page/JSConsole.h \ $(intermediates)/page/JSCoordinates.h \ $(intermediates)/page/JSDOMSelection.h \ diff --git a/WebCore/Android.derived.v8bindings.mk b/WebCore/Android.derived.v8bindings.mk index a9f403a..e3bd4ca 100644 --- a/WebCore/Android.derived.v8bindings.mk +++ b/WebCore/Android.derived.v8bindings.mk @@ -281,6 +281,7 @@ $(patsubst %.h,%.cpp,$(GEN)): $(intermediates)/bindings/%.cpp : $(intermediates) # page GEN := \ $(intermediates)/bindings/V8BarInfo.h \ + $(intermediates)/bindings/V8Connection.h \ $(intermediates)/bindings/V8Console.h \ $(intermediates)/bindings/V8Coordinates.h \ $(intermediates)/bindings/V8DOMSelection.h \ diff --git a/WebCore/Android.jscbindings.mk b/WebCore/Android.jscbindings.mk index 6dd55ff..428f99a 100644 --- a/WebCore/Android.jscbindings.mk +++ b/WebCore/Android.jscbindings.mk @@ -29,6 +29,7 @@ BINDING_C_INCLUDES := \ $(LOCAL_PATH)/bridge/c \ $(LOCAL_PATH)/bridge/jni \ $(LOCAL_PATH)/bridge/jni/jsc \ + $(LOCAL_PATH)/bridge/jsc \ \ $(JAVASCRIPTCORE_PATH)/API \ $(JAVASCRIPTCORE_PATH)/assembler \ @@ -187,13 +188,13 @@ LOCAL_SRC_FILES += \ bridge/c/c_instance.cpp \ bridge/c/c_runtime.cpp \ bridge/c/c_utility.cpp \ - bridge/jni/jni_class.cpp \ - bridge/jni/jni_instance.cpp \ - bridge/jni/jni_runtime.cpp \ - bridge/jni/jni_utility.cpp \ - bridge/jni/jsc/jni_utility_private.cpp \ + bridge/jni/JNIBridge.cpp \ + bridge/jni/JNIUtility.cpp \ + bridge/jni/jsc/JNIUtilityPrivate.cpp \ + bridge/jni/jsc/JavaClassJSC.cpp \ + bridge/jni/jsc/JavaInstanceJSC.cpp \ + bridge/jsc/BridgeJSC.cpp \ bridge/npruntime.cpp \ - bridge/runtime.cpp \ bridge/runtime_array.cpp \ bridge/runtime_method.cpp \ bridge/runtime_object.cpp \ diff --git a/WebCore/Android.mk b/WebCore/Android.mk index d5bc740..7c3781a 100644 --- a/WebCore/Android.mk +++ b/WebCore/Android.mk @@ -326,6 +326,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ \ page/BarInfo.cpp \ page/Chrome.cpp \ + page/Connection.cpp \ page/Console.cpp \ page/ContextMenuController.cpp \ page/DOMSelection.cpp \ @@ -401,6 +402,8 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ platform/android/GeolocationServiceBridge.cpp \ platform/android/KeyEventAndroid.cpp \ platform/android/LocalizedStringsAndroid.cpp \ + platform/android/PlatformTouchEventAndroid.cpp \ + platform/android/PlatformTouchPointAndroid.cpp \ platform/android/PopupMenuAndroid.cpp \ platform/android/RenderThemeAndroid.cpp \ platform/android/ScreenAndroid.cpp \ diff --git a/WebCore/Android.v8bindings.mk b/WebCore/Android.v8bindings.mk index 5ab8e69..d5eb37a 100644 --- a/WebCore/Android.v8bindings.mk +++ b/WebCore/Android.v8bindings.mk @@ -171,5 +171,8 @@ LOCAL_SRC_FILES += \ bindings/v8/custom/V8XMLSerializerConstructor.cpp LOCAL_SRC_FILES += \ - bridge/jni/jni_utility.cpp \ - bridge/jni/v8/jni_utility_private.cpp + bridge/jni/JNIUtility.cpp \ + bridge/jni/v8/JNIUtilityPrivate.cpp \ + bridge/jni/v8/JavaNPObjectV8.cpp \ + bridge/jni/v8/JavaClassV8.cpp \ + bridge/jni/v8/JavaInstanceV8.cpp diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 67567ab..777f32b 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,346 @@ +2010-01-21 Steve Block <steveblock@google.com> + + Reviewed by David Levin. + + Move bridge interfaces Field, Class, Instance and Array from Bridge to BridgeJSC + https://bugs.webkit.org/show_bug.cgi?id=33589 + + These interfaces use JSC-specific types, so are moved out of Bridge.h to allow the file to + be used with both JSC and V8. + + No new tests, refactoring only. + + * Android.jscbindings.mk: Modified. Removed Bridge.cpp and added BridgeJSC.cpp + * GNUmakefile.am: Modified. Removed Bridge.cpp and added BridgeJSC.[cpp|h] + * WebCore.pro: Modified. Removed Bridge.cpp and added BridgeJSC.[cpp|h] + * WebCore.xcodeproj/project.pbxproj: Modified. Removed Bridge.cpp and added BridgeJSC.[cpp|h] + * WebCoreSources.bkl: Modified. Removed Bridge.cpp and added BridgeJSC.cpp + * bridge/Bridge.cpp: Removed. + * bridge/Bridge.h: Modfied. Moved Field, Class, Instance and Array interfaces to BridgeJSC.h + * bridge/jsc: Added. + * bridge/jsc/BridgeJSC.cpp: Copied from WebCore/bridge/Bridge.cpp. + * bridge/jsc/BridgeJSC.h: Copied from WebCore/bridge/Bridge.h. + +2010-01-21 Steve Block <steveblock@google.com> + + Reviewed by David Levin. + + Fixes style in WebCore/bridge/jni/JNIBridge + https://bugs.webkit.org/show_bug.cgi?id=33914 + + No new tests, style fixes only. + + * bridge/jni/JNIBridge.cpp: + * bridge/jni/JNIBridge.h: + +2010-01-20 Steve Block <steveblock@google.com> + + Reviewed by David Levin. + + Renames jni_runtime.[cpp|h] to JNIBridge.[cpp|h] + https://bugs.webkit.org/show_bug.cgi?id=33899 + + No new tests, refactoring only. + + * Android.jscbindings.mk: Modified. Removes jni_runtime.cpp and adds JNIBridge.cpp + * GNUmakefile.am: Modified. Removes jni_runtime.h and adds JNIBridge.h + * WebCore.xcodeproj/project.pbxproj: Modified. Removes jni_runtime.[cpp|h] and adds JNIBridge.[cpp|h] + * bridge/jni/JNIBridge.cpp: Copied from WebCore/bridge/jni/jni_runtime.cpp. + * bridge/jni/JNIBridge.h: Copied from WebCore/bridge/jni/jni_runtime.h. + * bridge/jni/jni_jsobject.mm: Modified. Updated to include JNIBridge.h + * bridge/jni/jni_runtime.cpp: Removed. + * bridge/jni/jni_runtime.h: Removed. + * bridge/jni/jsc/JNIUtilityPrivate.cpp: Modified. Updated to include JNIBridge.h + * bridge/jni/jsc/JavaClassJSC.cpp: Modified. Removed superfluous include + * bridge/jni/jsc/JavaClassJSC.h: Modified. Updated to include JNIBridge.h + * bridge/jni/jsc/JavaInstanceJSC.cpp: Modified. Updated to include JNIBridge.h + +2010-01-20 Steve Block <steveblock@google.com> + + Reviewed by David Levin. + + Fixes style in WebCore/bridge/Bridge + https://bugs.webkit.org/show_bug.cgi?id=33839 + + No new tests, style fixes only. + + * bridge/Bridge.cpp: Modified. + * bridge/Bridge.h: Modified. + * bridge/c/c_instance.cpp: Modified. + (JSC::Bindings::CInstance::invokeMethod): Modified. Use renamed m_rootObject member + (JSC::Bindings::CInstance::invokeDefaultMethod): Modified. Use renamed m_rootObject member + (JSC::Bindings::CInstance::invokeConstruct): Modified. Use renamed m_rootObject member + * bridge/jni/jni_runtime.cpp: Modified. + (JavaArray::JavaArray): Modified. Use renamed m_rootObject member + (JavaArray::rootObject): Modified. Use renamed m_rootObject member + * bridge/objc/objc_instance.mm: Modified. + (ObjcInstance::invokeMethod): Modified. Use renamed m_rootObject member + (ObjcInstance::invokeDefaultMethod): Modified. Use renamed m_rootObject member + (ObjcInstance::getValueOfUndefinedField): Modified. Use renamed m_rootObject member + * bridge/objc/objc_runtime.mm: Modified. + (JSC::Bindings::ObjcArray::valueAt): Modified. Use renamed m_rootObject member + * bridge/qt/qt_runtime.cpp: Modified. + (JSC::Bindings::::rootObject): Modified. Use renamed m_rootObject member + +2010-01-19 Steve Block <steveblock@google.com> + + Reviewed by David Levin. + + Fixes style in WebCore/bridge/JNIUtility + https://bugs.webkit.org/show_bug.cgi?id=33870 + + No new tests, style fixes only. + + * bridge/jni/JNIUtility.cpp: + * bridge/jni/JNIUtility.h: + +2010-01-19 Steve Block <steveblock@google.com> + + Reviewed by David Levin. + + Renames jni_utility and jni_utility_private to JNIUtility and JNIUtilityPrivate + https://bugs.webkit.org/show_bug.cgi?id=33843 + + No new tests, refactoring only. + + * Android.jscbindings.mk: + * Android.v8bindings.mk: + * GNUmakefile.am: + * WebCore.xcodeproj/project.pbxproj: + * bridge/jni/JNIUtility.cpp: Copied from WebCore/bridge/jni/jni_utility.cpp. + * bridge/jni/JNIUtility.h: Copied from WebCore/bridge/jni/jni_utility.h. + * bridge/jni/jni_jsobject.mm: + * bridge/jni/jni_objc.mm: + * bridge/jni/jni_runtime.cpp: + * bridge/jni/jni_runtime.h: + * bridge/jni/jni_utility.cpp: Removed. + * bridge/jni/jni_utility.h: Removed. + * bridge/jni/jsc/JNIUtilityPrivate.cpp: Copied from WebCore/bridge/jni/jsc/jni_utility_private.cpp. + (JSC::Bindings::convertValueToJValue): + * bridge/jni/jsc/JNIUtilityPrivate.h: Copied from WebCore/bridge/jni/jsc/jni_utility_private.h. + * bridge/jni/jsc/JavaClassJSC.cpp: + * bridge/jni/jsc/JavaInstanceJSC.cpp: + * bridge/jni/jsc/JavaStringJSC.h: + * bridge/jni/jsc/jni_utility_private.cpp: Removed. + * bridge/jni/jsc/jni_utility_private.h: Removed. + * platform/android/GeolocationServiceBridge.cpp: + * platform/android/GeolocationServiceBridge.h: + * platform/android/TemporaryLinkStubs.cpp: + +2010-01-19 Steve Block <steveblock@google.com> + + Reviewed by David Levin. + + Fixes style in WebCore/bridge/jni/jsc/JavaClassJSC + https://bugs.webkit.org/show_bug.cgi?id=33819 + + No new tests, style fixes only. + + * bridge/jni/jsc/JavaClassJSC.cpp: Modified. + * bridge/jni/jsc/JavaClassJSC.h: Modified. + +2010-01-18 Steve Block <steveblock@google.com> + + Reviewed by Adam Barth. + + Moves JSC-specific implementation of JavaString to a private implementation class. + https://bugs.webkit.org/show_bug.cgi?id=33558 + + Also modifies JavaField::name and JavaMethod::name to return const JavaString&, rather than UString::Rep*, + which is JSC-specific. This allows this code to be used with both JSC and V8, as required by Android. + + No new tests, refactoring only. + + * WebCore.xcodeproj/project.pbxproj: Modified. Added JavaStringJSC.h + * bridge/jni/jni_class.cpp: Modified. + (JavaClass::JavaClass): Modified. Updates call sites of JavaField::name and JavaMethod::name. + * bridge/jni/jni_runtime.h: Modified. + (JSC::Bindings::JavaString::JavaString): Modified. Pass through to implementation. + (JSC::Bindings::JavaString::UTF8String): Modified. Pass through to implementation. + (JSC::Bindings::JavaString::uchars): Modified. Pass through to implementation. + (JSC::Bindings::JavaString::length): Modified. Pass through to implementation. + (JSC::Bindings::JavaString::operator UString): Modified. Pass through to implementation. + (JSC::Bindings::JavaField::name): Modified. Pass through to implementation. + (JSC::Bindings::JavaMethod::name): Modified. Pass through to implementation. + * bridge/jni/jsc/JavaStringJSC.h: Added. + (JSC::Bindings::JavaStringImpl::~JavaStringImpl): + (JSC::Bindings::JavaStringImpl::init): + (JSC::Bindings::JavaStringImpl::UTF8String): + (JSC::Bindings::JavaStringImpl::uchars): + (JSC::Bindings::JavaStringImpl::length): + (JSC::Bindings::JavaStringImpl::uString): + +2010-01-19 Steve Block <steveblock@google.com> + + Reviewed by Adam Barth. + + Renames WebCore/bridge/runtime.[cpp|h] to WebCore/bridge/Bridge.[cpp|h] + https://bugs.webkit.org/show_bug.cgi?id=33801 + + runtime.[cpp|h] contains general interface classes for use in the bridge, + so Bridge is a more appropriate name than runtime. + + No new tests, renaming only. + + * Android.jscbindings.mk: + * GNUmakefile.am: + * WebCore.pro: + * WebCore.xcodeproj/project.pbxproj: + * WebCoreSources.bkl: + * bindings/js/JSPluginElementFunctions.cpp: + * bindings/js/ScriptControllerGtk.cpp: + * bindings/js/ScriptControllerHaiku.cpp: + * bindings/js/ScriptControllerMac.mm: + * bindings/js/ScriptControllerQt.cpp: + * bindings/js/ScriptControllerWin.cpp: + * bindings/js/ScriptControllerWx.cpp: + * bindings/js/ScriptInstance.h: + * bindings/objc/WebScriptObject.mm: + * bridge/Bridge.cpp: Copied from WebCore/bridge/runtime.cpp. + * bridge/Bridge.h: Copied from WebCore/bridge/runtime.h. + * bridge/c/c_class.h: + * bridge/c/c_instance.h: + * bridge/c/c_runtime.h: + * bridge/jni/jni_instance.h: + * bridge/objc/objc_runtime.h: + * bridge/qt/qt_class.h: + * bridge/qt/qt_instance.h: + * bridge/qt/qt_runtime.cpp: + * bridge/qt/qt_runtime.h: + * bridge/runtime.cpp: Removed. + * bridge/runtime.h: Removed. + * bridge/runtime_array.h: + * bridge/runtime_method.h: + * bridge/runtime_object.h: + * bridge/runtime_root.cpp: + * bridge/testbindings.cpp: + * bridge/testbindings.mm: + * bridge/testqtbindings.cpp: + * page/win/FrameWin.cpp: + * platform/graphics/wince/MediaPlayerProxy.cpp: + * plugins/PluginView.cpp: + * plugins/gtk/PluginViewGtk.cpp: + * plugins/mac/PluginViewMac.cpp: + * plugins/qt/PluginViewQt.cpp: + * plugins/symbian/PluginViewSymbian.cpp: + * plugins/win/PluginViewWin.cpp: + +2010-01-18 Steve Block <steveblock@google.com> + + Reviewed by Adam Barth. + + Fix style in WebCore/bridge/jni/jsc/JavaInstanceJSC.[cpp|h] + https://bugs.webkit.org/show_bug.cgi?id=33792 + + No new tests, style fixes only. + + * bridge/jni/jni_runtime.cpp: Modified. + (JavaField::dispatchValueFromInstance): Modified. Updated to use renamed JavaInstance::m_instance + (JavaField::dispatchSetValueToInstance): Modified. Updated to use renamed JavaInstance::m_instance + (JavaArray::JavaArray): Modified. Updated to use renamed JavaInstance::m_instance + * bridge/jni/jni_runtime.h: Modified. + (JSC::Bindings::JavaArray::javaArray): Modified. Updated to use renamed JavaInstance::m_instance + * bridge/jni/jsc/JavaInstanceJSC.cpp: Modified. Fixed style + * bridge/jni/jsc/JavaInstanceJSC.h: Modified. Fixed style + +2010-01-18 Steve Block <steveblock@google.com> + + Reviewed by Adam Barth. + + Moves JSC-specific version of JavaInstance from bridge/jni/jni_instance to bridge/jni/jsc/JavaInstanceJSC + https://bugs.webkit.org/show_bug.cgi?id=33672 + + No new tests, refactoring only. + + * Android.jscbindings.mk: Modified. Removed jni_instance.cpp and added JavaInstanceJSC.cpp + * GNUmakefile.am: Modified. Removed jni_instance.h and added JavaInstanceJSC.h + * WebCore.xcodeproj/project.pbxproj: Modified. Removed jni_instance.[cpp|h] and added JavaInstanceJSC.[cpp|h] + * bindings/js/ScriptControllerMac.mm: Modified. Includes JavaInstanceJSC.h + * bridge/jni/jni_instance.cpp: Removed. + * bridge/jni/jni_instance.h: Removed. + * bridge/jni/jni_runtime.h: Modified. Includes JavaInstanceJSC.h + * bridge/jni/jsc/JavaInstanceJSC.cpp: Copied from WebCore/bridge/jni/jni_instance.cpp. + * bridge/jni/jsc/JavaInstanceJSC.h: Copied from WebCore/bridge/jni/jni_instance.h. + +2009-12-13 Sam Weinig <sam@webkit.org> + + Reviewed by Dan Bernstein. + + Fix for https://bugs.webkit.org/show_bug.cgi?id=32499 + Add client based Geolocation provider + + Add first cut of a client based Geolocation provider. This is guarded by + ENABLE(CLIENT_BASED_GEOLOCATION) and is off by default for now. This adds a + GeolocationControllerClient interface that no-one currently implements, + but will in a subsequent patch. + + * GNUmakefile.am: + * WebCore.base.exp: + * WebCore.gypi: + * WebCore.pro: + * WebCore.vcproj/WebCore.vcproj: + * WebCore.xcodeproj/project.pbxproj: + * WebCoreSources.bkl: + * page/Geolocation.cpp: + (WebCore::createGeopositionFromGeolocationPosition): + (WebCore::createPositionErrorFromGeolocationError): + (WebCore::Geolocation::Geolocation): + (WebCore::Geolocation::~Geolocation): + (WebCore::Geolocation::disconnectFrame): + (WebCore::Geolocation::lastPosition): + (WebCore::Geolocation::startRequest): + (WebCore::Geolocation::fatalErrorOccurred): + (WebCore::Geolocation::requestTimedOut): + (WebCore::Geolocation::clearWatch): + (WebCore::Geolocation::handleError): + (WebCore::Geolocation::positionChanged): + (WebCore::Geolocation::makeSuccessCallbacks): + (WebCore::Geolocation::errorOccurred): + (WebCore::Geolocation::geolocationServicePositionChanged): + (WebCore::Geolocation::geolocationServiceErrorOccurred): + (WebCore::Geolocation::startUpdating): + (WebCore::Geolocation::stopUpdating): + * page/Geolocation.h: + * page/GeolocationController.cpp: Added. + (WebCore::GeolocationController::GeolocationController): + (WebCore::GeolocationController::~GeolocationController): + (WebCore::GeolocationController::addObserver): + (WebCore::GeolocationController::removeObserver): + (WebCore::GeolocationController::positionChanged): + (WebCore::GeolocationController::errorOccurred): + (WebCore::GeolocationController::lastPosition): + * page/GeolocationController.h: Added. + * page/GeolocationControllerClient.h: Added. + (WebCore::GeolocationControllerClient::~GeolocationControllerClient): + * page/GeolocationError.h: Added. + (WebCore::GeolocationError::): + (WebCore::GeolocationError::create): + (WebCore::GeolocationError::code): + (WebCore::GeolocationError::message): + * page/GeolocationPosition.h: Added. + (WebCore::GeolocationPosition::create): + (WebCore::GeolocationPosition::timestamp): + (WebCore::GeolocationPosition::latitude): + (WebCore::GeolocationPosition::longitude): + (WebCore::GeolocationPosition::accuracy): + (WebCore::GeolocationPosition::altitude): + (WebCore::GeolocationPosition::altitudeAccuracy): + (WebCore::GeolocationPosition::heading): + (WebCore::GeolocationPosition::speed): + (WebCore::GeolocationPosition::canProvideAltitude): + (WebCore::GeolocationPosition::canProvideAltitudeAccuracy): + (WebCore::GeolocationPosition::canProvideHeading): + (WebCore::GeolocationPosition::canProvideSpeed): + (WebCore::GeolocationPosition::GeolocationPosition): + * page/Geoposition.h: + (WebCore::Geoposition::create): + * page/Page.cpp: + (WebCore::Page::Page): + * page/Page.h: + (WebCore::Page::geolocationController): + * svg/graphics/SVGImage.cpp: + (WebCore::SVGImage::dataChanged): + 2009-12-10 Alexey Proskuryakov <ap@apple.com> Reviewed by Darin Adler. @@ -60,6 +403,24 @@ (WebCore::WebGLRenderingContext::bufferSubData): (WebCore::WebGLRenderingContext::compileShader): (WebCore::WebGLRenderingContext::createShader): + +2010-01-18 Steve Block <steveblock@google.com> + + Reviewed by Adam Barth. + + Moves JSC-specific version of JavaClass from bridge/jni/jni_class to bridge/jni/jsc/JavaClassJSC + https://bugs.webkit.org/show_bug.cgi?id=33561 + + No new tests, refactoring only. + + * Android.jscbindings.mk: Modified. Removed jni_class.cpp and added JavaClassJSC.cpp + * GNUmakefile.am: Modified. Removed jni_class.h and added JavaClassJSC.h + * WebCore.xcodeproj/project.pbxproj: Modified. Removed jni_class.[cpp|h] and added JavaClassJSC.[cpp|h] + * bridge/jni/jni_class.cpp: Removed. + * bridge/jni/jni_class.h: Removed. + * bridge/jni/jsc/JavaClassJSC.cpp: Copied from WebCore/bridge/jni/jni_class.cpp. + * bridge/jni/jsc/JavaClassJSC.h: Copied from WebCore/bridge/jni/jni_class.h. + * bridge/jni/jsc/JavaInstanceJSC.cpp: Modified. Includes JavaClassJSC.h (WebCore::WebGLRenderingContext::detachShader): (WebCore::WebGLRenderingContext::disableVertexAttribArray): (WebCore::WebGLRenderingContext::drawArrays): diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am index f8fa302..9c5f000 100644 --- a/WebCore/GNUmakefile.am +++ b/WebCore/GNUmakefile.am @@ -14,6 +14,7 @@ webcore_cppflags += \ -I$(srcdir)/WebCore/bindings/js \ -I$(srcdir)/WebCore/bridge \ -I$(srcdir)/WebCore/bridge/c \ + -I$(srcdir)/WebCore/bridge/jni/jsc \ -I$(srcdir)/WebCore/css \ -I$(srcdir)/WebCore/dom \ -I$(srcdir)/WebCore/dom/default \ @@ -483,6 +484,7 @@ webcore_sources += \ WebCore/bindings/js/SerializedScriptValue.h \ WebCore/bindings/js/StringSourceProvider.h \ WebCore/bindings/ScriptControllerBase.cpp \ + WebCore/bridge/Bridge.h \ WebCore/bridge/IdentifierRep.cpp \ WebCore/bridge/IdentifierRep.h \ WebCore/bridge/NP_jsobject.cpp \ @@ -495,19 +497,19 @@ webcore_sources += \ WebCore/bridge/c/c_runtime.h \ WebCore/bridge/c/c_utility.cpp \ WebCore/bridge/c/c_utility.h \ - WebCore/bridge/jni/jni_class.h \ - WebCore/bridge/jni/jni_instance.h \ + WebCore/bridge/jni/JNIBridge.h \ + WebCore/bridge/jni/JNIUtility.h \ WebCore/bridge/jni/jni_jsobject.h \ - WebCore/bridge/jni/jni_runtime.h \ - WebCore/bridge/jni/jni_utility.h \ + WebCore/bridge/jni/jsc/JavaClassJSC.h \ + WebCore/bridge/jni/jsc/JavaInstanceJSC.h \ + WebCore/bridge/jsc/BridgeJSC.h \ + WebCore/bridge/jsc/BridgeJSC.cpp \ WebCore/bridge/npapi.h \ WebCore/bridge/npruntime.cpp \ WebCore/bridge/npruntime.h \ WebCore/bridge/npruntime_impl.h \ WebCore/bridge/npruntime_internal.h \ WebCore/bridge/npruntime_priv.h \ - WebCore/bridge/runtime.cpp \ - WebCore/bridge/runtime.h \ WebCore/bridge/runtime_array.cpp \ WebCore/bridge/runtime_array.h \ WebCore/bridge/runtime_method.cpp \ @@ -1347,6 +1349,11 @@ webcore_sources += \ WebCore/page/FrameView.h \ WebCore/page/Geolocation.cpp \ WebCore/page/Geolocation.h \ + WebCore/page/GeolocationController.cpp \ + WebCore/page/GeolocationController.h \ + WebCore/page/GeolocationControllerClient.h \ + WebCore/page/GeolocationError.h \ + WebCore/page/GeolocationPosition.h \ WebCore/page/Geoposition.h \ WebCore/page/HaltablePlugin.h \ WebCore/page/History.cpp \ diff --git a/WebCore/WebCore.base.exp b/WebCore/WebCore.base.exp index 8df5524..c29629a 100644 --- a/WebCore/WebCore.base.exp +++ b/WebCore/WebCore.base.exp @@ -292,6 +292,7 @@ __ZN7WebCore14ResourceHandle12releaseProxyEv __ZN7WebCore14ResourceHandle20forceContentSniffingEv __ZN7WebCore14ResourceLoader14cancelledErrorEv __ZN7WebCore14ResourceLoader19setShouldBufferDataEb +__ZN7WebCore14SVGSMILElement13isSMILElementEPNS_4NodeE __ZN7WebCore14SecurityOrigin16createFromStringERKNS_6StringE __ZN7WebCore14SecurityOrigin18setLocalLoadPolicyENS0_15LocalLoadPolicyE __ZN7WebCore14SecurityOrigin18shouldHideReferrerERKNS_4KURLERKNS_6StringE @@ -414,6 +415,7 @@ __ZN7WebCore21JavaScriptDebugServer23recompileAllJSFunctionsEPNS_5TimerIS0_EE __ZN7WebCore21JavaScriptDebugServer6sharedEv __ZN7WebCore21PlatformKeyboardEvent24disambiguateKeyDownEventENS0_4TypeEb __ZN7WebCore21PlatformKeyboardEventC1EP7NSEvent +__ZN7WebCore21SVGDocumentExtensions21sampleAnimationAtTimeERKNS_6StringEPNS_14SVGSMILElementEd __ZN7WebCore21SerializedScriptValue11deserializeEPK15OpaqueJSContextPPK13OpaqueJSValue __ZN7WebCore21SerializedScriptValue6createEPK15OpaqueJSContextPK13OpaqueJSValuePS6_ __ZN7WebCore21SerializedScriptValueD1Ev @@ -495,7 +497,7 @@ __ZN7WebCore4Page6goBackEv __ZN7WebCore4Page8goToItemEPNS_11HistoryItemENS_13FrameLoadTypeE __ZN7WebCore4Page9goForwardEv __ZN7WebCore4Page9initGroupEv -__ZN7WebCore4PageC1EPNS_12ChromeClientEPNS_17ContextMenuClientEPNS_12EditorClientEPNS_10DragClientEPNS_15InspectorClientEPNS_18PluginHalterClientE +__ZN7WebCore4PageC1EPNS_12ChromeClientEPNS_17ContextMenuClientEPNS_12EditorClientEPNS_10DragClientEPNS_15InspectorClientEPNS_18PluginHalterClientEPNS_27GeolocationControllerClientE __ZN7WebCore4PageD1Ev __ZN7WebCore4coreEP20NSURLProtectionSpace __ZN7WebCore5Cache11setDisabledEb @@ -601,8 +603,10 @@ __ZN7WebCore7cookiesEPKNS_8DocumentERKNS_4KURLE __ZN7WebCore7nsColorERKNS_5ColorE __ZN7WebCore8Document11createRangeEv __ZN7WebCore8Document13removeMarkersENS_14DocumentMarker10MarkerTypeE +__ZN7WebCore8Document13svgExtensionsEv __ZN7WebCore8Document14setFocusedNodeEN3WTF10PassRefPtrINS_4NodeEEE __ZN7WebCore8Document17getFocusableNodesERN3WTF6VectorINS1_6RefPtrINS_4NodeEEELm0EEE +__ZN7WebCore8Document19accessSVGExtensionsEv __ZN7WebCore8Document22createDocumentFragmentEv __ZN7WebCore8Document23renderedRectsForMarkersENS_14DocumentMarker10MarkerTypeE __ZN7WebCore8Document24setShouldCreateRenderersEb @@ -627,9 +631,9 @@ __ZN7WebCore8Settings20setCursiveFontFamilyERKNS_12AtomicStringE __ZN7WebCore8Settings20setFantasyFontFamilyERKNS_12AtomicStringE __ZN7WebCore8Settings20setJavaScriptEnabledEb __ZN7WebCore8Settings20setXSSAuditorEnabledEb +__ZN7WebCore8Settings21setShowRepaintCounterEb __ZN7WebCore8Settings21setStandardFontFamilyERKNS_12AtomicStringE __ZN7WebCore8Settings21setWebSecurityEnabledEb -__ZN7WebCore8Settings21setShowRepaintCounterEb __ZN7WebCore8Settings22setLocalStorageEnabledEb __ZN7WebCore8Settings22setSansSerifFontFamilyERKNS_12AtomicStringE __ZN7WebCore8Settings22setShowsURLsInToolTipsEb @@ -961,9 +965,9 @@ __ZNK7WebCore8Document31displayStringModifiedByEncodingERKNS_6StringE __ZNK7WebCore8Document4bodyEv __ZNK7WebCore8Document6domainEv __ZNK7WebCore8IntPointcv8_NSPointEv +__ZNK7WebCore8Position10downstreamENS0_27EditingBoundaryCrossingRuleE __ZNK7WebCore8Position25leadingWhitespacePositionENS_9EAffinityEb __ZNK7WebCore8Position26trailingWhitespacePositionENS_9EAffinityEb -__ZNK7WebCore8Position10downstreamENS0_27EditingBoundaryCrossingRuleE __ZNK7WebCore8Position8upstreamENS0_27EditingBoundaryCrossingRuleE __ZNK7WebCore9DOMWindow27pendingUnloadEventListenersEv __ZNK7WebCore9FloatRectcv7_NSRectEv @@ -982,10 +986,6 @@ __ZTVN7WebCore12ChromeClientE __ZTVN7WebCore17FileChooserClientE __ZTVN7WebCore17FrameLoaderClientE __ZTVN7WebCore25HistoryPropertyListWriterE -__ZN7WebCore14SVGSMILElement13isSMILElementEPNS_4NodeE -__ZN7WebCore21SVGDocumentExtensions21sampleAnimationAtTimeERKNS_6StringEPNS_14SVGSMILElementEd -__ZN7WebCore8Document19accessSVGExtensionsEv -__ZN7WebCore8Document13svgExtensionsEv _filenameByFixingIllegalCharacters _hasCaseInsensitiveSubstring _hasCaseInsensitiveSuffix diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi index 4a37c79..0115a41 100644 --- a/WebCore/WebCore.gypi +++ b/WebCore/WebCore.gypi @@ -1785,6 +1785,11 @@ 'page/FrameView.h', 'page/Geolocation.cpp', 'page/Geolocation.h', + 'page/GeolocationController.cpp' + 'page/GeolocationController.h' + 'page/GeolocationControllerClient.h' + 'page/GeolocationError.h' + 'page/GeolocationPosition.h' 'page/Geoposition.h', 'page/HaltablePlugin.h', 'page/History.cpp', diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro index bfeee61..4dc1294 100644 --- a/WebCore/WebCore.pro +++ b/WebCore/WebCore.pro @@ -779,7 +779,6 @@ SOURCES += \ bridge/NP_jsobject.cpp \ bridge/npruntime.cpp \ bridge/runtime_array.cpp \ - bridge/runtime.cpp \ bridge/runtime_method.cpp \ bridge/runtime_object.cpp \ bridge/runtime_root.cpp \ @@ -787,6 +786,7 @@ SOURCES += \ bridge/c/c_instance.cpp \ bridge/c/c_runtime.cpp \ bridge/c/c_utility.cpp \ + bridge/jsc/BridgeJSC.cpp \ css/CSSBorderImageValue.cpp \ css/CSSCanvasValue.cpp \ css/CSSCharsetRule.cpp \ @@ -1160,6 +1160,7 @@ SOURCES += \ page/FrameTree.cpp \ page/FrameView.cpp \ page/Geolocation.cpp \ + page/GeolocationController.cpp \ page/History.cpp \ page/Location.cpp \ page/MouseEventWithHitTestResults.cpp \ @@ -1458,10 +1459,12 @@ HEADERS += \ bindings/js/SerializedScriptValue.h \ bindings/js/StringSourceProvider.h \ bindings/js/WorkerScriptController.h \ + bridge/Bridge.h \ bridge/c/c_class.h \ bridge/c/c_instance.h \ bridge/c/c_runtime.h \ bridge/c/c_utility.h \ + bridge/jsc/BridgeJSC.h \ bridge/IdentifierRep.h \ bridge/NP_jsobject.h \ bridge/npruntime.h \ @@ -1469,7 +1472,6 @@ HEADERS += \ bridge/qt/qt_instance.h \ bridge/qt/qt_runtime.h \ bridge/runtime_array.h \ - bridge/runtime.h \ bridge/runtime_method.h \ bridge/runtime_object.h \ bridge/runtime_root.h \ diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj index 09945f5..db19ea3 100644 --- a/WebCore/WebCore.vcproj/WebCore.vcproj +++ b/WebCore/WebCore.vcproj/WebCore.vcproj @@ -20645,6 +20645,26 @@ <File
RelativePath="..\page\Geolocation.cpp"
>
+ RelativePath="..\page\GeolocationController.cpp" + > + </File> + <File + RelativePath="..\page\GeolocationController.h" + > + </File> + <File + RelativePath="..\page\GeolocationControllerClient.h" + > + </File> + <File + RelativePath="..\page\GeolocationError.h" + > + </File> + <File + RelativePath="..\page\GeolocationPosition.h" + > + </File> + <File </File>
<File
RelativePath="..\page\Geolocation.h"
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj index 2d0b804..8c805ad 100644 --- a/WebCore/WebCore.xcodeproj/project.pbxproj +++ b/WebCore/WebCore.xcodeproj/project.pbxproj @@ -295,17 +295,9 @@ 1A569CFC0D7E2B82007C3983 /* c_runtime.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CCB0D7E2B82007C3983 /* c_runtime.h */; }; 1A569CFD0D7E2B82007C3983 /* c_utility.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CCC0D7E2B82007C3983 /* c_utility.cpp */; }; 1A569CFE0D7E2B82007C3983 /* c_utility.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CCD0D7E2B82007C3983 /* c_utility.h */; }; - 1A569CFF0D7E2B82007C3983 /* jni_class.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CCF0D7E2B82007C3983 /* jni_class.cpp */; }; - 1A569D000D7E2B82007C3983 /* jni_class.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CD00D7E2B82007C3983 /* jni_class.h */; }; - 1A569D010D7E2B82007C3983 /* jni_instance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CD10D7E2B82007C3983 /* jni_instance.cpp */; }; - 1A569D020D7E2B82007C3983 /* jni_instance.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CD20D7E2B82007C3983 /* jni_instance.h */; }; 1A569D030D7E2B82007C3983 /* jni_jsobject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CD30D7E2B82007C3983 /* jni_jsobject.mm */; }; 1A569D040D7E2B82007C3983 /* jni_jsobject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CD40D7E2B82007C3983 /* jni_jsobject.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1A569D050D7E2B82007C3983 /* jni_objc.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CD50D7E2B82007C3983 /* jni_objc.mm */; }; - 1A569D060D7E2B82007C3983 /* jni_runtime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CD60D7E2B82007C3983 /* jni_runtime.cpp */; }; - 1A569D070D7E2B82007C3983 /* jni_runtime.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CD70D7E2B82007C3983 /* jni_runtime.h */; }; - 1A569D080D7E2B82007C3983 /* jni_utility.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CD80D7E2B82007C3983 /* jni_utility.cpp */; }; - 1A569D090D7E2B82007C3983 /* jni_utility.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CD90D7E2B82007C3983 /* jni_utility.h */; }; 1A569D0A0D7E2B82007C3983 /* NP_jsobject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CDA0D7E2B82007C3983 /* NP_jsobject.cpp */; }; 1A569D0B0D7E2B82007C3983 /* NP_jsobject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CDB0D7E2B82007C3983 /* NP_jsobject.h */; }; 1A569D0C0D7E2B82007C3983 /* npapi.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CDC0D7E2B82007C3983 /* npapi.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -324,8 +316,6 @@ 1A569D190D7E2B82007C3983 /* objc_utility.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CEA0D7E2B82007C3983 /* objc_utility.h */; }; 1A569D1A0D7E2B82007C3983 /* objc_utility.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CEB0D7E2B82007C3983 /* objc_utility.mm */; }; 1A569D1B0D7E2B82007C3983 /* WebScriptObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CEC0D7E2B82007C3983 /* WebScriptObject.h */; }; - 1A569D1C0D7E2B82007C3983 /* runtime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CED0D7E2B82007C3983 /* runtime.cpp */; }; - 1A569D1D0D7E2B82007C3983 /* runtime.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CEE0D7E2B82007C3983 /* runtime.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1A569D1E0D7E2B82007C3983 /* runtime_array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CEF0D7E2B82007C3983 /* runtime_array.cpp */; }; 1A569D1F0D7E2B82007C3983 /* runtime_array.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CF00D7E2B82007C3983 /* runtime_array.h */; }; 1A569D200D7E2B82007C3983 /* runtime_method.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CF10D7E2B82007C3983 /* runtime_method.cpp */; }; @@ -1101,10 +1091,21 @@ 54C50F7B0E801DF3009832A0 /* XMLTokenizerLibxml2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 54C50F7A0E801DF3009832A0 /* XMLTokenizerLibxml2.cpp */; }; 550A0BC9085F6039007353D6 /* QualifiedName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BC7085F6039007353D6 /* QualifiedName.cpp */; }; 550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */ = {isa = PBXBuildFile; fileRef = 550A0BC8085F6039007353D6 /* QualifiedName.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 599D1E3210C97D6E00E0EF12 /* jni_utility_private.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 599D1E3010C97D6E00E0EF12 /* jni_utility_private.cpp */; }; - 599D1E3310C97D6E00E0EF12 /* jni_utility_private.h in Headers */ = {isa = PBXBuildFile; fileRef = 599D1E3110C97D6E00E0EF12 /* jni_utility_private.h */; }; + 5913953B110758450083EC55 /* JNIBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 5913953A110758450083EC55 /* JNIBridge.h */; }; + 5913953D1107584E0083EC55 /* JNIBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5913953C1107584E0083EC55 /* JNIBridge.cpp */; }; + 599E759011055A1F00D904FA /* Bridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 599E758F11055A1F00D904FA /* Bridge.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 599E759211055A2A00D904FA /* Bridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 599E759111055A2A00D904FA /* Bridge.cpp */; }; + 59A9E7B01104758800DFB4C1 /* JavaInstanceJSC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59A9E7AF1104758800DFB4C1 /* JavaInstanceJSC.cpp */; }; + 59A9E7B21104759400DFB4C1 /* JavaInstanceJSC.h in Headers */ = {isa = PBXBuildFile; fileRef = 59A9E7B11104759400DFB4C1 /* JavaInstanceJSC.h */; }; + 59BC393F11054A1300FD85DB /* JavaStringJSC.h in Headers */ = {isa = PBXBuildFile; fileRef = 59BC393E11054A1300FD85DB /* JavaStringJSC.h */; }; 59C77F2A10545B3B00506104 /* GeolocationServiceMock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59C77F2810545B3B00506104 /* GeolocationServiceMock.cpp */; }; 59C77F2B10545B3B00506104 /* GeolocationServiceMock.h in Headers */ = {isa = PBXBuildFile; fileRef = 59C77F2910545B3B00506104 /* GeolocationServiceMock.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 59E560A71105336600AA1258 /* JavaClassJSC.h in Headers */ = {isa = PBXBuildFile; fileRef = 59E560A61105336600AA1258 /* JavaClassJSC.h */; }; + 59E560A91105336F00AA1258 /* JavaClassJSC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59E560A81105336F00AA1258 /* JavaClassJSC.cpp */; }; + 59EE122C1106080500885116 /* JNIUtilityPrivate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59EE122B1106080500885116 /* JNIUtilityPrivate.cpp */; }; + 59EE122E1106080F00885116 /* JNIUtilityPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 59EE122D1106080F00885116 /* JNIUtilityPrivate.h */; }; + 59EE12301106081F00885116 /* JNIUtility.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59EE122F1106081F00885116 /* JNIUtility.cpp */; }; + 59EE12321106082900885116 /* JNIUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = 59EE12311106082900885116 /* JNIUtility.h */; }; 5D15E3AB0F9E6AC1009E0E3F /* XMLTokenizerScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D15E3A90F9E6AC1009E0E3F /* XMLTokenizerScope.cpp */; }; 5D15E3AC0F9E6AC1009E0E3F /* XMLTokenizerScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D15E3AA0F9E6AC1009E0E3F /* XMLTokenizerScope.h */; }; 5D874F130D161D3200796C3B /* NetscapePlugInStreamLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93E227DD0AF589AD00D48324 /* NetscapePlugInStreamLoader.cpp */; }; @@ -4189,6 +4190,11 @@ BC53C6080DA56C570021EB5D /* Gradient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC53C6070DA56C570021EB5D /* Gradient.cpp */; }; BC53C60B0DA56CF10021EB5D /* GradientCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC53C60A0DA56CF10021EB5D /* GradientCG.cpp */; }; BC53C6920DA591140021EB5D /* CSSGradientValue.h in Headers */ = {isa = PBXBuildFile; fileRef = BC53C6910DA591140021EB5D /* CSSGradientValue.h */; }; + BC56CB2110D5AC8000A77C64 /* GeolocationController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC56CB1C10D5AC8000A77C64 /* GeolocationController.cpp */; }; + BC56CB2210D5AC8000A77C64 /* GeolocationController.h in Headers */ = {isa = PBXBuildFile; fileRef = BC56CB1D10D5AC8000A77C64 /* GeolocationController.h */; }; + BC56CB2310D5AC8000A77C64 /* GeolocationControllerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = BC56CB1E10D5AC8000A77C64 /* GeolocationControllerClient.h */; }; + BC56CB2410D5AC8000A77C64 /* GeolocationError.h in Headers */ = {isa = PBXBuildFile; fileRef = BC56CB1F10D5AC8000A77C64 /* GeolocationError.h */; }; + BC56CB2510D5AC8000A77C64 /* GeolocationPosition.h in Headers */ = {isa = PBXBuildFile; fileRef = BC56CB2010D5AC8000A77C64 /* GeolocationPosition.h */; }; BC5823F50C0A98DF0053F1B5 /* JSHTMLElementCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC5823F40C0A98DF0053F1B5 /* JSHTMLElementCustom.cpp */; }; BC5825F30C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC5825F20C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp */; }; BC588AF00BFA6CF900EE679E /* HTMLParserErrorCodes.h in Headers */ = {isa = PBXBuildFile; fileRef = BC588AEF0BFA6CF900EE679E /* HTMLParserErrorCodes.h */; }; @@ -5515,17 +5521,9 @@ 1A569CCB0D7E2B82007C3983 /* c_runtime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = c_runtime.h; sourceTree = "<group>"; }; 1A569CCC0D7E2B82007C3983 /* c_utility.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = c_utility.cpp; sourceTree = "<group>"; }; 1A569CCD0D7E2B82007C3983 /* c_utility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = c_utility.h; sourceTree = "<group>"; }; - 1A569CCF0D7E2B82007C3983 /* jni_class.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jni_class.cpp; sourceTree = "<group>"; }; - 1A569CD00D7E2B82007C3983 /* jni_class.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jni_class.h; sourceTree = "<group>"; }; - 1A569CD10D7E2B82007C3983 /* jni_instance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jni_instance.cpp; sourceTree = "<group>"; }; - 1A569CD20D7E2B82007C3983 /* jni_instance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jni_instance.h; sourceTree = "<group>"; }; 1A569CD30D7E2B82007C3983 /* jni_jsobject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = jni_jsobject.mm; sourceTree = "<group>"; }; 1A569CD40D7E2B82007C3983 /* jni_jsobject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jni_jsobject.h; sourceTree = "<group>"; }; 1A569CD50D7E2B82007C3983 /* jni_objc.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = jni_objc.mm; sourceTree = "<group>"; }; - 1A569CD60D7E2B82007C3983 /* jni_runtime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jni_runtime.cpp; sourceTree = "<group>"; }; - 1A569CD70D7E2B82007C3983 /* jni_runtime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jni_runtime.h; sourceTree = "<group>"; }; - 1A569CD80D7E2B82007C3983 /* jni_utility.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jni_utility.cpp; sourceTree = "<group>"; }; - 1A569CD90D7E2B82007C3983 /* jni_utility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jni_utility.h; sourceTree = "<group>"; }; 1A569CDA0D7E2B82007C3983 /* NP_jsobject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NP_jsobject.cpp; path = bridge/NP_jsobject.cpp; sourceTree = "<group>"; }; 1A569CDB0D7E2B82007C3983 /* NP_jsobject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NP_jsobject.h; path = bridge/NP_jsobject.h; sourceTree = "<group>"; }; 1A569CDC0D7E2B82007C3983 /* npapi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = npapi.h; path = bridge/npapi.h; sourceTree = "<group>"; }; @@ -5544,8 +5542,6 @@ 1A569CEA0D7E2B82007C3983 /* objc_utility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = objc_utility.h; sourceTree = "<group>"; }; 1A569CEB0D7E2B82007C3983 /* objc_utility.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = objc_utility.mm; sourceTree = "<group>"; }; 1A569CEC0D7E2B82007C3983 /* WebScriptObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptObject.h; sourceTree = "<group>"; }; - 1A569CED0D7E2B82007C3983 /* runtime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = runtime.cpp; path = bridge/runtime.cpp; sourceTree = "<group>"; }; - 1A569CEE0D7E2B82007C3983 /* runtime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = runtime.h; path = bridge/runtime.h; sourceTree = "<group>"; }; 1A569CEF0D7E2B82007C3983 /* runtime_array.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = runtime_array.cpp; path = bridge/runtime_array.cpp; sourceTree = "<group>"; }; 1A569CF00D7E2B82007C3983 /* runtime_array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = runtime_array.h; path = bridge/runtime_array.h; sourceTree = "<group>"; }; 1A569CF10D7E2B82007C3983 /* runtime_method.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = runtime_method.cpp; path = bridge/runtime_method.cpp; sourceTree = "<group>"; }; @@ -6425,10 +6421,21 @@ 54C50F7A0E801DF3009832A0 /* XMLTokenizerLibxml2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLTokenizerLibxml2.cpp; sourceTree = "<group>"; }; 550A0BC7085F6039007353D6 /* QualifiedName.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QualifiedName.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; 550A0BC8085F6039007353D6 /* QualifiedName.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = QualifiedName.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; - 599D1E3010C97D6E00E0EF12 /* jni_utility_private.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jni_utility_private.cpp; path = jsc/jni_utility_private.cpp; sourceTree = "<group>"; }; - 599D1E3110C97D6E00E0EF12 /* jni_utility_private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = jni_utility_private.h; path = jsc/jni_utility_private.h; sourceTree = "<group>"; }; + 5913953A110758450083EC55 /* JNIBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JNIBridge.h; sourceTree = "<group>"; }; + 5913953C1107584E0083EC55 /* JNIBridge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JNIBridge.cpp; sourceTree = "<group>"; }; + 599E758F11055A1F00D904FA /* Bridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Bridge.h; path = bridge/Bridge.h; sourceTree = "<group>"; }; + 599E759111055A2A00D904FA /* Bridge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Bridge.cpp; path = bridge/Bridge.cpp; sourceTree = "<group>"; }; + 59A9E7AF1104758800DFB4C1 /* JavaInstanceJSC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JavaInstanceJSC.cpp; path = jsc/JavaInstanceJSC.cpp; sourceTree = "<group>"; }; + 59A9E7B11104759400DFB4C1 /* JavaInstanceJSC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JavaInstanceJSC.h; path = jsc/JavaInstanceJSC.h; sourceTree = "<group>"; }; + 59BC393E11054A1300FD85DB /* JavaStringJSC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JavaStringJSC.h; path = jsc/JavaStringJSC.h; sourceTree = "<group>"; }; 59C77F2810545B3B00506104 /* GeolocationServiceMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GeolocationServiceMock.cpp; path = mock/GeolocationServiceMock.cpp; sourceTree = "<group>"; }; 59C77F2910545B3B00506104 /* GeolocationServiceMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GeolocationServiceMock.h; path = mock/GeolocationServiceMock.h; sourceTree = "<group>"; }; + 59E560A61105336600AA1258 /* JavaClassJSC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JavaClassJSC.h; path = jsc/JavaClassJSC.h; sourceTree = "<group>"; }; + 59E560A81105336F00AA1258 /* JavaClassJSC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JavaClassJSC.cpp; path = jsc/JavaClassJSC.cpp; sourceTree = "<group>"; }; + 59EE122B1106080500885116 /* JNIUtilityPrivate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JNIUtilityPrivate.cpp; path = jsc/JNIUtilityPrivate.cpp; sourceTree = "<group>"; }; + 59EE122D1106080F00885116 /* JNIUtilityPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JNIUtilityPrivate.h; path = jsc/JNIUtilityPrivate.h; sourceTree = "<group>"; }; + 59EE122F1106081F00885116 /* JNIUtility.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JNIUtility.cpp; sourceTree = "<group>"; }; + 59EE12311106082900885116 /* JNIUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JNIUtility.h; sourceTree = "<group>"; }; 5D15E3A90F9E6AC1009E0E3F /* XMLTokenizerScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLTokenizerScope.cpp; sourceTree = "<group>"; }; 5D15E3AA0F9E6AC1009E0E3F /* XMLTokenizerScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLTokenizerScope.h; sourceTree = "<group>"; }; 5D925B650F64D4DD00B847F0 /* ScrollBehavior.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollBehavior.cpp; sourceTree = "<group>"; }; @@ -9356,6 +9363,11 @@ BC53C6070DA56C570021EB5D /* Gradient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Gradient.cpp; sourceTree = "<group>"; }; BC53C60A0DA56CF10021EB5D /* GradientCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GradientCG.cpp; sourceTree = "<group>"; }; BC53C6910DA591140021EB5D /* CSSGradientValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSGradientValue.h; sourceTree = "<group>"; }; + BC56CB1C10D5AC8000A77C64 /* GeolocationController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeolocationController.cpp; sourceTree = "<group>"; }; + BC56CB1D10D5AC8000A77C64 /* GeolocationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationController.h; sourceTree = "<group>"; }; + BC56CB1E10D5AC8000A77C64 /* GeolocationControllerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationControllerClient.h; sourceTree = "<group>"; }; + BC56CB1F10D5AC8000A77C64 /* GeolocationError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationError.h; sourceTree = "<group>"; }; + BC56CB2010D5AC8000A77C64 /* GeolocationPosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationPosition.h; sourceTree = "<group>"; }; BC5823F40C0A98DF0053F1B5 /* JSHTMLElementCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLElementCustom.cpp; sourceTree = "<group>"; }; BC5825F20C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSStyleDeclarationCustom.cpp; sourceTree = "<group>"; }; BC588AEF0BFA6CF900EE679E /* HTMLParserErrorCodes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HTMLParserErrorCodes.h; sourceTree = "<group>"; }; @@ -10234,6 +10246,8 @@ 1A569CC40D7E2B60007C3983 /* bridge */ = { isa = PBXGroup; children = ( + 599E759111055A2A00D904FA /* Bridge.cpp */, + 599E758F11055A1F00D904FA /* Bridge.h */, 1A569CC50D7E2B82007C3983 /* c */, 1A569CCE0D7E2B82007C3983 /* jni */, 1A569CE20D7E2B82007C3983 /* objc */, @@ -10247,8 +10261,6 @@ 1A569CDF0D7E2B82007C3983 /* npruntime_impl.h */, 1A569CE00D7E2B82007C3983 /* npruntime_internal.h */, 1A569CE10D7E2B82007C3983 /* npruntime_priv.h */, - 1A569CED0D7E2B82007C3983 /* runtime.cpp */, - 1A569CEE0D7E2B82007C3983 /* runtime.h */, 1A569CEF0D7E2B82007C3983 /* runtime_array.cpp */, 1A569CF00D7E2B82007C3983 /* runtime_array.h */, 1A569CF10D7E2B82007C3983 /* runtime_method.cpp */, @@ -10280,18 +10292,14 @@ 1A569CCE0D7E2B82007C3983 /* jni */ = { isa = PBXGroup; children = ( + 5913953C1107584E0083EC55 /* JNIBridge.cpp */, + 5913953A110758450083EC55 /* JNIBridge.h */, + 59EE12311106082900885116 /* JNIUtility.h */, + 59EE122F1106081F00885116 /* JNIUtility.cpp */, 599D1E2F10C97D4C00E0EF12 /* jsc */, - 1A569CCF0D7E2B82007C3983 /* jni_class.cpp */, - 1A569CD00D7E2B82007C3983 /* jni_class.h */, - 1A569CD10D7E2B82007C3983 /* jni_instance.cpp */, - 1A569CD20D7E2B82007C3983 /* jni_instance.h */, 1A569CD40D7E2B82007C3983 /* jni_jsobject.h */, 1A569CD30D7E2B82007C3983 /* jni_jsobject.mm */, 1A569CD50D7E2B82007C3983 /* jni_objc.mm */, - 1A569CD60D7E2B82007C3983 /* jni_runtime.cpp */, - 1A569CD70D7E2B82007C3983 /* jni_runtime.h */, - 1A569CD80D7E2B82007C3983 /* jni_utility.cpp */, - 1A569CD90D7E2B82007C3983 /* jni_utility.h */, ); name = jni; path = bridge/jni; @@ -10986,8 +10994,13 @@ 599D1E2F10C97D4C00E0EF12 /* jsc */ = { isa = PBXGroup; children = ( - 599D1E3010C97D6E00E0EF12 /* jni_utility_private.cpp */, - 599D1E3110C97D6E00E0EF12 /* jni_utility_private.h */, + 59EE122D1106080F00885116 /* JNIUtilityPrivate.h */, + 59EE122B1106080500885116 /* JNIUtilityPrivate.cpp */, + 59BC393E11054A1300FD85DB /* JavaStringJSC.h */, + 59E560A81105336F00AA1258 /* JavaClassJSC.cpp */, + 59E560A61105336600AA1258 /* JavaClassJSC.h */, + 59A9E7B11104759400DFB4C1 /* JavaInstanceJSC.h */, + 59A9E7AF1104758800DFB4C1 /* JavaInstanceJSC.cpp */, ); name = jsc; sourceTree = "<group>"; @@ -11275,6 +11288,11 @@ FE80D7B70E9C1F25000D6F75 /* Geolocation.cpp */, FE80D7B80E9C1F25000D6F75 /* Geolocation.h */, FE80D7B90E9C1F25000D6F75 /* Geolocation.idl */, + BC56CB1C10D5AC8000A77C64 /* GeolocationController.cpp */, + BC56CB1D10D5AC8000A77C64 /* GeolocationController.h */, + BC56CB1E10D5AC8000A77C64 /* GeolocationControllerClient.h */, + BC56CB1F10D5AC8000A77C64 /* GeolocationError.h */, + BC56CB2010D5AC8000A77C64 /* GeolocationPosition.h */, FE80D7BB0E9C1F25000D6F75 /* Geoposition.h */, FE80D7BC0E9C1F25000D6F75 /* Geoposition.idl */, 7693BACE106C2DCA007B0823 /* HaltablePlugin.h */, @@ -17054,11 +17072,7 @@ 1C81BA0E0E97348300266E07 /* JavaScriptDebugServer.h in Headers */, 1C81BA010E9733CB00266E07 /* JavaScriptProfile.h in Headers */, 1C81B9FF0E9733CB00266E07 /* JavaScriptProfileNode.h in Headers */, - 1A569D000D7E2B82007C3983 /* jni_class.h in Headers */, - 1A569D020D7E2B82007C3983 /* jni_instance.h in Headers */, 1A569D040D7E2B82007C3983 /* jni_jsobject.h in Headers */, - 1A569D070D7E2B82007C3983 /* jni_runtime.h in Headers */, - 1A569D090D7E2B82007C3983 /* jni_utility.h in Headers */, 93309DF4099E64920056E581 /* JoinTextNodesCommand.h in Headers */, 418F88050FF957AF0080F045 /* JSAbstractWorker.h in Headers */, 65DF31DB09D1C123000BE325 /* JSAttr.h in Headers */, @@ -17720,7 +17734,6 @@ A8CFF5E10A155A05000A4234 /* RootInlineBox.h in Headers */, 49E911C90EF86D47009D0CAF /* RotateTransformOperation.h in Headers */, 1C63A2480F71646600C09D5A /* RunLoopTimer.h in Headers */, - 1A569D1D0D7E2B82007C3983 /* runtime.h in Headers */, 1A569D1F0D7E2B82007C3983 /* runtime_array.h in Headers */, 1A569D210D7E2B82007C3983 /* runtime_method.h in Headers */, 1A569D230D7E2B82007C3983 /* runtime_object.h in Headers */, @@ -18242,10 +18255,13 @@ 7A0E770F10C00A8800A0276E /* InspectorFrontendHost.h in Headers */, 7A0E771F10C00DB100A0276E /* JSInspectorFrontendHost.h in Headers */, F4EAF4AF10C742B1009100D3 /* OpenTypeSanitizer.h in Headers */, - 599D1E3310C97D6E00E0EF12 /* jni_utility_private.h in Headers */, 7ADE722610CBBB9B006B3B3A /* ContextMenuSelectionHandler.h in Headers */, 0C3F1F5B10C8871200D72CE1 /* WebGLUniformLocation.h in Headers */, 0C45342810CDBBFA00869157 /* JSWebGLUniformLocation.h in Headers */, + BC56CB2210D5AC8000A77C64 /* GeolocationController.h in Headers */, + BC56CB2310D5AC8000A77C64 /* GeolocationControllerClient.h in Headers */, + BC56CB2410D5AC8000A77C64 /* GeolocationError.h in Headers */, + BC56CB2510D5AC8000A77C64 /* GeolocationPosition.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -18262,11 +18278,17 @@ 1CC93C640DAE929600E4BC3A /* Copy Forwarding and ICU Headers */, 93F199FD08245E59001E9ABC /* Resources */, 1C81BA330E97357C00266E07 /* Copy Inspector Resources */, + 59A9E7B21104759400DFB4C1 /* JavaInstanceJSC.h in Headers */, 1C5F9D760E09A1B400E91D0A /* Streamline Inspector Source */, + 59E560A71105336600AA1258 /* JavaClassJSC.h in Headers */, 93F19A0C08245E59001E9ABC /* Sources */, 93F19B1208245E59001E9ABC /* Frameworks */, 939D050109D9FF6B00984996 /* Check For Global Initializers */, + 599E759011055A1F00D904FA /* Bridge.h in Headers */, 933457E60EBFDF6B00B80894 /* Check For Exit Time Destructors */, + 5913953B110758450083EC55 /* JNIBridge.h in Headers */, + 59EE122E1106080F00885116 /* JNIUtilityPrivate.h in Headers */, + 59EE12321106082900885116 /* JNIUtility.h in Headers */, 5D0D540D0E9862F60029E223 /* Check For Weak VTables */, ); buildRules = ( @@ -18288,6 +18310,7 @@ buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */; compatibilityVersion = "Xcode 2.4"; hasScannedForEncodings = 1; + 59BC393F11054A1300FD85DB /* JavaStringJSC.h in Headers */, knownRegions = ( English, Japanese, @@ -19212,12 +19235,8 @@ 1C81BA0D0E97348300266E07 /* JavaScriptDebugServer.cpp in Sources */, 1C81BA020E9733CB00266E07 /* JavaScriptProfile.cpp in Sources */, 1C81BA000E9733CB00266E07 /* JavaScriptProfileNode.cpp in Sources */, - 1A569CFF0D7E2B82007C3983 /* jni_class.cpp in Sources */, - 1A569D010D7E2B82007C3983 /* jni_instance.cpp in Sources */, 1A569D030D7E2B82007C3983 /* jni_jsobject.mm in Sources */, 1A569D050D7E2B82007C3983 /* jni_objc.mm in Sources */, - 1A569D060D7E2B82007C3983 /* jni_runtime.cpp in Sources */, - 1A569D080D7E2B82007C3983 /* jni_utility.cpp in Sources */, 93309DF3099E64920056E581 /* JoinTextNodesCommand.cpp in Sources */, 418F88040FF957AE0080F045 /* JSAbstractWorker.cpp in Sources */, 415B7C570FF598E6006770F7 /* JSAbstractWorkerCustom.cpp in Sources */, @@ -19931,7 +19950,6 @@ A8CFF5E70A155A05000A4234 /* RootInlineBox.cpp in Sources */, 49E911C80EF86D47009D0CAF /* RotateTransformOperation.cpp in Sources */, 1C63A2490F71646600C09D5A /* RunLoopTimerCF.cpp in Sources */, - 1A569D1C0D7E2B82007C3983 /* runtime.cpp in Sources */, 1A569D1E0D7E2B82007C3983 /* runtime_array.cpp in Sources */, 1A569D200D7E2B82007C3983 /* runtime_method.cpp in Sources */, 1A569D220D7E2B82007C3983 /* runtime_object.cpp in Sources */, @@ -20400,9 +20418,9 @@ 7A0E771E10C00DB100A0276E /* JSInspectorFrontendHost.cpp in Sources */, F4EAF4AE10C742B1009100D3 /* OpenTypeSanitizer.cpp in Sources */, D01A27AD10C9BFD800026A42 /* SpaceSplitString.cpp in Sources */, - 599D1E3210C97D6E00E0EF12 /* jni_utility_private.cpp in Sources */, 0C3F1F5A10C8871200D72CE1 /* WebGLUniformLocation.cpp in Sources */, 0C45342710CDBBFA00869157 /* JSWebGLUniformLocation.cpp in Sources */, + BC56CB2110D5AC8000A77C64 /* GeolocationController.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -20411,11 +20429,17 @@ /* Begin PBXTargetDependency section */ DD041FF109D9E3250010AF2A /* PBXTargetDependency */ = { isa = PBXTargetDependency; + 59A9E7B01104758800DFB4C1 /* JavaInstanceJSC.cpp in Sources */, target = DD041FBE09D9DDBE0010AF2A /* Derived Sources */; + 59E560A91105336F00AA1258 /* JavaClassJSC.cpp in Sources */, targetProxy = DD041FF009D9E3250010AF2A /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ + 599E759211055A2A00D904FA /* Bridge.cpp in Sources */, + 59EE122C1106080500885116 /* JNIUtilityPrivate.cpp in Sources */, + 59EE12301106081F00885116 /* JNIUtility.cpp in Sources */, + 5913953D1107584E0083EC55 /* JNIBridge.cpp in Sources */, /* Begin PBXVariantGroup section */ BCC64F5F0DCFB84E0081EF3B /* localizedStrings.js */ = { isa = PBXVariantGroup; diff --git a/WebCore/WebCoreSources.bkl b/WebCore/WebCoreSources.bkl index cd94ae6..50e6b94 100644 --- a/WebCore/WebCoreSources.bkl +++ b/WebCore/WebCoreSources.bkl @@ -171,8 +171,8 @@ This file contains the list of files needed to build WebCore. bridge/c/c_instance.cpp bridge/c/c_runtime.cpp bridge/c/c_utility.cpp + bridge/jsc/BridgeJSC.cpp bridge/npruntime.cpp - bridge/runtime.cpp bridge/runtime_array.cpp bridge/runtime_method.cpp bridge/runtime_object.cpp @@ -777,6 +777,7 @@ This file contains the list of files needed to build WebCore. page/FrameTree.cpp page/FrameView.cpp page/Geolocation.cpp + page/GeolocationController.cpp page/History.cpp page/Location.cpp page/MouseEventWithHitTestResults.cpp diff --git a/WebCore/bindings/js/JSEventCustom.cpp b/WebCore/bindings/js/JSEventCustom.cpp index 7b951bd..04ceec5 100644 --- a/WebCore/bindings/js/JSEventCustom.cpp +++ b/WebCore/bindings/js/JSEventCustom.cpp @@ -78,7 +78,7 @@ #include "SVGZoomEvent.h" #endif -#if ENABLE(TOUCH_EVENTS) // Android +#if ENABLE(TOUCH_EVENTS) #include "JSTouchEvent.h" #include "TouchEvent.h" #endif @@ -118,7 +118,7 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Event* event) #endif else if (event->isCompositionEvent()) wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, CompositionEvent, event); -#if ENABLE(TOUCH_EVENTS) // Android +#if ENABLE(TOUCH_EVENTS) else if (event->isTouchEvent()) wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, TouchEvent, event); #endif diff --git a/WebCore/bindings/js/JSPluginElementFunctions.cpp b/WebCore/bindings/js/JSPluginElementFunctions.cpp index ada2a77..e927ef1 100644 --- a/WebCore/bindings/js/JSPluginElementFunctions.cpp +++ b/WebCore/bindings/js/JSPluginElementFunctions.cpp @@ -20,10 +20,10 @@ #include "config.h" #include "JSPluginElementFunctions.h" +#include "Bridge.h" #include "HTMLNames.h" #include "HTMLPlugInElement.h" #include "JSHTMLElement.h" -#include "runtime.h" #include "runtime_object.h" using namespace JSC; diff --git a/WebCore/bindings/js/ScriptController.cpp b/WebCore/bindings/js/ScriptController.cpp index 89f2345..8d34f88 100644 --- a/WebCore/bindings/js/ScriptController.cpp +++ b/WebCore/bindings/js/ScriptController.cpp @@ -247,7 +247,7 @@ bool ScriptController::processingUserGestureEvent() const // keyboard events || type == eventNames().keydownEvent || type == eventNames().keypressEvent || type == eventNames().keyupEvent -#if ENABLE(TOUCH_EVENTS) // Android +#if ENABLE(TOUCH_EVENTS) // touch events || type == eventNames().touchstartEvent || type == eventNames().touchmoveEvent || type == eventNames().touchendEvent || type == eventNames().touchcancelEvent diff --git a/WebCore/bindings/js/ScriptControllerAndroid.cpp b/WebCore/bindings/js/ScriptControllerAndroid.cpp index 91e5add..a2086e1 100644 --- a/WebCore/bindings/js/ScriptControllerAndroid.cpp +++ b/WebCore/bindings/js/ScriptControllerAndroid.cpp @@ -27,7 +27,7 @@ #include "ScriptController.h" #include "PluginView.h" -#include "runtime.h" +#include "Bridge.h" namespace WebCore { diff --git a/WebCore/bindings/js/ScriptControllerGtk.cpp b/WebCore/bindings/js/ScriptControllerGtk.cpp index c906034..6ffae69 100644 --- a/WebCore/bindings/js/ScriptControllerGtk.cpp +++ b/WebCore/bindings/js/ScriptControllerGtk.cpp @@ -31,9 +31,9 @@ #include "config.h" #include "ScriptController.h" +#include "Bridge.h" #include "PluginView.h" #include "runtime_root.h" -#include "runtime.h" namespace WebCore { diff --git a/WebCore/bindings/js/ScriptControllerHaiku.cpp b/WebCore/bindings/js/ScriptControllerHaiku.cpp index 3fe471d..a1f1590 100644 --- a/WebCore/bindings/js/ScriptControllerHaiku.cpp +++ b/WebCore/bindings/js/ScriptControllerHaiku.cpp @@ -27,8 +27,8 @@ #include "config.h" #include "ScriptController.h" +#include "Bridge.h" #include "PluginView.h" -#include "runtime.h" #include "runtime_root.h" diff --git a/WebCore/bindings/js/ScriptControllerMac.mm b/WebCore/bindings/js/ScriptControllerMac.mm index 21ec0f2..650cb78 100644 --- a/WebCore/bindings/js/ScriptControllerMac.mm +++ b/WebCore/bindings/js/ScriptControllerMac.mm @@ -29,6 +29,7 @@ #import "config.h" #import "ScriptController.h" +#import "Bridge.h" #import "DOMAbstractViewFrame.h" #import "DOMWindow.h" #import "Frame.h" @@ -37,6 +38,8 @@ #import "JSDOMWindow.h" #import "WebScriptObjectPrivate.h" #import "Widget.h" +#import "objc_instance.h" +#import "runtime_root.h" #import <JavaScriptCore/APICast.h> #import <runtime/JSLock.h> @@ -46,12 +49,8 @@ #import "npruntime_impl.h" #endif -#import "objc_instance.h" -#import "runtime_root.h" -#import "runtime.h" - #if ENABLE(MAC_JAVA_BRIDGE) -#import "jni_instance.h" +#import "JavaInstanceJSC.h" #endif @interface NSObject (WebPlugin) diff --git a/WebCore/bindings/js/ScriptControllerQt.cpp b/WebCore/bindings/js/ScriptControllerQt.cpp index 6b14190..55d4ba4 100644 --- a/WebCore/bindings/js/ScriptControllerQt.cpp +++ b/WebCore/bindings/js/ScriptControllerQt.cpp @@ -36,11 +36,11 @@ #include "config.h" #include "ScriptController.h" +#include "Bridge.h" #include "DOMWindow.h" #include "PluginView.h" #include "qt_instance.h" #include "runtime_root.h" -#include "runtime.h" #include <QWidget> diff --git a/WebCore/bindings/js/ScriptControllerWin.cpp b/WebCore/bindings/js/ScriptControllerWin.cpp index 703cf7c..e0a959e 100644 --- a/WebCore/bindings/js/ScriptControllerWin.cpp +++ b/WebCore/bindings/js/ScriptControllerWin.cpp @@ -27,8 +27,8 @@ #include "config.h" #include "ScriptController.h" +#include "Bridge.h" #include "PluginView.h" -#include "runtime.h" using namespace JSC::Bindings; diff --git a/WebCore/bindings/js/ScriptControllerWx.cpp b/WebCore/bindings/js/ScriptControllerWx.cpp index 1c14928..1d7b4ca 100644 --- a/WebCore/bindings/js/ScriptControllerWx.cpp +++ b/WebCore/bindings/js/ScriptControllerWx.cpp @@ -27,9 +27,9 @@ #include "config.h" #include "ScriptController.h" +#include "Bridge.h" #include "PluginView.h" #include "runtime_root.h" -#include "runtime.h" namespace WebCore { diff --git a/WebCore/bindings/js/ScriptInstance.h b/WebCore/bindings/js/ScriptInstance.h index 3095df9..0b3b59f 100644 --- a/WebCore/bindings/js/ScriptInstance.h +++ b/WebCore/bindings/js/ScriptInstance.h @@ -31,8 +31,8 @@ #ifndef ScriptInstance_h #define ScriptInstance_h +#include "Bridge.h" #include <wtf/RefPtr.h> -#include "runtime.h" namespace WebCore { diff --git a/WebCore/bindings/objc/WebScriptObject.mm b/WebCore/bindings/objc/WebScriptObject.mm index 1622a3c..d7bc90c 100644 --- a/WebCore/bindings/objc/WebScriptObject.mm +++ b/WebCore/bindings/objc/WebScriptObject.mm @@ -26,6 +26,7 @@ #import "config.h" #import "WebScriptObjectPrivate.h" +#import "Bridge.h" #import "Console.h" #import "DOMInternal.h" #import "DOMWindow.h" @@ -36,7 +37,6 @@ #import "StringSourceProvider.h" #import "WebCoreObjCExtras.h" #import "objc_instance.h" -#import "runtime.h" #import "runtime_object.h" #import "runtime_root.h" #import <JavaScriptCore/APICast.h> diff --git a/WebCore/bindings/v8/DOMObjectsInclude.h b/WebCore/bindings/v8/DOMObjectsInclude.h index 6ed14be..bded7f2 100644 --- a/WebCore/bindings/v8/DOMObjectsInclude.h +++ b/WebCore/bindings/v8/DOMObjectsInclude.h @@ -229,6 +229,7 @@ #endif // SVG #if PLATFORM(ANDROID) +#include "Connection.h" // TODO: Upstream TOUCH_EVENTS guard. #if ENABLE(TOUCH_EVENTS) #include "Touch.h" diff --git a/WebCore/bindings/v8/V8DOMWrapper.cpp b/WebCore/bindings/v8/V8DOMWrapper.cpp index 6a691a9..28b316a 100644 --- a/WebCore/bindings/v8/V8DOMWrapper.cpp +++ b/WebCore/bindings/v8/V8DOMWrapper.cpp @@ -32,18 +32,11 @@ #include "V8DOMWrapper.h" #include "CSSMutableStyleDeclaration.h" -// ANDROID: Upstream CHROMIUM guard. -#if PLATFORM(CHROMIUM) -#include "ChromiumBridge.h" -#endif #include "DOMObjectsInclude.h" #include "DocumentLoader.h" #include "FrameLoaderClient.h" #include "Notification.h" -// ANDROID: Upstream SVG guard. -#if ENABLE(SVG) #include "SVGElementInstance.h" -#endif #include "ScriptController.h" #include "V8AbstractEventListener.h" #include "V8Binding.h" @@ -592,13 +585,11 @@ v8::Persistent<v8::FunctionTemplate> V8DOMWrapper::getTemplate(V8ClassIndex::V8W instanceTemplate->SetInternalFieldCount(V8Custom::kXMLHttpRequestInternalFieldCount); break; } -// ANDROID: Upstream XPATH guard. #if ENABLE(XPATH) case V8ClassIndex::XPATHEVALUATOR: descriptor->SetCallHandler(USE_CALLBACK(XPathEvaluatorConstructor)); break; #endif -// ANDROID: Upstream XSLT guard. #if ENABLE(XSLT) case V8ClassIndex::XSLTPROCESSOR: descriptor->SetCallHandler(USE_CALLBACK(XSLTProcessorConstructor)); diff --git a/WebCore/bindings/v8/V8DOMWrapper.h b/WebCore/bindings/v8/V8DOMWrapper.h index 660b827..2761100 100644 --- a/WebCore/bindings/v8/V8DOMWrapper.h +++ b/WebCore/bindings/v8/V8DOMWrapper.h @@ -242,8 +242,6 @@ namespace WebCore { static PassRefPtr<EventListener> getEventListener(V8Proxy* proxy, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup); -#if PLATFORM(ANDROID) -// TODO: upstream XPATH guard. #if ENABLE(XPATH) // XPath-related utilities static RefPtr<XPathNSResolver> getXPathNSResolver(v8::Handle<v8::Value> value, V8Proxy* proxy = 0) @@ -256,7 +254,6 @@ namespace WebCore { return resolver; } #endif -#endif // DOMImplementation is a singleton and it is handled in a special // way. A wrapper is generated per document and stored in an diff --git a/WebCore/bindings/v8/V8Index.cpp b/WebCore/bindings/v8/V8Index.cpp index 9686dc6..ea13d2f 100644 --- a/WebCore/bindings/v8/V8Index.cpp +++ b/WebCore/bindings/v8/V8Index.cpp @@ -447,6 +447,7 @@ #include "V8PositionError.h" #if PLATFORM(ANDROID) +#include "V8Connection.h" // TODO: Upstream these guards to webkit.org #if ENABLE(TOUCH_EVENTS) #include "V8Touch.h" diff --git a/WebCore/bindings/v8/V8Index.h b/WebCore/bindings/v8/V8Index.h index d786aab..a3aebdf 100644 --- a/WebCore/bindings/v8/V8Index.h +++ b/WebCore/bindings/v8/V8Index.h @@ -512,6 +512,8 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)(); #else #define DOM_OBJECT_TOUCH_EVENT_TYPES(V) #endif +#define DOM_OBJECT_CONNECTION_TYPES(V) \ + V(CONNECTION, Connection) #endif #if PLATFORM(ANDROID) @@ -535,6 +537,7 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)(); DOM_OBJECT_INSPECTOR_TYPES(V) \ DOM_OBJECT_GEOLOCATION_TYPES(V) \ DOM_OBJECT_TOUCH_EVENT_TYPES(V) \ + DOM_OBJECT_CONNECTION_TYPES(V) \ DOM_OBJECT_VOIDCALLBACK_TYPES(V) #endif diff --git a/WebCore/bridge/Bridge.h b/WebCore/bridge/Bridge.h new file mode 100644 index 0000000..d92cd15 --- /dev/null +++ b/WebCore/bridge/Bridge.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2003, 2008, 2009 Apple Inc. All rights reserved. + * 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 Bridge_h +#define Bridge_h + +#include "BridgeJSC.h" + +namespace JSC { + +namespace Bindings { + +class Method : public Noncopyable { +public: + virtual int numParameters() const = 0; + + virtual ~Method() { } +}; + +} // namespace Bindings + +} // namespace JSC + +#endif diff --git a/WebCore/bridge/c/c_class.h b/WebCore/bridge/c/c_class.h index 7f20af4..52db2b9 100644 --- a/WebCore/bridge/c/c_class.h +++ b/WebCore/bridge/c/c_class.h @@ -28,8 +28,8 @@ #if ENABLE(NETSCAPE_PLUGIN_API) +#include "Bridge.h" #include "npruntime_internal.h" -#include "runtime.h" #include <wtf/HashMap.h> namespace JSC { diff --git a/WebCore/bridge/c/c_instance.cpp b/WebCore/bridge/c/c_instance.cpp index 77b5966..1b05259 100644 --- a/WebCore/bridge/c/c_instance.cpp +++ b/WebCore/bridge/c/c_instance.cpp @@ -138,7 +138,7 @@ JSValue CInstance::invokeMethod(ExecState* exec, const MethodList& methodList, c for (i = 0; i < count; i++) _NPN_ReleaseVariantValue(&cArgs[i]); - JSValue resultValue = convertNPVariantToValue(exec, &resultVariant, _rootObject.get()); + JSValue resultValue = convertNPVariantToValue(exec, &resultVariant, m_rootObject.get()); _NPN_ReleaseVariantValue(&resultVariant); return resultValue; } @@ -173,7 +173,7 @@ JSValue CInstance::invokeDefaultMethod(ExecState* exec, const ArgList& args) for (i = 0; i < count; i++) _NPN_ReleaseVariantValue(&cArgs[i]); - JSValue resultValue = convertNPVariantToValue(exec, &resultVariant, _rootObject.get()); + JSValue resultValue = convertNPVariantToValue(exec, &resultVariant, m_rootObject.get()); _NPN_ReleaseVariantValue(&resultVariant); return resultValue; } @@ -212,7 +212,7 @@ JSValue CInstance::invokeConstruct(ExecState* exec, const ArgList& args) for (i = 0; i < count; i++) _NPN_ReleaseVariantValue(&cArgs[i]); - JSValue resultValue = convertNPVariantToValue(exec, &resultVariant, _rootObject.get()); + JSValue resultValue = convertNPVariantToValue(exec, &resultVariant, m_rootObject.get()); _NPN_ReleaseVariantValue(&resultVariant); return resultValue; } diff --git a/WebCore/bridge/c/c_instance.h b/WebCore/bridge/c/c_instance.h index f9e9de3..7109582 100644 --- a/WebCore/bridge/c/c_instance.h +++ b/WebCore/bridge/c/c_instance.h @@ -28,9 +28,9 @@ #if ENABLE(NETSCAPE_PLUGIN_API) -#include "runtime.h" -#include <wtf/PassRefPtr.h> +#include "Bridge.h" #include "runtime_root.h" +#include <wtf/PassRefPtr.h> typedef struct NPObject NPObject; diff --git a/WebCore/bridge/c/c_runtime.h b/WebCore/bridge/c/c_runtime.h index e797342..5355934 100644 --- a/WebCore/bridge/c/c_runtime.h +++ b/WebCore/bridge/c/c_runtime.h @@ -28,8 +28,8 @@ #if ENABLE(NETSCAPE_PLUGIN_API) +#include "Bridge.h" #include "npruntime_internal.h" -#include "runtime.h" namespace JSC { namespace Bindings { diff --git a/WebCore/bridge/jni/JNIBridge.cpp b/WebCore/bridge/jni/JNIBridge.cpp new file mode 100644 index 0000000..627d227 --- /dev/null +++ b/WebCore/bridge/jni/JNIBridge.cpp @@ -0,0 +1,576 @@ +/* + * Copyright (C) 2003, 2004, 2005, 2007, 2009 Apple Inc. All rights reserved. + * 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "JNIBridge.h" + +#if ENABLE(MAC_JAVA_BRIDGE) + +#include "CString.h" +#include "JNIUtility.h" +#include "JNIUtilityPrivate.h" +#include "StringBuilder.h" +#include "runtime_array.h" +#include "runtime_object.h" +#include "runtime_root.h" +#include <runtime/Error.h> +#include <runtime/JSLock.h> + +#ifdef NDEBUG +#define JS_LOG(formatAndArgs...) ((void)0) +#else +#define JS_LOG(formatAndArgs...) { \ + fprintf(stderr, "%s:%d -- %s: ", __FILE__, __LINE__, __FUNCTION__); \ + fprintf(stderr, formatAndArgs); \ +} +#endif + +using namespace JSC; +using namespace JSC::Bindings; +using namespace WebCore; + + +JavaParameter::JavaParameter(JNIEnv* env, jstring type) +{ + m_type = JavaString(env, type); + m_JNIType = JNITypeFromClassName(m_type.UTF8String()); +} + +JavaField::JavaField(JNIEnv* env, jobject aField) +{ + // Get field type + jobject fieldType = callJNIMethod<jobject>(aField, "getType", "()Ljava/lang/Class;"); + jstring fieldTypeName = static_cast<jstring>(callJNIMethod<jobject>(fieldType, "getName", "()Ljava/lang/String;")); + m_type = JavaString(env, fieldTypeName); + m_JNIType = JNITypeFromClassName(m_type.UTF8String()); + + // Get field name + jstring fieldName = static_cast<jstring>(callJNIMethod<jobject>(aField, "getName", "()Ljava/lang/String;")); + m_name = JavaString(env, fieldName); + + m_field = new JObjectWrapper(aField); +} + +JSValue JavaArray::convertJObjectToArray(ExecState* exec, jobject anObject, const char* type, PassRefPtr<RootObject> rootObject) +{ + if (type[0] != '[') + return jsUndefined(); + + return new (exec) RuntimeArray(exec, new JavaArray(anObject, type, rootObject)); +} + +jvalue JavaField::dispatchValueFromInstance(ExecState* exec, const JavaInstance* instance, const char* name, const char* sig, JNIType returnType) const +{ + jobject jinstance = instance->javaInstance(); + jobject fieldJInstance = m_field->m_instance; + JNIEnv* env = getJNIEnv(); + jvalue result; + + bzero(&result, sizeof(jvalue)); + jclass cls = env->GetObjectClass(fieldJInstance); + if (cls) { + jmethodID mid = env->GetMethodID(cls, name, sig); + if (mid) { + RootObject* rootObject = instance->rootObject(); + if (rootObject && rootObject->nativeHandle()) { + JSValue exceptionDescription; + jvalue args[1]; + + args[0].l = jinstance; + dispatchJNICall(exec, rootObject->nativeHandle(), fieldJInstance, false, returnType, mid, args, result, 0, exceptionDescription); + if (exceptionDescription) + throwError(exec, GeneralError, exceptionDescription.toString(exec)); + } + } + } + return result; +} + +JSValue JavaField::valueFromInstance(ExecState* exec, const Instance* i) const +{ + const JavaInstance* instance = static_cast<const JavaInstance*>(i); + + JSValue jsresult = jsUndefined(); + + switch (m_JNIType) { + case array_type: + case object_type: + { + jvalue result = dispatchValueFromInstance(exec, instance, "get", "(Ljava/lang/Object;)Ljava/lang/Object;", object_type); + jobject anObject = result.l; + + const char* arrayType = type(); + if (arrayType[0] == '[') + jsresult = JavaArray::convertJObjectToArray(exec, anObject, arrayType, instance->rootObject()); + else if (anObject) + jsresult = JavaInstance::create(anObject, instance->rootObject())->createRuntimeObject(exec); + } + break; + + case boolean_type: + jsresult = jsBoolean(dispatchValueFromInstance(exec, instance, "getBoolean", "(Ljava/lang/Object;)Z", boolean_type).z); + break; + + case byte_type: + case char_type: + case short_type: + + case int_type: + { + jint value; + jvalue result = dispatchValueFromInstance(exec, instance, "getInt", "(Ljava/lang/Object;)I", int_type); + value = result.i; + jsresult = jsNumber(exec, static_cast<int>(value)); + } + break; + + case long_type: + case float_type: + case double_type: + { + jdouble value; + jvalue result = dispatchValueFromInstance(exec, instance, "getDouble", "(Ljava/lang/Object;)D", double_type); + value = result.i; + jsresult = jsNumber(exec, static_cast<double>(value)); + } + break; + default: + break; + } + + JS_LOG("getting %s = %s\n", UString(name()).UTF8String().c_str(), jsresult.toString(exec).ascii()); + + return jsresult; +} + +void JavaField::dispatchSetValueToInstance(ExecState* exec, const JavaInstance* instance, jvalue javaValue, const char* name, const char* sig) const +{ + jobject jinstance = instance->javaInstance(); + jobject fieldJInstance = m_field->m_instance; + JNIEnv* env = getJNIEnv(); + + jclass cls = env->GetObjectClass(fieldJInstance); + if (cls) { + jmethodID mid = env->GetMethodID(cls, name, sig); + if (mid) { + RootObject* rootObject = instance->rootObject(); + if (rootObject && rootObject->nativeHandle()) { + JSValue exceptionDescription; + jvalue args[2]; + jvalue result; + + args[0].l = jinstance; + args[1] = javaValue; + dispatchJNICall(exec, rootObject->nativeHandle(), fieldJInstance, false, void_type, mid, args, result, 0, exceptionDescription); + if (exceptionDescription) + throwError(exec, GeneralError, exceptionDescription.toString(exec)); + } + } + } +} + +void JavaField::setValueToInstance(ExecState* exec, const Instance* i, JSValue aValue) const +{ + const JavaInstance* instance = static_cast<const JavaInstance*>(i); + jvalue javaValue = convertValueToJValue(exec, aValue, m_JNIType, type()); + + JS_LOG("setting value %s to %s\n", UString(name()).UTF8String().c_str(), aValue.toString(exec).ascii()); + + switch (m_JNIType) { + case array_type: + case object_type: + { + dispatchSetValueToInstance(exec, instance, javaValue, "set", "(Ljava/lang/Object;Ljava/lang/Object;)V"); + } + break; + + case boolean_type: + { + dispatchSetValueToInstance(exec, instance, javaValue, "setBoolean", "(Ljava/lang/Object;Z)V"); + } + break; + + case byte_type: + { + dispatchSetValueToInstance(exec, instance, javaValue, "setByte", "(Ljava/lang/Object;B)V"); + } + break; + + case char_type: + { + dispatchSetValueToInstance(exec, instance, javaValue, "setChar", "(Ljava/lang/Object;C)V"); + } + break; + + case short_type: + { + dispatchSetValueToInstance(exec, instance, javaValue, "setShort", "(Ljava/lang/Object;S)V"); + } + break; + + case int_type: + { + dispatchSetValueToInstance(exec, instance, javaValue, "setInt", "(Ljava/lang/Object;I)V"); + } + break; + + case long_type: + { + dispatchSetValueToInstance(exec, instance, javaValue, "setLong", "(Ljava/lang/Object;J)V"); + } + break; + + case float_type: + { + dispatchSetValueToInstance(exec, instance, javaValue, "setFloat", "(Ljava/lang/Object;F)V"); + } + break; + + case double_type: + { + dispatchSetValueToInstance(exec, instance, javaValue, "setDouble", "(Ljava/lang/Object;D)V"); + } + break; + default: + break; + } +} + +JavaMethod::JavaMethod(JNIEnv* env, jobject aMethod) +{ + // Get return type + jobject returnType = callJNIMethod<jobject>(aMethod, "getReturnType", "()Ljava/lang/Class;"); + jstring returnTypeName = static_cast<jstring>(callJNIMethod<jobject>(returnType, "getName", "()Ljava/lang/String;")); + m_returnType = JavaString(env, returnTypeName); + m_JNIReturnType = JNITypeFromClassName(m_returnType.UTF8String()); + env->DeleteLocalRef(returnType); + env->DeleteLocalRef(returnTypeName); + + // Get method name + jstring methodName = static_cast<jstring>(callJNIMethod<jobject>(aMethod, "getName", "()Ljava/lang/String;")); + m_name = JavaString(env, methodName); + env->DeleteLocalRef(methodName); + + // Get parameters + jarray jparameters = static_cast<jarray>(callJNIMethod<jobject>(aMethod, "getParameterTypes", "()[Ljava/lang/Class;")); + m_numParameters = env->GetArrayLength(jparameters); + m_parameters = new JavaParameter[m_numParameters]; + + for (int i = 0; i < m_numParameters; i++) { + jobject aParameter = env->GetObjectArrayElement(static_cast<jobjectArray>(jparameters), i); + jstring parameterName = static_cast<jstring>(callJNIMethod<jobject>(aParameter, "getName", "()Ljava/lang/String;")); + m_parameters[i] = JavaParameter(env, parameterName); + env->DeleteLocalRef(aParameter); + env->DeleteLocalRef(parameterName); + } + env->DeleteLocalRef(jparameters); + + // Created lazily. + m_signature = 0; + m_methodID = 0; + + jclass modifierClass = env->FindClass("java/lang/reflect/Modifier"); + int modifiers = callJNIMethod<jint>(aMethod, "getModifiers", "()I"); + m_isStatic = static_cast<bool>(callJNIStaticMethod<jboolean>(modifierClass, "isStatic", "(I)Z", modifiers)); + env->DeleteLocalRef(modifierClass); +} + +JavaMethod::~JavaMethod() +{ + if (m_signature) + free(m_signature); + delete[] m_parameters; +}; + +// JNI method signatures use '/' between components of a class name, but +// we get '.' between components from the reflection API. +static void appendClassName(StringBuilder& builder, const char* className) +{ + ASSERT(JSLock::lockCount() > 0); + + char* c = strdup(className); + + char* result = c; + while (*c) { + if (*c == '.') + *c = '/'; + c++; + } + + builder.append(result); + + free(result); +} + +const char* JavaMethod::signature() const +{ + if (!m_signature) { + JSLock lock(SilenceAssertionsOnly); + + StringBuilder signatureBuilder; + signatureBuilder.append("("); + for (int i = 0; i < m_numParameters; i++) { + JavaParameter* aParameter = parameterAt(i); + JNIType type = aParameter->getJNIType(); + if (type == array_type) + appendClassName(signatureBuilder, aParameter->type()); + else { + signatureBuilder.append(signatureFromPrimitiveType(type)); + if (type == object_type) { + appendClassName(signatureBuilder, aParameter->type()); + signatureBuilder.append(";"); + } + } + } + signatureBuilder.append(")"); + + const char* returnType = m_returnType.UTF8String(); + if (m_JNIReturnType == array_type) + appendClassName(signatureBuilder, returnType); + else { + signatureBuilder.append(signatureFromPrimitiveType(m_JNIReturnType)); + if (m_JNIReturnType == object_type) { + appendClassName(signatureBuilder, returnType); + signatureBuilder.append(";"); + } + } + + String signatureString = signatureBuilder.toString(); + m_signature = strdup(signatureString.utf8().data()); + } + + return m_signature; +} + +JNIType JavaMethod::JNIReturnType() const +{ + return m_JNIReturnType; +} + +jmethodID JavaMethod::methodID(jobject obj) const +{ + if (!m_methodID) + m_methodID = getMethodID(obj, m_name.UTF8String(), signature()); + return m_methodID; +} + + +JavaArray::JavaArray(jobject array, const char* type, PassRefPtr<RootObject> rootObject) + : Array(rootObject) +{ + m_array = new JObjectWrapper(array); + // Java array are fixed length, so we can cache length. + JNIEnv* env = getJNIEnv(); + m_length = env->GetArrayLength(static_cast<jarray>(m_array->m_instance)); + m_type = strdup(type); + m_rootObject = rootObject; +} + +JavaArray::~JavaArray() +{ + free(const_cast<char*>(m_type)); +} + +RootObject* JavaArray::rootObject() const +{ + return m_rootObject && m_rootObject->isValid() ? m_rootObject.get() : 0; +} + +void JavaArray::setValueAt(ExecState* exec, unsigned index, JSValue aValue) const +{ + JNIEnv* env = getJNIEnv(); + char* javaClassName = 0; + + JNIType arrayType = JNITypeFromPrimitiveType(m_type[1]); + if (m_type[1] == 'L') { + // The type of the array will be something like: + // "[Ljava.lang.string;". This is guaranteed, so no need + // for extra sanity checks. + javaClassName = strdup(&m_type[2]); + javaClassName[strchr(javaClassName, ';')-javaClassName] = 0; + } + jvalue aJValue = convertValueToJValue(exec, aValue, arrayType, javaClassName); + + switch (arrayType) { + case object_type: + { + env->SetObjectArrayElement(static_cast<jobjectArray>(javaArray()), index, aJValue.l); + break; + } + + case boolean_type: + { + env->SetBooleanArrayRegion(static_cast<jbooleanArray>(javaArray()), index, 1, &aJValue.z); + break; + } + + case byte_type: + { + env->SetByteArrayRegion(static_cast<jbyteArray>(javaArray()), index, 1, &aJValue.b); + break; + } + + case char_type: + { + env->SetCharArrayRegion(static_cast<jcharArray>(javaArray()), index, 1, &aJValue.c); + break; + } + + case short_type: + { + env->SetShortArrayRegion(static_cast<jshortArray>(javaArray()), index, 1, &aJValue.s); + break; + } + + case int_type: + { + env->SetIntArrayRegion(static_cast<jintArray>(javaArray()), index, 1, &aJValue.i); + break; + } + + case long_type: + { + env->SetLongArrayRegion(static_cast<jlongArray>(javaArray()), index, 1, &aJValue.j); + } + + case float_type: + { + env->SetFloatArrayRegion(static_cast<jfloatArray>(javaArray()), index, 1, &aJValue.f); + break; + } + + case double_type: + { + env->SetDoubleArrayRegion(static_cast<jdoubleArray>(javaArray()), index, 1, &aJValue.d); + break; + } + default: + break; + } + + if (javaClassName) + free(const_cast<char*>(javaClassName)); +} + + +JSValue JavaArray::valueAt(ExecState* exec, unsigned index) const +{ + JNIEnv* env = getJNIEnv(); + JNIType arrayType = JNITypeFromPrimitiveType(m_type[1]); + switch (arrayType) { + case object_type: + { + jobjectArray objectArray = static_cast<jobjectArray>(javaArray()); + jobject anObject; + anObject = env->GetObjectArrayElement(objectArray, index); + + // No object? + if (!anObject) + return jsNull(); + + // Nested array? + if (m_type[1] == '[') + return JavaArray::convertJObjectToArray(exec, anObject, m_type + 1, rootObject()); + // or array of other object type? + return JavaInstance::create(anObject, rootObject())->createRuntimeObject(exec); + } + + case boolean_type: + { + jbooleanArray booleanArray = static_cast<jbooleanArray>(javaArray()); + jboolean aBoolean; + env->GetBooleanArrayRegion(booleanArray, index, 1, &aBoolean); + return jsBoolean(aBoolean); + } + + case byte_type: + { + jbyteArray byteArray = static_cast<jbyteArray>(javaArray()); + jbyte aByte; + env->GetByteArrayRegion(byteArray, index, 1, &aByte); + return jsNumber(exec, aByte); + } + + case char_type: + { + jcharArray charArray = static_cast<jcharArray>(javaArray()); + jchar aChar; + env->GetCharArrayRegion(charArray, index, 1, &aChar); + return jsNumber(exec, aChar); + break; + } + + case short_type: + { + jshortArray shortArray = static_cast<jshortArray>(javaArray()); + jshort aShort; + env->GetShortArrayRegion(shortArray, index, 1, &aShort); + return jsNumber(exec, aShort); + } + + case int_type: + { + jintArray intArray = static_cast<jintArray>(javaArray()); + jint anInt; + env->GetIntArrayRegion(intArray, index, 1, &anInt); + return jsNumber(exec, anInt); + } + + case long_type: + { + jlongArray longArray = static_cast<jlongArray>(javaArray()); + jlong aLong; + env->GetLongArrayRegion(longArray, index, 1, &aLong); + return jsNumber(exec, aLong); + } + + case float_type: + { + jfloatArray floatArray = static_cast<jfloatArray>(javaArray()); + jfloat aFloat; + env->GetFloatArrayRegion(floatArray, index, 1, &aFloat); + return jsNumber(exec, aFloat); + } + + case double_type: + { + jdoubleArray doubleArray = static_cast<jdoubleArray>(javaArray()); + jdouble aDouble; + env->GetDoubleArrayRegion(doubleArray, index, 1, &aDouble); + return jsNumber(exec, aDouble); + } + default: + break; + } + return jsUndefined(); +} + +unsigned int JavaArray::getLength() const +{ + return m_length; +} + +#endif // ENABLE(MAC_JAVA_BRIDGE) diff --git a/WebCore/bridge/jni/JNIBridge.h b/WebCore/bridge/jni/JNIBridge.h new file mode 100644 index 0000000..ce129af --- /dev/null +++ b/WebCore/bridge/jni/JNIBridge.h @@ -0,0 +1,166 @@ +/* + * Copyright (C) 2003, 2004, 2005, 2007, 2009, 2010 Apple Inc. All rights reserved. + * 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 JNIBridge_h +#define JNIBridge_h + +#if ENABLE(MAC_JAVA_BRIDGE) + +#include "JNIUtility.h" +#include "JavaInstanceJSC.h" + +#if USE(JSC) +#include "JavaStringJSC.h" +#endif + +namespace JSC { + +namespace Bindings { + +typedef const char* RuntimeType; + +class JavaString { +public: + JavaString() + { + m_impl.init(); + } + + JavaString(JNIEnv* e, jstring s) + { + m_impl.init(e, s); + } + + JavaString(jstring s) + { + m_impl.init(getJNIEnv(), s); + } + + const char* UTF8String() const { return m_impl.UTF8String(); } + const jchar* uchars() const { return m_impl.uchars(); } + int length() const { return m_impl.length(); } +#if USE(JSC) + operator UString() const { return m_impl.uString(); } +#endif + +private: + JavaStringImpl m_impl; +}; + +class JavaParameter { +public: + JavaParameter() : m_JNIType(invalid_type) { } + JavaParameter(JNIEnv*, jstring type); + virtual ~JavaParameter() { } + + RuntimeType type() const { return m_type.UTF8String(); } + JNIType getJNIType() const { return m_JNIType; } + +private: + JavaString m_type; + JNIType m_JNIType; +}; + + +class JavaField : public Field { +public: + JavaField(JNIEnv*, jobject aField); + + virtual JSValue valueFromInstance(ExecState*, const Instance*) const; + virtual void setValueToInstance(ExecState*, const Instance*, JSValue) const; + + const JavaString& name() const { return m_name; } + virtual RuntimeType type() const { return m_type.UTF8String(); } + + JNIType getJNIType() const { return m_JNIType; } + +private: + void dispatchSetValueToInstance(ExecState*, const JavaInstance*, jvalue, const char* name, const char* sig) const; + jvalue dispatchValueFromInstance(ExecState*, const JavaInstance*, const char* name, const char* sig, JNIType returnType) const; + + JavaString m_name; + JavaString m_type; + JNIType m_JNIType; + RefPtr<JObjectWrapper> m_field; +}; + + +class JavaMethod : public Method { +public: + JavaMethod(JNIEnv*, jobject aMethod); + ~JavaMethod(); + + const JavaString& name() const { return m_name; } + RuntimeType returnType() const { return m_returnType.UTF8String(); } + JavaParameter* parameterAt(int i) const { return &m_parameters[i]; } + int numParameters() const { return m_numParameters; } + + const char* signature() const; + JNIType JNIReturnType() const; + + jmethodID methodID(jobject obj) const; + + bool isStatic() const { return m_isStatic; } + +private: + JavaParameter* m_parameters; + int m_numParameters; + JavaString m_name; + mutable char* m_signature; + JavaString m_returnType; + JNIType m_JNIReturnType; + mutable jmethodID m_methodID; + bool m_isStatic; +}; + +class JavaArray : public Array { +public: + JavaArray(jobject array, const char* type, PassRefPtr<RootObject>); + virtual ~JavaArray(); + + RootObject* rootObject() const; + + virtual void setValueAt(ExecState*, unsigned int index, JSValue) const; + virtual JSValue valueAt(ExecState*, unsigned int index) const; + virtual unsigned int getLength() const; + + jobject javaArray() const { return m_array->m_instance; } + + static JSValue convertJObjectToArray(ExecState*, jobject, const char* type, PassRefPtr<RootObject>); + +private: + RefPtr<JObjectWrapper> m_array; + unsigned int m_length; + const char* m_type; +}; + +} // namespace Bindings + +} // namespace JSC + +#endif // ENABLE(MAC_JAVA_BRIDGE) + +#endif // JNIBridge_h diff --git a/WebCore/bridge/jni/jni_utility.cpp b/WebCore/bridge/jni/JNIUtility.cpp index faa7a8b..ee45710 100644 --- a/WebCore/bridge/jni/jni_utility.cpp +++ b/WebCore/bridge/jni/JNIUtility.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -20,11 +20,11 @@ * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" -#include "jni_utility.h" +#include "JNIUtility.h" #if ENABLE(MAC_JAVA_BRIDGE) @@ -34,7 +34,7 @@ namespace JSC { namespace Bindings { -static jint KJS_GetCreatedJavaVMs(JavaVM** vmBuf, jsize bufLen, jsize* nVMs) +static jint KJSGetCreatedJavaVMs(JavaVM** vmBuf, jsize bufLen, jsize* nVMs) { static void* javaVMFramework = 0; if (!javaVMFramework) @@ -42,43 +42,43 @@ static jint KJS_GetCreatedJavaVMs(JavaVM** vmBuf, jsize bufLen, jsize* nVMs) if (!javaVMFramework) return JNI_ERR; - static jint(*functionPointer)(JavaVM**, jsize, jsize *) = 0; + typedef jint(*FunctionPointerType)(JavaVM**, jsize, jsize*); + static FunctionPointerType functionPointer = 0; if (!functionPointer) - functionPointer = (jint(*)(JavaVM**, jsize, jsize *))dlsym(javaVMFramework, "JNI_GetCreatedJavaVMs"); + functionPointer = reinterpret_cast<FunctionPointerType>(dlsym(javaVMFramework, "JNI_GetCreatedJavaVMs")); if (!functionPointer) return JNI_ERR; return functionPointer(vmBuf, bufLen, nVMs); } -static JavaVM *jvm = 0; +static JavaVM* jvm = 0; // Provide the ability for an outside component to specify the JavaVM to use -// If the jvm value is set, the getJavaVM function below will just return. +// If the jvm value is set, the getJavaVM function below will just return. // In getJNIEnv(), if AttachCurrentThread is called to a VM that is already // attached, the result is a no-op. -void setJavaVM(JavaVM *javaVM) +void setJavaVM(JavaVM* javaVM) { jvm = javaVM; } -JavaVM *getJavaVM() +JavaVM* getJavaVM() { if (jvm) return jvm; - JavaVM *jvmArray[1]; + JavaVM* jvmArray[1]; jsize bufLen = 1; jsize nJVMs = 0; jint jniError = 0; // Assumes JVM is already running ..., one per process - jniError = KJS_GetCreatedJavaVMs(jvmArray, bufLen, &nJVMs); - if ( jniError == JNI_OK && nJVMs > 0 ) { + jniError = KJSGetCreatedJavaVMs(jvmArray, bufLen, &nJVMs); + if (jniError == JNI_OK && nJVMs > 0) jvm = jvmArray[0]; - } - else - fprintf(stderr, "%s: JNI_GetCreatedJavaVMs failed, returned %ld\n", __PRETTY_FUNCTION__, (long)jniError); - + else + fprintf(stderr, "%s: JNI_GetCreatedJavaVMs failed, returned %ld\n", __PRETTY_FUNCTION__, static_cast<long>(jniError)); + return jvm; } @@ -90,29 +90,27 @@ JNIEnv* getJNIEnv() } u; jint jniError = 0; - jniError = (getJavaVM())->AttachCurrentThread(&u.dummy, NULL); + jniError = getJavaVM()->AttachCurrentThread(&u.dummy, 0); if (jniError == JNI_OK) return u.env; - else - fprintf(stderr, "%s: AttachCurrentThread failed, returned %ld\n", __PRETTY_FUNCTION__, (long)jniError); - return NULL; + fprintf(stderr, "%s: AttachCurrentThread failed, returned %ld\n", __PRETTY_FUNCTION__, static_cast<long>(jniError)); + return 0; } -jmethodID getMethodID (jobject obj, const char *name, const char *sig) +jmethodID getMethodID(jobject obj, const char* name, const char* sig) { - JNIEnv *env = getJNIEnv(); + JNIEnv* env = getJNIEnv(); jmethodID mid = 0; - - if ( env != NULL) { - jclass cls = env->GetObjectClass(obj); - if ( cls != NULL ) { + + if (env) { + jclass cls = env->GetObjectClass(obj); + if (cls) { mid = env->GetMethodID(cls, name, sig); if (!mid) { env->ExceptionClear(); mid = env->GetStaticMethodID(cls, name, sig); - if (!mid) { + if (!mid) env->ExceptionClear(); - } } } env->DeleteLocalRef(cls); @@ -120,118 +118,118 @@ jmethodID getMethodID (jobject obj, const char *name, const char *sig) return mid; } -const char *getCharactersFromJString (jstring aJString) +const char* getCharactersFromJString(jstring aJString) { - return getCharactersFromJStringInEnv (getJNIEnv(), aJString); + return getCharactersFromJStringInEnv(getJNIEnv(), aJString); } -void releaseCharactersForJString (jstring aJString, const char *s) +void releaseCharactersForJString(jstring aJString, const char* s) { - releaseCharactersForJStringInEnv (getJNIEnv(), aJString, s); + releaseCharactersForJStringInEnv(getJNIEnv(), aJString, s); } -const char *getCharactersFromJStringInEnv (JNIEnv *env, jstring aJString) +const char* getCharactersFromJStringInEnv(JNIEnv* env, jstring aJString) { jboolean isCopy; - const char *s = env->GetStringUTFChars((jstring)aJString, &isCopy); + const char* s = env->GetStringUTFChars(aJString, &isCopy); if (!s) { env->ExceptionDescribe(); env->ExceptionClear(); - fprintf (stderr, "\n"); + fprintf(stderr, "\n"); } return s; } -void releaseCharactersForJStringInEnv (JNIEnv *env, jstring aJString, const char *s) +void releaseCharactersForJStringInEnv(JNIEnv* env, jstring aJString, const char* s) { - env->ReleaseStringUTFChars (aJString, s); + env->ReleaseStringUTFChars(aJString, s); } -const jchar *getUCharactersFromJStringInEnv (JNIEnv *env, jstring aJString) +const jchar* getUCharactersFromJStringInEnv(JNIEnv* env, jstring aJString) { jboolean isCopy; - const jchar *s = env->GetStringChars((jstring)aJString, &isCopy); + const jchar* s = env->GetStringChars(aJString, &isCopy); if (!s) { env->ExceptionDescribe(); env->ExceptionClear(); - fprintf (stderr, "\n"); + fprintf(stderr, "\n"); } return s; } -void releaseUCharactersForJStringInEnv (JNIEnv *env, jstring aJString, const jchar *s) +void releaseUCharactersForJStringInEnv(JNIEnv* env, jstring aJString, const jchar* s) { - env->ReleaseStringChars (aJString, s); + env->ReleaseStringChars(aJString, s); } -JNIType JNITypeFromClassName(const char *name) +JNIType JNITypeFromClassName(const char* name) { JNIType type; - - if (strcmp("byte",name) == 0) + + if (!strcmp("byte", name)) type = byte_type; - else if (strcmp("short",name) == 0) + else if (!strcmp("short", name)) type = short_type; - else if (strcmp("int",name) == 0) + else if (!strcmp("int", name)) type = int_type; - else if (strcmp("long",name) == 0) + else if (!strcmp("long", name)) type = long_type; - else if (strcmp("float",name) == 0) + else if (!strcmp("float", name)) type = float_type; - else if (strcmp("double",name) == 0) + else if (!strcmp("double", name)) type = double_type; - else if (strcmp("char",name) == 0) + else if (!strcmp("char", name)) type = char_type; - else if (strcmp("boolean",name) == 0) + else if (!strcmp("boolean", name)) type = boolean_type; - else if (strcmp("void",name) == 0) + else if (!strcmp("void", name)) type = void_type; - else if ('[' == name[0]) + else if ('[' == name[0]) type = array_type; else type = object_type; - + return type; } -const char *signatureFromPrimitiveType(JNIType type) +const char* signatureFromPrimitiveType(JNIType type) { - switch (type){ - case void_type: - return "V"; - - case array_type: - return "["; - - case object_type: - return "L"; - - case boolean_type: - return "Z"; - - case byte_type: - return "B"; - - case char_type: - return "C"; - - case short_type: - return "S"; - - case int_type: - return "I"; - - case long_type: - return "J"; - - case float_type: - return "F"; - - case double_type: - return "D"; - - case invalid_type: - default: + switch (type) { + case void_type: + return "V"; + + case array_type: + return "["; + + case object_type: + return "L"; + + case boolean_type: + return "Z"; + + case byte_type: + return "B"; + + case char_type: + return "C"; + + case short_type: + return "S"; + + case int_type: + return "I"; + + case long_type: + return "J"; + + case float_type: + return "F"; + + case double_type: + return "D"; + + case invalid_type: + default: break; } return ""; @@ -239,58 +237,58 @@ const char *signatureFromPrimitiveType(JNIType type) JNIType JNITypeFromPrimitiveType(char type) { - switch (type){ - case 'V': - return void_type; - - case 'L': - return object_type; - - case '[': - return array_type; - - case 'Z': - return boolean_type; - - case 'B': - return byte_type; - - case 'C': - return char_type; - - case 'S': - return short_type; - - case 'I': - return int_type; - - case 'J': - return long_type; - - case 'F': - return float_type; - - case 'D': - return double_type; - - default: + switch (type) { + case 'V': + return void_type; + + case 'L': + return object_type; + + case '[': + return array_type; + + case 'Z': + return boolean_type; + + case 'B': + return byte_type; + + case 'C': + return char_type; + + case 'S': + return short_type; + + case 'I': + return int_type; + + case 'J': + return long_type; + + case 'F': + return float_type; + + case 'D': + return double_type; + + default: break; } return invalid_type; } -jvalue getJNIField( jobject obj, JNIType type, const char *name, const char *signature) +jvalue getJNIField(jobject obj, JNIType type, const char* name, const char* signature) { - JavaVM *jvm = getJavaVM(); - JNIEnv *env = getJNIEnv(); + JavaVM* jvm = getJavaVM(); + JNIEnv* env = getJNIEnv(); jvalue result; - bzero (&result, sizeof(jvalue)); - if ( obj != NULL && jvm != NULL && env != NULL) { + bzero(&result, sizeof(jvalue)); + if (obj && jvm && env) { jclass cls = env->GetObjectClass(obj); - if ( cls != NULL ) { + if (cls) { jfieldID field = env->GetFieldID(cls, name, signature); - if ( field != NULL ) { + if (field) { switch (type) { case array_type: case object_type: @@ -321,29 +319,25 @@ jvalue getJNIField( jobject obj, JNIType type, const char *name, const char *sig result.d = env->functions->GetDoubleField(env, obj, field); break; default: - fprintf(stderr, "%s: invalid field type (%d)\n", __PRETTY_FUNCTION__, (int)type); + fprintf(stderr, "%s: invalid field type (%d)\n", __PRETTY_FUNCTION__, static_cast<int>(type)); } - } - else - { + } else { fprintf(stderr, "%s: Could not find field: %s\n", __PRETTY_FUNCTION__, name); env->ExceptionDescribe(); env->ExceptionClear(); - fprintf (stderr, "\n"); + fprintf(stderr, "\n"); } env->DeleteLocalRef(cls); - } - else { + } else fprintf(stderr, "%s: Could not find class for object\n", __PRETTY_FUNCTION__); - } } return result; } -} // end of namespace Bindings +} // namespace Bindings -} // end of namespace JSC +} // namespace JSC #endif // ENABLE(MAC_JAVA_BRIDGE) diff --git a/WebCore/bridge/jni/jni_utility.h b/WebCore/bridge/jni/JNIUtility.h index 66b3b2f..85c3533 100644 --- a/WebCore/bridge/jni/jni_utility.h +++ b/WebCore/bridge/jni/JNIUtility.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2003, 2004, 2005, 2008, 2009, 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -20,11 +20,11 @@ * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _JNI_UTILITY_H_ -#define _JNI_UTILITY_H_ +#ifndef JNIUtility_h +#define JNIUtility_h #if ENABLE(MAC_JAVA_BRIDGE) @@ -56,26 +56,26 @@ namespace Bindings { class JavaParameter; -const char *getCharactersFromJString(jstring aJString); -void releaseCharactersForJString(jstring aJString, const char *s); +const char* getCharactersFromJString(jstring); +void releaseCharactersForJString(jstring, const char*); -const char *getCharactersFromJStringInEnv(JNIEnv *env, jstring aJString); -void releaseCharactersForJStringInEnv(JNIEnv *env, jstring aJString, const char *s); -const jchar *getUCharactersFromJStringInEnv(JNIEnv *env, jstring aJString); -void releaseUCharactersForJStringInEnv(JNIEnv *env, jstring aJString, const jchar *s); +const char* getCharactersFromJStringInEnv(JNIEnv*, jstring); +void releaseCharactersForJStringInEnv(JNIEnv*, jstring, const char*); +const jchar* getUCharactersFromJStringInEnv(JNIEnv*, jstring); +void releaseUCharactersForJStringInEnv(JNIEnv*, jstring, const jchar*); -JNIType JNITypeFromClassName(const char *name); +JNIType JNITypeFromClassName(const char* name); JNIType JNITypeFromPrimitiveType(char type); -const char *signatureFromPrimitiveType(JNIType type); +const char* signatureFromPrimitiveType(JNIType); -jvalue getJNIField(jobject obj, JNIType type, const char *name, const char *signature); +jvalue getJNIField(jobject, JNIType, const char* name, const char* signature); -jmethodID getMethodID(jobject obj, const char *name, const char *sig); +jmethodID getMethodID(jobject, const char* name, const char* sig); JNIEnv* getJNIEnv(); JavaVM* getJavaVM(); void setJavaVM(JavaVM*); - - + + template <typename T> struct JNICaller; template<> struct JNICaller<void> { @@ -97,7 +97,7 @@ template<> struct JNICaller<jobject> { static jobject callV(jobject obj, jmethodID mid, va_list args) { return getJNIEnv()->CallObjectMethodV(obj, mid, args); - } + } }; template<> struct JNICaller<jboolean> { @@ -113,7 +113,6 @@ template<> struct JNICaller<jboolean> { { return getJNIEnv()->CallStaticBooleanMethod(cls, mid, args); } - }; template<> struct JNICaller<jbyte> { @@ -135,7 +134,7 @@ template<> struct JNICaller<jchar> { static jchar callV(jobject obj, jmethodID mid, va_list args) { return getJNIEnv()->CallCharMethodV(obj, mid, args); - } + } }; template<> struct JNICaller<jshort> { @@ -197,36 +196,30 @@ template<typename T> T callJNIMethodIDA(jobject obj, jmethodID mid, jvalue *args { return JNICaller<T>::callA(obj, mid, args); } - + template<typename T> -static T callJNIMethodV(jobject obj, const char *name, const char *sig, va_list args) +static T callJNIMethodV(jobject obj, const char* name, const char* sig, va_list args) { - JavaVM *jvm = getJavaVM(); - JNIEnv *env = getJNIEnv(); - - if ( obj != NULL && jvm != NULL && env != NULL) { + JavaVM* jvm = getJavaVM(); + JNIEnv* env = getJNIEnv(); + + if (obj && jvm && env) { jclass cls = env->GetObjectClass(obj); - if ( cls != NULL ) { + if (cls) { jmethodID mid = env->GetMethodID(cls, name, sig); - if ( mid != NULL ) - { + if (mid) { // Avoids references to cls without popping the local frame. env->DeleteLocalRef(cls); return JNICaller<T>::callV(obj, mid, args); } - else - { - fprintf(stderr, "%s: Could not find method: %s for %p\n", __PRETTY_FUNCTION__, name, obj); - env->ExceptionDescribe(); - env->ExceptionClear(); - fprintf (stderr, "\n"); - } + fprintf(stderr, "%s: Could not find method: %s for %p\n", __PRETTY_FUNCTION__, name, obj); + env->ExceptionDescribe(); + env->ExceptionClear(); + fprintf(stderr, "\n"); env->DeleteLocalRef(cls); - } - else { + } else fprintf(stderr, "%s: Could not find class for %p\n", __PRETTY_FUNCTION__, obj); - } } return 0; @@ -237,46 +230,46 @@ T callJNIMethod(jobject obj, const char* methodName, const char* methodSignature { va_list args; va_start(args, methodSignature); - - T result= callJNIMethodV<T>(obj, methodName, methodSignature, args); - + + T result = callJNIMethodV<T>(obj, methodName, methodSignature, args); + va_end(args); - + return result; } - + template<typename T> T callJNIStaticMethod(jclass cls, const char* methodName, const char* methodSignature, ...) { - JavaVM *jvm = getJavaVM(); - JNIEnv *env = getJNIEnv(); + JavaVM* jvm = getJavaVM(); + JNIEnv* env = getJNIEnv(); va_list args; - + va_start(args, methodSignature); - + T result = 0; - - if (cls != NULL && jvm != NULL && env != NULL) { + + if (cls && jvm && env) { jmethodID mid = env->GetStaticMethodID(cls, methodName, methodSignature); - if (mid != NULL) + if (mid) result = JNICaller<T>::callStaticV(cls, mid, args); else { fprintf(stderr, "%s: Could not find method: %s for %p\n", __PRETTY_FUNCTION__, methodName, cls); env->ExceptionDescribe(); env->ExceptionClear(); - fprintf (stderr, "\n"); + fprintf(stderr, "\n"); } } - + va_end(args); - + return result; } - + } // namespace Bindings } // namespace JSC #endif // ENABLE(MAC_JAVA_BRIDGE) -#endif // _JNI_UTILITY_H_ +#endif // JNIUtility_h diff --git a/WebCore/bridge/jni/jni_jsobject.mm b/WebCore/bridge/jni/jni_jsobject.mm index 6683af6..de67711 100644 --- a/WebCore/bridge/jni/jni_jsobject.mm +++ b/WebCore/bridge/jni/jni_jsobject.mm @@ -29,13 +29,13 @@ #if ENABLE(MAC_JAVA_BRIDGE) #include "Frame.h" +#include "JNIBridge.h" +#include "JNIUtility.h" +#include "JNIUtilityPrivate.h" #include "JSDOMBinding.h" #include "ScriptController.h" #include "StringSourceProvider.h" #include "WebCoreFrameView.h" -#include "jni_runtime.h" -#include "jni_utility.h" -#include "jni_utility_private.h" #include "runtime_object.h" #include "runtime_root.h" #include <interpreter/CallFrame.h> diff --git a/WebCore/bridge/jni/jni_objc.mm b/WebCore/bridge/jni/jni_objc.mm index fb2d694..e2e71c5 100644 --- a/WebCore/bridge/jni/jni_objc.mm +++ b/WebCore/bridge/jni/jni_objc.mm @@ -28,8 +28,8 @@ #if ENABLE(MAC_JAVA_BRIDGE) #import <Foundation/Foundation.h> -#import "jni_utility.h" -#import "jni_utility_private.h" +#import "JNIUtility.h" +#import "JNIUtilityPrivate.h" #import "objc_utility.h" #include <runtime/JSLock.h> diff --git a/WebCore/bridge/jni/jni_runtime.cpp b/WebCore/bridge/jni/jni_runtime.cpp deleted file mode 100644 index be11981..0000000 --- a/WebCore/bridge/jni/jni_runtime.cpp +++ /dev/null @@ -1,548 +0,0 @@ -/* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 <jni_runtime.h> - -#if ENABLE(MAC_JAVA_BRIDGE) - -#include "jni_utility.h" -#include "jni_utility_private.h" -#include "runtime_array.h" -#include "runtime_object.h" -#include "runtime_root.h" -#include <runtime/Error.h> -#include <runtime/JSLock.h> - -#ifdef NDEBUG -#define JS_LOG(formatAndArgs...) ((void)0) -#else -#define JS_LOG(formatAndArgs...) { \ - fprintf (stderr, "%s:%d -- %s: ", __FILE__, __LINE__, __FUNCTION__); \ - fprintf(stderr, formatAndArgs); \ -} -#endif - -using namespace JSC; -using namespace JSC::Bindings; - - -JavaParameter::JavaParameter (JNIEnv *env, jstring type) -{ - _type = JavaString (env, type); - _JNIType = JNITypeFromClassName (_type.UTF8String()); -} - -JavaField::JavaField (JNIEnv *env, jobject aField) -{ - // Get field type - jobject fieldType = callJNIMethod<jobject>(aField, "getType", "()Ljava/lang/Class;"); - jstring fieldTypeName = (jstring)callJNIMethod<jobject>(fieldType, "getName", "()Ljava/lang/String;"); - _type = JavaString(env, fieldTypeName); - _JNIType = JNITypeFromClassName (_type.UTF8String()); - - // Get field name - jstring fieldName = (jstring)callJNIMethod<jobject>(aField, "getName", "()Ljava/lang/String;"); - _name = JavaString(env, fieldName); - - _field = new JObjectWrapper(aField); -} - -JSValue JavaArray::convertJObjectToArray(ExecState* exec, jobject anObject, const char* type, PassRefPtr<RootObject> rootObject) -{ - if (type[0] != '[') - return jsUndefined(); - - return new (exec) RuntimeArray(exec, new JavaArray((jobject)anObject, type, rootObject)); -} - -jvalue JavaField::dispatchValueFromInstance(ExecState *exec, const JavaInstance *instance, const char *name, const char *sig, JNIType returnType) const -{ - jobject jinstance = instance->javaInstance(); - jobject fieldJInstance = _field->_instance; - JNIEnv *env = getJNIEnv(); - jvalue result; - - bzero (&result, sizeof(jvalue)); - jclass cls = env->GetObjectClass(fieldJInstance); - if ( cls != NULL ) { - jmethodID mid = env->GetMethodID(cls, name, sig); - if ( mid != NULL ) - { - RootObject* rootObject = instance->rootObject(); - if (rootObject && rootObject->nativeHandle()) { - JSValue exceptionDescription; - jvalue args[1]; - - args[0].l = jinstance; - dispatchJNICall(exec, rootObject->nativeHandle(), fieldJInstance, false, returnType, mid, args, result, 0, exceptionDescription); - if (exceptionDescription) - throwError(exec, GeneralError, exceptionDescription.toString(exec)); - } - } - } - return result; -} - -JSValue JavaField::valueFromInstance(ExecState* exec, const Instance* i) const -{ - const JavaInstance *instance = static_cast<const JavaInstance *>(i); - - JSValue jsresult = jsUndefined(); - - switch (_JNIType) { - case array_type: - case object_type: { - jvalue result = dispatchValueFromInstance (exec, instance, "get", "(Ljava/lang/Object;)Ljava/lang/Object;", object_type); - jobject anObject = result.l; - - const char *arrayType = type(); - if (arrayType[0] == '[') { - jsresult = JavaArray::convertJObjectToArray(exec, anObject, arrayType, instance->rootObject()); - } - else if (anObject != 0){ - jsresult = JavaInstance::create(anObject, instance->rootObject())->createRuntimeObject(exec); - } - } - break; - - case boolean_type: - jsresult = jsBoolean(dispatchValueFromInstance(exec, instance, "getBoolean", "(Ljava/lang/Object;)Z", boolean_type).z); - break; - - case byte_type: - case char_type: - case short_type: - - case int_type: { - jint value; - jvalue result = dispatchValueFromInstance (exec, instance, "getInt", "(Ljava/lang/Object;)I", int_type); - value = result.i; - jsresult = jsNumber(exec, (int)value); - } - break; - - case long_type: - case float_type: - case double_type: { - jdouble value; - jvalue result = dispatchValueFromInstance (exec, instance, "getDouble", "(Ljava/lang/Object;)D", double_type); - value = result.i; - jsresult = jsNumber(exec, (double)value); - } - break; - default: - break; - } - - JS_LOG ("getting %s = %s\n", UString(name()).UTF8String().c_str(), jsresult.toString(exec).ascii()); - - return jsresult; -} - -void JavaField::dispatchSetValueToInstance(ExecState *exec, const JavaInstance *instance, jvalue javaValue, const char *name, const char *sig) const -{ - jobject jinstance = instance->javaInstance(); - jobject fieldJInstance = _field->_instance; - JNIEnv *env = getJNIEnv(); - - jclass cls = env->GetObjectClass(fieldJInstance); - if ( cls != NULL ) { - jmethodID mid = env->GetMethodID(cls, name, sig); - if ( mid != NULL ) - { - RootObject* rootObject = instance->rootObject(); - if (rootObject && rootObject->nativeHandle()) { - JSValue exceptionDescription; - jvalue args[2]; - jvalue result; - - args[0].l = jinstance; - args[1] = javaValue; - dispatchJNICall(exec, rootObject->nativeHandle(), fieldJInstance, false, void_type, mid, args, result, 0, exceptionDescription); - if (exceptionDescription) - throwError(exec, GeneralError, exceptionDescription.toString(exec)); - } - } - } -} - -void JavaField::setValueToInstance(ExecState* exec, const Instance* i, JSValue aValue) const -{ - const JavaInstance *instance = static_cast<const JavaInstance *>(i); - jvalue javaValue = convertValueToJValue (exec, aValue, _JNIType, type()); - - JS_LOG ("setting value %s to %s\n", UString(name()).UTF8String().c_str(), aValue.toString(exec).ascii()); - - switch (_JNIType) { - case array_type: - case object_type: { - dispatchSetValueToInstance (exec, instance, javaValue, "set", "(Ljava/lang/Object;Ljava/lang/Object;)V"); - } - break; - - case boolean_type: { - dispatchSetValueToInstance (exec, instance, javaValue, "setBoolean", "(Ljava/lang/Object;Z)V"); - } - break; - - case byte_type: { - dispatchSetValueToInstance (exec, instance, javaValue, "setByte", "(Ljava/lang/Object;B)V"); - } - break; - - case char_type: { - dispatchSetValueToInstance (exec, instance, javaValue, "setChar", "(Ljava/lang/Object;C)V"); - } - break; - - case short_type: { - dispatchSetValueToInstance (exec, instance, javaValue, "setShort", "(Ljava/lang/Object;S)V"); - } - break; - - case int_type: { - dispatchSetValueToInstance (exec, instance, javaValue, "setInt", "(Ljava/lang/Object;I)V"); - } - break; - - case long_type: { - dispatchSetValueToInstance (exec, instance, javaValue, "setLong", "(Ljava/lang/Object;J)V"); - } - break; - - case float_type: { - dispatchSetValueToInstance (exec, instance, javaValue, "setFloat", "(Ljava/lang/Object;F)V"); - } - break; - - case double_type: { - dispatchSetValueToInstance (exec, instance, javaValue, "setDouble", "(Ljava/lang/Object;D)V"); - } - break; - default: - break; - } -} - -JavaMethod::JavaMethod (JNIEnv *env, jobject aMethod) -{ - // Get return type - jobject returnType = callJNIMethod<jobject>(aMethod, "getReturnType", "()Ljava/lang/Class;"); - jstring returnTypeName = (jstring)callJNIMethod<jobject>(returnType, "getName", "()Ljava/lang/String;"); - _returnType =JavaString (env, returnTypeName); - _JNIReturnType = JNITypeFromClassName (_returnType.UTF8String()); - env->DeleteLocalRef (returnType); - env->DeleteLocalRef (returnTypeName); - - // Get method name - jstring methodName = (jstring)callJNIMethod<jobject>(aMethod, "getName", "()Ljava/lang/String;"); - _name = JavaString (env, methodName); - env->DeleteLocalRef (methodName); - - // Get parameters - jarray jparameters = (jarray)callJNIMethod<jobject>(aMethod, "getParameterTypes", "()[Ljava/lang/Class;"); - _numParameters = env->GetArrayLength (jparameters); - _parameters = new JavaParameter[_numParameters]; - - int i; - for (i = 0; i < _numParameters; i++) { - jobject aParameter = env->GetObjectArrayElement ((jobjectArray)jparameters, i); - jstring parameterName = (jstring)callJNIMethod<jobject>(aParameter, "getName", "()Ljava/lang/String;"); - _parameters[i] = JavaParameter(env, parameterName); - env->DeleteLocalRef (aParameter); - env->DeleteLocalRef (parameterName); - } - env->DeleteLocalRef (jparameters); - - // Created lazily. - _signature = 0; - _methodID = 0; - - jclass modifierClass = env->FindClass("java/lang/reflect/Modifier"); - int modifiers = callJNIMethod<jint>(aMethod, "getModifiers", "()I"); - _isStatic = (bool)callJNIStaticMethod<jboolean>(modifierClass, "isStatic", "(I)Z", modifiers); - env->DeleteLocalRef(modifierClass); -} - -JavaMethod::~JavaMethod() -{ - if (_signature) - free(_signature); - delete [] _parameters; -}; - -// JNI method signatures use '/' between components of a class name, but -// we get '.' between components from the reflection API. -static void appendClassName(UString& aString, const char* className) -{ - ASSERT(JSLock::lockCount() > 0); - - char *result, *cp = strdup(className); - - result = cp; - while (*cp) { - if (*cp == '.') - *cp = '/'; - cp++; - } - - aString.append(result); - - free (result); -} - -const char *JavaMethod::signature() const -{ - if (!_signature) { - JSLock lock(SilenceAssertionsOnly); - - UString signatureBuilder("("); - for (int i = 0; i < _numParameters; i++) { - JavaParameter* aParameter = parameterAt(i); - JNIType _JNIType = aParameter->getJNIType(); - if (_JNIType == array_type) - appendClassName(signatureBuilder, aParameter->type()); - else { - signatureBuilder.append(signatureFromPrimitiveType(_JNIType)); - if (_JNIType == object_type) { - appendClassName(signatureBuilder, aParameter->type()); - signatureBuilder.append(";"); - } - } - } - signatureBuilder.append(")"); - - const char *returnType = _returnType.UTF8String(); - if (_JNIReturnType == array_type) { - appendClassName(signatureBuilder, returnType); - } else { - signatureBuilder.append(signatureFromPrimitiveType(_JNIReturnType)); - if (_JNIReturnType == object_type) { - appendClassName(signatureBuilder, returnType); - signatureBuilder.append(";"); - } - } - - _signature = strdup(signatureBuilder.ascii()); - } - - return _signature; -} - -JNIType JavaMethod::JNIReturnType() const -{ - return _JNIReturnType; -} - -jmethodID JavaMethod::methodID (jobject obj) const -{ - if (_methodID == 0) { - _methodID = getMethodID (obj, _name.UTF8String(), signature()); - } - return _methodID; -} - - -JavaArray::JavaArray(jobject array, const char* type, PassRefPtr<RootObject> rootObject) - : Array(rootObject) -{ - _array = new JObjectWrapper(array); - // Java array are fixed length, so we can cache length. - JNIEnv *env = getJNIEnv(); - _length = env->GetArrayLength((jarray)_array->_instance); - _type = strdup(type); - _rootObject = rootObject; -} - -JavaArray::~JavaArray () -{ - free ((void *)_type); -} - -RootObject* JavaArray::rootObject() const -{ - return _rootObject && _rootObject->isValid() ? _rootObject.get() : 0; -} - -void JavaArray::setValueAt(ExecState* exec, unsigned index, JSValue aValue) const -{ - JNIEnv *env = getJNIEnv(); - char *javaClassName = 0; - - JNIType arrayType = JNITypeFromPrimitiveType(_type[1]); - if (_type[1] == 'L'){ - // The type of the array will be something like: - // "[Ljava.lang.string;". This is guaranteed, so no need - // for extra sanity checks. - javaClassName = strdup(&_type[2]); - javaClassName[strchr(javaClassName, ';')-javaClassName] = 0; - } - jvalue aJValue = convertValueToJValue (exec, aValue, arrayType, javaClassName); - - switch (arrayType) { - case object_type: { - env->SetObjectArrayElement((jobjectArray)javaArray(), index, aJValue.l); - break; - } - - case boolean_type: { - env->SetBooleanArrayRegion((jbooleanArray)javaArray(), index, 1, &aJValue.z); - break; - } - - case byte_type: { - env->SetByteArrayRegion((jbyteArray)javaArray(), index, 1, &aJValue.b); - break; - } - - case char_type: { - env->SetCharArrayRegion((jcharArray)javaArray(), index, 1, &aJValue.c); - break; - } - - case short_type: { - env->SetShortArrayRegion((jshortArray)javaArray(), index, 1, &aJValue.s); - break; - } - - case int_type: { - env->SetIntArrayRegion((jintArray)javaArray(), index, 1, &aJValue.i); - break; - } - - case long_type: { - env->SetLongArrayRegion((jlongArray)javaArray(), index, 1, &aJValue.j); - } - - case float_type: { - env->SetFloatArrayRegion((jfloatArray)javaArray(), index, 1, &aJValue.f); - break; - } - - case double_type: { - env->SetDoubleArrayRegion((jdoubleArray)javaArray(), index, 1, &aJValue.d); - break; - } - default: - break; - } - - if (javaClassName) - free ((void *)javaClassName); -} - - -JSValue JavaArray::valueAt(ExecState* exec, unsigned index) const -{ - JNIEnv *env = getJNIEnv(); - JNIType arrayType = JNITypeFromPrimitiveType(_type[1]); - switch (arrayType) { - case object_type: { - jobjectArray objectArray = (jobjectArray)javaArray(); - jobject anObject; - anObject = env->GetObjectArrayElement(objectArray, index); - - // No object? - if (!anObject) { - return jsNull(); - } - - // Nested array? - if (_type[1] == '[') { - return JavaArray::convertJObjectToArray(exec, anObject, _type+1, rootObject()); - } - // or array of other object type? - return JavaInstance::create(anObject, rootObject())->createRuntimeObject(exec); - } - - case boolean_type: { - jbooleanArray booleanArray = (jbooleanArray)javaArray(); - jboolean aBoolean; - env->GetBooleanArrayRegion(booleanArray, index, 1, &aBoolean); - return jsBoolean(aBoolean); - } - - case byte_type: { - jbyteArray byteArray = (jbyteArray)javaArray(); - jbyte aByte; - env->GetByteArrayRegion(byteArray, index, 1, &aByte); - return jsNumber(exec, aByte); - } - - case char_type: { - jcharArray charArray = (jcharArray)javaArray(); - jchar aChar; - env->GetCharArrayRegion(charArray, index, 1, &aChar); - return jsNumber(exec, aChar); - break; - } - - case short_type: { - jshortArray shortArray = (jshortArray)javaArray(); - jshort aShort; - env->GetShortArrayRegion(shortArray, index, 1, &aShort); - return jsNumber(exec, aShort); - } - - case int_type: { - jintArray intArray = (jintArray)javaArray(); - jint anInt; - env->GetIntArrayRegion(intArray, index, 1, &anInt); - return jsNumber(exec, anInt); - } - - case long_type: { - jlongArray longArray = (jlongArray)javaArray(); - jlong aLong; - env->GetLongArrayRegion(longArray, index, 1, &aLong); - return jsNumber(exec, aLong); - } - - case float_type: { - jfloatArray floatArray = (jfloatArray)javaArray(); - jfloat aFloat; - env->GetFloatArrayRegion(floatArray, index, 1, &aFloat); - return jsNumber(exec, aFloat); - } - - case double_type: { - jdoubleArray doubleArray = (jdoubleArray)javaArray(); - jdouble aDouble; - env->GetDoubleArrayRegion(doubleArray, index, 1, &aDouble); - return jsNumber(exec, aDouble); - } - default: - break; - } - return jsUndefined(); -} - -unsigned int JavaArray::getLength() const -{ - return _length; -} - -#endif // ENABLE(MAC_JAVA_BRIDGE) diff --git a/WebCore/bridge/jni/jni_runtime.h b/WebCore/bridge/jni/jni_runtime.h deleted file mode 100644 index 81484ff..0000000 --- a/WebCore/bridge/jni/jni_runtime.h +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 _JNI_RUNTIME_H_ -#define _JNI_RUNTIME_H_ - -#if ENABLE(MAC_JAVA_BRIDGE) - -#include <jni_utility.h> -#include <jni_instance.h> -#include <runtime/JSLock.h> - - -namespace JSC -{ - -namespace Bindings -{ - -typedef const char* RuntimeType; - -class JavaString -{ -public: - JavaString() - { - JSLock lock(SilenceAssertionsOnly); - _rep = UString().rep(); - } - - void _commonInit (JNIEnv *e, jstring s) - { - int _size = e->GetStringLength (s); - const jchar *uc = getUCharactersFromJStringInEnv (e, s); - { - JSLock lock(SilenceAssertionsOnly); - _rep = UString(reinterpret_cast<const UChar*>(uc), _size).rep(); - } - releaseUCharactersForJStringInEnv (e, s, uc); - } - - JavaString (JNIEnv *e, jstring s) { - _commonInit (e, s); - } - - JavaString (jstring s) { - _commonInit (getJNIEnv(), s); - } - - ~JavaString() - { - JSLock lock(SilenceAssertionsOnly); - _rep = 0; - } - - const char *UTF8String() const { - if (_utf8String.c_str() == 0) { - JSLock lock(SilenceAssertionsOnly); - _utf8String = UString(_rep).UTF8String(); - } - return _utf8String.c_str(); - } - const jchar *uchars() const { return (const jchar *)_rep->data(); } - int length() const { return _rep->size(); } - operator UString() const { return UString(_rep); } - -private: - RefPtr<UString::Rep> _rep; - mutable CString _utf8String; -}; - -class JavaParameter -{ -public: - JavaParameter () : _JNIType(invalid_type) {}; - JavaParameter (JNIEnv *env, jstring type); - virtual ~JavaParameter() { } - - RuntimeType type() const { return _type.UTF8String(); } - JNIType getJNIType() const { return _JNIType; } - -private: - JavaString _type; - JNIType _JNIType; -}; - - -class JavaField : public Field -{ -public: - JavaField (JNIEnv *env, jobject aField); - - virtual JSValue valueFromInstance(ExecState *exec, const Instance *instance) const; - virtual void setValueToInstance(ExecState *exec, const Instance *instance, JSValue aValue) const; - - UString::Rep* name() const { return ((UString)_name).rep(); } - virtual RuntimeType type() const { return _type.UTF8String(); } - - JNIType getJNIType() const { return _JNIType; } - -private: - void dispatchSetValueToInstance(ExecState *exec, const JavaInstance *instance, jvalue javaValue, const char *name, const char *sig) const; - jvalue dispatchValueFromInstance(ExecState *exec, const JavaInstance *instance, const char *name, const char *sig, JNIType returnType) const; - - JavaString _name; - JavaString _type; - JNIType _JNIType; - RefPtr<JObjectWrapper> _field; -}; - - -class JavaMethod : public Method -{ -public: - JavaMethod(JNIEnv* env, jobject aMethod); - ~JavaMethod(); - - UString::Rep* name() const { return ((UString)_name).rep(); } - RuntimeType returnType() const { return _returnType.UTF8String(); }; - JavaParameter* parameterAt(int i) const { return &_parameters[i]; }; - int numParameters() const { return _numParameters; }; - - const char *signature() const; - JNIType JNIReturnType() const; - - jmethodID methodID (jobject obj) const; - - bool isStatic() const { return _isStatic; } - -private: - JavaParameter* _parameters; - int _numParameters; - JavaString _name; - mutable char* _signature; - JavaString _returnType; - JNIType _JNIReturnType; - mutable jmethodID _methodID; - bool _isStatic; -}; - -class JavaArray : public Array -{ -public: - JavaArray(jobject array, const char* type, PassRefPtr<RootObject>); - virtual ~JavaArray(); - - RootObject* rootObject() const; - - virtual void setValueAt(ExecState *exec, unsigned int index, JSValue aValue) const; - virtual JSValue valueAt(ExecState *exec, unsigned int index) const; - virtual unsigned int getLength() const; - - jobject javaArray() const { return _array->_instance; } - - static JSValue convertJObjectToArray (ExecState* exec, jobject anObject, const char* type, PassRefPtr<RootObject>); - -private: - RefPtr<JObjectWrapper> _array; - unsigned int _length; - const char *_type; -}; - -} // namespace Bindings - -} // namespace JSC - -#endif // ENABLE(MAC_JAVA_BRIDGE) - -#endif // _JNI_RUNTIME_H_ diff --git a/WebCore/bridge/jni/jsc/jni_utility_private.cpp b/WebCore/bridge/jni/jsc/JNIUtilityPrivate.cpp index 7f8afd5..e89d0e0 100644 --- a/WebCore/bridge/jni/jsc/jni_utility_private.cpp +++ b/WebCore/bridge/jni/jsc/JNIUtilityPrivate.cpp @@ -25,11 +25,11 @@ */ #include "config.h" -#include "jni_utility_private.h" +#include "JNIUtilityPrivate.h" #if ENABLE(MAC_JAVA_BRIDGE) -#include "jni_runtime.h" +#include "JNIBridge.h" #include "runtime_array.h" #include "runtime_object.h" #include <runtime/JSArray.h> @@ -189,7 +189,7 @@ jvalue convertValueToJValue(ExecState* exec, JSValue value, JNIType jniType, con if (instance) result.l = instance->javaInstance(); } else if (objectImp->classInfo() == &RuntimeArray::s_info) { - // Input is a JavaScript Array that was originally created from a Java Array + // Input is a JavaScript Array that was originally created from a Java Array RuntimeArray* imp = static_cast<RuntimeArray*>(objectImp); JavaArray* array = static_cast<JavaArray*>(imp->getConcreteArray()); result.l = array->javaArray(); @@ -284,7 +284,7 @@ jvalue convertValueToJValue(ExecState* exec, JSValue value, JNIType jniType, con return result; } -} // end of namespace Bindings +} // end of namespace Bindings } // end of namespace JSC diff --git a/WebCore/bridge/jni/jsc/jni_utility_private.h b/WebCore/bridge/jni/jsc/JNIUtilityPrivate.h index 647852e..0297f97 100644 --- a/WebCore/bridge/jni/jsc/jni_utility_private.h +++ b/WebCore/bridge/jni/jsc/JNIUtilityPrivate.h @@ -24,12 +24,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _JNI_UTILITY_PRIVATE_H_ -#define _JNI_UTILITY_PRIVATE_H_ +#ifndef JNIUtilityPrivate_h +#define JNIUtilityPrivate_h #if ENABLE(MAC_JAVA_BRIDGE) -#include "jni_utility.h" +#include "JNIUtility.h" #include <runtime/JSValue.h> namespace JSC { @@ -48,4 +48,4 @@ bool dispatchJNICall(ExecState*, const void* targetAppletView, jobject obj, bool #endif // ENABLE(MAC_JAVA_BRIDGE) -#endif // _JNI_UTILITY_H_ +#endif // JNIUtilityPrivate_h diff --git a/WebCore/bridge/jni/jni_class.cpp b/WebCore/bridge/jni/jsc/JavaClassJSC.cpp index 6728e7b..350c8ae 100644 --- a/WebCore/bridge/jni/jni_class.cpp +++ b/WebCore/bridge/jni/jsc/JavaClassJSC.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -20,48 +20,47 @@ * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" -#include "jni_class.h" +#include "JavaClassJSC.h" #if ENABLE(MAC_JAVA_BRIDGE) +#include "JNIUtility.h" #include "JSDOMWindow.h" #include <runtime/Identifier.h> #include <runtime/JSLock.h> -#include "jni_utility.h" -#include "jni_runtime.h" using namespace JSC::Bindings; JavaClass::JavaClass(jobject anInstance) { jobject aClass = callJNIMethod<jobject>(anInstance, "getClass", "()Ljava/lang/Class;"); - + if (!aClass) { fprintf(stderr, "%s: unable to call getClass on instance %p\n", __PRETTY_FUNCTION__, anInstance); return; } - + jstring className = (jstring)callJNIMethod<jobject>(aClass, "getName", "()Ljava/lang/String;"); - const char *classNameC = getCharactersFromJString(className); - _name = strdup(classNameC); + const char* classNameC = getCharactersFromJString(className); + m_name = strdup(classNameC); releaseCharactersForJString(className, classNameC); int i; - JNIEnv *env = getJNIEnv(); + JNIEnv* env = getJNIEnv(); // Get the fields jarray fields = (jarray)callJNIMethod<jobject>(aClass, "getFields", "()[Ljava/lang/reflect/Field;"); - int numFields = env->GetArrayLength(fields); + int numFields = env->GetArrayLength(fields); for (i = 0; i < numFields; i++) { jobject aJField = env->GetObjectArrayElement((jobjectArray)fields, i); - JavaField *aField = new JavaField(env, aJField); // deleted in the JavaClass destructor + JavaField* aField = new JavaField(env, aJField); // deleted in the JavaClass destructor { JSLock lock(SilenceAssertionsOnly); - _fields.set(aField->name(), aField); + m_fields.set(((UString)aField->name()).rep(), aField); } env->DeleteLocalRef(aJField); } @@ -71,75 +70,76 @@ JavaClass::JavaClass(jobject anInstance) int numMethods = env->GetArrayLength(methods); for (i = 0; i < numMethods; i++) { jobject aJMethod = env->GetObjectArrayElement((jobjectArray)methods, i); - JavaMethod *aMethod = new JavaMethod(env, aJMethod); // deleted in the JavaClass destructor + JavaMethod* aMethod = new JavaMethod(env, aJMethod); // deleted in the JavaClass destructor MethodList* methodList; { JSLock lock(SilenceAssertionsOnly); - methodList = _methods.get(aMethod->name()); + methodList = m_methods.get(((UString)aMethod->name()).rep()); if (!methodList) { methodList = new MethodList(); - _methods.set(aMethod->name(), methodList); + m_methods.set(((UString)aMethod->name()).rep(), methodList); } } methodList->append(aMethod); env->DeleteLocalRef(aJMethod); - } + } env->DeleteLocalRef(fields); env->DeleteLocalRef(methods); env->DeleteLocalRef(aClass); } -JavaClass::~JavaClass() { - free((void *)_name); +JavaClass::~JavaClass() +{ + free(const_cast<char*>(m_name)); JSLock lock(SilenceAssertionsOnly); - deleteAllValues(_fields); - _fields.clear(); + deleteAllValues(m_fields); + m_fields.clear(); - MethodListMap::const_iterator end = _methods.end(); - for (MethodListMap::const_iterator it = _methods.begin(); it != end; ++it) { + MethodListMap::const_iterator end = m_methods.end(); + for (MethodListMap::const_iterator it = m_methods.begin(); it != end; ++it) { const MethodList* methodList = it->second; deleteAllValues(*methodList); delete methodList; } - _methods.clear(); + m_methods.clear(); } MethodList JavaClass::methodsNamed(const Identifier& identifier, Instance*) const { - MethodList *methodList = _methods.get(identifier.ustring().rep()); - + MethodList* methodList = m_methods.get(identifier.ustring().rep()); + if (methodList) return *methodList; return MethodList(); } -Field *JavaClass::fieldNamed(const Identifier& identifier, Instance*) const +Field* JavaClass::fieldNamed(const Identifier& identifier, Instance*) const { - return _fields.get(identifier.ustring().rep()); + return m_fields.get(identifier.ustring().rep()); } bool JavaClass::isNumberClass() const { - return ((strcmp(_name, "java.lang.Byte") == 0 || - strcmp(_name, "java.lang.Short") == 0 || - strcmp(_name, "java.lang.Integer") == 0 || - strcmp(_name, "java.lang.Long") == 0 || - strcmp(_name, "java.lang.Float") == 0 || - strcmp(_name, "java.lang.Double") == 0) ); + return (!strcmp(m_name, "java.lang.Byte") + || !strcmp(m_name, "java.lang.Short") + || !strcmp(m_name, "java.lang.Integer") + || !strcmp(m_name, "java.lang.Long") + || !strcmp(m_name, "java.lang.Float") + || !strcmp(m_name, "java.lang.Double")); } bool JavaClass::isBooleanClass() const { - return strcmp(_name, "java.lang.Boolean") == 0; + return !strcmp(m_name, "java.lang.Boolean"); } bool JavaClass::isStringClass() const { - return strcmp(_name, "java.lang.String") == 0; + return !strcmp(m_name, "java.lang.String"); } #endif // ENABLE(MAC_JAVA_BRIDGE) diff --git a/WebCore/bridge/jni/jni_class.h b/WebCore/bridge/jni/jsc/JavaClassJSC.h index 890b4d3..b20781b 100644 --- a/WebCore/bridge/jni/jni_class.h +++ b/WebCore/bridge/jni/jsc/JavaClassJSC.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2003, 2004, 2005, 2007, 2009, 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -20,15 +20,15 @@ * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JNI_CLASS_H_ -#define JNI_CLASS_H_ +#ifndef JavaClassJSC_h +#define JavaClassJSC_h #if ENABLE(MAC_JAVA_BRIDGE) -#include <jni_runtime.h> +#include "JNIBridge.h" #include <wtf/HashMap.h> namespace JSC { @@ -37,20 +37,20 @@ namespace Bindings { class JavaClass : public Class { public: - JavaClass (jobject anInstance); - ~JavaClass (); + JavaClass(jobject); + ~JavaClass(); + + virtual MethodList methodsNamed(const Identifier&, Instance*) const; + virtual Field* fieldNamed(const Identifier&, Instance*) const; - virtual MethodList methodsNamed(const Identifier&, Instance* instance) const; - virtual Field *fieldNamed(const Identifier&, Instance* instance) const; - bool isNumberClass() const; bool isBooleanClass() const; bool isStringClass() const; - + private: - const char *_name; - FieldMap _fields; - MethodListMap _methods; + const char* m_name; + FieldMap m_fields; + MethodListMap m_methods; }; } // namespace Bindings @@ -59,4 +59,4 @@ private: #endif // ENABLE(MAC_JAVA_BRIDGE) -#endif // JNI_CLASS_H_ +#endif // JavaClassJSC_h diff --git a/WebCore/bridge/jni/jni_instance.cpp b/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp index 3783d10..d9e0f60 100644 --- a/WebCore/bridge/jni/jni_instance.cpp +++ b/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2003, 2008, 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -20,18 +20,18 @@ * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" -#include "jni_instance.h" +#include "JavaInstanceJSC.h" #if ENABLE(MAC_JAVA_BRIDGE) -#include "jni_class.h" -#include "jni_runtime.h" -#include "jni_utility.h" -#include "jni_utility_private.h" +#include "JNIBridge.h" +#include "JNIUtility.h" +#include "JNIUtilityPrivate.h" +#include "JavaClassJSC.h" #include "runtime_object.h" #include "runtime_root.h" #include <runtime/ArgList.h> @@ -46,83 +46,83 @@ #define JS_LOG(formatAndArgs...) ((void)0) #else #define JS_LOG(formatAndArgs...) { \ - fprintf (stderr, "%s:%d -- %s: ", __FILE__, __LINE__, __FUNCTION__); \ + fprintf(stderr, "%s:%d -- %s: ", __FILE__, __LINE__, __FUNCTION__); \ fprintf(stderr, formatAndArgs); \ } #endif - + using namespace JSC::Bindings; using namespace JSC; -JavaInstance::JavaInstance (jobject instance, PassRefPtr<RootObject> rootObject) +JavaInstance::JavaInstance(jobject instance, PassRefPtr<RootObject> rootObject) : Instance(rootObject) { - _instance = new JObjectWrapper (instance); - _class = 0; + m_instance = new JObjectWrapper(instance); + m_class = 0; } -JavaInstance::~JavaInstance () +JavaInstance::~JavaInstance() { - delete _class; + delete m_class; } #define NUM_LOCAL_REFS 64 void JavaInstance::virtualBegin() { - getJNIEnv()->PushLocalFrame (NUM_LOCAL_REFS); + getJNIEnv()->PushLocalFrame(NUM_LOCAL_REFS); } void JavaInstance::virtualEnd() { - getJNIEnv()->PopLocalFrame (NULL); + getJNIEnv()->PopLocalFrame(0); } -Class *JavaInstance::getClass() const +Class* JavaInstance::getClass() const { - if (_class == 0) - _class = new JavaClass (_instance->_instance); - return _class; + if (!m_class) + m_class = new JavaClass (m_instance->m_instance); + return m_class; } JSValue JavaInstance::stringValue(ExecState* exec) const { JSLock lock(SilenceAssertionsOnly); - - jstring stringValue = (jstring)callJNIMethod<jobject>(_instance->_instance, "toString", "()Ljava/lang/String;"); - JNIEnv *env = getJNIEnv(); - const jchar *c = getUCharactersFromJStringInEnv(env, stringValue); - UString u((const UChar *)c, (int)env->GetStringLength(stringValue)); + + jstring stringValue = (jstring)callJNIMethod<jobject>(m_instance->m_instance, "toString", "()Ljava/lang/String;"); + JNIEnv* env = getJNIEnv(); + const jchar* c = getUCharactersFromJStringInEnv(env, stringValue); + UString u((const UChar*)c, (int)env->GetStringLength(stringValue)); releaseUCharactersForJStringInEnv(env, stringValue, c); return jsString(exec, u); } JSValue JavaInstance::numberValue(ExecState* exec) const { - jdouble doubleValue = callJNIMethod<jdouble>(_instance->_instance, "doubleValue", "()D"); + jdouble doubleValue = callJNIMethod<jdouble>(m_instance->m_instance, "doubleValue", "()D"); return jsNumber(exec, doubleValue); } JSValue JavaInstance::booleanValue() const { - jboolean booleanValue = callJNIMethod<jboolean>(_instance->_instance, "booleanValue", "()Z"); + jboolean booleanValue = callJNIMethod<jboolean>(m_instance->m_instance, "booleanValue", "()Z"); return jsBoolean(booleanValue); } -JSValue JavaInstance::invokeMethod (ExecState *exec, const MethodList &methodList, const ArgList &args) +JSValue JavaInstance::invokeMethod(ExecState* exec, const MethodList& methodList, const ArgList &args) { int i, count = args.size(); - jvalue *jArgs; + jvalue* jArgs; JSValue resultValue; - Method *method = 0; + Method* method = 0; size_t numMethods = methodList.size(); - - // Try to find a good match for the overloaded method. The + + // Try to find a good match for the overloaded method. The // fundamental problem is that JavaScript doesn have the - // notion of method overloading and Java does. We could + // notion of method overloading and Java does. We could // get a bit more sophisticated and attempt to does some // type checking as we as checking the number of parameters. - Method *aMethod; + Method* aMethod; for (size_t methodIndex = 0; methodIndex < numMethods; methodIndex++) { aMethod = methodList[methodIndex]; if (aMethod->numParameters() == count) { @@ -130,26 +130,25 @@ JSValue JavaInstance::invokeMethod (ExecState *exec, const MethodList &methodLis break; } } - if (method == 0) { - JS_LOG ("unable to find an appropiate method\n"); + if (!method) { + JS_LOG("unable to find an appropiate method\n"); return jsUndefined(); } - - const JavaMethod *jMethod = static_cast<const JavaMethod*>(method); - JS_LOG ("call %s %s on %p\n", UString(jMethod->name()).UTF8String().c_str(), jMethod->signature(), _instance->_instance); - - if (count > 0) { - jArgs = (jvalue *)malloc (count * sizeof(jvalue)); - } + + const JavaMethod* jMethod = static_cast<const JavaMethod*>(method); + JS_LOG("call %s %s on %p\n", UString(jMethod->name()).UTF8String().c_str(), jMethod->signature(), m_instance->m_instance); + + if (count > 0) + jArgs = (jvalue*)malloc(count * sizeof(jvalue)); else jArgs = 0; - + for (i = 0; i < count; i++) { JavaParameter* aParameter = jMethod->parameterAt(i); jArgs[i] = convertValueToJValue(exec, args.at(i), aParameter->getJNIType(), aParameter->type()); JS_LOG("arg[%d] = %s\n", i, args.at(i).toString(exec).ascii()); } - + jvalue result; // Try to use the JNI abstraction first, otherwise fall back to @@ -161,129 +160,136 @@ JSValue JavaInstance::invokeMethod (ExecState *exec, const MethodList &methodLis bool handled = false; if (rootObject->nativeHandle()) { - jobject obj = _instance->_instance; + jobject obj = m_instance->m_instance; JSValue exceptionDescription; - const char *callingURL = 0; // FIXME, need to propagate calling URL to Java + const char *callingURL = 0; // FIXME, need to propagate calling URL to Java handled = dispatchJNICall(exec, rootObject->nativeHandle(), obj, jMethod->isStatic(), jMethod->JNIReturnType(), jMethod->methodID(obj), jArgs, result, callingURL, exceptionDescription); if (exceptionDescription) { throwError(exec, GeneralError, exceptionDescription.toString(exec)); - free (jArgs); + free(jArgs); return jsUndefined(); } } - + // The following code can be conditionally removed once we have a Tiger update that // contains the new Java plugin. It is needed for builds prior to Tiger. - if (!handled) { - jobject obj = _instance->_instance; - switch (jMethod->JNIReturnType()){ - case void_type: - callJNIMethodIDA<void>(obj, jMethod->methodID(obj), jArgs); - break; - case object_type: - result.l = callJNIMethodIDA<jobject>(obj, jMethod->methodID(obj), jArgs); - break; - case boolean_type: - result.z = callJNIMethodIDA<jboolean>(obj, jMethod->methodID(obj), jArgs); - break; - case byte_type: - result.b = callJNIMethodIDA<jbyte>(obj, jMethod->methodID(obj), jArgs); - break; - case char_type: - result.c = callJNIMethodIDA<jchar>(obj, jMethod->methodID(obj), jArgs); - break; - case short_type: - result.s = callJNIMethodIDA<jshort>(obj, jMethod->methodID(obj), jArgs); - break; - case int_type: - result.i = callJNIMethodIDA<jint>(obj, jMethod->methodID(obj), jArgs); - break; - - case long_type: - result.j = callJNIMethodIDA<jlong>(obj, jMethod->methodID(obj), jArgs); - break; - case float_type: - result.f = callJNIMethodIDA<jfloat>(obj, jMethod->methodID(obj), jArgs); - break; - case double_type: - result.d = callJNIMethodIDA<jdouble>(obj, jMethod->methodID(obj), jArgs); - break; - case invalid_type: - default: - break; + if (!handled) { + jobject obj = m_instance->m_instance; + switch (jMethod->JNIReturnType()) { + case void_type: + callJNIMethodIDA<void>(obj, jMethod->methodID(obj), jArgs); + break; + case object_type: + result.l = callJNIMethodIDA<jobject>(obj, jMethod->methodID(obj), jArgs); + break; + case boolean_type: + result.z = callJNIMethodIDA<jboolean>(obj, jMethod->methodID(obj), jArgs); + break; + case byte_type: + result.b = callJNIMethodIDA<jbyte>(obj, jMethod->methodID(obj), jArgs); + break; + case char_type: + result.c = callJNIMethodIDA<jchar>(obj, jMethod->methodID(obj), jArgs); + break; + case short_type: + result.s = callJNIMethodIDA<jshort>(obj, jMethod->methodID(obj), jArgs); + break; + case int_type: + result.i = callJNIMethodIDA<jint>(obj, jMethod->methodID(obj), jArgs); + break; + + case long_type: + result.j = callJNIMethodIDA<jlong>(obj, jMethod->methodID(obj), jArgs); + break; + case float_type: + result.f = callJNIMethodIDA<jfloat>(obj, jMethod->methodID(obj), jArgs); + break; + case double_type: + result.d = callJNIMethodIDA<jdouble>(obj, jMethod->methodID(obj), jArgs); + break; + case invalid_type: + default: + break; } } - - switch (jMethod->JNIReturnType()){ - case void_type: { + + switch (jMethod->JNIReturnType()) { + case void_type: + { resultValue = jsUndefined(); } break; - - case object_type: { - if (result.l != 0) { - const char *arrayType = jMethod->returnType(); - if (arrayType[0] == '[') { + + case object_type: + { + if (result.l) { + const char* arrayType = jMethod->returnType(); + if (arrayType[0] == '[') resultValue = JavaArray::convertJObjectToArray(exec, result.l, arrayType, rootObject); - } - else { + else resultValue = JavaInstance::create(result.l, rootObject)->createRuntimeObject(exec); - } - } - else { + } else resultValue = jsUndefined(); - } } break; - - case boolean_type: { + + case boolean_type: + { resultValue = jsBoolean(result.z); } break; - - case byte_type: { + + case byte_type: + { resultValue = jsNumber(exec, result.b); } break; - - case char_type: { + + case char_type: + { resultValue = jsNumber(exec, result.c); } break; - - case short_type: { + + case short_type: + { resultValue = jsNumber(exec, result.s); } break; - - case int_type: { + + case int_type: + { resultValue = jsNumber(exec, result.i); } break; - - case long_type: { + + case long_type: + { resultValue = jsNumber(exec, result.j); } break; - - case float_type: { + + case float_type: + { resultValue = jsNumber(exec, result.f); } break; - - case double_type: { + + case double_type: + { resultValue = jsNumber(exec, result.d); } break; - case invalid_type: - default: { + case invalid_type: + default: + { resultValue = jsUndefined(); } break; } - free (jArgs); + free(jArgs); return resultValue; } @@ -294,7 +300,7 @@ JSValue JavaInstance::defaultValue(ExecState* exec, PreferredPrimitiveType hint) return stringValue(exec); if (hint == PreferNumber) return numberValue(exec); - JavaClass *aClass = static_cast<JavaClass*>(getClass()); + JavaClass* aClass = static_cast<JavaClass*>(getClass()); if (aClass->isStringClass()) return stringValue(exec); if (aClass->isNumberClass()) @@ -304,32 +310,32 @@ JSValue JavaInstance::defaultValue(ExecState* exec, PreferredPrimitiveType hint) return valueOf(exec); } -JSValue JavaInstance::valueOf(ExecState* exec) const +JSValue JavaInstance::valueOf(ExecState* exec) const { return stringValue(exec); } JObjectWrapper::JObjectWrapper(jobject instance) -: _refCount(0) + : m_refCount(0) { - assert (instance != 0); + assert(instance); // Cache the JNIEnv used to get the global ref for this java instanace. // It'll be used to delete the reference. - _env = getJNIEnv(); - - _instance = _env->NewGlobalRef (instance); - - JS_LOG ("new global ref %p for %p\n", _instance, instance); - - if (_instance == NULL) { - fprintf (stderr, "%s: could not get GlobalRef for %p\n", __PRETTY_FUNCTION__, instance); - } + m_env = getJNIEnv(); + + m_instance = m_env->NewGlobalRef(instance); + + JS_LOG("new global ref %p for %p\n", m_instance, instance); + + if (!m_instance) + fprintf(stderr, "%s: could not get GlobalRef for %p\n", __PRETTY_FUNCTION__, instance); } -JObjectWrapper::~JObjectWrapper() { - JS_LOG ("deleting global ref %p\n", _instance); - _env->DeleteGlobalRef (_instance); +JObjectWrapper::~JObjectWrapper() +{ + JS_LOG("deleting global ref %p\n", m_instance); + m_env->DeleteGlobalRef(m_instance); } #endif // ENABLE(MAC_JAVA_BRIDGE) diff --git a/WebCore/bridge/jni/jni_instance.h b/WebCore/bridge/jni/jsc/JavaInstanceJSC.h index 049bfdb..d7b6102 100644 --- a/WebCore/bridge/jni/jni_instance.h +++ b/WebCore/bridge/jni/jsc/JavaInstanceJSC.h @@ -20,15 +20,15 @@ * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _JNI_INSTANCE_H_ -#define _JNI_INSTANCE_H_ +#ifndef JavaInstanceJSC_h +#define JavaInstanceJSC_h #if ENABLE(MAC_JAVA_BRIDGE) -#include "runtime.h" +#include "Bridge.h" #include "runtime_root.h" #include <JavaVM/jni.h> @@ -39,8 +39,7 @@ namespace Bindings { class JavaClass; -class JObjectWrapper -{ +class JObjectWrapper { friend class RefPtr<JObjectWrapper>; friend class JavaArray; friend class JavaField; @@ -48,46 +47,45 @@ friend class JavaInstance; friend class JavaMethod; public: - jobject instance() const { return _instance; } - void setInstance(jobject instance) { _instance = instance; } + jobject instance() const { return m_instance; } + void setInstance(jobject instance) { m_instance = instance; } protected: - JObjectWrapper(jobject instance); + JObjectWrapper(jobject instance); ~JObjectWrapper(); - - void ref() { _refCount++; } - void deref() - { - if (--_refCount == 0) - delete this; + + void ref() { m_refCount++; } + void deref() + { + if (!(--m_refCount)) + delete this; } - jobject _instance; + jobject m_instance; private: - JNIEnv *_env; - unsigned int _refCount; + JNIEnv* m_env; + unsigned int m_refCount; }; -class JavaInstance : public Instance -{ +class JavaInstance : public Instance { public: - static PassRefPtr<JavaInstance> create(jobject instance, PassRefPtr<RootObject> rootObject) + static PassRefPtr<JavaInstance> create(jobject instance, PassRefPtr<RootObject> rootObject) { return adoptRef(new JavaInstance(instance, rootObject)); } - + ~JavaInstance(); - - virtual Class *getClass() const; - + + virtual Class* getClass() const; + virtual JSValue valueOf(ExecState*) const; virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const; virtual JSValue invokeMethod(ExecState* exec, const MethodList& method, const ArgList& args); - jobject javaInstance() const { return _instance->_instance; } - + jobject javaInstance() const { return m_instance->m_instance; } + JSValue stringValue(ExecState*) const; JSValue numberValue(ExecState*) const; JSValue booleanValue() const; @@ -97,8 +95,8 @@ protected: virtual void virtualBegin(); virtual void virtualEnd(); - RefPtr<JObjectWrapper> _instance; - mutable JavaClass *_class; + RefPtr<JObjectWrapper> m_instance; + mutable JavaClass* m_class; }; } // namespace Bindings @@ -107,4 +105,4 @@ protected: #endif // ENABLE(MAC_JAVA_BRIDGE) -#endif // _JNI_INSTANCE_H_ +#endif // JavaInstanceJSC_h diff --git a/WebCore/bridge/jni/jsc/JavaStringJSC.h b/WebCore/bridge/jni/jsc/JavaStringJSC.h new file mode 100644 index 0000000..720f887 --- /dev/null +++ b/WebCore/bridge/jni/jsc/JavaStringJSC.h @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2010 Apple Computer, Inc. All rights reserved. + * + * 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 JavaStringJSC_h +#define JavaStringJSC_h + +#include "JNIUtility.h" +#include "JavaInstanceJSC.h" +#include <runtime/JSLock.h> + + +namespace JSC { + +namespace Bindings { + +class JavaStringImpl { +public: + ~JavaStringImpl() + { + JSLock lock(SilenceAssertionsOnly); + m_rep = 0; + } + + void init() + { + JSLock lock(SilenceAssertionsOnly); + m_rep = UString().rep(); + } + + void init(JNIEnv* e, jstring s) + { + int size = e->GetStringLength(s); + const jchar* uc = getUCharactersFromJStringInEnv(e, s); + { + JSLock lock(SilenceAssertionsOnly); + m_rep = UString(reinterpret_cast<const UChar*>(uc), size).rep(); + } + releaseUCharactersForJStringInEnv(e, s, uc); + } + + const char* UTF8String() const + { + if (!m_utf8String.c_str()) { + JSLock lock(SilenceAssertionsOnly); + m_utf8String = UString(m_rep).UTF8String(); + } + return m_utf8String.c_str(); + } + const jchar* uchars() const { return (const jchar*)m_rep->data(); } + int length() const { return m_rep->size(); } + UString uString() const { return UString(m_rep); } + +private: + RefPtr<UString::Rep> m_rep; + mutable CString m_utf8String; +}; + +} // namespace Bindings + +} // namespace JSC + +#endif // JavaStringJSC_h diff --git a/WebCore/bridge/jni/v8/jni_utility_private.cpp b/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp index 6c8f018..a817bc0 100644 --- a/WebCore/bridge/jni/v8/jni_utility_private.cpp +++ b/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp @@ -24,10 +24,10 @@ */ #include "config.h" -#include "jni_utility_private.h" +#include "JNIUtilityPrivate.h" +#include "JavaNPObjectV8.h" #include "jni_runtime.h" -#include "jni_npobject.h" namespace JSC { @@ -42,7 +42,7 @@ jvalue convertNPVariantToJValue(NPVariant value, JNIType jniType, const char* ja case array_type: case object_type: { - result.l = (jobject)0; + result.l = static_cast<jobject>(0); // First see if we have a Java instance. if (type == NPVariantType_Object) { @@ -53,25 +53,25 @@ jvalue convertNPVariantToJValue(NPVariant value, JNIType jniType, const char* ja // Now convert value to a string if the target type is a java.lang.string, and we're not // converting from a Null. - if (result.l == 0 && strcmp(javaClassName, "java.lang.String") == 0) { + if (!result.l && !strcmp(javaClassName, "java.lang.String")) { #ifdef CONVERT_NULL_TO_EMPTY_STRING if (type == NPVariantType_Null) { - JNIEnv *env = getJNIEnv(); + JNIEnv* env = getJNIEnv(); jchar buf[2]; - jobject javaString = env->functions->NewString (env, buf, 0); + jobject javaString = env->functions->NewString(env, buf, 0); result.l = javaString; - } - else + } else #else - if (type == NPVariantType_String) { + if (type == NPVariantType_String) #endif + { NPString src = NPVARIANT_TO_STRING(value); - JNIEnv *env = getJNIEnv(); + JNIEnv* env = getJNIEnv(); jobject javaString = env->NewStringUTF(src.UTF8Characters); result.l = javaString; } - } else if (result.l == 0) - bzero (&result, sizeof(jvalue)); // Handle it the same as a void case + } else if (!result.l) + bzero(&result, sizeof(jvalue)); // Handle it the same as a void case } break; @@ -80,14 +80,14 @@ jvalue convertNPVariantToJValue(NPVariant value, JNIType jniType, const char* ja if (type == NPVariantType_Bool) result.z = NPVARIANT_TO_BOOLEAN(value); else - bzero(&result, sizeof(jvalue)); // as void case + bzero(&result, sizeof(jvalue)); // as void case } break; case byte_type: { if (type == NPVariantType_Int32) - result.b = (char)NPVARIANT_TO_INT32(value); + result.b = static_cast<char>(NPVARIANT_TO_INT32(value)); else bzero(&result, sizeof(jvalue)); } @@ -96,7 +96,7 @@ jvalue convertNPVariantToJValue(NPVariant value, JNIType jniType, const char* ja case char_type: { if (type == NPVariantType_Int32) - result.c = (char)NPVARIANT_TO_INT32(value); + result.c = static_cast<char>(NPVARIANT_TO_INT32(value)); else bzero(&result, sizeof(jvalue)); } @@ -105,7 +105,7 @@ jvalue convertNPVariantToJValue(NPVariant value, JNIType jniType, const char* ja case short_type: { if (type == NPVariantType_Int32) - result.s = (jshort)NPVARIANT_TO_INT32(value); + result.s = static_cast<jshort>(NPVARIANT_TO_INT32(value)); else bzero(&result, sizeof(jvalue)); } @@ -114,7 +114,7 @@ jvalue convertNPVariantToJValue(NPVariant value, JNIType jniType, const char* ja case int_type: { if (type == NPVariantType_Int32) - result.i = (jint)NPVARIANT_TO_INT32(value); + result.i = static_cast<jint>(NPVARIANT_TO_INT32(value)); else bzero(&result, sizeof(jvalue)); } @@ -123,9 +123,9 @@ jvalue convertNPVariantToJValue(NPVariant value, JNIType jniType, const char* ja case long_type: { if (type == NPVariantType_Int32) - result.j = (jlong)NPVARIANT_TO_INT32(value); + result.j = static_cast<jlong>(NPVARIANT_TO_INT32(value)); else if (type == NPVariantType_Double) - result.j = (jlong)NPVARIANT_TO_DOUBLE(value); + result.j = static_cast<jlong>(NPVARIANT_TO_DOUBLE(value)); else bzero(&result, sizeof(jvalue)); } @@ -134,9 +134,9 @@ jvalue convertNPVariantToJValue(NPVariant value, JNIType jniType, const char* ja case float_type: { if (type == NPVariantType_Int32) - result.j = (jfloat)NPVARIANT_TO_INT32(value); + result.j = static_cast<jfloat>(NPVARIANT_TO_INT32(value)); else if (type == NPVariantType_Double) - result.j = (jfloat)NPVARIANT_TO_DOUBLE(value); + result.j = static_cast<jfloat>(NPVARIANT_TO_DOUBLE(value)); else bzero(&result, sizeof(jvalue)); } @@ -145,9 +145,9 @@ jvalue convertNPVariantToJValue(NPVariant value, JNIType jniType, const char* ja case double_type: { if (type == NPVariantType_Int32) - result.j = (jdouble)NPVARIANT_TO_INT32(value); + result.j = static_cast<jdouble>(NPVARIANT_TO_INT32(value)); else if (type == NPVariantType_Double) - result.j = (jdouble)NPVARIANT_TO_DOUBLE(value); + result.j = static_cast<jdouble>(NPVARIANT_TO_DOUBLE(value)); else bzero(&result, sizeof(jvalue)); } @@ -178,20 +178,18 @@ void convertJValueToNPVariant(jvalue value, JNIType jniType, const char* javaTyp case object_type: { - if (value.l != 0) { - if (strcmp(javaTypeName, "java.lang.String") == 0) { - const char* v = getCharactersFromJString((jstring)value.l); + if (value.l) { + if (!strcmp(javaTypeName, "java.lang.String")) { + const char* v = getCharactersFromJString(static_cast<jstring>(value.l)); // s is freed in NPN_ReleaseVariantValue (see npruntime.cpp) const char* s = strdup(v); - releaseCharactersForJString((jstring)value.l, v); + releaseCharactersForJString(static_cast<jstring>(value.l), v); STRINGZ_TO_NPVARIANT(s, *result); - } else { + } else OBJECT_TO_NPVARIANT(JavaInstanceToNPObject(new JavaInstance(value.l)), *result); - } } - else { + else VOID_TO_NPVARIANT(*result); - } } break; diff --git a/WebCore/bridge/jni/v8/jni_utility_private.h b/WebCore/bridge/jni/v8/JNIUtilityPrivate.h index 397de7b..f20cfb2 100644 --- a/WebCore/bridge/jni/v8/jni_utility_private.h +++ b/WebCore/bridge/jni/v8/JNIUtilityPrivate.h @@ -23,10 +23,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _JNI_UTILITY_PRIVATE_H_ -#define _JNI_UTILITY_PRIVATE_H_ +#ifndef JNIUtilityPrivate_h +#define JNIUtilityPrivate_h -#include "jni_utility.h" +#include "JNIUtility.h" #include "npruntime.h" namespace JSC { @@ -40,4 +40,4 @@ void convertJValueToNPVariant(jvalue, JNIType, const char* javaClassName, NPVari } // namespace JSC -#endif // _JNI_UTILITY_H_ +#endif // JNIUtilityPrivate_h diff --git a/V8Binding/jni/jni_class.cpp b/WebCore/bridge/jni/v8/JavaClassV8.cpp index a1d321a..c29cf86 100644 --- a/V8Binding/jni/jni_class.cpp +++ b/WebCore/bridge/jni/v8/JavaClassV8.cpp @@ -1,33 +1,33 @@ /* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * Copyright 2009, The Android Open Source Project + * Copyright (C) 2010 Apple Computer, Inc. All rights reserved. + * 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: - * 1. Redistributions of source code must retain the above copyright + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright + * * 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 APPLE COMPUTER, INC. ``AS IS'' AND ANY + * 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 APPLE COMPUTER, INC. OR + * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" +#include "JavaClassV8.h" -#include "jni_class.h" -#include "jni_utility.h" +#include "JNIUtility.h" #include "jni_runtime.h" using namespace JSC::Bindings; @@ -35,28 +35,28 @@ using namespace JSC::Bindings; JavaClass::JavaClass(jobject anInstance) { jobject aClass = callJNIMethod<jobject>(anInstance, "getClass", "()Ljava/lang/Class;"); - + if (!aClass) { fprintf(stderr, "%s: unable to call getClass on instance %p\n", __PRETTY_FUNCTION__, anInstance); return; } - + jstring className = (jstring)callJNIMethod<jobject>(aClass, "getName", "()Ljava/lang/String;"); - const char *classNameC = getCharactersFromJString(className); - _name = strdup(classNameC); + const char* classNameC = getCharactersFromJString(className); + m_name = strdup(classNameC); releaseCharactersForJString(className, classNameC); int i; - JNIEnv *env = getJNIEnv(); + JNIEnv* env = getJNIEnv(); // Get the fields jarray fields = (jarray)callJNIMethod<jobject>(aClass, "getFields", "()[Ljava/lang/reflect/Field;"); - int numFields = env->GetArrayLength(fields); + int numFields = env->GetArrayLength(fields); for (i = 0; i < numFields; i++) { jobject aJField = env->GetObjectArrayElement((jobjectArray)fields, i); - JavaField *aField = new JavaField(env, aJField); // deleted in the JavaClass destructor + JavaField* aField = new JavaField(env, aJField); // deleted in the JavaClass destructor { - _fields.set(aField->name(), aField); + m_fields.set(aField->name().UTF8String(), aField); } env->DeleteLocalRef(aJField); } @@ -66,42 +66,43 @@ JavaClass::JavaClass(jobject anInstance) int numMethods = env->GetArrayLength(methods); for (i = 0; i < numMethods; i++) { jobject aJMethod = env->GetObjectArrayElement((jobjectArray)methods, i); - JavaMethod *aMethod = new JavaMethod(env, aJMethod); // deleted in the JavaClass destructor + JavaMethod* aMethod = new JavaMethod(env, aJMethod); // deleted in the JavaClass destructor MethodList* methodList; { - methodList = _methods.get(aMethod->name()); + methodList = m_methods.get(aMethod->name().UTF8String()); if (!methodList) { methodList = new MethodList(); - _methods.set(aMethod->name(), methodList); + m_methods.set(aMethod->name().UTF8String(), methodList); } } methodList->append(aMethod); env->DeleteLocalRef(aJMethod); - } + } env->DeleteLocalRef(fields); env->DeleteLocalRef(methods); env->DeleteLocalRef(aClass); } -JavaClass::~JavaClass() { - free((void *)_name); +JavaClass::~JavaClass() +{ + free((void*)m_name); - deleteAllValues(_fields); - _fields.clear(); + deleteAllValues(m_fields); + m_fields.clear(); - MethodListMap::const_iterator end = _methods.end(); - for (MethodListMap::const_iterator it = _methods.begin(); it != end; ++it) { + MethodListMap::const_iterator end = m_methods.end(); + for (MethodListMap::const_iterator it = m_methods.begin(); it != end; ++it) { const MethodList* methodList = it->second; deleteAllValues(*methodList); delete methodList; } - _methods.clear(); + m_methods.clear(); } MethodList JavaClass::methodsNamed(const char* name) const { - MethodList *methodList = _methods.get(name); - + MethodList* methodList = m_methods.get(name); + if (methodList) return *methodList; return MethodList(); @@ -109,5 +110,5 @@ MethodList JavaClass::methodsNamed(const char* name) const JavaField* JavaClass::fieldNamed(const char* name) const { - return _fields.get(name); + return m_fields.get(name); } diff --git a/V8Binding/jni/jni_class.h b/WebCore/bridge/jni/v8/JavaClassV8.h index 58787d3..12cdf93 100644 --- a/V8Binding/jni/jni_class.h +++ b/WebCore/bridge/jni/v8/JavaClassV8.h @@ -1,37 +1,37 @@ /* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * Copyright 2009, The Android Open Source Project + * Copyright (C) 2010 Apple Computer, Inc. All rights reserved. + * 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: - * 1. Redistributions of source code must retain the above copyright + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright + * * 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 APPLE COMPUTER, INC. ``AS IS'' AND ANY + * 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 APPLE COMPUTER, INC. OR + * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JNI_CLASS_H_ -#define JNI_CLASS_H_ +#ifndef JavaClassV8_h +#define JavaClassV8_h -#include <jni_runtime.h> -#include <wtf/HashMap.h> -#include <wtf/Vector.h> #include "PlatformString.h" #include "StringHash.h" +#include "jni_runtime.h" +#include <wtf/HashMap.h> +#include <wtf/Vector.h> namespace JSC { @@ -43,20 +43,20 @@ typedef HashMap<WebCore::String, JavaField*> FieldMap; class JavaClass { public: - JavaClass (jobject anInstance); - ~JavaClass (); + JavaClass(jobject anInstance); + ~JavaClass(); - MethodList methodsNamed(const char* name) const; + MethodList methodsNamed(const char* name) const; JavaField* fieldNamed(const char* name) const; private: - const char *_name; - MethodListMap _methods; - FieldMap _fields; + const char* m_name; + MethodListMap m_methods; + FieldMap m_fields; }; } // namespace Bindings } // namespace JSC -#endif // JNI_CLASS_H_ +#endif // JavaClassV8_h diff --git a/V8Binding/jni/jni_instance.cpp b/WebCore/bridge/jni/v8/JavaInstanceV8.cpp index 70da861..13d4984 100644 --- a/V8Binding/jni/jni_instance.cpp +++ b/WebCore/bridge/jni/v8/JavaInstanceV8.cpp @@ -1,6 +1,5 @@ /* - * Copyright (C) 2003, 2008 Apple Inc. All rights reserved. - * Copyright 2009, The Android Open Source Project + * 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 @@ -21,61 +20,58 @@ * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#define LOG_TAG "v8binding" - #include "config.h" +#include "JavaInstanceV8.h" -#include "jni_class.h" -#include "jni_instance.h" +#include "JNIUtility.h" +#include "JavaClassV8.h" #include "jni_runtime.h" -#include "jni_utility.h" #include <assert.h> #include <utils/Log.h> +#define LOG_TAG "v8binding" + using namespace JSC::Bindings; -JavaInstance::JavaInstance (jobject instance) +JavaInstance::JavaInstance(jobject instance) { - _instance = new JObjectWrapper(instance); - _class = 0; + m_instance = new JObjectWrapper(instance); + m_class = 0; } -JavaInstance::~JavaInstance () +JavaInstance::~JavaInstance() { - _instance = 0; - delete _class; + m_instance = 0; + delete m_class; } -JavaClass* JavaInstance::getClass() const +JavaClass* JavaInstance::getClass() const { - if (_class == 0) { - _class = new JavaClass(javaInstance()); + if (!m_class) { + m_class = new JavaClass(javaInstance()); } - return _class; + return m_class; } bool JavaInstance::invokeMethod(const char* methodName, const NPVariant* args, int count, NPVariant* resultValue) { - int i; - jvalue *jArgs; - JavaMethod *method = 0; - VOID_TO_NPVARIANT(*resultValue); MethodList methodList = getClass()->methodsNamed(methodName); size_t numMethods = methodList.size(); - - // Try to find a good match for the overloaded method. The + + // Try to find a good match for the overloaded method. The // fundamental problem is that JavaScript doesn have the - // notion of method overloading and Java does. We could + // notion of method overloading and Java does. We could // get a bit more sophisticated and attempt to does some // type checking as we as checking the number of parameters. - JavaMethod *aMethod; + JavaMethod* aMethod; + JavaMethod* method = 0; for (size_t methodIndex = 0; methodIndex < numMethods; methodIndex++) { aMethod = methodList[methodIndex]; if (aMethod->numParameters() == count) { @@ -83,93 +79,90 @@ bool JavaInstance::invokeMethod(const char* methodName, const NPVariant* args, i break; } } - if (method == 0) { + if (!method) { LOGW("unable to find an appropiate method\n"); return false; } - - const JavaMethod *jMethod = static_cast<const JavaMethod*>(method); - - if (count > 0) { - jArgs = (jvalue *)malloc (count * sizeof(jvalue)); - } - else - jArgs = 0; - - for (i = 0; i < count; i++) { + + const JavaMethod* jMethod = static_cast<const JavaMethod*>(method); + + jvalue* jArgs = 0; + if (count > 0) + jArgs = (jvalue*)malloc (count * sizeof(jvalue)); + + for (int i = 0; i < count; i++) { JavaParameter* aParameter = jMethod->parameterAt(i); jArgs[i] = convertNPVariantToJValue(args[i], aParameter->getJNIType(), aParameter->type()); } - + jvalue result; // The following code can be conditionally removed once we have a Tiger update that // contains the new Java plugin. It is needed for builds prior to Tiger. - { + { jobject obj = javaInstance(); - switch (jMethod->JNIReturnType()){ - case void_type: - callJNIMethodIDA<void>(obj, jMethod->methodID(obj), jArgs); - break; - case object_type: - result.l = callJNIMethodIDA<jobject>(obj, jMethod->methodID(obj), jArgs); - break; - case boolean_type: - result.z = callJNIMethodIDA<jboolean>(obj, jMethod->methodID(obj), jArgs); - break; - case byte_type: - result.b = callJNIMethodIDA<jbyte>(obj, jMethod->methodID(obj), jArgs); - break; - case char_type: - result.c = callJNIMethodIDA<jchar>(obj, jMethod->methodID(obj), jArgs); - break; - case short_type: - result.s = callJNIMethodIDA<jshort>(obj, jMethod->methodID(obj), jArgs); - break; - case int_type: - result.i = callJNIMethodIDA<jint>(obj, jMethod->methodID(obj), jArgs); - break; - - case long_type: - result.j = callJNIMethodIDA<jlong>(obj, jMethod->methodID(obj), jArgs); - break; - case float_type: - result.f = callJNIMethodIDA<jfloat>(obj, jMethod->methodID(obj), jArgs); - break; - case double_type: - result.d = callJNIMethodIDA<jdouble>(obj, jMethod->methodID(obj), jArgs); - break; - case invalid_type: - default: - break; + switch (jMethod->JNIReturnType()) { + case void_type: + callJNIMethodIDA<void>(obj, jMethod->methodID(obj), jArgs); + break; + case object_type: + result.l = callJNIMethodIDA<jobject>(obj, jMethod->methodID(obj), jArgs); + break; + case boolean_type: + result.z = callJNIMethodIDA<jboolean>(obj, jMethod->methodID(obj), jArgs); + break; + case byte_type: + result.b = callJNIMethodIDA<jbyte>(obj, jMethod->methodID(obj), jArgs); + break; + case char_type: + result.c = callJNIMethodIDA<jchar>(obj, jMethod->methodID(obj), jArgs); + break; + case short_type: + result.s = callJNIMethodIDA<jshort>(obj, jMethod->methodID(obj), jArgs); + break; + case int_type: + result.i = callJNIMethodIDA<jint>(obj, jMethod->methodID(obj), jArgs); + break; + + case long_type: + result.j = callJNIMethodIDA<jlong>(obj, jMethod->methodID(obj), jArgs); + break; + case float_type: + result.f = callJNIMethodIDA<jfloat>(obj, jMethod->methodID(obj), jArgs); + break; + case double_type: + result.d = callJNIMethodIDA<jdouble>(obj, jMethod->methodID(obj), jArgs); + break; + case invalid_type: + default: + break; } } - + convertJValueToNPVariant(result, jMethod->JNIReturnType(), jMethod->returnType(), resultValue); - free (jArgs); + free(jArgs); return true; } JObjectWrapper::JObjectWrapper(jobject instance) -: _refCount(0) + : m_refCount(0) { - assert (instance != 0); + assert(instance); // Cache the JNIEnv used to get the global ref for this java instanace. // It'll be used to delete the reference. - _env = getJNIEnv(); + m_env = getJNIEnv(); - _instance = _env->NewGlobalRef(instance); + m_instance = m_env->NewGlobalRef(instance); - LOGV("new global ref %p for %p\n", _instance, instance); + LOGV("new global ref %p for %p\n", m_instance, instance); - if (_instance == NULL) { + if (!m_instance) fprintf (stderr, "%s: could not get GlobalRef for %p\n", __PRETTY_FUNCTION__, instance); - } } JObjectWrapper::~JObjectWrapper() { - LOGV("deleting global ref %p\n", _instance); - _env->DeleteGlobalRef(_instance); + LOGV("deleting global ref %p\n", m_instance); + m_env->DeleteGlobalRef(m_instance); } diff --git a/V8Binding/jni/jni_instance.h b/WebCore/bridge/jni/v8/JavaInstanceV8.h index 608b461..dcd51e8 100644 --- a/V8Binding/jni/jni_instance.h +++ b/WebCore/bridge/jni/v8/JavaInstanceV8.h @@ -1,6 +1,5 @@ /* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * Copyright 2009, The Android Open Source Project + * 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 @@ -21,13 +20,13 @@ * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _JNI_INSTANCE_H_ -#define _JNI_INSTANCE_H_ +#ifndef JavaInstanceV8_h +#define JavaInstanceV8_h -#include "jni_utility_private.h" +#include "JNIUtilityPrivate.h" #include <JavaVM/jni.h> #include <wtf/RefCounted.h> @@ -41,36 +40,34 @@ namespace Bindings { class JavaClass; -class JObjectWrapper -{ +class JObjectWrapper { friend class RefPtr<JObjectWrapper>; friend class JavaField; friend class JavaInstance; public: - jobject instance() const { return _instance; } - void setInstance(jobject instance) { _instance = instance; } + jobject instance() const { return m_instance; } + void setInstance(jobject instance) { m_instance = instance; } protected: - JObjectWrapper(jobject instance); + JObjectWrapper(jobject instance); ~JObjectWrapper(); - - void ref() { _refCount++; } - void deref() - { - if (--_refCount == 0) - delete this; + + void ref() { m_refCount++; } + void deref() + { + if (!(--m_refCount)) + delete this; } - jobject _instance; + jobject m_instance; private: - JNIEnv *_env; - unsigned int _refCount; + JNIEnv* m_env; + unsigned int m_refCount; }; -class JavaInstance : public RefCounted<JavaInstance> -{ +class JavaInstance : public RefCounted<JavaInstance> { public: JavaInstance(jobject instance); virtual ~JavaInstance(); @@ -79,7 +76,7 @@ public: bool invokeMethod(const char* name, const NPVariant* args, int argsCount, NPVariant* result); - jobject javaInstance() const { return _instance->_instance; } + jobject javaInstance() const { return m_instance->m_instance; } // These functions are called before and after the main entry points into // the native implementations. They can be used to establish and cleanup @@ -88,8 +85,8 @@ public: void end() { virtualEnd(); } protected: - RefPtr<JObjectWrapper> _instance; - mutable JavaClass* _class; + RefPtr<JObjectWrapper> m_instance; + mutable JavaClass* m_class; virtual void virtualBegin() {} virtual void virtualEnd() {} @@ -99,4 +96,4 @@ protected: } // namespace JSC -#endif // _JNI_INSTANCE_H_ +#endif // JavaInstanceV8_h diff --git a/V8Binding/jni/jni_npobject.cpp b/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp index 8a49a19..636d075 100644 --- a/V8Binding/jni/jni_npobject.cpp +++ b/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp @@ -25,22 +25,22 @@ #include "config.h" +#include "JavaNPObjectV8.h" -#include "jni_npobject.h" -#include "jni_class.h" -#include "jni_instance.h" +#include "JNIUtility.h" +#include "JavaClassV8.h" +#include "JavaInstanceV8.h" #include "jni_runtime.h" -#include "jni_utility.h" -// This source file should be in bridge/jni, so it's OK to use the private -// NPAPI header from here. #include "npruntime_impl.h" -namespace JSC { namespace Bindings { +namespace JSC { + +namespace Bindings { + static NPObject* AllocJavaNPObject(NPP, NPClass*) { - JavaNPObject* obj = - static_cast<JavaNPObject*>(malloc(sizeof(JavaNPObject))); - if (obj == 0) + JavaNPObject* obj = static_cast<JavaNPObject*>(malloc(sizeof(JavaNPObject))); + if (!obj) return 0; bzero(obj, sizeof(JavaNPObject)); return reinterpret_cast<NPObject*>(obj); @@ -49,7 +49,7 @@ static NPObject* AllocJavaNPObject(NPP, NPClass*) static void FreeJavaNPObject(NPObject* npobj) { JavaNPObject* obj = reinterpret_cast<JavaNPObject*>(npobj); - obj->_instance = 0; // free does not call the destructor + obj->m_instance = 0; // free does not call the destructor free(obj); } @@ -72,7 +72,7 @@ static NPClass JavaNPObjectClass = { NPObject* JavaInstanceToNPObject(JavaInstance* instance) { JavaNPObject* object = reinterpret_cast<JavaNPObject*>(_NPN_CreateObject(0, &JavaNPObjectClass)); - object->_instance = instance; + object->m_instance = instance; return reinterpret_cast<NPObject*>(object); } @@ -80,17 +80,17 @@ NPObject* JavaInstanceToNPObject(JavaInstance* instance) { // Returns null if obj is not a wrapper of JavaInstance JavaInstance* ExtractJavaInstance(NPObject* obj) { if (obj->_class == &JavaNPObjectClass) { - return reinterpret_cast<JavaNPObject*>(obj)->_instance.get(); + return reinterpret_cast<JavaNPObject*>(obj)->m_instance.get(); } return 0; } bool JavaNPObject_HasMethod(NPObject* obj, NPIdentifier identifier) { JavaInstance* instance = ExtractJavaInstance(obj); - if (instance == 0) + if (!instance) return false; NPUTF8* name = _NPN_UTF8FromIdentifier(identifier); - if (name == 0) + if (!name) return false; instance->begin(); @@ -103,13 +103,12 @@ bool JavaNPObject_HasMethod(NPObject* obj, NPIdentifier identifier) { return result; } -bool JavaNPObject_Invoke(NPObject* obj, NPIdentifier identifier, - const NPVariant* args, uint32_t argCount, NPVariant* result) { +bool JavaNPObject_Invoke(NPObject* obj, NPIdentifier identifier, const NPVariant* args, uint32_t argCount, NPVariant* result) { JavaInstance* instance = ExtractJavaInstance(obj); - if (instance == 0) + if (!instance) return false; NPUTF8* name = _NPN_UTF8FromIdentifier(identifier); - if (name == 0) + if (!name) return false; instance->begin(); @@ -119,18 +118,17 @@ bool JavaNPObject_Invoke(NPObject* obj, NPIdentifier identifier, // TODO: use NPN_MemFree free(name); return r; - } bool JavaNPObject_HasProperty(NPObject* obj, NPIdentifier identifier) { JavaInstance* instance = ExtractJavaInstance(obj); - if (instance == 0) + if (!instance) return false; NPUTF8* name = _NPN_UTF8FromIdentifier(identifier); - if (name == 0) + if (!name) return false; instance->begin(); - bool result = instance->getClass()->fieldNamed(name) != 0; + bool result = instance->getClass()->fieldNamed(name); instance->end(); free(name); return result; @@ -139,10 +137,10 @@ bool JavaNPObject_HasProperty(NPObject* obj, NPIdentifier identifier) { bool JavaNPObject_GetProperty(NPObject* obj, NPIdentifier identifier, NPVariant* result) { VOID_TO_NPVARIANT(*result); JavaInstance* instance = ExtractJavaInstance(obj); - if (instance == 0) + if (!instance) return false; NPUTF8* name = _NPN_UTF8FromIdentifier(identifier); - if (name == 0) + if (!name) return false; instance->begin(); @@ -150,13 +148,12 @@ bool JavaNPObject_GetProperty(NPObject* obj, NPIdentifier identifier, NPVariant* instance->end(); free(name); // TODO: use NPN_MemFree - if (field == 0) { + if (!field) return false; - } jvalue value = getJNIField(instance->javaInstance(), field->getJNIType(), - field->name(), + field->name().UTF8String(), field->type()); convertJValueToNPVariant(value, field->getJNIType(), field->type(), result); @@ -164,4 +161,6 @@ bool JavaNPObject_GetProperty(NPObject* obj, NPIdentifier identifier, NPVariant* return true; } -}} // namespace +} // namespace Bindings + +} // namespace JSC diff --git a/V8Binding/jni/jni_npobject.h b/WebCore/bridge/jni/v8/JavaNPObjectV8.h index 943b661..c36ef70 100644 --- a/V8Binding/jni/jni_npobject.h +++ b/WebCore/bridge/jni/v8/JavaNPObjectV8.h @@ -1,5 +1,5 @@ /* - * Copyright 2009, The Android Open Source Project + * 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 @@ -23,30 +23,36 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JNI_NPOBJECT_H_ -#define JNI_NPOBJECT_H_ +#ifndef JavaNPObjectV8_h +#define JavaNPObjectV8_h -#include "npruntime.h" #include "jni_runtime.h" - -#include <wtf/RefPtr.h> +#include "npruntime.h" #include <JavaVM/jni.h> +#include <wtf/RefPtr.h> -namespace JSC { namespace Bindings { + +namespace JSC { + +namespace Bindings { + +class JavaInstance; struct JavaNPObject { - NPObject _object; - RefPtr<JavaInstance> _instance; + NPObject m_object; + RefPtr<JavaInstance> m_instance; }; -NPObject* JavaInstanceToNPObject(JavaInstance* instance); -JavaInstance* ExtractJavaInstance(NPObject* obj); +NPObject* JavaInstanceToNPObject(JavaInstance*); +JavaInstance* ExtractJavaInstance(NPObject*); + +bool JavaNPObject_HasMethod(NPObject*, NPIdentifier name); +bool JavaNPObject_Invoke(NPObject*, NPIdentifier methodName, const NPVariant* args, uint32_t argCount, NPVariant* result); +bool JavaNPObject_HasProperty(NPObject*, NPIdentifier name); +bool JavaNPObject_GetProperty(NPObject*, NPIdentifier name, NPVariant* result); -bool JavaNPObject_HasMethod(NPObject* obj, NPIdentifier name); -bool JavaNPObject_Invoke(NPObject* obj, NPIdentifier methodName, const NPVariant* args, uint32_t argCount, NPVariant* result); -bool JavaNPObject_HasProperty(NPObject* obj, NPIdentifier name); -bool JavaNPObject_GetProperty(NPObject* obj, NPIdentifier name, NPVariant* ressult); +} // namespace Bindings -} } +} // namespace JSC -#endif JNI_NPOBJECT_H_ +#endif // JavaNPObjectV8_h diff --git a/WebCore/bridge/jni/v8/JavaStringV8.h b/WebCore/bridge/jni/v8/JavaStringV8.h new file mode 100644 index 0000000..8788e58 --- /dev/null +++ b/WebCore/bridge/jni/v8/JavaStringV8.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2010 Apple Computer, Inc. All rights reserved. + * + * 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 JavaStringV8_h +#define JavaStringV8_h + +#include "CString.h" +#include "JNIUtility.h" + + +namespace JSC { + +namespace Bindings { + +class JavaStringImpl { +public: + void init() {} + + void init(JNIEnv* e, jstring s) + { + int size = e->GetStringLength(s); + const char* cs = getCharactersFromJStringInEnv(e, s); + { + m_utf8String = WebCore::CString(cs, size); + } + releaseCharactersForJStringInEnv(e, s, cs); + } + + const char* UTF8String() const { return m_utf8String.data(); } + const jchar* uchars() const { return 0; } // Not implemented + int length() const { return m_utf8String.length(); } + +private: + WebCore::CString m_utf8String; +}; + +} // namespace Bindings + +} // namespace JSC + +#endif // JavaStringV8_h diff --git a/WebCore/bridge/runtime.cpp b/WebCore/bridge/jsc/BridgeJSC.cpp index eac8586..ed582d3 100644 --- a/WebCore/bridge/runtime.cpp +++ b/WebCore/bridge/jsc/BridgeJSC.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved. + * 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 @@ -20,11 +21,11 @@ * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" -#include "runtime.h" +#include "BridgeJSC.h" #include "runtime_object.h" #include "runtime_root.h" @@ -34,12 +35,14 @@ #include "qt_instance.h" #endif -namespace JSC { namespace Bindings { +namespace JSC { + +namespace Bindings { Array::Array(PassRefPtr<RootObject> rootObject) - : _rootObject(rootObject) + : m_rootObject(rootObject) { - ASSERT(_rootObject); + ASSERT(m_rootObject); } Array::~Array() @@ -47,10 +50,10 @@ Array::~Array() } Instance::Instance(PassRefPtr<RootObject> rootObject) - : _rootObject(rootObject) + : m_rootObject(rootObject) , m_runtimeObject(0) { - ASSERT(_rootObject); + ASSERT(m_rootObject); } Instance::~Instance() @@ -82,28 +85,28 @@ void Instance::end() RuntimeObjectImp* Instance::createRuntimeObject(ExecState* exec) { - ASSERT(_rootObject); - ASSERT(_rootObject->isValid()); + ASSERT(m_rootObject); + ASSERT(m_rootObject->isValid()); if (m_runtimeObject) return m_runtimeObject; JSLock lock(SilenceAssertionsOnly); m_runtimeObject = newRuntimeObject(exec); - _rootObject->addRuntimeObject(m_runtimeObject); + m_rootObject->addRuntimeObject(m_runtimeObject); return m_runtimeObject; } RuntimeObjectImp* Instance::newRuntimeObject(ExecState* exec) { JSLock lock(SilenceAssertionsOnly); - return new (exec) RuntimeObjectImp(exec, this); + return new (exec)RuntimeObjectImp(exec, this); } void Instance::willDestroyRuntimeObject() { - ASSERT(_rootObject); - ASSERT(_rootObject->isValid()); + ASSERT(m_rootObject); + ASSERT(m_rootObject->isValid()); ASSERT(m_runtimeObject); - _rootObject->removeRuntimeObject(m_runtimeObject); + m_rootObject->removeRuntimeObject(m_runtimeObject); m_runtimeObject = 0; } @@ -113,9 +116,11 @@ void Instance::willInvalidateRuntimeObject() m_runtimeObject = 0; } -RootObject* Instance::rootObject() const -{ - return _rootObject && _rootObject->isValid() ? _rootObject.get() : 0; +RootObject* Instance::rootObject() const +{ + return m_rootObject && m_rootObject->isValid() ? m_rootObject.get() : 0; } -} } // namespace JSC::Bindings +} // namespace Bindings + +} // namespace JSC diff --git a/WebCore/bridge/runtime.h b/WebCore/bridge/jsc/BridgeJSC.h index 6682a97..8e2cb2b 100644 --- a/WebCore/bridge/runtime.h +++ b/WebCore/bridge/jsc/BridgeJSC.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2003, 2008, 2009 Apple Inc. All rights reserved. + * 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 @@ -20,11 +21,13 @@ * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JAVASCRIPTCORE_BINDINGS_RUNTIME_H -#define JAVASCRIPTCORE_BINDINGS_RUNTIME_H +#ifndef BridgeJSC_h +#define BridgeJSC_h + +#if USE(JSC) #include <runtime/JSString.h> #include <wtf/HashMap.h> @@ -55,13 +58,6 @@ public: virtual ~Field() { } }; -class Method : public Noncopyable { -public: - virtual int numParameters() const = 0; - - virtual ~Method() { } -}; - class Class : public Noncopyable { public: virtual MethodList methodsNamed(const Identifier&, Instance*) const = 0; @@ -85,12 +81,12 @@ public: // any needed state. void begin(); void end(); - + virtual Class* getClass() const = 0; RuntimeObjectImp* createRuntimeObject(ExecState*); void willInvalidateRuntimeObject(); void willDestroyRuntimeObject(); - + // Returns false if the value was not set successfully. virtual bool setValueOfUndefinedField(ExecState*, const Identifier&, JSValue) { return false; } @@ -98,18 +94,18 @@ public: virtual bool supportsInvokeDefaultMethod() const { return false; } virtual JSValue invokeDefaultMethod(ExecState*, const ArgList&) { return jsUndefined(); } - + virtual bool supportsConstruct() const { return false; } virtual JSValue invokeConstruct(ExecState*, const ArgList&) { return JSValue(); } - + virtual void getPropertyNames(ExecState*, PropertyNameArray&) { } virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const = 0; - + virtual JSValue valueOf(ExecState* exec) const = 0; - + RootObject* rootObject() const; - + virtual ~Instance(); virtual bool getOwnPropertySlot(JSObject*, ExecState*, const Identifier&, PropertySlot&) { return false; } @@ -121,7 +117,7 @@ protected: virtual void virtualEnd() { } virtual RuntimeObjectImp* newRuntimeObject(ExecState*); - RefPtr<RootObject> _rootObject; + RefPtr<RootObject> m_rootObject; private: RuntimeObjectImp* m_runtimeObject; @@ -131,23 +127,25 @@ class Array : public Noncopyable { public: Array(PassRefPtr<RootObject>); virtual ~Array(); - - virtual void setValueAt(ExecState *, unsigned index, JSValue) const = 0; - virtual JSValue valueAt(ExecState *, unsigned index) const = 0; + + virtual void setValueAt(ExecState*, unsigned index, JSValue) const = 0; + virtual JSValue valueAt(ExecState*, unsigned index) const = 0; virtual unsigned int getLength() const = 0; protected: - RefPtr<RootObject> _rootObject; + RefPtr<RootObject> m_rootObject; }; -const char *signatureForParameters(const ArgList&); +const char* signatureForParameters(const ArgList&); typedef HashMap<RefPtr<UString::Rep>, MethodList*> MethodListMap; -typedef HashMap<RefPtr<UString::Rep>, Method*> MethodMap; -typedef HashMap<RefPtr<UString::Rep>, Field*> FieldMap; - +typedef HashMap<RefPtr<UString::Rep>, Method*> MethodMap; +typedef HashMap<RefPtr<UString::Rep>, Field*> FieldMap; + } // namespace Bindings } // namespace JSC +#endif // USE(JSC) + #endif diff --git a/WebCore/bridge/objc/objc_instance.mm b/WebCore/bridge/objc/objc_instance.mm index 9f2e3bb..25da8b9 100644 --- a/WebCore/bridge/objc/objc_instance.mm +++ b/WebCore/bridge/objc/objc_instance.mm @@ -277,7 +277,7 @@ JSValue ObjcInstance::invokeMethod(ExecState* exec, const MethodList &methodList if (*type != 'v') { [invocation getReturnValue:buffer]; - result = convertObjcValueToValue(exec, buffer, objcValueType, _rootObject.get()); + result = convertObjcValueToValue(exec, buffer, objcValueType, m_rootObject.get()); } } @catch(NSException* localException) { } @@ -329,7 +329,7 @@ JSValue ObjcInstance::invokeDefaultMethod(ExecState* exec, const ArgList &args) // OK with 32 here. char buffer[32]; [invocation getReturnValue:buffer]; - result = convertObjcValueToValue(exec, buffer, objcValueType, _rootObject.get()); + result = convertObjcValueToValue(exec, buffer, objcValueType, m_rootObject.get()); } @catch(NSException* localException) { } moveGlobalExceptionToExecState(exec); @@ -383,7 +383,7 @@ JSValue ObjcInstance::getValueOfUndefinedField(ExecState* exec, const Identifier @try { id objcValue = [targetObject valueForUndefinedKey:[NSString stringWithCString:property.ascii() encoding:NSASCIIStringEncoding]]; - result = convertObjcValueToValue(exec, &objcValue, ObjcObjectType, _rootObject.get()); + result = convertObjcValueToValue(exec, &objcValue, ObjcObjectType, m_rootObject.get()); } @catch(NSException* localException) { // Do nothing. Class did not override valueForUndefinedKey:. } diff --git a/WebCore/bridge/objc/objc_runtime.h b/WebCore/bridge/objc/objc_runtime.h index 63f3254..4de1ce6 100644 --- a/WebCore/bridge/objc/objc_runtime.h +++ b/WebCore/bridge/objc/objc_runtime.h @@ -26,8 +26,8 @@ #ifndef KJS_BINDINGS_OBJC_RUNTIME_H #define KJS_BINDINGS_OBJC_RUNTIME_H +#include "Bridge.h" #include "objc_header.h" -#include "runtime.h" #include <runtime/JSGlobalObject.h> #include <wtf/RetainPtr.h> diff --git a/WebCore/bridge/objc/objc_runtime.mm b/WebCore/bridge/objc/objc_runtime.mm index 5efc865..772695c 100644 --- a/WebCore/bridge/objc/objc_runtime.mm +++ b/WebCore/bridge/objc/objc_runtime.mm @@ -174,7 +174,7 @@ JSValue ObjcArray::valueAt(ExecState* exec, unsigned int index) const @try { id obj = [_array.get() objectAtIndex:index]; if (obj) - return convertObjcValueToValue (exec, &obj, ObjcObjectType, _rootObject.get()); + return convertObjcValueToValue (exec, &obj, ObjcObjectType, m_rootObject.get()); } @catch(NSException* localException) { return throwError(exec, GeneralError, "Objective-C exception."); } diff --git a/WebCore/bridge/qt/qt_class.h b/WebCore/bridge/qt/qt_class.h index dc6b130..b7a04cf 100644 --- a/WebCore/bridge/qt/qt_class.h +++ b/WebCore/bridge/qt/qt_class.h @@ -20,8 +20,7 @@ #ifndef BINDINGS_QT_CLASS_H_ #define BINDINGS_QT_CLASS_H_ -#include "runtime.h" - +#include "Bridge.h" #include "qglobal.h" QT_BEGIN_NAMESPACE diff --git a/WebCore/bridge/qt/qt_instance.h b/WebCore/bridge/qt/qt_instance.h index 0afc6c7..1fc253a 100644 --- a/WebCore/bridge/qt/qt_instance.h +++ b/WebCore/bridge/qt/qt_instance.h @@ -20,11 +20,11 @@ #ifndef BINDINGS_QT_INSTANCE_H_ #define BINDINGS_QT_INSTANCE_H_ -#include <QtScript/qscriptengine.h> -#include "runtime.h" +#include "Bridge.h" #include "runtime_root.h" -#include <qpointer.h> +#include <QtScript/qscriptengine.h> #include <qhash.h> +#include <qpointer.h> #include <qset.h> namespace JSC { diff --git a/WebCore/bridge/qt/qt_runtime.cpp b/WebCore/bridge/qt/qt_runtime.cpp index 94749b4..c711baa 100644 --- a/WebCore/bridge/qt/qt_runtime.cpp +++ b/WebCore/bridge/qt/qt_runtime.cpp @@ -46,7 +46,6 @@ #include "qvarlengtharray.h" #include <JSFunction.h> #include <limits.h> -#include <runtime.h> #include <runtime/Error.h> #include <runtime_array.h> #include <runtime_object.h> @@ -1744,7 +1743,7 @@ template <typename T> QtArray<T>::~QtArray () template <typename T> RootObject* QtArray<T>::rootObject() const { - return _rootObject && _rootObject->isValid() ? _rootObject.get() : 0; + return m_rootObject && m_rootObject->isValid() ? m_rootObject.get() : 0; } template <typename T> void QtArray<T>::setValueAt(ExecState* exec, unsigned index, JSValue aValue) const diff --git a/WebCore/bridge/qt/qt_runtime.h b/WebCore/bridge/qt/qt_runtime.h index dc55f61..d9450eb 100644 --- a/WebCore/bridge/qt/qt_runtime.h +++ b/WebCore/bridge/qt/qt_runtime.h @@ -20,9 +20,9 @@ #ifndef BINDINGS_QT_RUNTIME_H_ #define BINDINGS_QT_RUNTIME_H_ +#include "Bridge.h" #include "Completion.h" #include "Protect.h" -#include "runtime.h" #include "runtime_method.h" #include <qbytearray.h> diff --git a/WebCore/bridge/runtime_array.h b/WebCore/bridge/runtime_array.h index 1218b8c..eeaa337 100644 --- a/WebCore/bridge/runtime_array.h +++ b/WebCore/bridge/runtime_array.h @@ -26,7 +26,7 @@ #ifndef RUNTIME_ARRAY_H_ #define RUNTIME_ARRAY_H_ -#include "runtime.h" +#include "Bridge.h" #include <runtime/JSGlobalObject.h> namespace JSC { diff --git a/WebCore/bridge/runtime_method.h b/WebCore/bridge/runtime_method.h index 9676048..148be32 100644 --- a/WebCore/bridge/runtime_method.h +++ b/WebCore/bridge/runtime_method.h @@ -26,7 +26,7 @@ #ifndef RUNTIME_FUNCTION_H_ #define RUNTIME_FUNCTION_H_ -#include "runtime.h" +#include "Bridge.h" #include <runtime/InternalFunction.h> #include <runtime/JSGlobalObject.h> #include <wtf/OwnPtr.h> diff --git a/WebCore/bridge/runtime_object.h b/WebCore/bridge/runtime_object.h index 391e078..7d658fa 100644 --- a/WebCore/bridge/runtime_object.h +++ b/WebCore/bridge/runtime_object.h @@ -26,7 +26,7 @@ #ifndef KJS_RUNTIME_OBJECT_H #define KJS_RUNTIME_OBJECT_H -#include "runtime.h" +#include "Bridge.h" #include <runtime/JSGlobalObject.h> namespace JSC { diff --git a/WebCore/bridge/runtime_root.cpp b/WebCore/bridge/runtime_root.cpp index 0e9bf74..143c3ad 100644 --- a/WebCore/bridge/runtime_root.cpp +++ b/WebCore/bridge/runtime_root.cpp @@ -26,7 +26,7 @@ #include "config.h" #include "runtime_root.h" -#include "runtime.h" +#include "Bridge.h" #include "runtime_object.h" #include <runtime/JSGlobalObject.h> #include <wtf/HashCountedSet.h> diff --git a/WebCore/bridge/testbindings.cpp b/WebCore/bridge/testbindings.cpp index e4bbc7e..bcba115 100644 --- a/WebCore/bridge/testbindings.cpp +++ b/WebCore/bridge/testbindings.cpp @@ -19,19 +19,17 @@ * */ #include "config.h" -#include <assert.h> -#include <stdio.h> -#include <string.h> -#include "JSValue.h" +#include "Bridge.h" #include "JSObject.h" -#include "types.h" +#include "JSValue.h" #include "interpreter.h" - #include "npruntime_internal.h" - -#include "runtime.h" #include "runtime_object.h" +#include "types.h" +#include <assert.h> +#include <stdio.h> +#include <string.h> #define LOG(formatAndArgs...) { \ diff --git a/WebCore/bridge/testbindings.mm b/WebCore/bridge/testbindings.mm index ca70e17..31564a8 100644 --- a/WebCore/bridge/testbindings.mm +++ b/WebCore/bridge/testbindings.mm @@ -24,20 +24,18 @@ */ #include "config.h" -#include <Foundation/Foundation.h> +#include "Bridge.h" +#include <Foundation/Foundation.h> +#include "JSObject.h" +#include "JSValue.h" #import <WebKit/WebScriptObject.h> - +#include "interpreter.h" +#include "runtime_object.h" #include <stdio.h> #include <string.h> - -#include "JSValue.h" -#include "JSObject.h" #include "types.h" -#include "interpreter.h" -#include "runtime.h" -#include "runtime_object.h" #define LOG(formatAndArgs...) { \ fprintf (stderr, "%s: ", __PRETTY_FUNCTION__); \ diff --git a/WebCore/bridge/testqtbindings.cpp b/WebCore/bridge/testqtbindings.cpp index 41a9a3a..73df155 100644 --- a/WebCore/bridge/testqtbindings.cpp +++ b/WebCore/bridge/testqtbindings.cpp @@ -23,21 +23,18 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" -#include <assert.h> -#include <stdio.h> -#include <string.h> -#include "JSValue.h" +#include "Bridge.h" #include "JSObject.h" -#include "types.h" +#include "JSValue.h" #include "interpreter.h" - -#include "qobject.h" #include "qdebug.h" - -#include "runtime.h" +#include "qobject.h" #include "runtime_object.h" - +#include "types.h" +#include <assert.h> +#include <stdio.h> +#include <string.h> class MyObject : public QObject diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp index 13c2fae..d031853 100644 --- a/WebCore/dom/Document.cpp +++ b/WebCore/dom/Document.cpp @@ -171,12 +171,10 @@ #include "SVGStyleElement.h" #endif -#if ENABLE(TOUCH_EVENTS) // Android -#include "TouchEvent.h" #if PLATFORM(ANDROID) +// FIXME: We shouldn't be including this from WebCore! #include "WebViewCore.h" #endif -#endif #ifdef ANDROID_META_SUPPORT #include "Settings.h" @@ -191,6 +189,11 @@ #include "TimeCounter.h" #endif +#if ENABLE(TOUCH_EVENTS) +#include "ChromeClient.h" +#include "TouchEvent.h" +#endif + #if ENABLE(WML) #include "WMLDocument.h" #include "WMLElement.h" @@ -1484,17 +1487,6 @@ void Document::detach() FrameView* view = m_frame->view(); if (view) view->detachCustomScrollbars(); - -#if ENABLE(TOUCH_EVENTS) // Android - // clean up for the top document - if (!m_frame->ownerElement()) { - m_touchEventListeners.clear(); -#if PLATFORM(ANDROID) - if (view) - android::WebViewCore::getWebViewCore(view)->needTouchEvents(false); -#endif - } -#endif } // indicate destruction mode, i.e. attached() but renderer == 0 @@ -2257,7 +2249,8 @@ void Document::processMetadataSettings(const String& content) String key(buffer.substring(keyBegin, keyEnd - keyBegin)); String value(buffer.substring(valueBegin, valueEnd - valueBegin)); - frame()->settings()->setMetadataSettings(key, value); + if (frame()) + frame()->settings()->setMetadataSettings(key, value); } } #endif @@ -3061,7 +3054,7 @@ PassRefPtr<Event> Document::createEvent(const String& eventType, ExceptionCode& else if (eventType == "SVGZoomEvents") event = SVGZoomEvent::create(); #endif -#if ENABLE(TOUCH_EVENTS) // Android +#if ENABLE(TOUCH_EVENTS) else if (eventType == "TouchEvent") event = TouchEvent::create(); #endif @@ -3101,6 +3094,14 @@ void Document::addListenerTypeIfNeeded(const AtomicString& eventType) addListenerType(TRANSITIONEND_LISTENER); else if (eventType == eventNames().beforeloadEvent) addListenerType(BEFORELOAD_LISTENER); + else if (eventType == eventNames().touchstartEvent + || eventType == eventNames().touchmoveEvent + || eventType == eventNames().touchendEvent + || eventType == eventNames().touchcancelEvent) { + addListenerType(TOUCH_LISTENER); + if (Page* page = this->page()) + page->chrome()->client()->needTouchEvents(true); + } } CSSStyleDeclaration* Document::getOverrideStyle(Element*, const String&) @@ -4672,38 +4673,6 @@ void Document::parseDNSPrefetchControlHeader(const String& dnsPrefetchControl) m_haveExplicitlyDisabledDNSPrefetch = true; } -#if ENABLE(TOUCH_EVENTS) // Android -void Document::addTouchEventListener(Node* node) -{ - // Note: we only keep track of touch listener in the top frame - if (m_frame && m_frame->tree()->parent()) { - m_frame->page()->mainFrame()->document()->addTouchEventListener(node); - } else { -#if PLATFORM(ANDROID) - if (m_frame && m_frame->view() && m_touchEventListeners.isEmpty()) - android::WebViewCore::getWebViewCore(m_frame->view())->needTouchEvents(true); -#endif - m_touchEventListeners.add(node, 0); - } -} - -void Document::removeTouchEventListener(Node* node) -{ - // Note: we only keep track of touch listener in the top frame - if (m_frame && m_frame->tree()->parent()) { - m_frame->page()->mainFrame()->document()->removeTouchEventListener(node); - } else { -#if PLATFORM(ANDROID) - if (m_frame && m_frame->view() && m_touchEventListeners.size() == 1 && - m_touchEventListeners.contains(node)) - android::WebViewCore::getWebViewCore(m_frame->view())->needTouchEvents(false); -#endif - m_touchEventListeners.remove(node); - } -} - -#endif - void Document::reportException(const String& errorMessage, int lineNumber, const String& sourceURL) { if (DOMWindow* window = domWindow()) diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h index f2125b1..b24063a 100644 --- a/WebCore/dom/Document.h +++ b/WebCore/dom/Document.h @@ -252,6 +252,12 @@ public: DEFINE_ATTRIBUTE_EVENT_LISTENER(reset); DEFINE_ATTRIBUTE_EVENT_LISTENER(search); DEFINE_ATTRIBUTE_EVENT_LISTENER(selectstart); +#if ENABLE(TOUCH_EVENTS) + DEFINE_ATTRIBUTE_EVENT_LISTENER(touchstart); + DEFINE_ATTRIBUTE_EVENT_LISTENER(touchmove); + DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend); + DEFINE_ATTRIBUTE_EVENT_LISTENER(touchcancel); +#endif DocumentType* doctype() const { return m_docType.get(); } @@ -624,7 +630,8 @@ public: ANIMATIONSTART_LISTENER = 0x200, ANIMATIONITERATION_LISTENER = 0x400, TRANSITIONEND_LISTENER = 0x800, - BEFORELOAD_LISTENER = 0x1000 + BEFORELOAD_LISTENER = 0x1000, + TOUCH_LISTENER = 0x2000 }; bool hasListenerType(ListenerType listenerType) const { return (m_listenerTypes & listenerType); } @@ -937,17 +944,6 @@ protected: void clearXMLVersion() { m_xmlVersion = String(); } -#if ENABLE(TOUCH_EVENTS) // Android -public: - typedef HashMap<Node*, unsigned > TouchListenerMap; - - void addTouchEventListener(Node*); - void removeTouchEventListener(Node*); - const TouchListenerMap& touchEventListeners() const { return m_touchEventListeners; } - -private: - TouchListenerMap m_touchEventListeners; -#endif // ENABLE(TOUCH_EVENTS) private: virtual bool isDocument() const { return true; } @@ -1120,7 +1116,7 @@ private: #if ENABLE(XBL) OwnPtr<XBLBindingManager> m_bindingManager; // The access point through which documents and elements communicate with XBL. #endif - + typedef HashMap<AtomicStringImpl*, HTMLMapElement*> ImageMapsByName; ImageMapsByName m_imageMapsByName; diff --git a/WebCore/dom/Document.idl b/WebCore/dom/Document.idl index e54add0..69417c8 100644 --- a/WebCore/dom/Document.idl +++ b/WebCore/dom/Document.idl @@ -284,12 +284,6 @@ module core { attribute [DontEnum] EventListener onscroll; attribute [DontEnum] EventListener onselect; attribute [DontEnum] EventListener onsubmit; -#if ENABLE_TOUCH_EVENTS - attribute [DontEnum] EventListener ontouchstart; - attribute [DontEnum] EventListener ontouchend; - attribute [DontEnum] EventListener ontouchmove; - attribute [DontEnum] EventListener ontouchcancel; -#endif // attribute [DontEnum] EventListener oncanplay; // attribute [DontEnum] EventListener oncanplaythrough; @@ -326,6 +320,12 @@ module core { attribute [DontEnum] EventListener onreset; attribute [DontEnum] EventListener onsearch; attribute [DontEnum] EventListener onselectstart; +#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS + attribute [DontEnum] EventListener ontouchstart; + attribute [DontEnum] EventListener ontouchmove; + attribute [DontEnum] EventListener ontouchend; + attribute [DontEnum] EventListener ontouchcancel; +#endif #endif #endif }; diff --git a/WebCore/dom/Element.h b/WebCore/dom/Element.h index 97d3eb4..ce25d70 100644 --- a/WebCore/dom/Element.h +++ b/WebCore/dom/Element.h @@ -88,7 +88,12 @@ public: DEFINE_ATTRIBUTE_EVENT_LISTENER(reset); DEFINE_ATTRIBUTE_EVENT_LISTENER(search); DEFINE_ATTRIBUTE_EVENT_LISTENER(selectstart); - +#if ENABLE(TOUCH_EVENTS) + DEFINE_ATTRIBUTE_EVENT_LISTENER(touchstart); + DEFINE_ATTRIBUTE_EVENT_LISTENER(touchmove); + DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend); + DEFINE_ATTRIBUTE_EVENT_LISTENER(touchcancel); +#endif const AtomicString& getIDAttribute() const; bool hasAttribute(const QualifiedName&) const; const AtomicString& getAttribute(const QualifiedName&) const; diff --git a/WebCore/dom/Element.idl b/WebCore/dom/Element.idl index c24ef65..4a223bb 100644 --- a/WebCore/dom/Element.idl +++ b/WebCore/dom/Element.idl @@ -167,12 +167,6 @@ module core { attribute [DontEnum] EventListener onscroll; attribute [DontEnum] EventListener onselect; attribute [DontEnum] EventListener onsubmit; -#if ENABLE_TOUCH_EVENTS - attribute [DontEnum] EventListener ontouchstart; - attribute [DontEnum] EventListener ontouchend; - attribute [DontEnum] EventListener ontouchmove; - attribute [DontEnum] EventListener ontouchcancel; -#endif // attribute [DontEnum] EventListener oncanplay; // attribute [DontEnum] EventListener oncanplaythrough; @@ -209,6 +203,12 @@ module core { attribute [DontEnum] EventListener onreset; attribute [DontEnum] EventListener onsearch; attribute [DontEnum] EventListener onselectstart; +#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS + attribute [DontEnum] EventListener ontouchstart; + attribute [DontEnum] EventListener ontouchmove; + attribute [DontEnum] EventListener ontouchend; + attribute [DontEnum] EventListener ontouchcancel; +#endif #endif #endif }; diff --git a/WebCore/dom/Event.cpp b/WebCore/dom/Event.cpp index eda44b0..be2b37b 100644 --- a/WebCore/dom/Event.cpp +++ b/WebCore/dom/Event.cpp @@ -180,20 +180,20 @@ bool Event::isStorageEvent() const } #endif -#if ENABLE(TOUCH_EVENTS) // Android -bool Event::isTouchEvent() const +#if ENABLE(WORKERS) +bool Event::isErrorEvent() const { return false; } #endif -#if ENABLE(WORKERS) -bool Event::isErrorEvent() const +#if ENABLE(TOUCH_EVENTS) +bool Event::isTouchEvent() const { return false; } #endif - + bool Event::storesResultAsString() const { return false; diff --git a/WebCore/dom/Event.h b/WebCore/dom/Event.h index 7ec85a7..4624663 100644 --- a/WebCore/dom/Event.h +++ b/WebCore/dom/Event.h @@ -123,12 +123,12 @@ namespace WebCore { #if ENABLE(DOM_STORAGE) virtual bool isStorageEvent() const; #endif -#if ENABLE(TOUCH_EVENTS) // Android - virtual bool isTouchEvent() const; -#endif #if ENABLE(WORKERS) virtual bool isErrorEvent() const; #endif +#if ENABLE(TOUCH_EVENTS) + virtual bool isTouchEvent() const; +#endif bool propagationStopped() const { return m_propagationStopped; } diff --git a/WebCore/dom/EventNames.h b/WebCore/dom/EventNames.h index 63460a5..c8c3291 100644 --- a/WebCore/dom/EventNames.h +++ b/WebCore/dom/EventNames.h @@ -95,14 +95,6 @@ namespace WebCore { macro(storage) \ macro(submit) \ macro(textInput) \ -/* #if ENABLE(TOUCH_EVENTS) // Android */ \ - macro(touchstart) \ - macro(touchmove) \ - macro(touchend) \ - macro(touchcancel) \ - macro(touchlongpress) \ - macro(touchdoubletap) \ -/* #endif */ \ macro(unload) \ macro(updateready) \ macro(zoom) \ @@ -154,6 +146,15 @@ namespace WebCore { \ macro(orientationchange) \ \ + macro(touchstart) \ + macro(touchmove) \ + macro(touchend) \ + macro(touchcancel) \ +/* #if PLATFORM(ANDROID) */ \ + macro(touchlongpress) \ + macro(touchdoubletap) \ +/* #endif */ \ + \ // end of DOM_EVENT_NAMES_FOR_EACH class EventNames : public Noncopyable { diff --git a/WebCore/dom/Node.cpp b/WebCore/dom/Node.cpp index 4ae83de..c2d5281 100644 --- a/WebCore/dom/Node.cpp +++ b/WebCore/dom/Node.cpp @@ -101,6 +101,10 @@ #include "HTMLNoScriptElement.h" #endif +#if ENABLE(TOUCH_EVENTS) +#include "ChromeClient.h" +#endif + #define DUMP_NODE_STATISTICS 0 using namespace std; @@ -2422,16 +2426,8 @@ bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe if (Document* document = this->document()) document->addListenerTypeIfNeeded(eventType); - updateSVGElementInstancesAfterEventListenerChange(this); -#if ENABLE(TOUCH_EVENTS) // Android - if (this->document() && - (eventType == eventNames().touchstartEvent || - eventType == eventNames().touchendEvent || - eventType == eventNames().touchmoveEvent || - eventType == eventNames().touchcancelEvent)) - this->document()->addTouchEventListener(this); -#endif + updateSVGElementInstancesAfterEventListenerChange(this); return true; } @@ -2442,13 +2438,17 @@ bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis updateSVGElementInstancesAfterEventListenerChange(this); -#if ENABLE(TOUCH_EVENTS) // Android - if (this->document() && - (eventType == eventNames().touchstartEvent || - eventType == eventNames().touchendEvent || - eventType == eventNames().touchmoveEvent || - eventType == eventNames().touchcancelEvent)) - this->document()->removeTouchEventListener(this); +#if ENABLE(TOUCH_EVENTS) + if (Document* document = this->document()) { + if (document->page() + && (eventType == eventNames().touchstartEvent + || eventType == eventNames().touchmoveEvent + || eventType == eventNames().touchendEvent + || eventType == eventNames().touchcancelEvent)) + // Note the corresponding needTouchEvents(true) is called in Document::addListenerTypeIfNeeded(). + document->page()->chrome()->client()->needTouchEvents(false); + + } #endif return true; } diff --git a/WebCore/dom/Node.h b/WebCore/dom/Node.h index 7da8634..ebf275a 100644 --- a/WebCore/dom/Node.h +++ b/WebCore/dom/Node.h @@ -565,13 +565,6 @@ public: */ virtual bool disabled() const; -#if ENABLE(TOUCH_EVENTS) // Android - DEFINE_ATTRIBUTE_EVENT_LISTENER(touchstart); - DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend); - DEFINE_ATTRIBUTE_EVENT_LISTENER(touchmove); - DEFINE_ATTRIBUTE_EVENT_LISTENER(touchcancel); -#endif - using TreeShared<Node>::ref; using TreeShared<Node>::deref; diff --git a/WebCore/dom/Touch.cpp b/WebCore/dom/Touch.cpp index 561a786..41d5c19 100644 --- a/WebCore/dom/Touch.cpp +++ b/WebCore/dom/Touch.cpp @@ -25,7 +25,7 @@ #include "config.h" -#if ENABLE(TOUCH_EVENTS) // Android +#if ENABLE(TOUCH_EVENTS) #include "Touch.h" @@ -40,7 +40,7 @@ static int contentsX(Frame* frame) FrameView* frameView = frame->view(); if (!frameView) return 0; - return frameView->scrollX(); + return frameView->scrollX() / frame->pageZoomFactor(); } static int contentsY(Frame* frame) @@ -50,7 +50,7 @@ static int contentsY(Frame* frame) FrameView* frameView = frame->view(); if (!frameView) return 0; - return frameView->scrollY(); + return frameView->scrollY() / frame->pageZoomFactor(); } Touch::Touch(Frame* frame, EventTarget* target, unsigned identifier, diff --git a/WebCore/dom/Touch.h b/WebCore/dom/Touch.h index 62822fb..cf39faf 100644 --- a/WebCore/dom/Touch.h +++ b/WebCore/dom/Touch.h @@ -26,7 +26,7 @@ #ifndef TOUCH_H_ #define TOUCH_H_ -#if ENABLE(TOUCH_EVENTS) // Android +#if ENABLE(TOUCH_EVENTS) #include "EventTarget.h" #include "Frame.h" @@ -36,41 +36,41 @@ namespace WebCore { - class Touch : public RefCounted<Touch> { - public: - static PassRefPtr<Touch> create(Frame* frame, EventTarget* target, - unsigned identifier, int screenX, int screenY, int pageX, int pageY) - { - return adoptRef(new Touch(frame, target, identifier, screenX, - screenY, pageX, pageY)); - } +class Touch : public RefCounted<Touch> { +public: + static PassRefPtr<Touch> create(Frame* frame, EventTarget* target, + unsigned identifier, int screenX, int screenY, int pageX, int pageY) + { + return adoptRef(new Touch(frame, target, identifier, screenX, + screenY, pageX, pageY)); + } - void updateLocation(int screenX, int screenY, int pageX, int pageY); + void updateLocation(int screenX, int screenY, int pageX, int pageY); - Frame* frame() const { return m_frame.get(); } - EventTarget* target() const { return m_target.get(); } - unsigned identifier() const { return m_identifier; } - int clientX() const { return m_clientX; } - int clientY() const { return m_clientY; } - int screenX() const { return m_screenX; } - int screenY() const { return m_screenY; } - int pageX() const { return m_pageX; } - int pageY() const { return m_pageY; } + Frame* frame() const { return m_frame.get(); } + EventTarget* target() const { return m_target.get(); } + unsigned identifier() const { return m_identifier; } + int clientX() const { return m_clientX; } + int clientY() const { return m_clientY; } + int screenX() const { return m_screenX; } + int screenY() const { return m_screenY; } + int pageX() const { return m_pageX; } + int pageY() const { return m_pageY; } - private: - Touch(Frame* frame, EventTarget* target, unsigned identifier, - int screenX, int screenY, int pageX, int pageY); +private: + Touch(Frame* frame, EventTarget* target, unsigned identifier, + int screenX, int screenY, int pageX, int pageY); - RefPtr<Frame> m_frame; - RefPtr<EventTarget> m_target; - unsigned m_identifier; - int m_clientX; - int m_clientY; - int m_screenX; - int m_screenY; - int m_pageX; - int m_pageY; - }; + RefPtr<Frame> m_frame; + RefPtr<EventTarget> m_target; + unsigned m_identifier; + int m_clientX; + int m_clientY; + int m_screenX; + int m_screenY; + int m_pageX; + int m_pageY; +}; } // namespace WebCore diff --git a/WebCore/dom/TouchEvent.cpp b/WebCore/dom/TouchEvent.cpp index 7ce856f..1fbba6c 100644 --- a/WebCore/dom/TouchEvent.cpp +++ b/WebCore/dom/TouchEvent.cpp @@ -25,7 +25,7 @@ #include "config.h" -#if ENABLE(TOUCH_EVENTS) // Android +#if ENABLE(TOUCH_EVENTS) #include "TouchEvent.h" @@ -33,20 +33,24 @@ namespace WebCore { TouchEvent::TouchEvent(TouchList* touches, TouchList* targetTouches, TouchList* changedTouches, const AtomicString& type, - PassRefPtr<AbstractView> view, int screenX, int screenY, int pageX, int pageY) + PassRefPtr<AbstractView> view, int screenX, int screenY, int pageX, int pageY, + bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) : MouseRelatedEvent(type, true, true, view, 0, screenX, screenY, pageX, pageY, - false, false, false, false) + ctrlKey, altKey, shiftKey, metaKey) , m_touches(touches) , m_targetTouches(targetTouches) , m_changedTouches(changedTouches) +#if PLATFORM(ANDROID) , m_longPressPrevented(false) , m_doubleTapPrevented(false) +#endif { } void TouchEvent::initTouchEvent(TouchList* touches, TouchList* targetTouches, TouchList* changedTouches, const AtomicString& type, - PassRefPtr<AbstractView> view, int screenX, int screenY, int clientX, int clientY) + PassRefPtr<AbstractView> view, int screenX, int screenY, int clientX, int clientY, + bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) { if (dispatched()) return; @@ -55,6 +59,10 @@ void TouchEvent::initTouchEvent(TouchList* touches, TouchList* targetTouches, m_screenX = screenX; m_screenY = screenY; + m_ctrlKey = ctrlKey; + m_altKey = altKey; + m_shiftKey = shiftKey; + m_metaKey = metaKey; initCoordinates(clientX, clientY); } diff --git a/WebCore/dom/TouchEvent.h b/WebCore/dom/TouchEvent.h index 6b7d384..abc1ee2 100644 --- a/WebCore/dom/TouchEvent.h +++ b/WebCore/dom/TouchEvent.h @@ -26,61 +26,69 @@ #ifndef TouchEvent_h #define TouchEvent_h -#if ENABLE(TOUCH_EVENTS) // Android +#if ENABLE(TOUCH_EVENTS) #include "MouseRelatedEvent.h" #include "TouchList.h" namespace WebCore { - class TouchEvent : public MouseRelatedEvent { - public: - static PassRefPtr<TouchEvent> create() - { - return adoptRef(new TouchEvent); - } - static PassRefPtr<TouchEvent> create(TouchList* touches, - TouchList* targetTouches, TouchList* changedTouches, - const AtomicString& type, PassRefPtr<AbstractView> view, - int screenX, int screenY, int pageX, int pageY) - { - return adoptRef(new TouchEvent(touches, targetTouches, changedTouches, - type, view, screenX, screenY, pageX, pageY)); - } - - void initTouchEvent(TouchList* touches, TouchList* targetTouches, - TouchList* changedTouches, const AtomicString& type, - PassRefPtr<AbstractView> view, int screenX, int screenY, - int clientX, int clientY); - - TouchList* touches() const {return m_touches.get();} - TouchList* targetTouches() const {return m_targetTouches.get();} - TouchList* changedTouches() const {return m_changedTouches.get();} - - bool longPressPrevented() const { return m_longPressPrevented; } - void preventLongPress() { m_longPressPrevented = true; } - void setLongPressPrevented(bool prevented) { m_longPressPrevented = prevented; } - - bool doubleTapPrevented() const { return m_doubleTapPrevented; } - void preventDoubleTap() { m_doubleTapPrevented = true; } - void setDoubleTapPrevented(bool prevented) { m_doubleTapPrevented = prevented; } - - private: - TouchEvent() {} - TouchEvent(TouchList* touches, TouchList* targetTouches, - TouchList* changedTouches, const AtomicString& type, - PassRefPtr<AbstractView>, int screenX, int screenY, int pageX, - int pageY); - - virtual bool isTouchEvent() const {return true;} - - RefPtr<TouchList> m_touches; - RefPtr<TouchList> m_targetTouches; - RefPtr<TouchList> m_changedTouches; - - bool m_longPressPrevented; - bool m_doubleTapPrevented; - }; +class TouchEvent : public MouseRelatedEvent { +public: + static PassRefPtr<TouchEvent> create() + { + return adoptRef(new TouchEvent); + } + static PassRefPtr<TouchEvent> create(TouchList* touches, + TouchList* targetTouches, TouchList* changedTouches, + const AtomicString& type, PassRefPtr<AbstractView> view, + int screenX, int screenY, int pageX, int pageY, + bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) + { + return adoptRef(new TouchEvent(touches, targetTouches, changedTouches, + type, view, screenX, screenY, pageX, pageY, + ctrlKey, altKey, shiftKey, metaKey)); + } + + void initTouchEvent(TouchList* touches, TouchList* targetTouches, + TouchList* changedTouches, const AtomicString& type, + PassRefPtr<AbstractView> view, int screenX, int screenY, + int clientX, int clientY, + bool ctrlKey, bool altKey, bool shiftKey, bool metaKey); + + TouchList* touches() const { return m_touches.get(); } + TouchList* targetTouches() const { return m_targetTouches.get(); } + TouchList* changedTouches() const { return m_changedTouches.get(); } + +#if PLATFORM(ANDROID) + bool longPressPrevented() const { return m_longPressPrevented; } + void preventLongPress() { m_longPressPrevented = true; } + void setLongPressPrevented(bool prevented) { m_longPressPrevented = prevented; } + + bool doubleTapPrevented() const { return m_doubleTapPrevented; } + void preventDoubleTap() { m_doubleTapPrevented = true; } + void setDoubleTapPrevented(bool prevented) { m_doubleTapPrevented = prevented; } +#endif + +private: + TouchEvent() {} + TouchEvent(TouchList* touches, TouchList* targetTouches, + TouchList* changedTouches, const AtomicString& type, + PassRefPtr<AbstractView>, int screenX, int screenY, int pageX, + int pageY, + bool ctrlKey, bool altKey, bool shiftKey, bool metaKey); + + virtual bool isTouchEvent() const { return true; } + + RefPtr<TouchList> m_touches; + RefPtr<TouchList> m_targetTouches; + RefPtr<TouchList> m_changedTouches; + +#if PLATFORM(ANDROID) + bool m_longPressPrevented; + bool m_doubleTapPrevented; +#endif +}; } // namespace WebCore diff --git a/WebCore/dom/TouchEvent.idl b/WebCore/dom/TouchEvent.idl index b7148b0..010c36f 100644 --- a/WebCore/dom/TouchEvent.idl +++ b/WebCore/dom/TouchEvent.idl @@ -32,6 +32,10 @@ module events { readonly attribute TouchList touches; readonly attribute TouchList targetTouches; readonly attribute TouchList changedTouches; + readonly attribute boolean ctrlKey; + readonly attribute boolean shiftKey; + readonly attribute boolean altKey; + readonly attribute boolean metaKey; void initTouchEvent(in TouchList touches, in TouchList targetTouches, @@ -41,6 +45,10 @@ module events { in long screenX, in long screenY, in long clientX, - in long clientY); + in long clientY, + in boolean ctrlKey, + in boolean altKey, + in boolean shiftKey, + in boolean metaKey); }; } diff --git a/WebCore/dom/TouchList.cpp b/WebCore/dom/TouchList.cpp index 78b588e..4167e42 100644 --- a/WebCore/dom/TouchList.cpp +++ b/WebCore/dom/TouchList.cpp @@ -25,7 +25,7 @@ #include "config.h" -#if ENABLE(TOUCH_EVENTS) // Android +#if ENABLE(TOUCH_EVENTS) #include "TouchList.h" diff --git a/WebCore/dom/TouchList.h b/WebCore/dom/TouchList.h index fa5fc80..f5033c9 100644 --- a/WebCore/dom/TouchList.h +++ b/WebCore/dom/TouchList.h @@ -26,7 +26,7 @@ #ifndef TOUCHLIST_H_ #define TOUCHLIST_H_ -#if ENABLE(TOUCH_EVENTS) // Android +#if ENABLE(TOUCH_EVENTS) #include <wtf/RefCounted.h> #include <wtf/Vector.h> @@ -34,24 +34,24 @@ namespace WebCore { - class TouchList : public RefCounted<TouchList> { - public: - static PassRefPtr<TouchList> create() - { - return adoptRef(new TouchList); - } +class TouchList : public RefCounted<TouchList> { +public: + static PassRefPtr<TouchList> create() + { + return adoptRef(new TouchList); + } - unsigned length() const { return m_values.size(); } + unsigned length() const { return m_values.size(); } - Touch* item (unsigned); + Touch* item(unsigned); - void append(const PassRefPtr<Touch> touch) { m_values.append(touch); } + void append(const PassRefPtr<Touch> touch) { m_values.append(touch); } - private: - TouchList() {} +private: + TouchList() {} - Vector<RefPtr<Touch> > m_values; - }; + Vector<RefPtr<Touch> > m_values; +}; } // namespace WebCore diff --git a/WebCore/html/HTMLAttributeNames.in b/WebCore/html/HTMLAttributeNames.in index c989dbd..967b695 100644 --- a/WebCore/html/HTMLAttributeNames.in +++ b/WebCore/html/HTMLAttributeNames.in @@ -199,12 +199,10 @@ onstorage onsuspend onsubmit ontimeupdate -/* #if ENABLE(TOUCH_EVENTS) // Android */ ontouchstart ontouchmove ontouchend ontouchcancel -/* #endif */ onunload onvolumechange onwaiting diff --git a/WebCore/html/HTMLElement.cpp b/WebCore/html/HTMLElement.cpp index af15f6e..a4fc52a 100644 --- a/WebCore/html/HTMLElement.cpp +++ b/WebCore/html/HTMLElement.cpp @@ -218,20 +218,18 @@ void HTMLElement::parseMappedAttribute(MappedAttribute *attr) setAttributeEventListener(eventNames().webkitAnimationEndEvent, createAttributeEventListener(this, attr)); } else if (attr->name() == onwebkittransitionendAttr) { setAttributeEventListener(eventNames().webkitTransitionEndEvent, createAttributeEventListener(this, attr)); -#if ENABLE(TOUCH_EVENTS) // Android + } else if (attr->name() == oninputAttr) { + setAttributeEventListener(eventNames().inputEvent, createAttributeEventListener(this, attr)); + } else if (attr->name() == oninvalidAttr) { + setAttributeEventListener(eventNames().invalidEvent, createAttributeEventListener(this, attr)); } else if (attr->name() == ontouchstartAttr) { setAttributeEventListener(eventNames().touchstartEvent, createAttributeEventListener(this, attr)); - } else if (attr->name() == ontouchendAttr) { - setAttributeEventListener(eventNames().touchendEvent, createAttributeEventListener(this, attr)); } else if (attr->name() == ontouchmoveAttr) { setAttributeEventListener(eventNames().touchmoveEvent, createAttributeEventListener(this, attr)); + } else if (attr->name() == ontouchendAttr) { + setAttributeEventListener(eventNames().touchendEvent, createAttributeEventListener(this, attr)); } else if (attr->name() == ontouchcancelAttr) { setAttributeEventListener(eventNames().touchcancelEvent, createAttributeEventListener(this, attr)); -#endif - } else if (attr->name() == oninputAttr) { - setAttributeEventListener(eventNames().inputEvent, createAttributeEventListener(this, attr)); - } else if (attr->name() == oninvalidAttr) { - setAttributeEventListener(eventNames().invalidEvent, createAttributeEventListener(this, attr)); } } diff --git a/WebCore/page/ChromeClient.h b/WebCore/page/ChromeClient.h index 117953c..b28473b 100644 --- a/WebCore/page/ChromeClient.h +++ b/WebCore/page/ChromeClient.h @@ -225,6 +225,10 @@ namespace WebCore { virtual void willPopUpMenu(NSMenu *) { } #endif +#if ENABLE(TOUCH_EVENTS) + virtual void needTouchEvents(bool, bool force = false) = 0; +#endif + protected: virtual ~ChromeClient() { } }; diff --git a/WebCore/page/Connection.cpp b/WebCore/page/Connection.cpp new file mode 100644 index 0000000..ffbb838 --- /dev/null +++ b/WebCore/page/Connection.cpp @@ -0,0 +1,39 @@ +/* + * 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 "Connection.h" + +#include "NetworkStateNotifier.h" + +namespace WebCore { + +Connection::ConnectionType Connection::type() const +{ + return networkStateNotifier().type(); +} + +};
\ No newline at end of file diff --git a/WebCore/page/Connection.h b/WebCore/page/Connection.h new file mode 100644 index 0000000..837a36f --- /dev/null +++ b/WebCore/page/Connection.h @@ -0,0 +1,54 @@ +/* + * 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 Connection_h +#define Connection_h + +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> + +namespace WebCore { + +class Connection : public RefCounted<Connection> { +public: + enum ConnectionType { + Unknown = 0, + Ethernet = 1, + WiFi = 2, + Cell_2G = 3, + Cell_3G = 4, + }; + + static PassRefPtr<Connection> create() { return adoptRef(new Connection()); } + + ConnectionType type() const; + +private: + Connection() { } +}; + +} // namespace WebCore + +#endif // Connection_h diff --git a/WebCore/page/Connection.idl b/WebCore/page/Connection.idl new file mode 100644 index 0000000..b4cfbd1 --- /dev/null +++ b/WebCore/page/Connection.idl @@ -0,0 +1,38 @@ +/* + * 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. + */ + + module core { + + interface Connection { + readonly attribute unsigned short type; + + const unsigned short UNKNOWN = 0; + const unsigned short ETHERNET = 1; + const unsigned short WIFI = 2; + const unsigned short CELL_2G = 3; + const unsigned short CELL_3G = 4; + }; + +} diff --git a/WebCore/page/DOMWindow.h b/WebCore/page/DOMWindow.h index 5e2d990..0aee619 100644 --- a/WebCore/page/DOMWindow.h +++ b/WebCore/page/DOMWindow.h @@ -322,13 +322,12 @@ namespace WebCore { DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(webkitanimationend, webkitAnimationEnd); DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(webkittransitionend, webkitTransitionEnd); -#if ENABLE(TOUCH_EVENTS) // Android +#if ENABLE(TOUCH_EVENTS) DEFINE_ATTRIBUTE_EVENT_LISTENER(touchstart); - DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend); DEFINE_ATTRIBUTE_EVENT_LISTENER(touchmove); + DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend); DEFINE_ATTRIBUTE_EVENT_LISTENER(touchcancel); #endif - void captureEvents(); void releaseEvents(); diff --git a/WebCore/page/DOMWindow.idl b/WebCore/page/DOMWindow.idl index c4b08c6..cfc9401 100644 --- a/WebCore/page/DOMWindow.idl +++ b/WebCore/page/DOMWindow.idl @@ -206,12 +206,6 @@ module window { raises(DOMException); // Events -#if ENABLE_TOUCH_EVENTS - attribute EventListener ontouchstart; - attribute EventListener ontouchend; - attribute EventListener ontouchmove; - attribute EventListener ontouchcancel; -#endif attribute EventListener onabort; attribute EventListener onbeforeunload; @@ -296,6 +290,12 @@ module window { #if defined(ENABLE_ORIENTATION_EVENTS) && ENABLE_ORIENTATION_EVENTS attribute EventListener onorientationchange; #endif +#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS + attribute [DontEnum] EventListener ontouchstart; + attribute [DontEnum] EventListener ontouchmove; + attribute [DontEnum] EventListener ontouchend; + attribute [DontEnum] EventListener ontouchcancel; +#endif // EventTarget interface [Custom] void addEventListener(in DOMString type, @@ -466,9 +466,6 @@ module window { attribute WheelEventConstructor WheelEvent; attribute MessageEventConstructor MessageEvent; attribute EventExceptionConstructor EventException; -#if ENABLE_TOUCH_EVENTS - attribute TouchEventConstructor TouchEvent; -#endif attribute WebKitCSSKeyframeRuleConstructor WebKitCSSKeyframeRule; attribute WebKitCSSKeyframesRuleConstructor WebKitCSSKeyframesRule; @@ -576,6 +573,10 @@ module window { #endif #endif +#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS + attribute TouchEventConstructor TouchEvent; +#endif + #endif // defined(LANGUAGE_JAVASCRIPT) #if defined(V8_BINDING) && V8_BINDING diff --git a/WebCore/page/EventHandler.cpp b/WebCore/page/EventHandler.cpp index 8b6b602..a7dc13a 100644 --- a/WebCore/page/EventHandler.cpp +++ b/WebCore/page/EventHandler.cpp @@ -56,6 +56,7 @@ #include "Page.h" #include "PlatformKeyboardEvent.h" #include "PlatformWheelEvent.h" +#include "PluginView.h" #include "RenderFrameSet.h" #include "RenderTextControlSingleLine.h" #include "RenderView.h" @@ -74,9 +75,9 @@ #include "SVGUseElement.h" #endif -#if ENABLE(TOUCH_EVENTS) // Android -#include "TouchEvent.h" +#if ENABLE(TOUCH_EVENTS) #include "PlatformTouchEvent.h" +#include "TouchEvent.h" #endif #if defined(ANDROID_PLUGINS) @@ -207,8 +208,16 @@ void EventHandler::clear() m_lastScrollbarUnderMouse = 0; m_clickCount = 0; m_clickNode = 0; -#if ENABLE(TOUCH_EVENTS) // Android - m_touch = 0; +#if ENABLE(TOUCH_EVENTS) + m_touchEventTarget = 0; + if (Document* doc = m_frame->document()) { + if (Page* page = doc->page()) { + // We are clearing event handlers, which includes any touch + // event handlers so force webkit to tell the chrome client to + // stop forwarding the events. + page->chrome()->client()->needTouchEvents(false, true); + } + } #endif m_frameSetBeingResized = 0; #if ENABLE(DRAG_SUPPORT) @@ -2546,141 +2555,221 @@ bool EventHandler::passMousePressEventToScrollbar(MouseEventWithHitTestResults& return scrollbar->mouseDown(mev.event()); } -#if ENABLE(TOUCH_EVENTS) // Android -int EventHandler::handleTouchEvent(const PlatformTouchEvent& e) +// If scrollbar (under mouse) is different from last, send a mouse exited. Set +// last to scrollbar if setLast is true; else set last to 0. +void EventHandler::updateLastScrollbarUnderMouse(Scrollbar* scrollbar, bool setLast) { - // only handle the touch event in the top frame handler - if (m_frame->tree()->parent(true)) - return m_frame->tree()->parent()->eventHandler()->handleTouchEvent(e); - - Document* doc = m_frame->document(); - if (!doc) - return 0; - - RenderObject* docRenderer = doc->renderer(); - if (!docRenderer) - return 0; - - if (doc->touchEventListeners().size() == 0) - return 0; + if (m_lastScrollbarUnderMouse != scrollbar) { + // Send mouse exited to the old scrollbar. + if (m_lastScrollbarUnderMouse) + m_lastScrollbarUnderMouse->mouseExited(); + m_lastScrollbarUnderMouse = setLast ? scrollbar : 0; + } +} - TouchEventType type = e.eventType(); - if (type == TouchEventStart || type == TouchEventLongPress || type == TouchEventDoubleTap) { - Frame* frame = m_frame; - IntPoint vPoint = frame->view()->windowToContents(e.pos()); - HitTestRequest request(HitTestRequest::ReadOnly); - HitTestResult result(vPoint); - frame->contentRenderer()->layer()->hitTest(request, result); - Node* node = result.innerNode(); - if (node) { - RenderObject* target = node->renderer(); - while (target && target->isWidget()) { - Widget* widget = static_cast<RenderWidget*>(target)->widget(); - if (widget->isFrameView()) { - frame = static_cast<FrameView*>(widget)->frame(); - vPoint = frame->view()->windowToContents(e.pos()); - HitTestResult ret(vPoint); - frame->contentRenderer()->layer()->hitTest(request, ret); - node = ret.innerNode(); - if (!node) - break; - else - target = node->renderer(); - } else - // plugin view?? - break; - } +#if ENABLE(TOUCH_EVENTS) +#if PLATFORM(ANDROID) +// TODO(benm): On Android we return an int back to Java to signify whether the default actions +// for longpress/doubletap in the Browser should be prevented. I think that before upstreaming +// to webkit.org we can refactor the Java side to not require this. +int EventHandler::handleTouchEvent(const PlatformTouchEvent& event) +#else +bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) +#endif +{ + RefPtr<TouchList> touches = TouchList::create(); + RefPtr<TouchList> pressedTouches = TouchList::create(); + RefPtr<TouchList> releasedTouches = TouchList::create(); + RefPtr<TouchList> movedTouches = TouchList::create(); + RefPtr<TouchList> targetTouches = TouchList::create(); + RefPtr<TouchList> cancelTouches = TouchList::create(); + + const Vector<PlatformTouchPoint>& points = event.touchPoints(); + AtomicString* eventName = 0; + + for (int i = 0; i < points.size(); ++i) { + const PlatformTouchPoint& point = points[i]; + IntPoint framePoint = documentPointForWindowPoint(m_frame, point.pos()); + HitTestResult result = hitTestResultAtPoint(framePoint, /*allowShadowContent*/ false); + Node* target = result.innerNode(); + + // Touch events should not go to text nodes + if (target && target->isTextNode()) + target = target->parentNode(); + + Document* doc = target->document(); + if (!doc) + continue; + if (!doc->hasListenerType(Document::TOUCH_LISTENER)) + continue; + + int adjustedPageX = lroundf(framePoint.x() / m_frame->pageZoomFactor()); + int adjustedPageY = lroundf(framePoint.y() / m_frame->pageZoomFactor()); + + if ( (event.type() == TouchStart +#if PLATFORM(ANDROID) + || event.type() == TouchDoubleTap + || event.type() == TouchLongPress +#endif + ) && !i) { + m_touchEventTarget = target; + m_firstTouchScreenPos = point.screenPos(); + m_firstTouchPagePos = framePoint; } - if (!node) { - // reset to the top document node - node = doc; - frame = m_frame; - vPoint = frame->view()->windowToContents(e.pos()); - } + RefPtr<Touch> touch = Touch::create(m_frame, m_touchEventTarget.get(), point.id(), + point.screenPos().x(), point.screenPos().y(), + adjustedPageX, adjustedPageY); - m_touch = Touch::create(frame, node, 0, - e.x(), e.y(), vPoint.x(), vPoint.y()); - } else if (m_touch) { - if ((type == TouchEventMove) && (e.x() == m_touch->screenX()) && - (e.y() == m_touch->screenY())) { - // don't trigger the event if it hasn't really moved - return 0; + if (point.state() == PlatformTouchPoint::TouchReleased) + releasedTouches->append(touch); + else if (point.state() == PlatformTouchPoint::TouchCancelled) + cancelTouches->append(touch); + else { + if (point.state() == PlatformTouchPoint::TouchPressed) + pressedTouches->append(touch); + else { + touches->append(touch); + if (m_touchEventTarget == target) + targetTouches->append(touch); + if (point.state() == PlatformTouchPoint::TouchMoved) + movedTouches->append(touch); + } } + } - IntPoint vPoint = m_touch->frame()->view()->windowToContents(e.pos()); - m_touch->updateLocation(e.x(), e.y(), vPoint.x(), vPoint.y()); - } else { + if (!m_touchEventTarget) +#if PLATFORM(ANDROID) return 0; - } +#else + return false; +#endif - RefPtr<TouchList> touchList = TouchList::create(); - touchList->append(m_touch); - // For TouchEventEnd, touches and targetTouches are empty list - RefPtr<TouchList> emptyList = TouchList::create(); - RefPtr<TouchEvent> te; - switch(type) { - case TouchEventStart: - te = TouchEvent::create(touchList.get(), touchList.get(), touchList.get(), - eventNames().touchstartEvent, m_touch->frame()->document()->defaultView(), - m_touch->screenX(), m_touch->screenY(), m_touch->pageX(), m_touch->pageY()); - break; + bool defaultPrevented = false; +#if PLATFORM(ANDROID) + // TODO (benm): We should be able to remove this prior to upstreaming once Java side refactorings to make + // preventDeault work better are complete. + bool longPressPrevented = false; + bool doubleTapPrevented = false; +#endif - case TouchEventEnd: - te = TouchEvent::create(emptyList.get(), emptyList.get(), touchList.get(), - eventNames().touchendEvent, m_touch->frame()->document()->defaultView(), - m_touch->screenX(), m_touch->screenY(), m_touch->pageX(), m_touch->pageY()); - break; + if (event.type() == TouchCancel) { + eventName = &eventNames().touchcancelEvent; + RefPtr<TouchEvent> cancelEv = + TouchEvent::create(TouchList::create().get(), TouchList::create().get(), cancelTouches.get(), + *eventName, m_touchEventTarget->document()->defaultView(), + m_firstTouchScreenPos.x(), m_firstTouchScreenPos.y(), + m_firstTouchPagePos.x(), m_firstTouchPagePos.y(), + event.ctrlKey(), event.altKey(), event.shiftKey(), + event.metaKey()); + + ExceptionCode ec = 0; + m_touchEventTarget->dispatchEvent(cancelEv.get(), ec); + defaultPrevented |= cancelEv->defaultPrevented(); + } + + if (releasedTouches->length() > 0) { + eventName = &eventNames().touchendEvent; + + RefPtr<TouchEvent> endEv = + TouchEvent::create(touches.get(), targetTouches.get(), releasedTouches.get(), + *eventName, m_touchEventTarget->document()->defaultView(), + m_firstTouchScreenPos.x(), m_firstTouchScreenPos.y(), + m_firstTouchPagePos.x(), m_firstTouchPagePos.y(), + event.ctrlKey(), event.altKey(), event.shiftKey(), + event.metaKey()); + + ExceptionCode ec = 0; + m_touchEventTarget->dispatchEvent(endEv.get(), ec); + defaultPrevented |= endEv->defaultPrevented(); + } + + if (pressedTouches->length() > 0) { + // Add pressed touchpoints to touches and targetTouches. + for (int i = 0; i < pressedTouches->length(); ++i) { + touches->append(pressedTouches->item(i)); + if (m_touchEventTarget == pressedTouches->item(i)->target()) + targetTouches->append(pressedTouches->item(i)); + } - case TouchEventMove: - te = TouchEvent::create(touchList.get(), touchList.get(), touchList.get(), - eventNames().touchmoveEvent, m_touch->frame()->document()->defaultView(), - m_touch->screenX(), m_touch->screenY(), m_touch->pageX(), m_touch->pageY()); - break; +#if PLATFORM(ANDROID) + if (event.type() == TouchLongPress) { + eventName = &eventNames().touchlongpressEvent; + RefPtr<TouchEvent> longpressEv = + TouchEvent::create(touches.get(), targetTouches.get(), pressedTouches.get(), + *eventName, m_touchEventTarget->document()->defaultView(), + m_firstTouchScreenPos.x(), m_firstTouchScreenPos.y(), + m_firstTouchPagePos.x(), m_firstTouchPagePos.y(), + event.ctrlKey(), event.altKey(), event.shiftKey(), + event.metaKey()); + + ExceptionCode ec = 0; + m_touchEventTarget->dispatchEvent(longpressEv.get(), ec); + defaultPrevented |= longpressEv->defaultPrevented(); + } else if (event.type() == TouchDoubleTap) { + eventName = &eventNames().touchdoubletapEvent; + RefPtr<TouchEvent> doubleTapEv = + TouchEvent::create(touches.get(), targetTouches.get(), pressedTouches.get(), + *eventName, m_touchEventTarget->document()->defaultView(), + m_firstTouchScreenPos.x(), m_firstTouchScreenPos.y(), + m_firstTouchPagePos.x(), m_firstTouchPagePos.y(), + event.ctrlKey(), event.altKey(), event.shiftKey(), + event.metaKey()); + + ExceptionCode ec = 0; + m_touchEventTarget->dispatchEvent(doubleTapEv.get(), ec); + defaultPrevented |= doubleTapEv->defaultPrevented(); + } else { +#endif + eventName = &eventNames().touchstartEvent; + RefPtr<TouchEvent> startEv = + TouchEvent::create(touches.get(), targetTouches.get(), pressedTouches.get(), + *eventName, m_touchEventTarget->document()->defaultView(), + m_firstTouchScreenPos.x(), m_firstTouchScreenPos.y(), + m_firstTouchPagePos.x(), m_firstTouchPagePos.y(), + event.ctrlKey(), event.altKey(), event.shiftKey(), + event.metaKey()); + ExceptionCode ec = 0; + m_touchEventTarget->dispatchEvent(startEv.get(), ec); + defaultPrevented |= startEv->defaultPrevented(); +#if PLATFORM(ANDROID) + longPressPrevented |= startEv->longPressPrevented(); + doubleTapPrevented |= startEv->doubleTapPrevented(); + } +#endif + } - case TouchEventCancel: - te = TouchEvent::create(touchList.get(), touchList.get(), touchList.get(), - eventNames().touchcancelEvent, m_touch->frame()->document()->defaultView(), - m_touch->screenX(), m_touch->screenY(), m_touch->pageX(), m_touch->pageY()); - break; + if (movedTouches->length() > 0) { + eventName = &eventNames().touchmoveEvent; + RefPtr<TouchEvent> moveEv = + TouchEvent::create(touches.get(), targetTouches.get(), movedTouches.get(), + *eventName, m_touchEventTarget->document()->defaultView(), + m_firstTouchScreenPos.x(), m_firstTouchScreenPos.y(), + m_firstTouchPagePos.x(), m_firstTouchPagePos.y(), + event.ctrlKey(), event.altKey(), event.shiftKey(), + event.metaKey()); + ExceptionCode ec = 0; + m_touchEventTarget->dispatchEvent(moveEv.get(), ec); + defaultPrevented |= moveEv->defaultPrevented(); + } - case TouchEventLongPress: - te = TouchEvent::create(touchList.get(), touchList.get(), touchList.get(), - eventNames().touchlongpressEvent, m_touch->frame()->document()->defaultView(), - m_touch->screenX(), m_touch->screenY(), m_touch->pageX(), m_touch->pageY()); - break; - case TouchEventDoubleTap: - te = TouchEvent::create(touchList.get(), touchList.get(), touchList.get(), - eventNames().touchdoubletapEvent, m_touch->frame()->document()->defaultView(), - m_touch->screenX(), m_touch->screenY(), m_touch->pageX(), m_touch->pageY()); - break; + if (event.type() == TouchEnd || event.type() == TouchCancel) + m_touchEventTarget = 0; - default: - return false; - } - ExceptionCode ec = 0; - m_touch->target()->dispatchEvent(te.get(), ec); - if (type == TouchEventEnd || type == TouchEventCancel) - m_touch = 0; - if (type == TouchEventLongPress || type == TouchEventDoubleTap) +#if PLATFORM(ANDROID) + // TODO (benm): We should be able to remove this prior to upstreaming once Java side refactorings to make + // preventDefault work better are complete. + if (event.type() == TouchLongPress || event.type() == TouchDoubleTap) return 0; - return (te->defaultPrevented() ? preventTouch : 0) - | (te->longPressPrevented() ? preventLongPress : 0) - | (te->doubleTapPrevented() ? preventDoubleTap : 0); -} -#endif -// If scrollbar (under mouse) is different from last, send a mouse exited. Set -// last to scrollbar if setLast is true; else set last to 0. -void EventHandler::updateLastScrollbarUnderMouse(Scrollbar* scrollbar, bool setLast) -{ - if (m_lastScrollbarUnderMouse != scrollbar) { - // Send mouse exited to the old scrollbar. - if (m_lastScrollbarUnderMouse) - m_lastScrollbarUnderMouse->mouseExited(); - m_lastScrollbarUnderMouse = setLast ? scrollbar : 0; - } + return (defaultPrevented ? preventTouch : 0) + | (longPressPrevented ? preventLongPress : 0) + | (doubleTapPrevented ? preventDoubleTap : 0); +#else + return defaultPrevented; +#endif } +#endif } diff --git a/WebCore/page/EventHandler.h b/WebCore/page/EventHandler.h index 0da44f2..8ccd761 100644 --- a/WebCore/page/EventHandler.h +++ b/WebCore/page/EventHandler.h @@ -52,6 +52,7 @@ class KeyboardEvent; class MouseEventWithHitTestResults; class Node; class PlatformKeyboardEvent; +class PlatformTouchEvent; class PlatformWheelEvent; class RenderLayer; class RenderObject; @@ -60,11 +61,8 @@ class Scrollbar; class String; class SVGElementInstance; class TextEvent; +class TouchEvent; class Widget; -#if ENABLE(TOUCH_EVENTS) // Android -class PlatformTouchEvent; -class Touch; -#endif #if ENABLE(DRAG_SUPPORT) extern const int LinkDragHysteresis; @@ -75,13 +73,16 @@ extern const int GeneralDragHysteresis; enum HitTestScrollbars { ShouldHitTestScrollbars, DontHitTestScrollbars }; -#if ENABLE(TOUCH_EVENTS) // Android +#if PLATFORM(ANDROID) +// TODO (benm): I think with some Java refactoring we can remove this before upstreaming to webkit.org. +#if ENABLE(TOUCH_EVENTS) enum TouchResultMask { preventTouch = 1 << 0, preventLongPress = 1 << 1, preventDoubleTap = 1 << 2, }; #endif +#endif class EventHandler : public Noncopyable { public: @@ -151,11 +152,6 @@ public: bool handleMouseReleaseEvent(const PlatformMouseEvent&); bool handleWheelEvent(PlatformWheelEvent&); -#if ENABLE(TOUCH_EVENTS) // Android - // See TouchResultMask for the return value options - int handleTouchEvent(const PlatformTouchEvent&); -#endif - #if ENABLE(CONTEXT_MENUS) bool sendContextMenuEvent(const PlatformMouseEvent&); #endif @@ -208,6 +204,14 @@ public: static NSEvent *currentNSEvent(); #endif +#if ENABLE(TOUCH_EVENTS) +#if PLATFORM(ANDROID) + int handleTouchEvent(const PlatformTouchEvent&); +#else + bool handleTouchEvent(const PlatformTouchEvent&); +#endif +#endif + private: #if ENABLE(DRAG_SUPPORT) enum DragAndDropHandleType { @@ -389,9 +393,6 @@ private: int m_clickCount; RefPtr<Node> m_clickNode; -#if ENABLE(TOUCH_EVENTS) // Android - RefPtr<Touch> m_touch; -#endif #if ENABLE(DRAG_SUPPORT) RefPtr<Node> m_dragTarget; @@ -418,6 +419,12 @@ private: bool m_sendingEventToSubview; int m_activationEventNumber; #endif +#if ENABLE(TOUCH_EVENTS) + RefPtr<Node> m_touchEventTarget; + IntPoint m_firstTouchScreenPos; + IntPoint m_firstTouchPagePos; +#endif + }; } // namespace WebCore diff --git a/WebCore/page/Geolocation.cpp b/WebCore/page/Geolocation.cpp index 5fbad47..f0578a8 100644 --- a/WebCore/page/Geolocation.cpp +++ b/WebCore/page/Geolocation.cpp @@ -39,10 +39,45 @@ #include "SQLValue.h" #include <wtf/CurrentTime.h> +#if ENABLE(CLIENT_BASED_GEOLOCATION) +#include "Coordinates.h" +#include "GeolocationController.h" +#include "GeolocationError.h" +#include "GeolocationPosition.h" +#include "Geoposition.h" +#include "PositionError.h" +#endif + namespace WebCore { static const char permissionDeniedErrorMessage[] = "User denied Geolocation"; +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +static PassRefPtr<Geoposition> createGeoposition(GeolocationPosition* position) +{ + RefPtr<Coordinates> coordinates = Coordinates::create(position->latitude(), position->longitude(), position->canProvideAltitude(), position->altitude(), + position->accuracy(), position->canProvideAltitudeAccuracy(), position->altitudeAccuracy(), + position->canProvideHeading(), position->heading(), position->canProvideSpeed(), position->speed()); + return Geoposition::create(coordinates.release(), position->timestamp()); +} + +static PassRefPtr<PositionError> createPositionError(GeolocationError* error) +{ + PositionError::ErrorCode code = PositionError::POSITION_UNAVAILABLE; + switch (error->code()) { + case GeolocationError::PermissionDenied: + code = PositionError::PERMISSION_DENIED; + break; + case GeolocationError::PositionUnavailable: + code = PositionError::POSITION_UNAVAILABLE; + break; + } + + return PositionError::create(code, error->message()); +} +#endif + Geolocation::GeoNotifier::GeoNotifier(Geolocation* geolocation, PassRefPtr<PositionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> options) : m_geolocation(geolocation) , m_successCallback(successCallback) @@ -305,7 +340,9 @@ String* CachedPositionManager::s_databaseFile = 0; Geolocation::Geolocation(Frame* frame) : EventListener(GeolocationEventListenerType) , m_frame(frame) +#if !ENABLE(CLIENT_BASED_GEOLOCATION) , m_service(GeolocationService::create(this)) +#endif , m_allowGeolocation(Unknown) , m_shouldClearCache(false) , m_cachedPositionManager(new CachedPositionManager) @@ -327,7 +364,7 @@ Geolocation::~Geolocation() void Geolocation::disconnectFrame() { - m_service->stopUpdating(); + stopUpdating(); if (m_frame && m_frame->document()) m_frame->document()->setUsingGeolocation(false); m_frame = 0; @@ -335,6 +372,24 @@ void Geolocation::disconnectFrame() delete m_cachedPositionManager; } +Geoposition* Geolocation::lastPosition() +{ +#if ENABLE(CLIENT_BASED_GEOLOCATION) + if (!m_frame) + return 0; + + Page* page = m_frame->page(); + if (!page) + return 0; + + m_lastPosition = createGeoposition(page->geolocationController()->lastPosition()); +#else + m_lastPosition = m_service->lastPosition(); +#endif + + return m_lastPosition.get(); +} + void Geolocation::getCurrentPosition(PassRefPtr<PositionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> options) { RefPtr<GeoNotifier> notifier = startRequest(successCallback, errorCallback, options); @@ -391,7 +446,7 @@ void Geolocation::fatalErrorOccurred(Geolocation::GeoNotifier* notifier) m_watchers.remove(notifier); if (!hasListeners()) - m_service->stopUpdating(); + stopUpdating(); } void Geolocation::requestTimedOut(GeoNotifier* notifier) @@ -400,7 +455,7 @@ void Geolocation::requestTimedOut(GeoNotifier* notifier) m_oneShots.remove(notifier); if (!hasListeners()) - m_service->stopUpdating(); + stopUpdating(); } void Geolocation::requestReturnedCachedPosition(GeoNotifier* notifier) @@ -408,11 +463,11 @@ void Geolocation::requestReturnedCachedPosition(GeoNotifier* notifier) // If this is a one-shot request, stop it. m_oneShots.remove(notifier); if (!hasListeners()) - m_service->stopUpdating(); + stopUpdating(); // Otherwise, if the watch still exists, start the service to get updates. if (m_watchers.contains(notifier)) { - if (notifier->hasZeroTimeout() || m_service->startUpdating(notifier->m_options.get())) + if (notifier->hasZeroTimeout() || startUpdating(notifier->m_options.get())) notifier->startTimerIfNeeded(); else notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, "Failed to start Geolocation service")); @@ -436,7 +491,7 @@ void Geolocation::clearWatch(int watchId) m_watchers.remove(watchId); if (!hasListeners()) - m_service->stopUpdating(); + stopUpdating(); } void Geolocation::suspend() @@ -497,7 +552,6 @@ void Geolocation::sendPosition(Vector<RefPtr<GeoNotifier> >& notifiers, Geoposit RefPtr<GeoNotifier> notifier = *it; ASSERT(notifier->m_successCallback); - notifier->m_timer.stop(); notifier->m_successCallback->handleEvent(position); } } @@ -554,7 +608,7 @@ void Geolocation::handleError(PositionError* error) sendError(watchersCopy, error); if (!hasListeners()) - m_service->stopUpdating(); + stopUpdating(); } void Geolocation::requestPermission() @@ -575,12 +629,11 @@ void Geolocation::requestPermission() page->chrome()->requestGeolocationPermissionForFrame(m_frame, this); } -void Geolocation::geolocationServicePositionChanged(GeolocationService* service) +void Geolocation::positionChanged(PassRefPtr<Geoposition> newPosition) { - ASSERT_UNUSED(service, service == m_service); - ASSERT(m_service->lastPosition()); + m_currentPosition = newPosition; - m_cachedPositionManager->setCachedPosition(m_service->lastPosition()); + m_cachedPositionManager->setCachedPosition(m_currentPosition.get()); // Stop all currently running timers. stopTimers(); @@ -599,7 +652,7 @@ void Geolocation::geolocationServicePositionChanged(GeolocationService* service) void Geolocation::makeSuccessCallbacks() { - ASSERT(m_service->lastPosition()); + ASSERT(m_currentPosition); ASSERT(isAllowed()); Vector<RefPtr<GeoNotifier> > oneShotsCopy; @@ -613,23 +666,85 @@ void Geolocation::makeSuccessCallbacks() // further callbacks to these notifiers. m_oneShots.clear(); - sendPosition(oneShotsCopy, m_service->lastPosition()); - sendPosition(watchersCopy, m_service->lastPosition()); + sendPosition(oneShotsCopy, m_currentPosition.get()); + sendPosition(watchersCopy, m_currentPosition.get()); if (!hasListeners()) - m_service->stopUpdating(); + stopUpdating(); +} + +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +void Geolocation::setPosition(GeolocationPosition* position) +{ + positionChanged(createGeoposition(position)); +} + +void Geolocation::setError(GeolocationError* error) +{ + RefPtr<PositionError> positionError = createPositionError(error); + handleError(positionError.get()); +} + +#else + +void Geolocation::geolocationServicePositionChanged(GeolocationService* service) +{ + ASSERT_UNUSED(service, service == m_service); + ASSERT(m_service->lastPosition()); + + positionChanged(m_service->lastPosition()); } void Geolocation::geolocationServiceErrorOccurred(GeolocationService* service) { ASSERT(service->lastError()); - + // Note that we do not stop timers here. For one-shots, the request is // cleared in handleError. For watchers, the spec requires that the timer is // not cleared. handleError(service->lastError()); } +#endif + +bool Geolocation::startUpdating(PositionOptions* options) +{ +#if ENABLE(CLIENT_BASED_GEOLOCATION) + // FIXME: Pass options to client. + UNUSED_PARAM(options); + + if (!m_frame) + return false; + + Page* page = m_frame->page(); + if (!page) + return false; + + page->geolocationController()->addObserver(this); + return true; +#else + return m_service->startUpdating(options); +#endif +} + +void Geolocation::stopUpdating() +{ +#if ENABLE(CLIENT_BASED_GEOLOCATION) + if (!m_frame) + return; + + Page* page = m_frame->page(); + if (!page) + return; + + page->geolocationController()->removeObserver(this); +#else + m_service->stopUpdating(); +#endif + +} + bool Geolocation::operator==(const EventListener& listener) { if (listener.type() != GeolocationEventListenerType) diff --git a/WebCore/page/Geolocation.h b/WebCore/page/Geolocation.h index fd9d560..5b5feb5 100644 --- a/WebCore/page/Geolocation.h +++ b/WebCore/page/Geolocation.h @@ -48,8 +48,16 @@ namespace WebCore { class Frame; class CachedPositionManager; - -class Geolocation : public GeolocationServiceClient, public EventListener { +#if ENABLE(CLIENT_BASED_GEOLOCATION) +class GeolocationPosition; +class GeolocationError; +#endif + +class Geolocation : public EventListener +#if !ENABLE(CLIENT_BASED_GEOLOCATION) + , public GeolocationServiceClient +#endif +{ public: static PassRefPtr<Geolocation> create(Frame* frame) { return adoptRef(new Geolocation(frame)); } @@ -57,7 +65,7 @@ public: void disconnectFrame(); - Geoposition* lastPosition() const { return m_service->lastPosition(); } + Geoposition* lastPosition(); void getCurrentPosition(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>); int watchPosition(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>); @@ -73,6 +81,11 @@ public: void setShouldClearCache(bool shouldClearCache) { m_shouldClearCache = shouldClearCache; } bool shouldClearCache() const { return m_shouldClearCache; } +#if ENABLE(CLIENT_BASED_GEOLOCATION) + void setPostion(GeolocationPosition*); + void setError(GeolocationError*); +#endif + static void setDatabasePath(String); private: @@ -126,14 +139,20 @@ private: void stopTimersForWatchers(); void stopTimers(); + void positionChanged(PassRefPtr<Geoposition>); void makeSuccessCallbacks(); void handleError(PositionError*); void requestPermission(); + bool startUpdating(PositionOptions*); + void stopUpdating(); + +#if !ENABLE(CLIENT_BASED_GEOLOCATION) // GeolocationServiceClient virtual void geolocationServicePositionChanged(GeolocationService*); virtual void geolocationServiceErrorOccurred(GeolocationService*); +#endif PassRefPtr<GeoNotifier> startRequest(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>); @@ -151,7 +170,11 @@ private: GeoNotifierSet m_oneShots; Watchers m_watchers; Frame* m_frame; +#if !ENABLE(CLIENT_BASED_GEOLOCATION) OwnPtr<GeolocationService> m_service; +#endif + RefPtr<Geoposition> m_lastPosition; + RefPtr<Geoposition> m_currentPosition; enum { Unknown, diff --git a/WebCore/page/GeolocationController.cpp b/WebCore/page/GeolocationController.cpp new file mode 100644 index 0000000..44eba6e --- /dev/null +++ b/WebCore/page/GeolocationController.cpp @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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 APPLE INC. AND ITS CONTRIBUTORS ``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 APPLE INC. OR ITS 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 "GeolocationController.h" + +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +#include "GeolocationControllerClient.h" + +namespace WebCore { + +GeolocationController::GeolocationController(Page* page, GeolocationControllerClient* client) + : m_page(page) + , m_client(client) +{ +} + +GeolocationController::~GeolocationController() +{ +} + +void GeolocationController::addObserver(Geolocation* observer) +{ + ASSERT(!m_observers.contains(observer)); + + bool wasEmpty = m_observers.isEmpty(); + m_observers.add(observer); + if (wasEmpty) + m_client->startUpdating(); +} + +void GeolocationController::removeObserver(Geolocation* observer) +{ + ASSERT(m_observers.contains(observer)); + + m_observers.remove(observer); + if (m_observers.isEmpty()) + m_client->stopUpdating(); +} + +void GeolocationController::positionChanged(GeolocationPosition* position) +{ + HashSet<RefPtr<Geolocation> >::const_iterator end = m_observers.end(); + for (HashSet<RefPtr<Geolocation> >::const_iterator it = m_observers.begin(); it != end; ++it) + (*it)->setPosition(position); +} + +void GeolocationController::errorOccurred(GeolocationError* error) +{ + HashSet<RefPtr<Geolocation> >::const_iterator end = m_observers.end(); + for (HashSet<RefPtr<Geolocation> >::const_iterator it = m_observers.begin(); it != end; ++it) + (*it)->setError(error); +} + +GeolocationPosition* GeolocationController::lastPosition() +{ + return m_client->lastPosition(); +} + +} // namespace WebCore + +#endif // ENABLE(CLIENT_BASED_GEOLOCATION) diff --git a/WebCore/page/GeolocationController.h b/WebCore/page/GeolocationController.h new file mode 100644 index 0000000..80f9ca8 --- /dev/null +++ b/WebCore/page/GeolocationController.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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 APPLE INC. AND ITS CONTRIBUTORS ``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 APPLE INC. OR ITS 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 GeolocationController_h +#define GeolocationController_h + +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +#include "Geolocation.h" +#include <wtf/HashSet.h> +#include <wtf/Noncopyable.h> +#include <wtf/RefPtr.h> + +namespace WebCore { + +class GeolocationControllerClient; +class GeolocationError; +class GeolocationPosition; +class Page; + +class GeolocationController : public Noncopyable { +public: + GeolocationController(Page*, GeolocationControllerClient*); + ~GeolocationController(); + + void addObserver(Geolocation*); + void removeObserver(Geolocation*); + + void positionChanged(GeolocationPosition*); + void errorOccurred(GeolocationError*); + + GeolocationPosition* lastPosition(); + +private: + Page* m_page; + GeolocationControllerClient* m_client; + + HashSet<RefPtr<Geolocation> > m_observers; +}; + +} // namespace WebCore + +#endif // ENABLE(CLIENT_BASED_GEOLOCATION) + +#endif // GeolocationController_h diff --git a/WebCore/page/GeolocationControllerClient.h b/WebCore/page/GeolocationControllerClient.h new file mode 100644 index 0000000..830c64b --- /dev/null +++ b/WebCore/page/GeolocationControllerClient.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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 APPLE INC. AND ITS CONTRIBUTORS ``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 APPLE INC. OR ITS 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 GeolocationControllerClient_h +#define GeolocationControllerClient_h + +namespace WebCore { + +class GeolocationPosition; + +class GeolocationControllerClient { +public: + virtual void startUpdating() = 0; + virtual void stopUpdating() = 0; + virtual GeolocationPosition* lastPosition() = 0; + +protected: + virtual ~GeolocationControllerClient() { } +}; + +} // namespace WebCore + +#endif // GeolocationControllerClient_h diff --git a/WebCore/page/GeolocationError.h b/WebCore/page/GeolocationError.h new file mode 100644 index 0000000..9761ca6 --- /dev/null +++ b/WebCore/page/GeolocationError.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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 APPLE INC. AND ITS CONTRIBUTORS ``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 APPLE INC. OR ITS 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 GeolocationError_h +#define GeolocationError_h + +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +#include "PlatformString.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> + +namespace WebCore { + +class GeolocationError : public RefCounted<GeolocationError> { +public: + enum ErrorCode { + PermissionDenied, + PositionUnavailable + }; + + static PassRefPtr<GeolocationError> create(ErrorCode code, const String& message) { return adoptRef(new GeolocationError(code, message)); } + + ErrorCode code() const { return m_code; } + const String& message() const { return m_message; } + +private: + GeolocationError(ErrorCode code, const String& message); + + ErrorCode m_code; + String m_message; +}; + +} // namespace WebCore + +#endif // ENABLE(CLIENT_BASED_GEOLOCATION) + +#endif // GeolocationError_h diff --git a/WebCore/page/GeolocationPosition.h b/WebCore/page/GeolocationPosition.h new file mode 100644 index 0000000..c31e9c4 --- /dev/null +++ b/WebCore/page/GeolocationPosition.h @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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 APPLE INC. AND ITS CONTRIBUTORS ``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 APPLE INC. OR ITS 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 GeolocationPosition_h +#define GeolocationPosition_h + +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +#include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> + +namespace WebCore { + +class GeolocationPosition : public RefCounted<GeolocationPosition> { +public: + static PassRefPtr<GeolocationPosition> create(double timestamp, double latitude, double longitude, double accuracy) { return adoptRef(new GeolocationPosition(timestamp, latitude, longitude, accuracy)); } + + static PassRefPtr<GeolocationPosition> create(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed) { return adoptRef(new GeolocationPosition(timestamp, latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed)); } + + double timestamp() const { return m_timestamp; } + + double latitude() const { return m_latitude; } + double longitude() const { return m_longitude; } + double accuracy() const { return m_accuracy; } + double altitude() const { return m_altitude; } + double altitudeAccuracy() const { return m_altitudeAccuracy; } + double heading() const { return m_heading; } + double speed() const { return m_speed; } + + bool canProvideAltitude() const { return m_canProvideAltitude; } + bool canProvideAltitudeAccuracy() const { return m_canProvideAltitudeAccuracy; } + bool canProvideHeading() const { return m_canProvideHeading; } + bool canProvideSpeed() const { return m_canProvideSpeed; } + +private: + GeolocationPosition(double timestamp, double latitude, double longitude, double accuracy) + : m_timestamp(timestamp) + , m_latitude(latitude) + , m_longitude(longitude) + , m_accuracy(accuracy) + , m_altitude(0) + , m_altitudeAccuracy(0) + , m_heading(0) + , m_speed(0) + , m_canProvideAltitude(false) + , m_canProvideAltitudeAccuracy(false) + , m_canProvideHeading(false) + , m_canProvideSpeed(false) + { + } + + GeolocationPosition(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed) + : m_timestamp(timestamp) + , m_latitude(latitude) + , m_longitude(longitude) + , m_accuracy(accuracy) + , m_altitude(altitude) + , m_altitudeAccuracy(altitudeAccuracy) + , m_heading(heading) + , m_speed(speed) + , m_canProvideAltitude(providesAltitude) + , m_canProvideAltitudeAccuracy(providesAltitudeAccuracy) + , m_canProvideHeading(providesHeading) + , m_canProvideSpeed(providesSpeed) + { + } + + double m_timestamp; + + double m_latitude; + double m_longitude; + double m_accuracy; + double m_altitude; + double m_altitudeAccuracy; + double m_heading; + double m_speed; + + bool m_canProvideAltitude; + bool m_canProvideAltitudeAccuracy; + bool m_canProvideHeading; + bool m_canProvideSpeed; +}; + +} // namespace WebCore + +#endif // ENABLE(CLIENT_BASED_GEOLOCATION) + +#endif // GeolocationPosition_h diff --git a/WebCore/page/Geoposition.h b/WebCore/page/Geoposition.h index f3c703b..8b215b1 100644 --- a/WebCore/page/Geoposition.h +++ b/WebCore/page/Geoposition.h @@ -37,8 +37,11 @@ typedef int ExceptionCode; class Geoposition : public RefCounted<Geoposition> { public: - static PassRefPtr<Geoposition> create(PassRefPtr<Coordinates> coordinates, DOMTimeStamp timestamp) { return adoptRef(new Geoposition(coordinates, timestamp)); } - + static PassRefPtr<Geoposition> create(PassRefPtr<Coordinates> coordinates, DOMTimeStamp timestamp) + { + return adoptRef(new Geoposition(coordinates, timestamp)); + } + DOMTimeStamp timestamp() const { return m_timestamp; } Coordinates* coords() const { return m_coordinates.get(); } diff --git a/WebCore/page/Navigator.cpp b/WebCore/page/Navigator.cpp index a4193fc..8563a0e 100644 --- a/WebCore/page/Navigator.cpp +++ b/WebCore/page/Navigator.cpp @@ -24,6 +24,9 @@ #include "Navigator.h" #include "CookieJar.h" +#if PLATFORM(ANDROID) +#include "Connection.h" +#endif #include "ExceptionCode.h" #include "Frame.h" #include "FrameLoader.h" @@ -155,6 +158,15 @@ Geolocation* Navigator::geolocation() const return m_geolocation.get(); } +#if PLATFORM(ANDROID) +Connection* Navigator::connection() const +{ + if (!m_connection) + m_connection = Connection::create(); + return m_connection.get(); +} +#endif + #if ENABLE(DOM_STORAGE) void Navigator::getStorageUpdates() { diff --git a/WebCore/page/Navigator.h b/WebCore/page/Navigator.h index 107082b..9967fba 100644 --- a/WebCore/page/Navigator.h +++ b/WebCore/page/Navigator.h @@ -27,6 +27,9 @@ namespace WebCore { +#if PLATFORM(ANDROID) + class Connection; +#endif class Frame; class Geolocation; class MimeTypeArray; @@ -57,6 +60,10 @@ namespace WebCore { // This is used for GC marking. Geolocation* optionalGeolocation() const { return m_geolocation.get(); } +#if PLATFORM(ANDROID) + Connection* connection() const; +#endif + #if ENABLE(DOM_STORAGE) // Relinquishes the storage lock, if one exists. void getStorageUpdates(); @@ -71,6 +78,9 @@ namespace WebCore { mutable RefPtr<PluginArray> m_plugins; mutable RefPtr<MimeTypeArray> m_mimeTypes; mutable RefPtr<Geolocation> m_geolocation; +#if PLATFORM(ANDROID) + mutable RefPtr<Connection> m_connection; +#endif }; } diff --git a/WebCore/page/Navigator.idl b/WebCore/page/Navigator.idl index 99b22af..f3079de 100644 --- a/WebCore/page/Navigator.idl +++ b/WebCore/page/Navigator.idl @@ -39,6 +39,9 @@ module window { readonly attribute boolean onLine; + // ANDROID-only for now, upstreaming in progress. + readonly attribute Connection connection; + #if defined(ENABLE_GEOLOCATION) && ENABLE_GEOLOCATION readonly attribute Geolocation geolocation; #endif diff --git a/WebCore/page/Page.cpp b/WebCore/page/Page.cpp index c4f33d6..1a035a5 100644 --- a/WebCore/page/Page.cpp +++ b/WebCore/page/Page.cpp @@ -77,6 +77,10 @@ #include "WMLPageState.h" #endif +#if ENABLE(CLIENT_BASED_GEOLOCATION) +#include "GeolocationController.h" +#endif + namespace WebCore { static HashSet<Page*>* allPages; @@ -101,7 +105,7 @@ static void networkStateChanged() frames[i]->document()->dispatchWindowEvent(Event::create(eventName, false, false)); } -Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, EditorClient* editorClient, DragClient* dragClient, InspectorClient* inspectorClient, PluginHalterClient* pluginHalterClient) +Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, EditorClient* editorClient, DragClient* dragClient, InspectorClient* inspectorClient, PluginHalterClient* pluginHalterClient, GeolocationControllerClient* geolocationControllerClient) : m_chrome(new Chrome(this, chromeClient)) , m_dragCaretController(new SelectionController(0, true)) #if ENABLE(DRAG_SUPPORT) @@ -114,6 +118,9 @@ Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, Edi #if ENABLE(INSPECTOR) , m_inspectorController(new InspectorController(this, inspectorClient)) #endif +#if ENABLE(CLIENT_BASED_GEOLOCATION) + , m_geolocationController(new GeolocationController(this, geolocationControllerClient)) +#endif , m_settings(new Settings(this)) , m_progress(new ProgressTracker) , m_backForwardList(BackForwardList::create(this)) @@ -148,6 +155,10 @@ Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, Edi #if !ENABLE(INSPECTOR) UNUSED_PARAM(inspectorClient); #endif +#if !ENABLE(CLIENT_BASED_GEOLOCATION) + UNUSED_PARAM(geolocationControllerClient); +#endif + if (!allPages) { allPages = new HashSet<Page*>; diff --git a/WebCore/page/Page.h b/WebCore/page/Page.h index 4886464..40d96a7 100644 --- a/WebCore/page/Page.h +++ b/WebCore/page/Page.h @@ -54,6 +54,8 @@ namespace WebCore { class EditorClient; class FocusController; class Frame; + class GeolocationController; + class GeolocationControllerClient; class HaltablePlugin; class InspectorClient; class InspectorController; @@ -85,7 +87,7 @@ namespace WebCore { public: static void setNeedsReapplyStyles(); - Page(ChromeClient*, ContextMenuClient*, EditorClient*, DragClient*, InspectorClient*, PluginHalterClient*); + Page(ChromeClient*, ContextMenuClient*, EditorClient*, DragClient*, InspectorClient*, PluginHalterClient*, GeolocationControllerClient*); ~Page(); RenderTheme* theme() const { return m_theme.get(); }; @@ -144,6 +146,9 @@ namespace WebCore { #if ENABLE(INSPECTOR) InspectorController* inspectorController() const { return m_inspectorController.get(); } #endif +#if ENABLE(CLIENT_BASED_GEOLOCATION) + GeolocationController* geolocationController() const { return m_geolocationController.get(); } +#endif Settings* settings() const { return m_settings.get(); } ProgressTracker* progress() const { return m_progress.get(); } @@ -250,6 +255,9 @@ namespace WebCore { #if ENABLE(INSPECTOR) OwnPtr<InspectorController> m_inspectorController; #endif +#if ENABLE(CLIENT_BASED_GEOLOCATION) + OwnPtr<GeolocationController> m_geolocationController; +#endif OwnPtr<Settings> m_settings; OwnPtr<ProgressTracker> m_progress; diff --git a/WebCore/page/win/FrameWin.cpp b/WebCore/page/win/FrameWin.cpp index b15d195..8440a80 100644 --- a/WebCore/page/win/FrameWin.cpp +++ b/WebCore/page/win/FrameWin.cpp @@ -24,14 +24,14 @@ */ #include "config.h" -#include "runtime.h" #include "FrameWin.h" -#include "TransformationMatrix.h" -#include "FloatRect.h" +#include "Bridge.h" #include "Document.h" +#include "FloatRect.h" #include "RenderView.h" #include "Settings.h" +#include "TransformationMatrix.h" using std::min; diff --git a/WebCore/platform/PlatformTouchEvent.h b/WebCore/platform/PlatformTouchEvent.h index 6c8629c..5371a40 100644 --- a/WebCore/platform/PlatformTouchEvent.h +++ b/WebCore/platform/PlatformTouchEvent.h @@ -1,67 +1,86 @@ /* - * Copyright 2008, 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 APPLE COMPUTER, INC. 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. - */ + Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ #ifndef PlatformTouchEvent_h #define PlatformTouchEvent_h -#if ENABLE(TOUCH_EVENTS) // Android +#include "PlatformTouchPoint.h" +#include <wtf/Vector.h> + +#if ENABLE(TOUCH_EVENTS) + +#if PLATFORM(QT) +QT_BEGIN_NAMESPACE +class QTouchEvent; +QT_END_NAMESPACE +#endif +#if PLATFORM(ANDROID) #include "IntPoint.h" +#endif namespace WebCore { - enum TouchEventType {TouchEventStart, TouchEventMove, TouchEventEnd, TouchEventCancel, TouchEventLongPress, TouchEventDoubleTap}; - - class PlatformTouchEvent { - public: - PlatformTouchEvent() - : m_eventType(TouchEventCancel) - { - } - - PlatformTouchEvent(const IntPoint& pos, const IntPoint& globalPos, TouchEventType eventType) - : m_position(pos) - , m_globalPosition(globalPos) - , m_eventType(eventType) - { - } - - const IntPoint& pos() const { return m_position; } - int x() const { return m_position.x(); } - int y() const { return m_position.y(); } - int globalX() const { return m_globalPosition.x(); } - int globalY() const { return m_globalPosition.y(); } - TouchEventType eventType() const { return m_eventType; } - - private: - IntPoint m_position; - IntPoint m_globalPosition; - TouchEventType m_eventType; - }; - -} // namespace WebCore +enum TouchEventType { + TouchStart + , TouchMove + , TouchEnd + , TouchCancel +#if PLATFORM(ANDROID) + , TouchLongPress + , TouchDoubleTap +#endif +}; + +class PlatformTouchEvent { +public: + PlatformTouchEvent() + : m_type(TouchStart) + , m_ctrlKey(false) + , m_altKey(false) + , m_shiftKey(false) + , m_metaKey(false) + {} +#if PLATFORM(QT) + PlatformTouchEvent(QTouchEvent*); +#elif PLATFORM(ANDROID) + PlatformTouchEvent(const IntPoint& absolutePagePos, TouchEventType, PlatformTouchPoint::State); +#endif + + TouchEventType type() const { return m_type; } + const Vector<PlatformTouchPoint>& touchPoints() const { return m_touchPoints; } + + bool ctrlKey() const { return m_ctrlKey; } + bool altKey() const { return m_altKey; } + bool shiftKey() const { return m_shiftKey; } + bool metaKey() const { return m_metaKey; } + +private: + TouchEventType m_type; + Vector<PlatformTouchPoint> m_touchPoints; + bool m_ctrlKey; + bool m_altKey; + bool m_shiftKey; + bool m_metaKey; +}; + +} #endif // ENABLE(TOUCH_EVENTS) diff --git a/WebCore/platform/PlatformTouchPoint.h b/WebCore/platform/PlatformTouchPoint.h new file mode 100644 index 0000000..53bd8ae --- /dev/null +++ b/WebCore/platform/PlatformTouchPoint.h @@ -0,0 +1,69 @@ +/* + Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef PlatformTouchPoint_h +#define PlatformTouchPoint_h + +#include "IntPoint.h" +#include <wtf/Platform.h> +#include <wtf/Vector.h> + +#if ENABLE(TOUCH_EVENTS) + +#if PLATFORM(QT) +#include <QTouchEvent> +#endif + +namespace WebCore { + +class PlatformTouchEvent; + +class PlatformTouchPoint { +public: + enum State { + TouchReleased, + TouchPressed, + TouchMoved, + TouchStationary, + TouchCancelled + }; + +#if PLATFORM(QT) + PlatformTouchPoint(const QTouchEvent::TouchPoint&); +#elif PLATFORM(ANDROID) + PlatformTouchPoint(const IntPoint& absolutePagePos, State); +#endif + + int id() const { return m_id; } + State state() const { return m_state; } + IntPoint screenPos() const { return m_screenPos; } + IntPoint pos() const { return m_pos; } + +private: + int m_id; + State m_state; + IntPoint m_screenPos; + IntPoint m_pos; +}; + +} + +#endif // ENABLE(TOUCH_EVENTS) + +#endif // PlatformTouchPoint_h diff --git a/WebCore/platform/android/GeolocationServiceBridge.cpp b/WebCore/platform/android/GeolocationServiceBridge.cpp index c8ba85d..a30d2e6 100644 --- a/WebCore/platform/android/GeolocationServiceBridge.cpp +++ b/WebCore/platform/android/GeolocationServiceBridge.cpp @@ -31,7 +31,6 @@ #include "PositionError.h" #include "WebViewCore.h" #include <JNIHelp.h> -#include <jni_utility.h> namespace WebCore { diff --git a/WebCore/platform/android/GeolocationServiceBridge.h b/WebCore/platform/android/GeolocationServiceBridge.h index 0a83ba7..6cf9ead 100644 --- a/WebCore/platform/android/GeolocationServiceBridge.h +++ b/WebCore/platform/android/GeolocationServiceBridge.h @@ -26,7 +26,7 @@ #ifndef GeolocationServiceBridge_h #define GeolocationServiceBridge_h -#include <jni_utility.h> +#include "JNIUtility.h" #include <wtf/PassRefPtr.h> namespace WebCore { diff --git a/WebCore/platform/android/PlatformTouchEventAndroid.cpp b/WebCore/platform/android/PlatformTouchEventAndroid.cpp new file mode 100644 index 0000000..e4af8a3 --- /dev/null +++ b/WebCore/platform/android/PlatformTouchEventAndroid.cpp @@ -0,0 +1,45 @@ +/* + * 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 "PlatformTouchEvent.h" + +#if ENABLE(TOUCH_EVENTS) + +namespace WebCore { + +PlatformTouchEvent::PlatformTouchEvent(const IntPoint& absolutePagePos, TouchEventType type, PlatformTouchPoint::State state) + : m_type(type) + , m_ctrlKey(false) + , m_altKey(false) + , m_shiftKey(false) + , m_metaKey(false) +{ + m_touchPoints.append(PlatformTouchPoint(absolutePagePos, state)); +} + +} + +#endif diff --git a/WebCore/platform/android/PlatformTouchPointAndroid.cpp b/WebCore/platform/android/PlatformTouchPointAndroid.cpp new file mode 100644 index 0000000..d790855 --- /dev/null +++ b/WebCore/platform/android/PlatformTouchPointAndroid.cpp @@ -0,0 +1,41 @@ +/* + * 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 "PlatformTouchPoint.h" + +#if ENABLE(TOUCH_EVENTS) + +namespace WebCore { + +PlatformTouchPoint::PlatformTouchPoint(const IntPoint& absolutePagePos, State state) + : m_id(0) + , m_state(state) + , m_screenPos(absolutePagePos) + , m_pos(absolutePagePos) { } + +} + +#endif diff --git a/WebCore/platform/android/TemporaryLinkStubs.cpp b/WebCore/platform/android/TemporaryLinkStubs.cpp index 3e71689..9741ad5 100644 --- a/WebCore/platform/android/TemporaryLinkStubs.cpp +++ b/WebCore/platform/android/TemporaryLinkStubs.cpp @@ -60,7 +60,6 @@ #include "KURL.h" #include "Language.h" #include "LocalizedStrings.h" -#include "MIMETypeRegistry.h" #include "MainResourceLoader.h" #include "Node.h" #include "NotImplemented.h" @@ -82,10 +81,10 @@ #if USE(JSC) #include "API/JSClassRef.h" +#include "JNIUtilityPrivate.h" #include "JavaScriptCallFrame.h" #include "JavaScriptDebugServer.h" #include "JavaScriptProfile.h" -#include "jni_utility_private.h" #endif using namespace WebCore; @@ -354,12 +353,6 @@ void* WebCore::Frame::dragImageForSelection() return 0; } - -WebCore::String WebCore::MIMETypeRegistry::getMIMETypeForExtension(WebCore::String const&) -{ - return WebCore::String(); -} - void WebCore::Pasteboard::writeImage(WebCore::Node*, WebCore::KURL const&, WebCore::String const&) {} namespace WebCore { diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index 7637be9..fa012b0 100644 --- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -111,9 +111,10 @@ GraphicsLayerAndroid::GraphicsLayerAndroid(GraphicsLayerClient* client) : m_contentLayer->setIsRootLayer(renderLayer->isRootLayer()); RenderView* view = static_cast<RenderView*>(renderLayer->renderer()); if (view->isPositioned() && view->style()->position() == FixedPosition) { - FloatPoint position(view->style()->left().value(), - view->style()->right().value()); - m_contentLayer->setFixedPosition(position); + m_contentLayer->setFixedPosition(view->style()->left(), + view->style()->top(), + view->style()->right(), + view->style()->bottom()); } } gDebugGraphicsLayerAndroidInstances++; @@ -121,9 +122,6 @@ GraphicsLayerAndroid::GraphicsLayerAndroid(GraphicsLayerClient* client) : GraphicsLayerAndroid::~GraphicsLayerAndroid() { - if (!parent() && m_frame && m_frame->view()) - PlatformBridge::setRootLayer(m_frame->view(), 0); - gDebugGraphicsLayerAndroidInstances--; } @@ -339,6 +337,7 @@ void GraphicsLayerAndroid::setOpacity(float opacity) MLOG("(%x) setFinalOpacity: %.2f=>%.2f (%.2f)", this, opacity, clampedOpacity, m_opacity); GraphicsLayer::setOpacity(clampedOpacity); + m_contentLayer->setOpacity(clampedOpacity); askForSync(); } diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp index 347021a..3b5d5b5 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -62,9 +62,12 @@ LayerAndroid::LayerAndroid(bool isRootLayer) : m_size(0, 0), m_position(0, 0), m_translation(0, 0), - m_fixedPosition(0, 0), m_anchorPoint(0, 0, 0), m_scale(1, 1, 1), + m_fixedLeft(Auto), + m_fixedTop(Auto), + m_fixedRight(Auto), + m_fixedBottom(Auto), m_recordingPicture(0) { gDebugLayerAndroidInstances++; @@ -84,9 +87,12 @@ LayerAndroid::LayerAndroid(LayerAndroid* layer) : m_size(layer->m_size), m_position(layer->m_position), m_translation(layer->m_translation), - m_fixedPosition(layer->m_fixedPosition), m_anchorPoint(layer->m_anchorPoint), - m_scale(layer->m_scale) + m_scale(layer->m_scale), + m_fixedLeft(layer->m_fixedLeft), + m_fixedRight(layer->m_fixedRight), + m_fixedTop(layer->m_fixedTop), + m_fixedBottom(layer->m_fixedBottom) { if (layer->m_recordingPicture) { layer->m_recordingPicture->ref(); @@ -167,9 +173,13 @@ void LayerAndroid::removeAnimation(const String& name) m_animations.remove(name); } -void LayerAndroid::setFixedPosition(FloatPoint position) +void LayerAndroid::setFixedPosition(Length left, Length top, + Length right, Length bottom) { - m_fixedPosition = position; + m_fixedLeft = left; + m_fixedTop = top; + m_fixedRight = right; + m_fixedBottom = bottom; m_isFixed = true; } @@ -205,10 +215,12 @@ void LayerAndroid::setBackgroundColor(const Color& color) static int gDebugChildLevel; -void LayerAndroid::paintOn(float scrollX, float scrollY, float scale, SkCanvas* canvas) +void LayerAndroid::paintOn(int scrollX, int scrollY, + int width, int height, + float scale, SkCanvas* canvas) { gDebugChildLevel = 0; - paintChildren(scrollX, scrollY, scale, canvas, 1); + paintChildren(scrollX, scrollY, width, height, scale, canvas, 1); } void LayerAndroid::setClip(SkCanvas* canvas) @@ -221,7 +233,8 @@ void LayerAndroid::setClip(SkCanvas* canvas) canvas->clipRect(clip); } -void LayerAndroid::paintChildren(float scrollX, float scrollY, +void LayerAndroid::paintChildren(int scrollX, int scrollY, + int width, int height, float scale, SkCanvas* canvas, float opacity) { @@ -230,7 +243,7 @@ void LayerAndroid::paintChildren(float scrollX, float scrollY, if (m_haveClip) setClip(canvas); - paintMe(scrollX, scrollY, scale, canvas, opacity); + paintMe(scrollX, scrollY, width, height, scale, canvas, opacity); canvas->translate(m_position.x() + m_translation.x(), m_position.y() + m_translation.y()); @@ -238,7 +251,8 @@ void LayerAndroid::paintChildren(float scrollX, float scrollY, LayerAndroid* layer = m_children[i].get(); if (layer) { gDebugChildLevel++; - layer->paintChildren(scrollX, scrollY, scale, canvas, opacity * m_opacity); + layer->paintChildren(scrollX, scrollY, width, height, scale, + canvas, opacity * m_opacity); gDebugChildLevel--; } } @@ -246,8 +260,10 @@ void LayerAndroid::paintChildren(float scrollX, float scrollY, canvas->restore(); } -void LayerAndroid::paintMe(float scrollX, - float scrollY, +void LayerAndroid::paintMe(int scrollX, + int scrollY, + int viewWidth, + int viewHeight, float scale, SkCanvas* canvas, float opacity) @@ -275,10 +291,24 @@ void LayerAndroid::paintMe(float scrollX, paintMode.setXfermodeMode(SkXfermode::kSrc_Mode); - float x, y; + float x = 0; + float y = 0; if (m_isFixed) { - x = m_fixedPosition.x() + (scrollX / scale); - y = m_fixedPosition.y() + (scrollY / scale); + float w = viewWidth / scale; + float h = viewHeight / scale; + float dx = scrollX / scale; + float dy = scrollY / scale; + + if (m_fixedLeft.type()) + x = dx + m_fixedLeft.calcFloatValue(w); + else if (m_fixedRight.type()) + x = dx + w - m_fixedRight.calcFloatValue(w) - m_size.width(); + + if (m_fixedTop.type()) + y = dy + m_fixedTop.calcFloatValue(h); + else if (m_fixedBottom.type()) + y = dy + h - m_fixedBottom.calcFloatValue(h) - m_size.height(); + } else { x = m_translation.x() + m_position.x(); y = m_translation.y() + m_position.y(); diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h index 284185d..467c7dd 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.h +++ b/WebCore/platform/graphics/android/LayerAndroid.h @@ -25,6 +25,7 @@ #include "FloatSize.h" #include "GraphicsContext.h" #include "GraphicsLayer.h" +#include "Length.h" #include "RefPtr.h" #include "StringHash.h" #include "Vector.h" @@ -64,7 +65,7 @@ public: void setBackgroundColor(const Color& color); void setIsRootLayer(bool isRootLayer) { m_isRootLayer = isRootLayer; } - void paintOn(float scrollX, float scrollY, float scale, SkCanvas*); + void paintOn(int scrollX, int scrollY, int width, int height, float scale, SkCanvas*); GraphicsContext* paintContext(); void removeAllChildren() { m_children.clear(); } void addChildren(LayerAndroid* layer) { m_children.append(layer); } @@ -77,7 +78,7 @@ public: FloatPoint translation() { return m_translation; } FloatSize size() { return m_size; } - void setFixedPosition(FloatPoint position); + void setFixedPosition(Length left, Length top, Length right, Length bottom); void addAnimation(PassRefPtr<AndroidAnimation> anim); void removeAnimation(const String& name); Vector<RefPtr<AndroidAnimationValue> >* evaluateAnimations() const; @@ -87,11 +88,13 @@ public: private: - void paintChildren(float scrollX, float scrollY, + void paintChildren(int scrollX, int scrollY, + int width, int height, float scale, SkCanvas* canvas, float opacity); - void paintMe(float scrollX, float scrollY, + void paintMe(int scrollX, int scrollY, + int width, int height, float scale, SkCanvas* canvas, float opacity); @@ -110,10 +113,14 @@ private: FloatSize m_size; FloatPoint m_position; FloatPoint m_translation; - FloatPoint m_fixedPosition; FloatPoint3D m_anchorPoint; FloatPoint3D m_scale; + Length m_fixedLeft; + Length m_fixedTop; + Length m_fixedRight; + Length m_fixedBottom; + SkPicture* m_recordingPicture; Color m_backgroundColor; diff --git a/WebCore/platform/graphics/wince/MediaPlayerProxy.cpp b/WebCore/platform/graphics/wince/MediaPlayerProxy.cpp index 9673d18..ceb5a7c 100644 --- a/WebCore/platform/graphics/wince/MediaPlayerProxy.cpp +++ b/WebCore/platform/graphics/wince/MediaPlayerProxy.cpp @@ -22,9 +22,7 @@ #include "config.h" #include "MediaPlayerProxy.h" -#include "c_class.h" -#include "c_instance.h" -#include "c_runtime.h" +#include "Bridge.h" #include "DocumentLoader.h" #include "HTMLPlugInElement.h" #include "HTMLVideoElement.h" @@ -32,14 +30,16 @@ #include "JSPluginElementFunctions.h" #include "MediaPlayer.h" #include "Node.h" -#include "npruntime_impl.h" #include "PlatformString.h" #include "PluginView.h" #include "RenderPartObject.h" #include "RenderWidget.h" -#include "runtime.h" -#include <runtime/Identifier.h> #include "Widget.h" +#include "c_class.h" +#include "c_instance.h" +#include "c_runtime.h" +#include "npruntime_impl.h" +#include <runtime/Identifier.h> using namespace JSC; diff --git a/WebCore/platform/network/NetworkStateNotifier.h b/WebCore/platform/network/NetworkStateNotifier.h index 570ced0..d0463d4 100644 --- a/WebCore/platform/network/NetworkStateNotifier.h +++ b/WebCore/platform/network/NetworkStateNotifier.h @@ -27,6 +27,9 @@ #define NetworkStateNotifier_h #include <wtf/Noncopyable.h> +#if PLATFORM(ANDROID) +#include "Connection.h" +#endif #if PLATFORM(MAC) @@ -54,9 +57,15 @@ public: void setNetworkStateChangedFunction(void (*)()); bool onLine() const { return m_isOnLine; } +#if PLATFORM(ANDROID) + Connection::ConnectionType type() const { return m_type; } +#endif private: bool m_isOnLine; +#if PLATFORM(ANDROID) + Connection::ConnectionType m_type; +#endif void (*m_networkStateChangedFunction)(); void updateState(); @@ -84,6 +93,7 @@ private: #elif PLATFORM(ANDROID) public: void networkStateChange(bool online); + void networkTypeChange(Connection::ConnectionType type); #endif }; @@ -91,6 +101,9 @@ public: inline NetworkStateNotifier::NetworkStateNotifier() : m_isOnLine(true) +#if PLATFORM(ANDROID) + , m_type(Connection::Unknown) +#endif , m_networkStateChangedFunction(0) { } diff --git a/WebCore/platform/network/android/NetworkStateNotifierAndroid.cpp b/WebCore/platform/network/android/NetworkStateNotifierAndroid.cpp index 3aa5578..134e206 100644 --- a/WebCore/platform/network/android/NetworkStateNotifierAndroid.cpp +++ b/WebCore/platform/network/android/NetworkStateNotifierAndroid.cpp @@ -39,4 +39,15 @@ void NetworkStateNotifier::networkStateChange(bool online) m_networkStateChangedFunction(); } +void NetworkStateNotifier::networkTypeChange(Connection::ConnectionType type) +{ + if (m_type == type) + return; + + m_type = type; + + if (m_networkStateChangedFunction) + m_networkStateChangedFunction(); +} + } diff --git a/WebCore/plugins/PluginPackage.h b/WebCore/plugins/PluginPackage.h index c46c7eb..d409ab6 100644 --- a/WebCore/plugins/PluginPackage.h +++ b/WebCore/plugins/PluginPackage.h @@ -35,9 +35,6 @@ #include "npruntime_internal.h" #include <wtf/HashMap.h> #include <wtf/RefCounted.h> -#if defined(ANDROID_PLUGINS) -#include <nativehelper/jni.h> -#endif #if PLATFORM(SYMBIAN) class QPluginLoader; @@ -123,11 +120,6 @@ namespace WebCore { Timer<PluginPackage> m_freeLibraryTimer; PluginQuirkSet m_quirks; - -#if defined(ANDROID_PLUGINS) - // Java Plugin object. - jobject m_pluginObject; -#endif }; struct PluginPackageHash { diff --git a/WebCore/plugins/PluginView.cpp b/WebCore/plugins/PluginView.cpp index 3f40000..89713b5 100644 --- a/WebCore/plugins/PluginView.cpp +++ b/WebCore/plugins/PluginView.cpp @@ -27,6 +27,12 @@ #include "config.h" #include "PluginView.h" +// ANDROID +// Temporary guard required until Bridge.h is script-engine independent +// See https://bugs.webkit.org/show_bug.cgi?id=32154 +#if USE(JSC) +#include "Bridge.h" +#endif #include "Document.h" #include "DocumentLoader.h" #include "Element.h" @@ -71,7 +77,6 @@ #include "JSDOMBinding.h" #include "c_instance.h" #include "runtime_root.h" -#include "runtime.h" #include <runtime/JSLock.h> #include <runtime/JSValue.h> @@ -126,15 +131,8 @@ void PluginView::setFrameRect(const IntRect& rect) if (m_element->document()->printing()) return; -#if defined(ANDROID_PLUGINS) - if (rect != frameRect()) { - Widget::setFrameRect(rect); - setNPWindowRect(rect); // only call when it changes - } -#else if (rect != frameRect()) Widget::setFrameRect(rect); -#endif updatePluginWidget(); diff --git a/WebCore/plugins/PluginView.h b/WebCore/plugins/PluginView.h index a5618f7..0ce9c7c 100644 --- a/WebCore/plugins/PluginView.h +++ b/WebCore/plugins/PluginView.h @@ -373,7 +373,7 @@ public: private: -#if defined(XP_UNIX) || defined(Q_WS_X11) || PLATFORM(SYMBIAN) +#if defined(XP_UNIX) || defined(Q_WS_X11) || PLATFORM(SYMBIAN) || defined(ANDROID_PLUGINS) void setNPWindowIfNeeded(); #elif defined(XP_MACOSX) NP_CGContext m_npCgContext; diff --git a/WebCore/plugins/android/PluginPackageAndroid.cpp b/WebCore/plugins/android/PluginPackageAndroid.cpp index 664f31c..d55da87 100644 --- a/WebCore/plugins/android/PluginPackageAndroid.cpp +++ b/WebCore/plugins/android/PluginPackageAndroid.cpp @@ -25,24 +25,23 @@ */ #include "config.h" -#include "PluginDatabase.h" #include "PluginPackage.h" #ifdef ANDROID_PLUGINS -#include "Timer.h" +#include "CString.h" +#include "JNIUtility.h" #include "PlatformString.h" +#include "PluginDatabase.h" +#include "PluginDebug.h" +#include "PluginDebugAndroid.h" #include "PluginMainThreadScheduler.h" -#include "CString.h" -#include "jni_utility.h" -#include "npruntime_impl.h" +#include "Timer.h" #include "npfunctions.h" +#include "npruntime_impl.h" #include <dlfcn.h> #include <errno.h> -#include "PluginDebug.h" -#include "PluginDebugAndroid.h" - #define LOG_TAG "WebKit" namespace WebCore { @@ -188,45 +187,6 @@ static void initializeExtraBrowserFuncs(NPNetscapeFuncs *funcs) funcs->enumerate = _NPN_Enumerate; } -static jobject createPluginObject(const char *name, - const char *path, - const char *fileName, - const char *description) -{ - JNIEnv *env = JSC::Bindings::getJNIEnv(); - // Create a Java "class Plugin" object instance - jclass pluginClass = env->FindClass("android/webkit/Plugin"); - if(!pluginClass) { - PLUGIN_LOG("Couldn't find class android.webkit.Plugin\n"); - return 0; - } - // Get Plugin(String, String, String, String, Context) - jmethodID pluginConstructor = env->GetMethodID( - pluginClass, - "<init>", - "(Ljava/lang/String;" - "Ljava/lang/String;" - "Ljava/lang/String;" - "Ljava/lang/String;)V"); - if(!pluginConstructor) { - PLUGIN_LOG("Couldn't get android.webkit.Plugin constructor\n"); - return 0; - } - // Make Java strings of name, path, fileName, description - jstring javaName = env->NewStringUTF(name); - jstring javaPath = env->NewStringUTF(path); - jstring javaFileName = env->NewStringUTF(fileName); - jstring javaDescription = env->NewStringUTF(description); - // Make a plugin instance - jobject pluginObject = env->NewObject(pluginClass, - pluginConstructor, - javaName, - javaPath, - javaFileName, - javaDescription); - return pluginObject; -} - bool PluginPackage::load() { PLUGIN_LOG("tid:%d isActive:%d isLoaded:%d loadCount:%d\n", @@ -284,8 +244,7 @@ bool PluginPackage::load() m_pluginFuncs.size = sizeof(m_pluginFuncs); if(NP_Initialize(&m_browserFuncs, &m_pluginFuncs, - JSC::Bindings::getJNIEnv(), - m_pluginObject) != NPERR_NO_ERROR) { + JSC::Bindings::getJNIEnv()) != NPERR_NO_ERROR) { PLUGIN_LOG("Couldn't initialize plugin\n"); return false; } @@ -393,22 +352,6 @@ bool PluginPackage::fetchInfo() m_mimeToDescriptions.set(mimeType, description); } - // Create a new Java Plugin object, this object is an instance of - // android.os.WebView.Plugin - CString path = m_path.utf8(); - CString filename = m_fileName.utf8(); - jobject pluginObject = createPluginObject(name, - path.data(), - filename.data(), - description); - if(!pluginObject) { - PLUGIN_LOG("Couldn't create Java Plugin\n"); - return false; - } - - // Retain the Java Plugin object - m_pluginObject = JSC::Bindings::getJNIEnv()->NewGlobalRef(pluginObject); - PLUGIN_LOG("Fetch Info Loaded plugin details ok \"%s\"\n", m_path.utf8().data()); diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp index e10641d..72fdf3f 100644 --- a/WebCore/plugins/android/PluginViewAndroid.cpp +++ b/WebCore/plugins/android/PluginViewAndroid.cpp @@ -52,7 +52,9 @@ #include "PlatformKeyboardEvent.h" #include "PluginMainThreadScheduler.h" #include "PluginPackage.h" +#include "Touch.h" #include "TouchEvent.h" +#include "TouchList.h" #include "android_graphics.h" #include "SkCanvas.h" #include "npruntime_impl.h" @@ -206,11 +208,16 @@ void PluginView::handleTouchEvent(TouchEvent* event) evt.data.touch.modifiers = 0; // todo - // convert to coordinates that are relative to the plugin. The pageX / pageY - // values are the only values in the event that are consistently in frame - // coordinates despite their misleading name. - evt.data.touch.x = event->pageX() - m_npWindow.x; - evt.data.touch.y = event->pageY() - m_npWindow.y; + // In the event of a touchend (up) event, we must ask the changedTouch for the + // co-ordinates as there is no touch in touches anymore. + TouchList* touches = (evt.data.touch.action == kUp_ANPTouchAction) ? + event->changedTouches() : event->touches(); + + // Convert to coordinates that are relative to the plugin. + // We only support single touch points at the moment, so we want to look at index 0 only. + IntPoint localPos = roundedIntPoint(m_element->renderer()->absoluteToLocal(IntPoint(touches->item(0)->pageX(), touches->item(0)->pageY()))); + evt.data.touch.x = localPos.x(); + evt.data.touch.y = localPos.y(); int16 ret = m_plugin->pluginFuncs()->event(m_instance, &evt); if (ignoreRet) @@ -243,11 +250,11 @@ void PluginView::handleMouseEvent(MouseEvent* event) SkANP::InitEvent(&evt, kMouse_ANPEventType); evt.data.mouse.action = isUp ? kUp_ANPMouseAction : kDown_ANPMouseAction; - // convert to coordinates that are relative to the plugin. The pageX / pageY - // values are the only values in the event that are consistently in frame - // coordinates despite their misleading name. - evt.data.mouse.x = event->pageX() - m_npWindow.x; - evt.data.mouse.y = event->pageY() - m_npWindow.y; + // Convert to coordinates that are relative to the plugin. + IntPoint localPos = roundedIntPoint(m_element->renderer()->absoluteToLocal(event->absoluteLocation())); + evt.data.mouse.x = localPos.x(); + evt.data.mouse.y = localPos.y(); + if (isDown) { // The plugin needs focus to receive keyboard events if (Page* page = m_parentFrame->page()) @@ -394,21 +401,34 @@ void PluginView::setParent(ScrollView* parent) } } -void PluginView::setNPWindowRect(const IntRect& rect) +void PluginView::setNPWindowRect(const IntRect&) { - if (!m_isStarted) - return; + setNPWindowIfNeeded(); +} - // the rect is relative to the frameview's (0,0) - m_npWindow.x = rect.x(); - m_npWindow.y = rect.y(); - m_npWindow.width = rect.width(); - m_npWindow.height = rect.height(); +void PluginView::setNPWindowIfNeeded() +{ + if (!m_isStarted || !parent()) + return; - m_npWindow.clipRect.left = 0; - m_npWindow.clipRect.top = 0; - m_npWindow.clipRect.right = rect.width(); - m_npWindow.clipRect.bottom = rect.height(); + // in Android, plugin always get the setwindow() in the page coordinate. + IntRect pageRect = m_windowRect; + ScrollView* top = parent(); + while (top->parent()) + top = top->parent(); + // only the top ScrollView can have the offset + pageRect.move(top->scrollOffset()); + + // the m_npWindow is relative to the page + m_npWindow.x = pageRect.x(); + m_npWindow.y = pageRect.y(); + m_npWindow.width = pageRect.width(); + m_npWindow.height = pageRect.height(); + + m_npWindow.clipRect.left = pageRect.x(); + m_npWindow.clipRect.top = pageRect.y(); + m_npWindow.clipRect.right = pageRect.x() + pageRect.width(); + m_npWindow.clipRect.bottom = pageRect.y() + pageRect.height(); if (m_plugin->pluginFuncs()->setwindow) { #if USE(JSC) @@ -587,16 +607,22 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect) } m_window->inval(rect, false); + context->save(); + context->translate(frame.x(), frame.y()); m_window->draw(android_gc2canvas(context)); + context->restore(); } -// new as of SVN 38068, Nov 5 2008 void PluginView::updatePluginWidget() { - // I bet/hope we can move all of setNPWindowRect() into here FrameView* frameView = static_cast<FrameView*>(parent()); if (frameView) { - m_windowRect = IntRect(frameView->contentsToWindow(frameRect().location()), frameRect().size()); + IntRect oldWindowRect = m_windowRect; + + m_windowRect = frameView->contentsToWindow(frameRect()); + + if (m_windowRect != oldWindowRect) + setNPWindowIfNeeded(); } } diff --git a/WebCore/plugins/gtk/PluginViewGtk.cpp b/WebCore/plugins/gtk/PluginViewGtk.cpp index 6ea9417..3e7e3ee 100644 --- a/WebCore/plugins/gtk/PluginViewGtk.cpp +++ b/WebCore/plugins/gtk/PluginViewGtk.cpp @@ -27,6 +27,7 @@ #include "config.h" #include "PluginView.h" +#include "Bridge.h" #include "Document.h" #include "DocumentLoader.h" #include "Element.h" @@ -51,7 +52,6 @@ #include "JSDOMBinding.h" #include "ScriptController.h" #include "npruntime_impl.h" -#include "runtime.h" #include "runtime_root.h" #include <runtime/JSLock.h> #include <runtime/JSValue.h> diff --git a/WebCore/plugins/mac/PluginViewMac.cpp b/WebCore/plugins/mac/PluginViewMac.cpp index 44a0262..816efa0 100644 --- a/WebCore/plugins/mac/PluginViewMac.cpp +++ b/WebCore/plugins/mac/PluginViewMac.cpp @@ -31,10 +31,7 @@ #include "config.h" #include "PluginView.h" -#include <runtime/JSLock.h> -#include <runtime/JSValue.h> -#include "wtf/RetainPtr.h" - +#include "Bridge.h" #include "Document.h" #include "DocumentLoader.h" #include "Element.h" @@ -53,7 +50,6 @@ #include "KeyboardEvent.h" #include "MouseEvent.h" #include "NotImplemented.h" -#include "npruntime_impl.h" #include "Page.h" #include "PlatformMouseEvent.h" #include "PlatformKeyboardEvent.h" @@ -61,10 +57,14 @@ #include "PluginPackage.h" #include "PluginMainThreadScheduler.h" #include "RenderLayer.h" -#include "runtime.h" -#include "runtime_root.h" #include "ScriptController.h" #include "Settings.h" +#include "npruntime_impl.h" +#include "runtime_root.h" +#include <runtime/JSLock.h> +#include <runtime/JSValue.h> +#include <wtf/RetainPtr.h> + using JSC::ExecState; using JSC::Interpreter; diff --git a/WebCore/plugins/npfunctions.h b/WebCore/plugins/npfunctions.h index 9f1b470..8bf5acb 100644 --- a/WebCore/plugins/npfunctions.h +++ b/WebCore/plugins/npfunctions.h @@ -206,7 +206,7 @@ typedef NPError (*MainFuncPtr)(NPNetscapeFuncs*, NPPluginFuncs*, NPP_ShutdownPro typedef EXPORTED_CALLBACK(NPError, NP_InitializeFuncPtr)(NPNetscapeFuncs*, NPPluginFuncs*); typedef EXPORTED_CALLBACK(char*, NP_GetMIMEDescriptionFuncPtr)(void); #elif defined(ANDROID_PLUGINS) -typedef EXPORTED_CALLBACK(NPError, NP_InitializeFuncPtr)(NPNetscapeFuncs*, NPPluginFuncs*, JNIEnv *java_environment, jobject application_context); +typedef EXPORTED_CALLBACK(NPError, NP_InitializeFuncPtr)(NPNetscapeFuncs*, NPPluginFuncs*, JNIEnv *java_environment); typedef EXPORTED_CALLBACK(char*, NP_GetMIMEDescriptionFuncPtr)(void); #else typedef EXPORTED_CALLBACK(NPError, NP_InitializeFuncPtr)(NPNetscapeFuncs*); diff --git a/WebCore/plugins/qt/PluginViewQt.cpp b/WebCore/plugins/qt/PluginViewQt.cpp index 063a7e5..bda76ce 100644 --- a/WebCore/plugins/qt/PluginViewQt.cpp +++ b/WebCore/plugins/qt/PluginViewQt.cpp @@ -28,6 +28,7 @@ #include "config.h" #include "PluginView.h" +#include "Bridge.h" #include "Document.h" #include "DocumentLoader.h" #include "Element.h" @@ -53,27 +54,27 @@ #include "PluginDebug.h" #include "PluginPackage.h" #include "PluginMainThreadScheduler.h" +#include "QWebPageClient.h" #include "RenderLayer.h" #include "ScriptController.h" #include "Settings.h" #include "npruntime_impl.h" -#include "runtime.h" #include "runtime_root.h" -#include "QWebPageClient.h" + #include <QApplication> #include <QDesktopWidget> #include <QKeyEvent> #include <QPainter> #include <QWidget> #include <QX11Info> -#include <runtime/JSLock.h> -#include <runtime/JSValue.h> #include <X11/X.h> #ifndef QT_NO_XRENDER #define Bool int #define Status int #include <X11/extensions/Xrender.h> #endif +#include <runtime/JSLock.h> +#include <runtime/JSValue.h> using JSC::ExecState; using JSC::Interpreter; diff --git a/WebCore/plugins/symbian/PluginViewSymbian.cpp b/WebCore/plugins/symbian/PluginViewSymbian.cpp index 14e25b1..44702fd 100644 --- a/WebCore/plugins/symbian/PluginViewSymbian.cpp +++ b/WebCore/plugins/symbian/PluginViewSymbian.cpp @@ -19,6 +19,7 @@ #include "config.h" #include "PluginView.h" +#include "Bridge.h" #include "Document.h" #include "DocumentLoader.h" #include "Element.h" @@ -36,8 +37,6 @@ #include "KeyboardEvent.h" #include "MouseEvent.h" #include "NotImplemented.h" -#include "npfunctions.h" -#include "npinterface.h" #include "Page.h" #include "PlatformKeyboardEvent.h" #include "PlatformMouseEvent.h" @@ -45,13 +44,14 @@ #include "PluginDebug.h" #include "PluginMainThreadScheduler.h" #include "PluginPackage.h" +#include "QWebPageClient.h" #include "RenderLayer.h" #include "ScriptController.h" #include "Settings.h" +#include "npfunctions.h" +#include "npinterface.h" #include "npruntime_impl.h" -#include "runtime.h" #include "runtime_root.h" -#include "QWebPageClient.h" #include <QKeyEvent> #include <QPixmap.h> #include <QRegion> diff --git a/WebCore/plugins/win/PluginViewWin.cpp b/WebCore/plugins/win/PluginViewWin.cpp index 89eecc6..37f1fc8 100644 --- a/WebCore/plugins/win/PluginViewWin.cpp +++ b/WebCore/plugins/win/PluginViewWin.cpp @@ -33,6 +33,7 @@ #if !PLATFORM(WX) #include "BitmapInfo.h" #endif +#include "Bridge.h" #include "Document.h" #include "DocumentLoader.h" #include "Element.h" @@ -62,11 +63,10 @@ #include "PluginDatabase.h" #include "PluginDebug.h" #include "PluginPackage.h" +#include "Settings.h" #include "c_instance.h" #include "npruntime_impl.h" #include "runtime_root.h" -#include "Settings.h" -#include "runtime.h" #include <runtime/JSLock.h> #include <runtime/JSValue.h> #include <wtf/ASCIICType.h> diff --git a/WebCore/svg/graphics/SVGImage.cpp b/WebCore/svg/graphics/SVGImage.cpp index c4be11e..5f050a4 100644 --- a/WebCore/svg/graphics/SVGImage.cpp +++ b/WebCore/svg/graphics/SVGImage.cpp @@ -245,7 +245,7 @@ bool SVGImage::dataChanged(bool allDataReceived) // FIXME: If this SVG ends up loading itself, we might leak the world. // The comment said that the Cache code does not know about CachedImages // holding Frames and won't know to break the cycle. But - m_page.set(new Page(m_chromeClient.get(), dummyContextMenuClient, dummyEditorClient, dummyDragClient, dummyInspectorClient, 0)); + m_page.set(new Page(m_chromeClient.get(), dummyContextMenuClient, dummyEditorClient, dummyDragClient, dummyInspectorClient, 0, 0)); m_page->settings()->setJavaScriptEnabled(false); m_page->settings()->setPluginsEnabled(false); diff --git a/WebKit/Android.mk b/WebKit/Android.mk index 7123df2..16ba925 100644 --- a/WebKit/Android.mk +++ b/WebKit/Android.mk @@ -41,6 +41,7 @@ LOCAL_SRC_FILES := \ android/jni/GeolocationPermissionsBridge.cpp \ android/jni/JavaBridge.cpp \ android/jni/JavaSharedClient.cpp \ + android/jni/MIMETypeRegistry.cpp \ android/jni/MockGeolocation.cpp \ android/jni/PictureSet.cpp \ android/jni/WebCoreFrameBridge.cpp \ diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp index f14c2c1..ffa96f8 100644 --- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp @@ -465,4 +465,14 @@ void ChromeClientAndroid::wakeUpMainThreadWithNewQuota(long newQuota) { m_quotaThreadCondition.signal(); } +#if ENABLE(TOUCH_EVENTS) +void ChromeClientAndroid::needTouchEvents(bool needTouchEvents, bool force) +{ + FrameView* frameView = m_webFrame->page()->mainFrame()->view(); + android::WebViewCore* core = android::WebViewCore::getWebViewCore(frameView); + if (core) + core->needTouchEvents(needTouchEvents, force); +} +#endif + } diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h index 45dd078..b61f9fd 100644 --- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h +++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h @@ -136,6 +136,10 @@ namespace android { virtual void populateVisitedLinks(); +#if ENABLE(TOUCH_EVENTS) + virtual void needTouchEvents(bool, bool); +#endif + // Methods used to request and provide Geolocation permissions. virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*); // Android-specific diff --git a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp index c928d46..ae39820 100644 --- a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp @@ -727,7 +727,10 @@ bool FrameLoaderClientAndroid::canShowMIMEType(const String& mimeType) const { if (MIMETypeRegistry::isSupportedImageResourceMIMEType(mimeType) || MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType) || MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType) || - PluginDatabase::installedPlugins()->isMIMETypeRegistered(mimeType) || + (m_frame && m_frame->settings() + && m_frame->settings()->arePluginsEnabled() + && PluginDatabase::installedPlugins()->isMIMETypeRegistered( + mimeType)) || DOMImplementation::isTextMIMEType(mimeType) || DOMImplementation::isXMLMIMEType(mimeType)) return true; @@ -1033,35 +1036,7 @@ WTF::PassRefPtr<Widget> FrameLoaderClientAndroid::createJavaAppletWidget(const I // the contents and work out if it can render it. ObjectContentType FrameLoaderClientAndroid::objectContentType(const KURL& url, const String& mimeType) { - if (mimeType.length() == 0) - { - // Guess the mimeType from the extension - if (url.hasPath()) - { - String path = url.path(); - int lastIndex = path.reverseFind('.'); - static const String image("image/"); - if (lastIndex >= 0) - { - String mime(path.substring(lastIndex + 1)); - mime.insert(image, 0); - if (Image::supportsType(mime)) - return ObjectContentImage; - } - } - return ObjectContentFrame; - } - - if (Image::supportsType(mimeType)) - return ObjectContentImage; - - if (PluginDatabase::installedPlugins()->isMIMETypeRegistered(mimeType)) - return ObjectContentOtherPlugin; - - if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType)) - return ObjectContentFrame; - - return ObjectContentNone; + return FrameLoader::defaultObjectContentType(url, mimeType); } // This function allows the application to set the correct CSS media diff --git a/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp b/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp index 1bb8802..bfb5305 100644 --- a/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp +++ b/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp @@ -24,19 +24,19 @@ */ #include "config.h" +#include "MediaPlayerPrivateAndroid.h" #if ENABLE(VIDEO) #include "GraphicsContext.h" -#include "MediaPlayerPrivateAndroid.h" #include "SkiaUtils.h" #include "TimeRanges.h" #include "WebCoreJni.h" #include "WebViewCore.h" -#include "jni_utility.h" #include <GraphicsJNI.h> #include <JNIHelp.h> +#include <JNIUtility.h> #include <SkBitmap.h> using namespace android; diff --git a/WebKit/android/benchmark/Intercept.h b/WebKit/android/benchmark/Intercept.h index fbf38bc..edd5123 100644 --- a/WebKit/android/benchmark/Intercept.h +++ b/WebKit/android/benchmark/Intercept.h @@ -26,12 +26,12 @@ #ifndef INTERCEPT_H #define INTERCEPT_H -#include "jni_utility.h" #include "MyJavaVM.h" #include "PlatformString.h" #include "Timer.h" #include "WebCoreFrameBridge.h" #include "WebCoreResourceLoader.h" +#include <JNIUtility.h> #include <wtf/Vector.h> namespace WebCore { diff --git a/WebKit/android/benchmark/MyJavaVM.cpp b/WebKit/android/benchmark/MyJavaVM.cpp index f73a3ea..574c745 100644 --- a/WebKit/android/benchmark/MyJavaVM.cpp +++ b/WebKit/android/benchmark/MyJavaVM.cpp @@ -24,10 +24,9 @@ */ #include "config.h" - #include "MyJavaVM.h" -#include "jni_utility.h" +#include <JNIUtility.h> #include <jni.h> static JNIEnv* s_env; diff --git a/WebKit/android/jni/JavaBridge.cpp b/WebKit/android/jni/JavaBridge.cpp index 049a7da..feca297 100644 --- a/WebKit/android/jni/JavaBridge.cpp +++ b/WebKit/android/jni/JavaBridge.cpp @@ -25,10 +25,11 @@ #define LOG_TAG "webcoreglue" -#include <config.h> -#include <wtf/Platform.h> +#include "config.h" +#include "AtomicString.h" #include "Cache.h" +#include "Connection.h" #include "CookieClient.h" #include "JavaSharedClient.h" #include "KeyGeneratorClient.h" @@ -39,17 +40,18 @@ #include "PluginDatabase.h" #include "Timer.h" #include "TimerClient.h" -#include "jni_utility.h" -#include "WebCoreJni.h" - #ifdef ANDROID_INSTRUMENT #include "TimeCounter.h" #endif +#include "WebCoreJni.h" -#include <jni.h> #include <JNIHelp.h> +#include <JNIUtility.h> #include <SkUtils.h> +#include <jni.h> #include <utils/misc.h> +#include <wtf/Platform.h> +#include <wtf/StdLibExtras.h> namespace android { @@ -96,6 +98,7 @@ public: static void SharedTimerFired(JNIEnv* env, jobject); static void SetCacheSize(JNIEnv* env, jobject obj, jint bytes); static void SetNetworkOnLine(JNIEnv* env, jobject obj, jboolean online); + static void SetNetworkType(JNIEnv* env, jobject obj, jstring type, jstring subtype); static void SetDeferringTimers(JNIEnv* env, jobject obj, jboolean defer); static void ServiceFuncPtrQueue(JNIEnv*); static void UpdatePluginDirectories(JNIEnv* env, jobject obj, jobjectArray array, jboolean reload); @@ -344,6 +347,29 @@ void JavaBridge::SetNetworkOnLine(JNIEnv* env, jobject obj, jboolean online) WebCore::networkStateNotifier().networkStateChange(online); } +void JavaBridge::SetNetworkType(JNIEnv* env, jobject obj, jstring javatype, jstring javasubtype) +{ + DEFINE_STATIC_LOCAL(AtomicString, wifi, ("wifi")); + DEFINE_STATIC_LOCAL(AtomicString, mobile, ("mobile")); + DEFINE_STATIC_LOCAL(AtomicString, mobileSupl, ("mobile_supl")); + DEFINE_STATIC_LOCAL(AtomicString, gprs, ("gprs")); + DEFINE_STATIC_LOCAL(AtomicString, edge, ("edge")); + DEFINE_STATIC_LOCAL(AtomicString, umts, ("umts")); + + String type = to_string(env, javatype); + String subtype = to_string(env, javasubtype); + Connection::ConnectionType connectionType = Connection::Unknown; + if (type == wifi) + connectionType = Connection::WiFi; + else if (type == mobile || type == mobileSupl) { + if (subtype == edge || subtype == gprs) + connectionType = Connection::Cell_2G; + else if (subtype == umts) + connectionType = Connection::Cell_3G; + } + WebCore::networkStateNotifier().networkTypeChange(connectionType); +} + void JavaBridge::ServiceFuncPtrQueue(JNIEnv*) { JavaSharedClient::ServiceFunctionPtrQueue(); @@ -383,6 +409,8 @@ static JNINativeMethod gWebCoreJavaBridgeMethods[] = { (void*) JavaBridge::SetCacheSize }, { "setNetworkOnLine", "(Z)V", (void*) JavaBridge::SetNetworkOnLine }, + { "setNetworkType", "(Ljava/lang/String;Ljava/lang/String;)V", + (void*) JavaBridge::SetNetworkType }, { "nativeServiceFuncPtrQueue", "()V", (void*) JavaBridge::ServiceFuncPtrQueue }, { "nativeUpdatePluginDirectories", "([Ljava/lang/String;Z)V", diff --git a/WebKit/android/jni/MIMETypeRegistry.cpp b/WebKit/android/jni/MIMETypeRegistry.cpp new file mode 100644 index 0000000..eec7af6 --- /dev/null +++ b/WebKit/android/jni/MIMETypeRegistry.cpp @@ -0,0 +1,60 @@ +/* + * 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. + */ + +#define LOG_TAG "WebCore" + +#include "config.h" +#include "MIMETypeRegistry.h" + +#include "PlatformString.h" +#include "WebCoreJni.h" + +#include <JNIUtility.h> +#include <jni.h> +#include <utils/Log.h> + +namespace WebCore { + +String MIMETypeRegistry::getMIMETypeForExtension(const String& ext) +{ + JNIEnv* env = JSC::Bindings::getJNIEnv(); + jclass mimeClass = env->FindClass("android/webkit/MimeTypeMap"); + LOG_ASSERT(mimeClass, "Could not find class MimeTypeMap"); + jmethodID mimeTypeFromExtension = env->GetStaticMethodID(mimeClass, + "mimeTypeFromExtension", + "(Ljava/lang/String;)Ljava/lang/String;"); + LOG_ASSERT(mimeTypeFromExtension, + "Could not find method mimeTypeFromExtension"); + jstring extString = + env->NewString((const jchar*) ext.characters(), ext.length()); + jobject mimeType = env->CallStaticObjectMethod(mimeClass, + mimeTypeFromExtension, extString); + String result = android::to_string(env, (jstring) mimeType); + env->DeleteLocalRef(extString); + env->DeleteLocalRef(mimeType); + return result; +} + +} diff --git a/WebKit/android/jni/MockGeolocation.cpp b/WebKit/android/jni/MockGeolocation.cpp index e76b1c1..df580c3 100755 --- a/WebKit/android/jni/MockGeolocation.cpp +++ b/WebKit/android/jni/MockGeolocation.cpp @@ -28,14 +28,14 @@ #include "config.h" -#include <JNIHelp.h> #include "Coordinates.h" #include "GeolocationServiceMock.h" #include "Geoposition.h" #include "JavaSharedClient.h" -#include "jni_utility.h" #include "PositionError.h" #include "WebCoreJni.h" +#include <JNIHelp.h> +#include <JNIUtility.h> #include <wtf/CurrentTime.h> using namespace WebCore; diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp index 150c428..6f11487 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -25,7 +25,7 @@ #define LOG_TAG "webcoreglue" -#include <config.h> +#include "config.h" #include <wtf/Platform.h> #include <wtf/CurrentTime.h> @@ -66,8 +66,8 @@ #include "JSDOMWindow.h" #include <runtime/JSLock.h> #elif USE(V8) -#include "jni_npobject.h" -#include "jni_instance.h" +#include "JavaNPObjectV8.h" +#include "JavaInstanceV8.h" #endif // USE(JSC) #include "KURL.h" @@ -99,11 +99,11 @@ #include <runtime_object.h> #endif // USE(JSC) -#include <jni_utility.h> +#include <JNIUtility.h> #include "jni.h" #if USE(JSC) -#include "jni_instance.h" +#include "JavaInstanceJSC.h" #endif // USE(JSC) #include <JNIHelp.h> @@ -871,7 +871,13 @@ static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAss WebCore::DragClient* dragC = new DragClientAndroid; InspectorClientAndroid* inspectorC = new InspectorClientAndroid; // Create a new page - WebCore::Page* page = new WebCore::Page(chromeC, contextMenuC, editorC, dragC, inspectorC, 0); + WebCore::Page* page = new WebCore::Page(chromeC, + contextMenuC, + editorC, + dragC, + inspectorC, + 0, // PluginHalterClient + 0); // GeolocationControllerClient // css files without explicit MIMETYPE is treated as generic text files in // the Java side. So we can't enforce CSS MIMETYPE. page->settings()->setEnforceCSSMIMETypeInStrictMode(false); @@ -1168,27 +1174,27 @@ private: { JNIEnv* env = getJNIEnv(); // JavaInstance creates a global ref to instance in its constructor. - env->DeleteGlobalRef(_instance->instance()); + env->DeleteGlobalRef(m_instance->instance()); // Set the object to a weak reference. - _instance->setInstance(env->NewWeakGlobalRef(instance)); + m_instance->setInstance(env->NewWeakGlobalRef(instance)); } ~WeakJavaInstance() { JNIEnv* env = getJNIEnv(); // Store the weak reference so we can delete it later. - jweak weak = _instance->instance(); + jweak weak = m_instance->instance(); // The JavaInstance destructor attempts to delete the global ref stored - // in _instance. Since we replaced it in our constructor with a weak + // in m_instance. Since we replaced it in our constructor with a weak // reference, restore the global ref here so the vm will not complain. - _instance->setInstance(env->NewGlobalRef( - getRealObject(env, _instance->instance()).get())); + m_instance->setInstance(env->NewGlobalRef( + getRealObject(env, m_instance->instance()).get())); // Delete the weak reference. env->DeleteWeakGlobalRef(weak); } virtual void virtualBegin() { - _weakRef = _instance->instance(); + _weakRef = m_instance->instance(); JNIEnv* env = getJNIEnv(); // This is odd. getRealObject returns an AutoJObject which is used to // cleanly create and delete a local reference. But, here we need to @@ -1197,7 +1203,7 @@ private: // and delete the local reference in virtualEnd(). _realObject = getRealObject(env, _weakRef).release(); // Point to the real object - _instance->setInstance(_realObject); + m_instance->setInstance(_realObject); // Call the base class method INHERITED::virtualBegin(); } @@ -1209,7 +1215,7 @@ private: // Get rid of the local reference to the real object. getJNIEnv()->DeleteLocalRef(_realObject); // Point back to the WeakReference. - _instance->setInstance(_weakRef); + m_instance->setInstance(_weakRef); } private: @@ -1518,7 +1524,7 @@ static void OrientationChanged(JNIEnv *env, jobject obj, int orientation) TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter); #endif WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj); - LOGE("Sending orientation: %d", orientation); + LOGV("Sending orientation: %d", orientation); pFrame->sendOrientationChangeEvent(orientation); } diff --git a/WebKit/android/jni/WebCoreJni.cpp b/WebKit/android/jni/WebCoreJni.cpp index ef33cc0..73acb7b 100644 --- a/WebKit/android/jni/WebCoreJni.cpp +++ b/WebKit/android/jni/WebCoreJni.cpp @@ -26,10 +26,10 @@ #define LOG_TAG "webcoreglue" #include "config.h" +#include "WebCoreJni.h" #include "NotImplemented.h" -#include "WebCoreJni.h" -#include "jni_utility.h" +#include <JNIUtility.h> #include <jni.h> #include <utils/Log.h> diff --git a/WebKit/android/jni/WebCoreJniOnLoad.cpp b/WebKit/android/jni/WebCoreJniOnLoad.cpp index d69177e..b5bf9dd 100644 --- a/WebKit/android/jni/WebCoreJniOnLoad.cpp +++ b/WebKit/android/jni/WebCoreJniOnLoad.cpp @@ -42,7 +42,6 @@ #include "InspectorClientAndroid.h" #include "IntRect.h" #include "JavaSharedClient.h" -#include "jni_utility.h" #include "Page.h" #include "PlatformGraphicsContext.h" #include "ResourceRequest.h" @@ -51,21 +50,19 @@ #include "SelectionController.h" #include "Settings.h" #include "SharedBuffer.h" +#include "SkBitmap.h" +#include "SkCanvas.h" +#include "SkImageEncoder.h" #include "SubstituteData.h" #include "TimerClient.h" #include "TextEncoding.h" #include "WebCoreViewBridge.h" #include "WebFrameView.h" #include "WebViewCore.h" - -#include "SkBitmap.h" -#include "SkCanvas.h" -#include "SkImageEncoder.h" - #include "benchmark/Intercept.h" #include "benchmark/MyJavaVM.h" -#include "jni_utility.h" +#include <JNIUtility.h> #include <jni.h> #include <utils/Log.h> @@ -189,8 +186,13 @@ 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; - Page* page = new Page(chrome, new ContextMenuClientAndroid, editor, - new DragClientAndroid, new InspectorClientAndroid, NULL); + Page* page = new Page(chrome, + new ContextMenuClientAndroid, + editor, + new DragClientAndroid, + new InspectorClientAndroid, + 0, // PluginHalterClient + 0); // GeolocationControllerClient editor->setPage(page); // Create MyWebFrame that intercepts network requests diff --git a/WebKit/android/jni/WebCoreResourceLoader.cpp b/WebKit/android/jni/WebCoreResourceLoader.cpp index 55af52d..b17c9a7 100644 --- a/WebKit/android/jni/WebCoreResourceLoader.cpp +++ b/WebKit/android/jni/WebCoreResourceLoader.cpp @@ -25,12 +25,8 @@ #define LOG_TAG "webcoreglue" -#include <config.h> -#include <wtf/Platform.h> - -#include "jni_utility.h" +#include "config.h" #include "WebCoreResourceLoader.h" -#include "SkUtils.h" #include "CString.h" #include "ResourceError.h" @@ -38,16 +34,18 @@ #include "ResourceHandleClient.h" #include "ResourceHandleInternal.h" #include "ResourceResponse.h" -#include "WebCoreJni.h" - +#include "SkUtils.h" #ifdef ANDROID_INSTRUMENT #include "TimeCounter.h" #endif +#include "WebCoreJni.h" -#include <utils/misc.h> #include <JNIHelp.h> +#include <JNIUtility.h> #include <SkTypes.h> #include <stdlib.h> +#include <utils/misc.h> +#include <wtf/Platform.h> namespace android { diff --git a/WebKit/android/jni/WebHistory.cpp b/WebKit/android/jni/WebHistory.cpp index 76a310b..f5a0b63 100644 --- a/WebKit/android/jni/WebHistory.cpp +++ b/WebKit/android/jni/WebHistory.cpp @@ -25,10 +25,7 @@ #define LOG_TAG "webhistory" -#include <config.h> -#include <wtf/OwnPtr.h> -#include <wtf/Platform.h> - +#include "config.h" #include "WebHistory.h" #include "BackForwardList.h" @@ -45,11 +42,13 @@ #include "WebCoreFrameBridge.h" #include "WebCoreJni.h" #include "WebIconDatabase.h" -#include "jni_utility.h" #include <JNIHelp.h> +#include "JNIUtility.h" #include <SkUtils.h> #include <utils/misc.h> +#include <wtf/OwnPtr.h> +#include <wtf/Platform.h> namespace android { diff --git a/WebKit/android/jni/WebIconDatabase.cpp b/WebKit/android/jni/WebIconDatabase.cpp index 20258a4..840d161 100644 --- a/WebKit/android/jni/WebIconDatabase.cpp +++ b/WebKit/android/jni/WebIconDatabase.cpp @@ -25,26 +25,25 @@ #define LOG_TAG "favicons" -#include <config.h> -#include <wtf/Platform.h> - +#include "config.h" #include "WebIconDatabase.h" +#include "GraphicsJNI.h" #include "IconDatabase.h" #include "Image.h" #include "IntRect.h" #include "JavaSharedClient.h" -#include "jni_utility.h" #include "KURL.h" #include "WebCoreJni.h" -#include <pthread.h> -#include "GraphicsJNI.h" +#include <JNIHelp.h> +#include <JNIUtility.h> #include <SkBitmap.h> #include <SkImageDecoder.h> #include <SkTemplates.h> +#include <pthread.h> #include <utils/misc.h> -#include <JNIHelp.h> +#include <wtf/Platform.h> namespace android { diff --git a/WebKit/android/jni/WebStorage.cpp b/WebKit/android/jni/WebStorage.cpp index 07e4880..3ab16fd 100644 --- a/WebKit/android/jni/WebStorage.cpp +++ b/WebKit/android/jni/WebStorage.cpp @@ -27,17 +27,16 @@ #if ENABLE(DATABASE) -#include <JNIHelp.h> +#include "JavaSharedClient.h" +#include "KURL.h" +#include "WebCoreJni.h" +#include <JNIHelp.h> +#include <JNIUtility.h> #include <WebCore/loader/appcache/ApplicationCacheStorage.h> #include <WebCore/page/SecurityOrigin.h> #include <WebCore/storage/DatabaseTracker.h> -#include "JavaSharedClient.h" -#include "jni_utility.h" -#include "KURL.h" -#include "WebCoreJni.h" - namespace android { static jobject GetOrigins(JNIEnv* env, jobject obj) diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 8414068..5ebc8eb 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -25,7 +25,7 @@ #define LOG_TAG "webcoreglue" -#include <config.h> +#include "config.h" #include "WebViewCore.h" #include "AtomicString.h" @@ -65,7 +65,6 @@ #include "HTMLSelectElement.h" #include "HTMLTextAreaElement.h" #include "InlineTextBox.h" -#include <JNIHelp.h> #include "KeyboardCodes.h" #include "Navigator.h" #include "Node.h" @@ -102,8 +101,10 @@ #include "WebFrameView.h" #include "HistoryItem.h" #include "android_graphics.h" + +#include <JNIHelp.h> +#include <JNIUtility.h> #include <ui/KeycodeLabels.h> -#include "jni_utility.h" #include <wtf/CurrentTime.h> #if USE(V8) @@ -266,6 +267,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_screenWidth = 320; m_scale = 1; m_screenWidthScale = 1; + m_touchEventListenerCount = 0; LOG_ASSERT(m_mainFrame, "Uh oh, somehow a frameview was made without an initial frame!"); @@ -348,6 +350,9 @@ WebViewCore* WebViewCore::getWebViewCore(const WebCore::FrameView* view) WebViewCore* WebViewCore::getWebViewCore(const WebCore::ScrollView* view) { + if (!view) + return 0; + WebFrameView* webFrameView = static_cast<WebFrameView*>(view->platformWidget()); if (!webFrameView) return 0; @@ -991,15 +996,28 @@ void WebViewCore::restoreScreenWidthScale(int scale) checkException(env); } -void WebViewCore::needTouchEvents(bool need) +void WebViewCore::needTouchEvents(bool need, bool force) { DEBUG_NAV_UI_LOGD("%s", __FUNCTION__); LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); #if ENABLE(TOUCH_EVENTS) // Android - JNIEnv* env = JSC::Bindings::getJNIEnv(); - env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_needTouchEvents, need); - checkException(env); + bool needToUpdateJava = false; + if (need) { + if (++m_touchEventListenerCount == 1) + needToUpdateJava = true; + } else { + if (force) + m_touchEventListenerCount = 0; + else if (--m_touchEventListenerCount == 0) + needToUpdateJava = true; + } + + if (needToUpdateJava || force) { + JNIEnv* env = JSC::Bindings::getJNIEnv(); + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_needTouchEvents, need); + checkException(env); + } #endif } @@ -1371,7 +1389,6 @@ void WebViewCore::drawPlugins() SkIRect dirty; if (w->isDirty(&dirty)) { w->draw(); - w->localToDocumentCoords(&dirty); inval.op(dirty, SkRegion::kUnion_Op); } } @@ -1910,29 +1927,47 @@ int WebViewCore::handleTouchEvent(int action, int x, int y) #endif #if ENABLE(TOUCH_EVENTS) // Android - WebCore::TouchEventType type = WebCore::TouchEventCancel; + WebCore::TouchEventType type = WebCore::TouchStart; + WebCore::PlatformTouchPoint::State touchState = WebCore::PlatformTouchPoint::TouchPressed; switch (action) { case 0: // MotionEvent.ACTION_DOWN - type = WebCore::TouchEventStart; + type = WebCore::TouchStart; break; case 1: // MotionEvent.ACTION_UP - type = WebCore::TouchEventEnd; + type = WebCore::TouchEnd; + touchState = WebCore::PlatformTouchPoint::TouchReleased; break; case 2: // MotionEvent.ACTION_MOVE - type = WebCore::TouchEventMove; + type = WebCore::TouchMove; + touchState = WebCore::PlatformTouchPoint::TouchMoved; break; case 3: // MotionEvent.ACTION_CANCEL - type = WebCore::TouchEventCancel; + type = WebCore::TouchCancel; + touchState = WebCore::PlatformTouchPoint::TouchCancelled; break; case 0x100: // WebViewCore.ACTION_LONGPRESS - type = WebCore::TouchEventLongPress; + type = WebCore::TouchLongPress; + touchState = WebCore::PlatformTouchPoint::TouchPressed; break; case 0x200: // WebViewCore.ACTION_DOUBLETAP - type = WebCore::TouchEventDoubleTap; + type = WebCore::TouchDoubleTap; + touchState = WebCore::PlatformTouchPoint::TouchPressed; + break; + default: + type = WebCore::TouchCancel; + touchState = WebCore::PlatformTouchPoint::TouchCancelled; break; } + + // Track previous touch and if stationary set the state. WebCore::IntPoint pt(x - m_scrollOffsetX, y - m_scrollOffsetY); - WebCore::PlatformTouchEvent te(pt, pt, type); + + if (type == WebCore::TouchMove && pt == m_lastTouchPoint) + touchState = WebCore::PlatformTouchPoint::TouchStationary; + + m_lastTouchPoint = pt; + + WebCore::PlatformTouchEvent te(pt, type, touchState); preventDefault = m_mainFrame->eventHandler()->handleTouchEvent(te); #endif @@ -2943,7 +2978,8 @@ static void FullScreenPluginHidden(JNIEnv* env, jobject obj, jint npp) { WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj); PluginWidgetAndroid* plugin = viewImpl->getPluginWidget((NPP)npp); - plugin->exitFullScreen(false); + if (plugin) + plugin->exitFullScreen(false); } static WebCore::IntRect jrect_to_webrect(JNIEnv* env, jobject obj) diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index 0569b4d..c662441 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -375,7 +375,7 @@ namespace android { Node* cursorNodeIsPlugin(); // Notify the Java side whether it needs to pass down the touch events - void needTouchEvents(bool); + void needTouchEvents(bool, bool); // Notify the Java side that webkit is requesting a keyboard void requestKeyboard(bool showKeyboard, bool isTextView); @@ -526,6 +526,11 @@ namespace android { bool handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* nodePtr); WebCore::HTMLAnchorElement* retrieveAnchorElement(WebCore::Frame* frame, WebCore::Node* node); +#if ENABLE(TOUCH_EVENTS) + int m_touchEventListenerCount; + IntPoint m_lastTouchPoint; +#endif + #if DEBUG_NAV_UI uint32_t m_now; #endif diff --git a/WebKit/android/nav/CachedRoot.cpp b/WebKit/android/nav/CachedRoot.cpp index d9669bd..5805e5f 100644 --- a/WebKit/android/nav/CachedRoot.cpp +++ b/WebKit/android/nav/CachedRoot.cpp @@ -154,11 +154,11 @@ public: } if (interestingType == false) return false; - if (mBoundsSlop.contains(rect) || + if (!mDrawnOver.contains(rect) && (mBoundsSlop.contains(rect) || (mBounds.fLeft == rect.fLeft && mBounds.fRight == rect.fRight && mBounds.fTop >= rect.fTop && mBounds.fBottom <= rect.fBottom) || (mBounds.fTop == rect.fTop && mBounds.fBottom == rect.fBottom && - mBounds.fLeft >= rect.fLeft && mBounds.fRight <= rect.fRight)) { + mBounds.fLeft >= rect.fLeft && mBounds.fRight <= rect.fRight))) { mDrawnOver.setEmpty(); mAllDrawnIn.join(rect); DBG_NAV_LOGD("BoundsCheck (contains) rect={%d,%d,%d,%d}" @@ -1125,8 +1125,8 @@ bool CachedRoot::maskIfHidden(BestData* best) const checker.drawPicture(*mPicture); boundsCheck.checkLast(); // was it not drawn or clipped out? + CachedNode* node = const_cast<CachedNode*>(best->mNode); if (boundsCheck.hidden()) { // if hidden, return false so that nav can try again - CachedNode* node = const_cast<CachedNode*>(best->mNode); #if DEBUG_NAV_UI const SkIRect& m = boundsCheck.mBounds; const SkIRect& s = boundsCheck.mBoundsSlop; @@ -1177,12 +1177,14 @@ bool CachedRoot::maskIfHidden(BestData* best) const #if DEBUG_NAV_UI const SkIRect& modded = boundsCheck.mBounds; DBG_NAV_LOGD("partially occluded node:%p (%d) old:{%d,%d,%d,%d}" - " new:{%d,%d,%d,%d}", best->mNode, best->mNode->index(), + " new:{%d,%d,%d,%d}", node, node->index(), orig.fLeft, orig.fTop, orig.fRight, orig.fBottom, base.fLeft, base.fTop, base.fRight, base.fBottom); #endif best->mMouseBounds = WebCore::IntRect(bounds.x() + base.fLeft - kMargin, bounds.y() + base.fTop - kMargin, base.width(), base.height()); + node->clip(best->mMouseBounds); + return true; } return false; } diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index 8931d72..dae93fc 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -25,9 +25,8 @@ #define LOG_TAG "webviewglue" -#include <config.h> +#include "config.h" -#include "android_graphics.h" #include "AndroidAnimation.h" #include "AndroidLog.h" #include "AtomicString.h" @@ -55,13 +54,12 @@ #include "SkPixelXorXfermode.h" #include "SkRect.h" #include "SkTime.h" -#include "WebCoreJni.h" -#include "WebViewCore.h" -#include "jni_utility.h" - #ifdef ANDROID_INSTRUMENT #include "TimeCounter.h" #endif +#include "WebCoreJni.h" +#include "WebViewCore.h" +#include "android_graphics.h" #ifdef GET_NATIVE_VIEW #undef GET_NATIVE_VIEW @@ -69,9 +67,10 @@ #define GET_NATIVE_VIEW(env, obj) ((WebView*)env->GetIntField(obj, gWebViewField)) -#include <ui/KeycodeLabels.h> +#include <JNIUtility.h> #include <JNIHelp.h> #include <jni.h> +#include <ui/KeycodeLabels.h> namespace android { @@ -1515,7 +1514,8 @@ static void nativeDrawMatches(JNIEnv *env, jobject obj, jobject canv) } static void nativeDrawLayers(JNIEnv *env, jobject obj, - jint layer, jfloat scrollX, jfloat scrollY, + jint layer, jint scrollX, jint scrollY, + jint width, jint height, jfloat scale, jobject canv) { if (!env) @@ -1529,7 +1529,7 @@ static void nativeDrawLayers(JNIEnv *env, jobject obj, LayerAndroid* layerImpl = reinterpret_cast<LayerAndroid*>(layer); SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, canv); if (canvas) - layerImpl->paintOn(scrollX, scrollY, scale, canvas); + layerImpl->paintOn(scrollX, scrollY, width, height, scale, canvas); #endif } @@ -1998,13 +1998,15 @@ static void nativeMoveCursorToNextTextInput(JNIEnv *env, jobject obj) CachedRoot* root = view->getFrameCache(WebView::DontAllowNewer); if (!root) return; - const CachedNode* current = root->currentCursor(); + const CachedFrame* containingFrame; + const CachedNode* current = root->currentCursor(&containingFrame); if (!current) - current = root->currentFocus(); + current = root->currentFocus(&containingFrame); if (!current) return; const CachedFrame* frame; - const CachedNode* next = root->nextTextField(current, &frame, true); + const CachedNode* next = containingFrame->nextTextField(current, &frame, + true); if (!next) return; const WebCore::IntRect& bounds = next->bounds(); @@ -2134,7 +2136,7 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeLayersHaveAnimations }, { "nativeEvaluateLayersAnimations", "(I)I", (void*) nativeEvaluateLayersAnimations }, - { "nativeDrawLayers", "(IFFFLandroid/graphics/Canvas;)V", + { "nativeDrawLayers", "(IIIIIFLandroid/graphics/Canvas;)V", (void*) nativeDrawLayers }, { "nativeUpdateLayers", "(II)V", (void*) nativeUpdateLayers }, diff --git a/WebKit/android/plugins/ANPSurfaceInterface.cpp b/WebKit/android/plugins/ANPSurfaceInterface.cpp index 02ff77e..6104910 100644 --- a/WebKit/android/plugins/ANPSurfaceInterface.cpp +++ b/WebKit/android/plugins/ANPSurfaceInterface.cpp @@ -25,17 +25,17 @@ // must include config.h first for webkit to fiddle with new/delete #include "config.h" +#include "ANPSurface_npapi.h" #include "PluginView.h" #include "PluginWidgetAndroid.h" #include "SkANP.h" +#include "android_graphics.h" +#include <JNIUtility.h> #include <ui/Surface.h> #include <ui/Rect.h> #include <ui/Region.h> -#include "jni_utility.h" #include <utils/RefBase.h> -#include "android_graphics.h" -#include "ANPSurface_npapi.h" using namespace android; diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp index 113a3bc..b815c90 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp @@ -24,10 +24,15 @@ */ #include "config.h" -#include "android_graphics.h" +#include "PluginWidgetAndroid.h" + +#if ENABLE(TOUCH_EVENTS) +#include "ChromeClient.h" +#endif #include "Document.h" #include "Element.h" #include "Frame.h" +#include "Page.h" #include "PluginPackage.h" #include "PluginView.h" #include "PluginWidgetAndroid.h" @@ -36,7 +41,8 @@ #include "SkFlipPixelRef.h" #include "SkString.h" #include "WebViewCore.h" -#include "jni_utility.h" +#include "android_graphics.h" +#include <JNIUtility.h> #define DEBUG_VISIBLE_RECTS 1 // temporary debug printfs and fixes @@ -48,7 +54,7 @@ PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view) m_eventFlags = 0; m_pluginWindow = NULL; m_requestedVisibleRectCount = 0; - m_requestedFrameRect.setEmpty(); + m_requestedDocRect.setEmpty(); m_visibleDocRect.setEmpty(); m_pluginBounds.setEmpty(); m_hasFocus = false; @@ -56,11 +62,16 @@ PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view) m_visible = true; m_zoomLevel = 0; m_embeddedView = NULL; + m_acceptEvents = false; } PluginWidgetAndroid::~PluginWidgetAndroid() { + m_acceptEvents = false; if (m_core) { m_core->removePlugin(this); + if (m_isFullScreen) { + exitFullScreen(true); + } if (m_embeddedView) { m_core->destroySurface(m_embeddedView); } @@ -78,6 +89,7 @@ PluginWidgetAndroid::~PluginWidgetAndroid() { void PluginWidgetAndroid::init(android::WebViewCore* core) { m_core = core; m_core->addPlugin(this); + m_acceptEvents = true; } static SkBitmap::Config computeConfig(bool isTransparent) { @@ -101,36 +113,32 @@ void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) { if (m_drawingModel == kSurface_ANPDrawingModel) { - IntPoint docPoint = frameToDocumentCoords(window->x, window->y); - - // if the surface exists check for changes and update accordingly - if (m_embeddedView && m_pluginBounds != oldPluginBounds) { - - m_core->updateSurface(m_embeddedView, docPoint.x(), docPoint.y(), - window->width, window->height); - // if the surface does not exist then create a new surface - } else if(!m_embeddedView) { + if (!m_embeddedView) { WebCore::PluginPackage* pkg = m_pluginView->plugin(); NPP instance = m_pluginView->instance(); - jobject pluginSurface; pkg->pluginFuncs()->getvalue(instance, kJavaSurface_ANPGetValue, static_cast<void*>(&pluginSurface)); jobject tempObj = m_core->addSurface(pluginSurface, - docPoint.x(), docPoint.y(), + window->x, window->y, window->width, window->height); if (tempObj) { JNIEnv* env = JSC::Bindings::getJNIEnv(); m_embeddedView = env->NewGlobalRef(tempObj); } - } - if (m_isFullScreen && m_pluginBounds != oldPluginBounds) { - m_core->updateFullScreenPlugin(docPoint.x(), docPoint.y(), - window->width, window->height); + } else if (m_pluginBounds != oldPluginBounds) { + // if the surface exists check for changes and update accordingly + if (m_isFullScreen) { + m_core->updateFullScreenPlugin(window->x, window->y, + window->width, window->height); + } else { + m_core->updateSurface(m_embeddedView, window->x, window->y, + window->width, window->height); + } } } else { m_flipPixelRef->safeUnref(); @@ -144,14 +152,7 @@ bool PluginWidgetAndroid::setDrawingModel(ANPDrawingModel model) { return true; } -void PluginWidgetAndroid::localToDocumentCoords(SkIRect* rect) const { - if (m_pluginWindow) { - IntPoint pluginDocCoords = frameToDocumentCoords(m_pluginWindow->x, - m_pluginWindow->y); - rect->offset(pluginDocCoords.x(), pluginDocCoords.y()); - } -} - +// returned rect is in the page coordinate bool PluginWidgetAndroid::isDirty(SkIRect* rect) const { // nothing to report if we haven't had setWindow() called yet if (NULL == m_flipPixelRef) { @@ -164,6 +165,7 @@ bool PluginWidgetAndroid::isDirty(SkIRect* rect) const { } else { if (rect) { *rect = dirty.getBounds(); + rect->offset(m_pluginWindow->x, m_pluginWindow->y); } return true; } @@ -211,8 +213,7 @@ void PluginWidgetAndroid::draw(SkCanvas* canvas) { if (canvas && m_pluginWindow) { SkBitmap bm(bitmap); bm.setPixelRef(m_flipPixelRef); - canvas->drawBitmap(bm, SkIntToScalar(m_pluginWindow->x), - SkIntToScalar(m_pluginWindow->y), NULL); + canvas->drawBitmap(bm, 0, 0); } } break; @@ -223,6 +224,8 @@ void PluginWidgetAndroid::draw(SkCanvas* canvas) { } bool PluginWidgetAndroid::sendEvent(const ANPEvent& evt) { + if (!m_acceptEvents) + return false; WebCore::PluginPackage* pkg = m_pluginView->plugin(); NPP instance = m_pluginView->instance(); // "missing" plugins won't have these @@ -252,12 +255,18 @@ void PluginWidgetAndroid::updateEventFlags(ANPEventFlags flags) { } Document* doc = m_pluginView->getParentFrame()->document(); +#if ENABLE(TOUCH_EVENTS) if((m_eventFlags ^ flags) & kTouch_ANPEventFlag) { - if(flags & kTouch_ANPEventFlag) - doc->addTouchEventListener(m_pluginView->getElement()); - else - doc->removeTouchEventListener(m_pluginView->getElement()); + if (flags & kTouch_ANPEventFlag) { + if (Page* page = doc->page()) + page->chrome()->client()->needTouchEvents(true, false); + doc->addListenerTypeIfNeeded(eventNames().touchstartEvent); + } else { + if (Page* page = doc->page()) + page->chrome()->client()->needTouchEvents(false, false); + } } +#endif m_eventFlags = flags; } @@ -283,7 +292,7 @@ void PluginWidgetAndroid::setVisibleScreen(const ANPRectI& visibleDocRect, float int newScreenH = m_visibleDocRect.height(); if (oldScreenW != newScreenW || oldScreenH != newScreenH) - computeVisibleFrameRect(); + computeVisibleDocRect(); bool visible = SkIRect::Intersects(m_visibleDocRect, m_pluginBounds); if(m_visible != visible) { @@ -328,10 +337,10 @@ void PluginWidgetAndroid::setVisibleRects(const ANPRectI rects[], int32_t count) } } #endif - computeVisibleFrameRect(); + computeVisibleDocRect(); } -void PluginWidgetAndroid::computeVisibleFrameRect() { +void PluginWidgetAndroid::computeVisibleDocRect() { // ensure the visibleDocRect has been set (i.e. not equal to zero) if (m_visibleDocRect.isEmpty() || !m_pluginWindow) @@ -345,7 +354,7 @@ void PluginWidgetAndroid::computeVisibleFrameRect() { ANPRectI* rect = &m_requestedVisibleRect[counter]; - // create skia rect for easier manipulation and convert it to frame coordinates + // create skia rect for easier manipulation and convert it to page coordinates SkIRect pluginRect; pluginRect.set(rect->left, rect->top, rect->right, rect->bottom); pluginRect.offset(m_pluginWindow->x, m_pluginWindow->y); @@ -377,35 +386,27 @@ void PluginWidgetAndroid::computeVisibleFrameRect() { visibleRect = pluginRect; } - m_requestedFrameRect = visibleRect; - scrollToVisibleFrameRect(); + m_requestedDocRect = visibleRect; + scrollToVisibleDocRect(); } -void PluginWidgetAndroid::scrollToVisibleFrameRect() { +void PluginWidgetAndroid::scrollToVisibleDocRect() { - if (!m_hasFocus || m_requestedFrameRect.isEmpty() || m_visibleDocRect.isEmpty()) { + if (!m_hasFocus || m_requestedDocRect.isEmpty() || m_visibleDocRect.isEmpty()) { #if DEBUG_VISIBLE_RECTS - SkDebugf("%s call m_hasFocus=%d m_requestedFrameRect.isEmpty()=%d" + SkDebugf("%s call m_hasFocus=%d m_requestedDocRect.isEmpty()=%d" " m_visibleDocRect.isEmpty()=%d", __FUNCTION__, m_hasFocus, - m_requestedFrameRect.isEmpty(), m_visibleDocRect.isEmpty()); + m_requestedDocRect.isEmpty(), m_visibleDocRect.isEmpty()); #endif return; } - // if the entire rect is already visible then we don't need to scroll, which - // requires converting the m_requestedFrameRect from frame to doc coordinates - IntPoint pluginDocPoint = frameToDocumentCoords(m_requestedFrameRect.fLeft, - m_requestedFrameRect.fTop); - SkIRect requestedDocRect; - requestedDocRect.set(pluginDocPoint.x(), pluginDocPoint.y(), - pluginDocPoint.x() + m_requestedFrameRect.width(), - pluginDocPoint.y() + m_requestedFrameRect.height()); - - if (m_visibleDocRect.contains(requestedDocRect)) + // if the entire rect is already visible then we don't need to scroll + if (m_visibleDocRect.contains(m_requestedDocRect)) return; // find the center of the visibleRect in document coordinates - int rectCenterX = requestedDocRect.fLeft + requestedDocRect.width()/2; - int rectCenterY = requestedDocRect.fTop + requestedDocRect.height()/2; + int rectCenterX = m_requestedDocRect.fLeft + m_requestedDocRect.width()/2; + int rectCenterY = m_requestedDocRect.fTop + m_requestedDocRect.height()/2; // find document coordinates for center of the visible screen int screenCenterX = m_visibleDocRect.fLeft + m_visibleDocRect.width()/2; @@ -423,24 +424,6 @@ void PluginWidgetAndroid::scrollToVisibleFrameRect() { core->scrollBy(deltaX, deltaY, true); } -IntPoint PluginWidgetAndroid::frameToDocumentCoords(int frameX, int frameY) const { - IntPoint docPoint = IntPoint(frameX, frameY); - - const ScrollView* currentScrollView = m_pluginView->parent(); - if (currentScrollView) { - const ScrollView* parentScrollView = currentScrollView->parent(); - while (parentScrollView) { - - docPoint.move(currentScrollView->x(), currentScrollView->y()); - - currentScrollView = parentScrollView; - parentScrollView = parentScrollView->parent(); - } - } - - return docPoint; -} - void PluginWidgetAndroid::requestFullScreen() { if (m_isFullScreen || !m_embeddedView) { return; @@ -456,9 +439,8 @@ void PluginWidgetAndroid::requestFullScreen() { m_core->destroySurface(m_embeddedView); // add the full screen view - IntPoint docPoint = frameToDocumentCoords(m_pluginWindow->x, m_pluginWindow->y); m_core->showFullScreenPlugin(m_embeddedView, m_pluginView->instance(), - docPoint.x(), docPoint.y(), m_pluginWindow->width, + m_pluginWindow->x, m_pluginWindow->y, m_pluginWindow->width, m_pluginWindow->height); m_isFullScreen = true; } @@ -474,8 +456,7 @@ void PluginWidgetAndroid::exitFullScreen(bool pluginInitiated) { } // add the embedded view back - IntPoint docPoint = frameToDocumentCoords(m_pluginWindow->x, m_pluginWindow->y); - m_core->updateSurface(m_embeddedView, docPoint.x(), docPoint.y(), + m_core->updateSurface(m_embeddedView, m_pluginWindow->x, m_pluginWindow->y, m_pluginWindow->width, m_pluginWindow->height); // send event to notify plugin of full screen change diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h index 93ad4a8..6633e1b 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.h +++ b/WebKit/android/plugins/PluginWidgetAndroid.h @@ -28,6 +28,7 @@ #include "android_npapi.h" #include "IntPoint.h" +#include "IntRect.h" #include "SkRect.h" #include <jni.h> @@ -73,14 +74,8 @@ struct PluginWidgetAndroid { */ bool setDrawingModel(ANPDrawingModel); - /* Utility method to convert from local (plugin) coordinates to document - coordinates. Needed (for instance) to convert the dirty rectangle into - document coordinates to inturn inval the screen. - */ - void localToDocumentCoords(SkIRect*) const; - - /* Returns true (and optionally updates rect with the dirty bounds) if - the plugin has invalidate us. + /* Returns true (and optionally updates rect with the dirty bounds in the + page coordinate) if the plugin has invalidate us. */ bool isDirty(SkIRect* dirtyBounds = NULL) const; /* Called by PluginView to invalidate a portion of the plugin area (in @@ -141,9 +136,8 @@ struct PluginWidgetAndroid { bool inFullScreen() { return m_isFullScreen; } private: - WebCore::IntPoint frameToDocumentCoords(int frameX, int frameY) const; - void computeVisibleFrameRect(); - void scrollToVisibleFrameRect(); + void computeVisibleDocRect(); + void scrollToVisibleDocRect(); WebCore::PluginView* m_pluginView; android::WebViewCore* m_core; @@ -151,14 +145,15 @@ private: ANPDrawingModel m_drawingModel; ANPEventFlags m_eventFlags; NPWindow* m_pluginWindow; - SkIRect m_pluginBounds; - SkIRect m_visibleDocRect; - SkIRect m_requestedFrameRect; + SkIRect m_pluginBounds; // relative to the page + SkIRect m_visibleDocRect; // relative to the page + SkIRect m_requestedDocRect; // relative to the page bool m_hasFocus; bool m_isFullScreen; bool m_visible; float m_zoomLevel; jobject m_embeddedView; + bool m_acceptEvents; /* We limit the number of rectangles to minimize storage and ensure adequate speed. diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog index d55548b..97b361a 100644 --- a/WebKit/chromium/ChangeLog +++ b/WebKit/chromium/ChangeLog @@ -1,3 +1,18 @@ +2009-12-13 Sam Weinig <sam@webkit.org> + + Reviewed by Dan Bernstein. + + Fix for https://bugs.webkit.org/show_bug.cgi?id=32499 + Add client based Geolocation provider + + Add first cut of a client based Geolocation provider. This is guarded by + ENABLE(CLIENT_BASED_GEOLOCATION) and is off by default for now. This adds a + GeolocationControllerClient interface that no-one currently implements, + but will in a subsequent patch. + + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::WebViewImpl): + 2009-12-10 Mike Belshe <mike@belshe.com> Unreviewed, build fix for chromium. diff --git a/WebKit/chromium/src/WebViewImpl.cpp b/WebKit/chromium/src/WebViewImpl.cpp index 357cdca..030c4bd 100644 --- a/WebKit/chromium/src/WebViewImpl.cpp +++ b/WebKit/chromium/src/WebViewImpl.cpp @@ -229,6 +229,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client) &m_editorClientImpl, &m_dragClientImpl, &m_inspectorClientImpl, + 0, 0)); m_page->backForwardList()->setClient(&m_backForwardListClientImpl); diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog index ac80deb..a72e2c9 100644 --- a/WebKit/gtk/ChangeLog +++ b/WebKit/gtk/ChangeLog @@ -1,3 +1,18 @@ +2009-12-13 Sam Weinig <sam@webkit.org> + + Reviewed by Dan Bernstein. + + Fix for https://bugs.webkit.org/show_bug.cgi?id=32499 + Add client based Geolocation provider + + Add first cut of a client based Geolocation provider. This is guarded by + ENABLE(CLIENT_BASED_GEOLOCATION) and is off by default for now. This adds a + GeolocationControllerClient interface that no-one currently implements, + but will in a subsequent patch. + + * webkit/webkitwebview.cpp: + (webkit_web_view_init): + 2009-12-10 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk> Reviewed by Xan Lopez. diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp index bebd01a..211f671 100644 --- a/WebKit/gtk/webkit/webkitwebview.cpp +++ b/WebKit/gtk/webkit/webkitwebview.cpp @@ -2589,7 +2589,7 @@ static void webkit_web_view_init(WebKitWebView* webView) priv->imContext = gtk_im_multicontext_new(); WebKit::InspectorClient* inspectorClient = new WebKit::InspectorClient(webView); - priv->corePage = new Page(new WebKit::ChromeClient(webView), new WebKit::ContextMenuClient(webView), new WebKit::EditorClient(webView), new WebKit::DragClient(webView), inspectorClient, 0); + priv->corePage = new Page(new WebKit::ChromeClient(webView), new WebKit::ContextMenuClient(webView), new WebKit::EditorClient(webView), new WebKit::DragClient(webView), inspectorClient, 0, 0); // We also add a simple wrapper class to provide the public // interface for the Web Inspector. diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog index b05f2a8..17c7470 100644 --- a/WebKit/mac/ChangeLog +++ b/WebKit/mac/ChangeLog @@ -1,3 +1,27 @@ +2010-01-19 Steve Block <steveblock@google.com> + + Reviewed by Adam Barth. + + Renames WebCore/bridge/runtime.[cpp|h] to WebCore/bridge/Bridge.[cpp|h] + https://bugs.webkit.org/show_bug.cgi?id=33801 + + * Plugins/Hosted/ProxyInstance.h: + +2009-12-13 Sam Weinig <sam@webkit.org> + + Reviewed by Dan Bernstein. + + Fix for https://bugs.webkit.org/show_bug.cgi?id=32499 + Add client based Geolocation provider + + Add first cut of a client based Geolocation provider. This is guarded by + ENABLE(CLIENT_BASED_GEOLOCATION) and is off by default for now. This adds a + GeolocationControllerClient interface that no-one currently implements, + but will in a subsequent patch. + + * WebView/WebView.mm: + (-[WebView _commonInitializationWithFrameName:groupName:usesDocumentViews:]): + 2009-12-10 Jon Honeycutt <jhoneycutt@apple.com> Mac build fix. Unreviewed. diff --git a/WebKit/mac/Plugins/Hosted/ProxyInstance.h b/WebKit/mac/Plugins/Hosted/ProxyInstance.h index 8a07def..f84c685 100644 --- a/WebKit/mac/Plugins/Hosted/ProxyInstance.h +++ b/WebKit/mac/Plugins/Hosted/ProxyInstance.h @@ -28,7 +28,7 @@ #ifndef ProxyInstance_h #define ProxyInstance_h -#include <WebCore/runtime.h> +#include <WebCore/Bridge.h> #include <WebCore/runtime_root.h> #include <wtf/OwnPtr.h> #include "WebKitPluginHostTypes.h" diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm index 33ea069..ad8f33a 100644 --- a/WebKit/mac/WebView/WebView.mm +++ b/WebKit/mac/WebView/WebView.mm @@ -607,7 +607,7 @@ static bool runningTigerMail() didOneTimeInitialization = true; } - _private->page = new Page(new WebChromeClient(self), new WebContextMenuClient(self), new WebEditorClient(self), new WebDragClient(self), new WebInspectorClient(self), new WebPluginHalterClient(self)); + _private->page = new Page(new WebChromeClient(self), new WebContextMenuClient(self), new WebEditorClient(self), new WebDragClient(self), new WebInspectorClient(self), new WebPluginHalterClient(self), 0); _private->page->settings()->setLocalStorageDatabasePath([[self preferences] _localStorageDatabasePath]); diff --git a/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp index ef97c3b..b98b4d5 100644 --- a/WebKit/qt/Api/qwebframe.cpp +++ b/WebKit/qt/Api/qwebframe.cpp @@ -21,6 +21,7 @@ #include "config.h" #include "qwebframe.h" +#include "Bridge.h" #include "CallFrame.h" #include "Document.h" #include "DocumentLoader.h" @@ -67,7 +68,6 @@ #include "qwebpage_p.h" #include "qwebsecurityorigin.h" #include "qwebsecurityorigin_p.h" -#include "runtime.h" #include "runtime_object.h" #include "runtime_root.h" #include "wtf/HashMap.h" diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp index ba6b9f3..50cbaf0 100644 --- a/WebKit/qt/Api/qwebpage.cpp +++ b/WebKit/qt/Api/qwebpage.cpp @@ -376,7 +376,7 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq) contextMenuClient = new ContextMenuClientQt(); editorClient = new EditorClientQt(q); page = new Page(chromeClient, contextMenuClient, editorClient, - new DragClientQt(q), new InspectorClientQt(q), 0); + new DragClientQt(q), new InspectorClientQt(q), 0, 0); settings = new QWebSettings(page->settings()); diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog index 2c2722b..4d2467a 100644 --- a/WebKit/qt/ChangeLog +++ b/WebKit/qt/ChangeLog @@ -1,3 +1,27 @@ +2010-01-19 Steve Block <steveblock@google.com> + + Reviewed by Adam Barth. + + Renames WebCore/bridge/runtime.[cpp|h] to WebCore/bridge/Bridge.[cpp|h] + https://bugs.webkit.org/show_bug.cgi?id=33801 + + * Api/qwebframe.cpp: + +2009-12-13 Sam Weinig <sam@webkit.org> + + Reviewed by Dan Bernstein. + + Fix for https://bugs.webkit.org/show_bug.cgi?id=32499 + Add client based Geolocation provider + + Add first cut of a client based Geolocation provider. This is guarded by + ENABLE(CLIENT_BASED_GEOLOCATION) and is off by default for now. This adds a + GeolocationControllerClient interface that no-one currently implements, + but will in a subsequent patch. + + * Api/qwebpage.cpp: + (QWebPagePrivate::QWebPagePrivate): + 2009-12-07 Benjamin Poulain <benjamin.poulain@nokia.com> Reviewed by Kenneth Rohde Christiansen. diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog index 95705a9..9ea12f6 100644 --- a/WebKit/win/ChangeLog +++ b/WebKit/win/ChangeLog @@ -1,3 +1,18 @@ +2009-12-13 Sam Weinig <sam@webkit.org> + + Reviewed by Dan Bernstein. + + Fix for https://bugs.webkit.org/show_bug.cgi?id=32499 + Add client based Geolocation provider + + Add first cut of a client based Geolocation provider. This is guarded by + ENABLE(CLIENT_BASED_GEOLOCATION) and is off by default for now. This adds a + GeolocationControllerClient interface that no-one currently implements, + but will in a subsequent patch. + + * WebView.cpp: + (WebView::initWithFrame): + 2009-12-10 Jon Honeycutt <jhoneycutt@apple.com> Pass more information about a plug-in to the PluginHalterDelegate diff --git a/WebKit/win/WebView.cpp b/WebKit/win/WebView.cpp index d98d390..aadf15e 100644 --- a/WebKit/win/WebView.cpp +++ b/WebKit/win/WebView.cpp @@ -2394,7 +2394,7 @@ HRESULT STDMETHODCALLTYPE WebView::initWithFrame( if (SUCCEEDED(m_preferences->shouldUseHighResolutionTimers(&useHighResolutionTimer))) Settings::setShouldUseHighResolutionTimers(useHighResolutionTimer); - m_page = new Page(new WebChromeClient(this), new WebContextMenuClient(this), new WebEditorClient(this), new WebDragClient(this), new WebInspectorClient(this), new WebPluginHalterClient(this)); + m_page = new Page(new WebChromeClient(this), new WebContextMenuClient(this), new WebEditorClient(this), new WebDragClient(this), new WebInspectorClient(this), new WebPluginHalterClient(this), 0); BSTR localStoragePath; if (SUCCEEDED(m_preferences->localStorageDatabasePath(&localStoragePath))) { |
