summaryrefslogtreecommitdiffstats
path: root/WebCore
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore')
-rw-r--r--WebCore/Android.derived.jscbindings.mk1
-rw-r--r--WebCore/Android.derived.v8bindings.mk1
-rw-r--r--WebCore/Android.jscbindings.mk10
-rw-r--r--WebCore/Android.mk5
-rw-r--r--WebCore/Android.v8bindings.mk8
-rw-r--r--WebCore/ChangeLog208
-rw-r--r--WebCore/GNUmakefile.am12
-rw-r--r--WebCore/WebCore.base.exp14
-rw-r--r--WebCore/WebCore.gypi5
-rw-r--r--WebCore/WebCore.pro4
-rw-r--r--WebCore/WebCore.vcproj/WebCore.vcproj20
-rw-r--r--WebCore/WebCore.xcodeproj/project.pbxproj68
-rw-r--r--WebCore/WebCoreSources.bkl3
-rw-r--r--WebCore/bindings/js/JSEventCustom.cpp4
-rw-r--r--WebCore/bindings/js/ScriptController.cpp2
-rw-r--r--WebCore/bindings/v8/ChildThreadDOMData.h3
-rw-r--r--WebCore/bindings/v8/DOMData.cpp4
-rw-r--r--WebCore/bindings/v8/DOMData.h4
-rw-r--r--WebCore/bindings/v8/DOMObjectsInclude.h1
-rw-r--r--WebCore/bindings/v8/NPV8Object.cpp23
-rw-r--r--WebCore/bindings/v8/NPV8Object.h7
-rw-r--r--WebCore/bindings/v8/ScriptController.cpp18
-rw-r--r--WebCore/bindings/v8/ScriptObject.cpp2
-rw-r--r--WebCore/bindings/v8/V8DOMWrapper.cpp9
-rw-r--r--WebCore/bindings/v8/V8DOMWrapper.h3
-rw-r--r--WebCore/bindings/v8/V8GCController.cpp14
-rw-r--r--WebCore/bindings/v8/V8Index.cpp1
-rw-r--r--WebCore/bindings/v8/V8Index.h3
-rw-r--r--WebCore/bindings/v8/WorkerContextExecutionProxy.cpp5
-rw-r--r--WebCore/bridge/Bridge.h110
-rw-r--r--WebCore/bridge/jni/JNIBridge.cpp576
-rw-r--r--WebCore/bridge/jni/JNIBridge.h166
-rw-r--r--WebCore/bridge/jni/JNIUtility.cpp (renamed from WebCore/bridge/jni/jni_utility.cpp)284
-rw-r--r--WebCore/bridge/jni/JNIUtility.h (renamed from WebCore/bridge/jni/jni_utility.h)103
-rw-r--r--WebCore/bridge/jni/jni_jsobject.mm6
-rw-r--r--WebCore/bridge/jni/jni_objc.mm4
-rw-r--r--WebCore/bridge/jni/jni_runtime.cpp553
-rw-r--r--WebCore/bridge/jni/jni_runtime.h172
-rw-r--r--WebCore/bridge/jni/jsc/JNIUtilityPrivate.cpp (renamed from WebCore/bridge/jni/jsc/jni_utility_private.cpp)8
-rw-r--r--WebCore/bridge/jni/jsc/JNIUtilityPrivate.h (renamed from WebCore/bridge/jni/jsc/jni_utility_private.h)8
-rw-r--r--WebCore/bridge/jni/jsc/JavaClassJSC.cpp3
-rw-r--r--WebCore/bridge/jni/jsc/JavaClassJSC.h2
-rw-r--r--WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp6
-rw-r--r--WebCore/bridge/jni/jsc/JavaStringJSC.h2
-rw-r--r--WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp (renamed from WebCore/bridge/jni/v8/jni_utility_private.cpp)60
-rw-r--r--WebCore/bridge/jni/v8/JNIUtilityPrivate.h (renamed from WebCore/bridge/jni/v8/jni_utility_private.h)8
-rw-r--r--WebCore/bridge/jni/v8/JavaClassV8.cpp114
-rw-r--r--WebCore/bridge/jni/v8/JavaClassV8.h62
-rw-r--r--WebCore/bridge/jni/v8/JavaInstanceV8.cpp168
-rw-r--r--WebCore/bridge/jni/v8/JavaInstanceV8.h99
-rw-r--r--WebCore/bridge/jni/v8/JavaNPObjectV8.cpp166
-rw-r--r--WebCore/bridge/jni/v8/JavaNPObjectV8.h58
-rw-r--r--WebCore/bridge/jni/v8/JavaStringV8.h63
-rw-r--r--WebCore/bridge/jsc/BridgeJSC.cpp (renamed from WebCore/bridge/Bridge.cpp)3
-rw-r--r--WebCore/bridge/jsc/BridgeJSC.h151
-rw-r--r--WebCore/config.h1
-rw-r--r--WebCore/dom/Document.cpp74
-rw-r--r--WebCore/dom/Document.h41
-rw-r--r--WebCore/dom/Document.idl12
-rw-r--r--WebCore/dom/Element.h7
-rw-r--r--WebCore/dom/Element.idl12
-rw-r--r--WebCore/dom/Event.cpp10
-rw-r--r--WebCore/dom/Event.h6
-rw-r--r--WebCore/dom/EventNames.h17
-rw-r--r--WebCore/dom/Node.cpp32
-rw-r--r--WebCore/dom/Node.h7
-rw-r--r--WebCore/dom/Touch.cpp6
-rw-r--r--WebCore/dom/Touch.h64
-rw-r--r--WebCore/dom/TouchEvent.cpp16
-rw-r--r--WebCore/dom/TouchEvent.h106
-rw-r--r--WebCore/dom/TouchEvent.idl10
-rw-r--r--WebCore/dom/TouchList.cpp2
-rw-r--r--WebCore/dom/TouchList.h28
-rw-r--r--WebCore/html/HTMLAttributeNames.in2
-rw-r--r--WebCore/html/HTMLElement.cpp14
-rw-r--r--WebCore/html/HTMLInputElement.cpp4
-rw-r--r--WebCore/html/HTMLTextAreaElement.cpp2
-rw-r--r--WebCore/html/HTMLTokenizer.cpp4
-rw-r--r--WebCore/loader/CachedImage.cpp2
-rw-r--r--WebCore/loader/FrameLoader.cpp22
-rw-r--r--WebCore/loader/FrameLoader.h5
-rw-r--r--WebCore/page/ChromeClient.h4
-rw-r--r--WebCore/page/Connection.cpp39
-rw-r--r--WebCore/page/Connection.h54
-rw-r--r--WebCore/page/Connection.idl38
-rw-r--r--WebCore/page/DOMWindow.h5
-rw-r--r--WebCore/page/DOMWindow.idl19
-rw-r--r--WebCore/page/EventHandler.cpp333
-rw-r--r--WebCore/page/EventHandler.h33
-rw-r--r--WebCore/page/FrameView.cpp8
-rw-r--r--WebCore/page/Geolocation.cpp162
-rw-r--r--WebCore/page/Geolocation.h31
-rw-r--r--WebCore/page/GeolocationController.cpp86
-rw-r--r--WebCore/page/GeolocationController.h67
-rw-r--r--WebCore/page/GeolocationControllerClient.h45
-rw-r--r--WebCore/page/GeolocationError.h60
-rw-r--r--WebCore/page/GeolocationPosition.h110
-rw-r--r--WebCore/page/Geoposition.h7
-rw-r--r--WebCore/page/Navigator.cpp12
-rw-r--r--WebCore/page/Navigator.h10
-rw-r--r--WebCore/page/Navigator.idl3
-rw-r--r--WebCore/page/Page.cpp13
-rw-r--r--WebCore/page/Page.h10
-rw-r--r--WebCore/platform/PlatformTouchEvent.h127
-rw-r--r--WebCore/platform/PlatformTouchPoint.h69
-rw-r--r--WebCore/platform/Timer.cpp5
-rw-r--r--WebCore/platform/android/GeolocationServiceAndroid.cpp10
-rw-r--r--WebCore/platform/android/GeolocationServiceBridge.cpp1
-rw-r--r--WebCore/platform/android/GeolocationServiceBridge.h2
-rw-r--r--WebCore/platform/android/PlatformBridge.h61
-rw-r--r--WebCore/platform/android/PlatformTouchEventAndroid.cpp (renamed from WebCore/platform/network/android/Cookie.cpp)34
-rw-r--r--WebCore/platform/android/PlatformTouchPointAndroid.cpp41
-rw-r--r--WebCore/platform/android/TemporaryLinkStubs.cpp2
-rw-r--r--WebCore/platform/graphics/BitmapImage.h2
-rw-r--r--WebCore/platform/graphics/FloatPoint.h2
-rw-r--r--WebCore/platform/graphics/FloatRect.h4
-rw-r--r--WebCore/platform/graphics/Gradient.cpp2
-rw-r--r--WebCore/platform/graphics/Gradient.h10
-rw-r--r--WebCore/platform/graphics/GraphicsContext.cpp6
-rw-r--r--WebCore/platform/graphics/GraphicsContext.h18
-rw-r--r--WebCore/platform/graphics/Image.h2
-rw-r--r--WebCore/platform/graphics/ImageSource.h18
-rw-r--r--WebCore/platform/graphics/IntPoint.h4
-rw-r--r--WebCore/platform/graphics/IntRect.h4
-rw-r--r--WebCore/platform/graphics/Path.h3
-rw-r--r--WebCore/platform/graphics/Pattern.h2
-rw-r--r--WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp1
-rw-r--r--WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h2
-rw-r--r--WebCore/platform/graphics/skia/NativeImageSkia.cpp5
-rw-r--r--WebCore/platform/graphics/transforms/TransformationMatrix.h4
-rw-r--r--WebCore/platform/image-decoders/ImageDecoder.h11
-rw-r--r--WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp5
-rw-r--r--WebCore/platform/network/NetworkStateNotifier.h21
-rw-r--r--WebCore/platform/network/ResourceHandle.h2
-rw-r--r--WebCore/platform/network/ResourceHandleInternal.h3
-rw-r--r--WebCore/platform/network/android/AuthenticationChallenge.h2
-rw-r--r--WebCore/platform/network/android/CookieJarAndroid.cpp (renamed from WebCore/platform/network/android/CookieClient.h)31
-rw-r--r--WebCore/platform/network/android/NetworkStateNotifierAndroid.cpp11
-rw-r--r--WebCore/plugins/PluginPackage.h8
-rw-r--r--WebCore/plugins/android/PluginPackageAndroid.cpp68
-rw-r--r--WebCore/plugins/android/PluginViewAndroid.cpp19
-rw-r--r--WebCore/plugins/npfunctions.h2
-rw-r--r--WebCore/rendering/RenderBlockLineLayout.cpp5
-rw-r--r--WebCore/rendering/RenderPartObject.cpp15
-rw-r--r--WebCore/svg/graphics/SVGImage.cpp2
-rw-r--r--WebCore/svg/graphics/SVGPaintServer.cpp4
146 files changed, 3795 insertions, 1927 deletions
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 9309d6e..59daf8d 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 \
@@ -52,6 +53,7 @@ BINDING_C_INCLUDES := \
$(base_intermediates)/WebCore/page \
$(base_intermediates)/WebCore/plugins \
$(base_intermediates)/WebCore/storage \
+ $(base_intermediates)/WebCore/svg \
$(base_intermediates)/WebCore/workers \
$(base_intermediates)/WebCore/xml
@@ -181,18 +183,18 @@ LOCAL_SRC_FILES += \
\
bindings/ScriptControllerBase.cpp \
\
- bridge/Bridge.cpp \
bridge/IdentifierRep.cpp \
bridge/NP_jsobject.cpp \
bridge/c/c_class.cpp \
bridge/c/c_instance.cpp \
bridge/c/c_runtime.cpp \
bridge/c/c_utility.cpp \
- bridge/jni/jni_runtime.cpp \
- bridge/jni/jni_utility.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/jni/jsc/jni_utility_private.cpp \
+ bridge/jsc/BridgeJSC.cpp \
bridge/npruntime.cpp \
bridge/runtime_array.cpp \
bridge/runtime_method.cpp \
diff --git a/WebCore/Android.mk b/WebCore/Android.mk
index 0ab375b..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 \
@@ -517,7 +520,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
platform/network/ResourceRequestBase.cpp \
platform/network/ResourceResponseBase.cpp \
\
- platform/network/android/Cookie.cpp \
+ platform/network/android/CookieJarAndroid.cpp \
platform/network/android/NetworkStateNotifierAndroid.cpp \
platform/network/android/ResourceHandleAndroid.cpp \
platform/network/android/ResourceRequestAndroid.cpp \
diff --git a/WebCore/Android.v8bindings.mk b/WebCore/Android.v8bindings.mk
index 5ab8e69..683de78 100644
--- a/WebCore/Android.v8bindings.mk
+++ b/WebCore/Android.v8bindings.mk
@@ -33,6 +33,7 @@ BINDING_C_INCLUDES := \
$(LOCAL_PATH)/bridge \
\
$(base_intermediates)/WebCore/bindings \
+ $(base_intermediates)/WebCore/svg \
$(base_intermediates)/JavaScriptCore
LOCAL_SRC_FILES += \
@@ -171,5 +172,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 80ec313..20bedf2 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,87 @@
+2010-01-18 Steve Falkenburg <sfalken@apple.com>
+
+ Reviewed by Sam Weinig.
+
+ <https://bugs.webkit.org/show_bug.cgi?id=33816>
+ Crashes in Geolocation code due to refcounting, observer balance issues.
+
+ Hold a ref to the GeoNotifier while dispatching a callback. The code was
+ copying a data member to avoid accessing a freed this ptr, but was still
+ using the this ptr.
+
+ Geolocation::removeObserver calls are not always balanced with addObserver.
+ Instead of asserting and continuing, don't try to remove non-existant
+ observers.
+
+ * page/Geolocation.cpp:
+ (WebCore::Geolocation::GeoNotifier::timerFired): Protect notifier.
+ * page/GeolocationController.cpp:
+ (WebCore::GeolocationController::removeObserver): Change ASSERT into an if with early return.
+
+2009-12-14 Sam Weinig <sam@webkit.org>
+
+ Fix the build.
+
+ * page/Geolocation.cpp:
+ * page/Geolocation.h:
+
+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.
@@ -29,6 +113,51 @@
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
@@ -160,6 +289,85 @@
* 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.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index fecc04c..9c5f000 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -484,7 +484,6 @@ webcore_sources += \
WebCore/bindings/js/SerializedScriptValue.h \
WebCore/bindings/js/StringSourceProvider.h \
WebCore/bindings/ScriptControllerBase.cpp \
- WebCore/bridge/Bridge.cpp \
WebCore/bridge/Bridge.h \
WebCore/bridge/IdentifierRep.cpp \
WebCore/bridge/IdentifierRep.h \
@@ -498,11 +497,13 @@ webcore_sources += \
WebCore/bridge/c/c_runtime.h \
WebCore/bridge/c/c_utility.cpp \
WebCore/bridge/c/c_utility.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 \
@@ -1348,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 e31c78c..4dc1294 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -775,7 +775,6 @@ SOURCES += \
bindings/js/ScheduledAction.cpp \
bindings/js/SerializedScriptValue.cpp \
bindings/ScriptControllerBase.cpp \
- bridge/Bridge.cpp \
bridge/IdentifierRep.cpp \
bridge/NP_jsobject.cpp \
bridge/npruntime.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 \
@@ -1463,6 +1464,7 @@ HEADERS += \
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 \
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 987136d..8c805ad 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -298,10 +298,6 @@
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, ); }; };
@@ -1095,8 +1091,8 @@
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 */; };
@@ -1106,6 +1102,10 @@
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 */; };
@@ -4190,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 */; };
@@ -5519,10 +5524,6 @@
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>"; };
@@ -6420,8 +6421,8 @@
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>"; };
@@ -6431,6 +6432,10 @@
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>"; };
@@ -9358,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>"; };
@@ -10282,14 +10292,14 @@
1A569CCE0D7E2B82007C3983 /* jni */ = {
isa = PBXGroup;
children = (
+ 5913953C1107584E0083EC55 /* JNIBridge.cpp */,
+ 5913953A110758450083EC55 /* JNIBridge.h */,
+ 59EE12311106082900885116 /* JNIUtility.h */,
+ 59EE122F1106081F00885116 /* JNIUtility.cpp */,
599D1E2F10C97D4C00E0EF12 /* jsc */,
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;
@@ -10984,13 +10994,13 @@
599D1E2F10C97D4C00E0EF12 /* jsc */ = {
isa = PBXGroup;
children = (
+ 59EE122D1106080F00885116 /* JNIUtilityPrivate.h */,
+ 59EE122B1106080500885116 /* JNIUtilityPrivate.cpp */,
59BC393E11054A1300FD85DB /* JavaStringJSC.h */,
59E560A81105336F00AA1258 /* JavaClassJSC.cpp */,
59E560A61105336600AA1258 /* JavaClassJSC.h */,
59A9E7B11104759400DFB4C1 /* JavaInstanceJSC.h */,
59A9E7AF1104758800DFB4C1 /* JavaInstanceJSC.cpp */,
- 599D1E3010C97D6E00E0EF12 /* jni_utility_private.cpp */,
- 599D1E3110C97D6E00E0EF12 /* jni_utility_private.h */,
);
name = jsc;
sourceTree = "<group>";
@@ -11278,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 */,
@@ -17058,8 +17073,6 @@
1C81BA010E9733CB00266E07 /* JavaScriptProfile.h in Headers */,
1C81B9FF0E9733CB00266E07 /* JavaScriptProfileNode.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 */,
@@ -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;
};
@@ -18270,6 +18286,9 @@
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 = (
@@ -19218,8 +19237,6 @@
1C81BA000E9733CB00266E07 /* JavaScriptProfileNode.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 */,
@@ -20401,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;
};
@@ -20420,6 +20437,9 @@
/* 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 3201bfa..50e6b94 100644
--- a/WebCore/WebCoreSources.bkl
+++ b/WebCore/WebCoreSources.bkl
@@ -165,13 +165,13 @@ This file contains the list of files needed to build WebCore.
</set>
<set append="1" var="WEBCORE_SOURCES_BRIDGE">
- bridge/Bridge.cpp
bridge/IdentifierRep.cpp
bridge/NP_jsobject.cpp
bridge/c/c_class.cpp
bridge/c/c_instance.cpp
bridge/c/c_runtime.cpp
bridge/c/c_utility.cpp
+ bridge/jsc/BridgeJSC.cpp
bridge/npruntime.cpp
bridge/runtime_array.cpp
bridge/runtime_method.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/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/v8/ChildThreadDOMData.h b/WebCore/bindings/v8/ChildThreadDOMData.h
index 173a5e8..dfb85e8 100644
--- a/WebCore/bindings/v8/ChildThreadDOMData.h
+++ b/WebCore/bindings/v8/ChildThreadDOMData.h
@@ -39,9 +39,6 @@ namespace WebCore {
class ChildThreadDOMData : public DOMData {
public:
ChildThreadDOMData();
-#if PLATFORM(ANDROID)
- virtual ~ChildThreadDOMData() { }
-#endif
DOMDataStore& getStore();
diff --git a/WebCore/bindings/v8/DOMData.cpp b/WebCore/bindings/v8/DOMData.cpp
index 54bcc55..ec9a938 100644
--- a/WebCore/bindings/v8/DOMData.cpp
+++ b/WebCore/bindings/v8/DOMData.cpp
@@ -44,6 +44,10 @@ DOMData::DOMData()
{
}
+DOMData::~DOMData()
+{
+}
+
DOMData* DOMData::getCurrent()
{
if (WTF::isMainThread())
diff --git a/WebCore/bindings/v8/DOMData.h b/WebCore/bindings/v8/DOMData.h
index 7bf9f91..4947e82 100644
--- a/WebCore/bindings/v8/DOMData.h
+++ b/WebCore/bindings/v8/DOMData.h
@@ -45,9 +45,7 @@ namespace WebCore {
class DOMData : public Noncopyable {
public:
DOMData();
-#if PLATFORM(ANDROID)
- virtual ~DOMData() { }
-#endif
+ virtual ~DOMData();
static DOMData* getCurrent();
virtual DOMDataStore& getStore() = 0;
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/NPV8Object.cpp b/WebCore/bindings/v8/NPV8Object.cpp
index 69cd303..e222ecd 100644
--- a/WebCore/bindings/v8/NPV8Object.cpp
+++ b/WebCore/bindings/v8/NPV8Object.cpp
@@ -28,10 +28,7 @@
#include "NPV8Object.h"
-#if PLATFORM(CHROMIUM)
-// TODO(andreip): upstream
-#include "ChromiumBridge.h"
-#endif
+#include "PlatformBridge.h"
#include "DOMWindow.h"
#include "Frame.h"
#include "OwnArrayPtr.h"
@@ -42,11 +39,6 @@
#include "V8Helpers.h"
#include "V8NPUtils.h"
#include "V8Proxy.h"
-#if PLATFORM(CHROMIUM)
-#include "bindings/npruntime.h"
-#else
-#include "bridge/npruntime.h"
-#endif
#include "npruntime_impl.h"
#include "npruntime_priv.h"
@@ -242,13 +234,7 @@ bool _NPN_InvokeDefault(NPP npp, NPObject* npObject, const NPVariant* arguments,
bool _NPN_Evaluate(NPP npp, NPObject* npObject, NPString* npScript, NPVariant* result)
{
-#if PLATFORM(CHROMIUM)
- bool popupsAllowed = WebCore::ChromiumBridge::popupsAllowed(npp);
-#else
- // TODO(andreip): Some of the binding code is specific to Chromium
- // and we don't want it to Android. What is the preferred way to handle this?
- bool popupsAllowed = false;
-#endif
+ bool popupsAllowed = WebCore::PlatformBridge::popupsAllowed(npp);
return _NPN_EvaluateHelper(npp, popupsAllowed, npObject, npScript, result);
}
@@ -461,12 +447,7 @@ bool _NPN_Enumerate(NPP npp, NPObject* npObject, NPIdentifier** identifier, uint
v8::Handle<v8::Value> enumeratorObj = script->Run();
v8::Handle<v8::Function> enumerator = v8::Handle<v8::Function>::Cast(enumeratorObj);
v8::Handle<v8::Value> argv[] = { obj };
-#if PLATFORM(ANDROID)
-// TODO(benm): implement an arry size function on android
- v8::Local<v8::Value> propsObj = enumerator->Call(v8::Handle<v8::Object>::Cast(enumeratorObj), 1, argv);
-#else
v8::Local<v8::Value> propsObj = enumerator->Call(v8::Handle<v8::Object>::Cast(enumeratorObj), ARRAYSIZE_UNSAFE(argv), argv);
-#endif
if (propsObj.IsEmpty())
return false;
diff --git a/WebCore/bindings/v8/NPV8Object.h b/WebCore/bindings/v8/NPV8Object.h
index 1b65a1f..62b3ba4 100644
--- a/WebCore/bindings/v8/NPV8Object.h
+++ b/WebCore/bindings/v8/NPV8Object.h
@@ -31,10 +31,13 @@
#define NPV8Object_h
#if PLATFORM(CHROMIUM)
-// TODO(andreip): diff and consolidate
+// FIXME: Chromium uses a different npruntime.h, which is in
+// the Chromium source repository under third_party/npapi/bindings.
+// The Google-specific changes in that file should probably be
+// moved into bridge/npruntime.h, guarded by an #if PlATFORM(CHROMIUM).
#include "bindings/npruntime.h"
#else
-#include "bridge/npruntime.h" // use WebCore version
+#include "bridge/npruntime.h" // Use WebCore version for Android and other ports.
#endif
#include <v8.h>
diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp
index 5b4dbc2..6ba70d6 100644
--- a/WebCore/bindings/v8/ScriptController.cpp
+++ b/WebCore/bindings/v8/ScriptController.cpp
@@ -32,12 +32,8 @@
#include "config.h"
#include "ScriptController.h"
-#if PLATFORM(CHROMIUM)
-#include "ChromiumBridge.h"
-#elif PLATFORM(ANDROID)
-#include "PluginView.h"
-#endif
+#include "PlatformBridge.h"
#include "CString.h"
#include "Document.h"
#include "DOMWindow.h"
@@ -306,23 +302,13 @@ PassScriptInstance ScriptController::createScriptInstanceForWidget(Widget* widge
{
ASSERT(widget);
-#if PLATFORM(CHROMIUM)
if (widget->isFrameView())
return 0;
- NPObject* npObject = ChromiumBridge::pluginScriptableObject(widget);
- if (!npObject)
- return 0;
-
-#elif PLATFORM(ANDROID)
- if (!widget->isPluginView())
- return 0;
+ NPObject* npObject = PlatformBridge::pluginScriptableObject(widget);
- PluginView* pluginView = static_cast<PluginView*>(widget);
- NPObject* npObject = pluginView->getNPObject();
if (!npObject)
return 0;
-#endif
// Frame Memory Management for NPObjects
// -------------------------------------
diff --git a/WebCore/bindings/v8/ScriptObject.cpp b/WebCore/bindings/v8/ScriptObject.cpp
index 5f5609c..8d80d34 100644
--- a/WebCore/bindings/v8/ScriptObject.cpp
+++ b/WebCore/bindings/v8/ScriptObject.cpp
@@ -144,9 +144,7 @@ bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, const S
bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, InspectorBackend* value)
{
ScriptScope scope(scriptState);
-#if !PLATFORM(ANDROID)
scope.global()->Set(v8::String::New(name), V8DOMWrapper::convertToV8Object(V8ClassIndex::INSPECTORBACKEND, value));
-#endif
return scope.success();
}
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/V8GCController.cpp b/WebCore/bindings/v8/V8GCController.cpp
index e08cf66..b478636 100644
--- a/WebCore/bindings/v8/V8GCController.cpp
+++ b/WebCore/bindings/v8/V8GCController.cpp
@@ -239,16 +239,6 @@ bool operator<(const GrouperItem& a, const GrouperItem& b)
typedef Vector<GrouperItem> GrouperList;
-#if PLATFORM(ANDROID)
-// Android's implementation of std::sort seems unable to do the necessary
-// template matching to pick up operator< for GrouperItem, so we have to
-// manually pass a comparison function.
-static bool compareGrouperItem(const GrouperItem& a, const GrouperItem& b)
-{
- return a < b;
-}
-#endif
-
class ObjectGrouperVisitor : public DOMWrapperMap<Node>::Visitor {
public:
ObjectGrouperVisitor()
@@ -295,11 +285,7 @@ public:
void applyGrouping()
{
// Group by sorting by the group id.
-#if PLATFORM(ANDROID)
- std::sort(m_grouper.begin(), m_grouper.end(), compareGrouperItem);
-#else
std::sort(m_grouper.begin(), m_grouper.end());
-#endif
// FIXME Should probably work in iterators here, but indexes were easier for my simple mind.
for (size_t i = 0; i < m_grouper.size(); ) {
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/bindings/v8/WorkerContextExecutionProxy.cpp b/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp
index 8c66d7b..412fde0 100644
--- a/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp
+++ b/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp
@@ -124,11 +124,6 @@ void WorkerContextExecutionProxy::initV8IfNeeded()
v8::V8::IgnoreOutOfMemoryException();
v8::V8::SetFatalErrorHandler(reportFatalErrorInV8);
-#if PLATFORM(ANDROID)
- const int workerThreadPreemptionIntervalMs = 5;
- v8::Locker::StartPreemption(workerThreadPreemptionIntervalMs);
-#endif
-
v8::ResourceConstraints resource_constraints;
uint32_t here;
resource_constraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uint32_t*));
diff --git a/WebCore/bridge/Bridge.h b/WebCore/bridge/Bridge.h
index 71c72c3..d92cd15 100644
--- a/WebCore/bridge/Bridge.h
+++ b/WebCore/bridge/Bridge.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
@@ -26,35 +27,12 @@
#ifndef Bridge_h
#define Bridge_h
-#include <runtime/JSString.h>
-#include <wtf/HashMap.h>
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
+#include "BridgeJSC.h"
namespace JSC {
-class ArgList;
-class Identifier;
-class JSGlobalObject;
-class PropertyNameArray;
-class RuntimeObjectImp;
-
namespace Bindings {
-class Instance;
-class Method;
-class RootObject;
-
-typedef Vector<Method*> MethodList;
-
-class Field {
-public:
- virtual JSValue valueFromInstance(ExecState*, const Instance*) const = 0;
- virtual void setValueToInstance(ExecState*, const Instance*, JSValue) const = 0;
-
- virtual ~Field() { }
-};
-
class Method : public Noncopyable {
public:
virtual int numParameters() const = 0;
@@ -62,90 +40,6 @@ public:
virtual ~Method() { }
};
-class Class : public Noncopyable {
-public:
- virtual MethodList methodsNamed(const Identifier&, Instance*) const = 0;
- virtual Field* fieldNamed(const Identifier&, Instance*) const = 0;
- virtual JSValue fallbackObject(ExecState*, Instance*, const Identifier&) { return jsUndefined(); }
-
- virtual ~Class() { }
-};
-
-typedef void (*KJSDidExecuteFunctionPtr)(ExecState*, JSObject* rootObject);
-
-class Instance : public RefCounted<Instance> {
-public:
- Instance(PassRefPtr<RootObject>);
-
- static void setDidExecuteFunction(KJSDidExecuteFunctionPtr func);
- static KJSDidExecuteFunctionPtr didExecuteFunction();
-
- // These functions are called before and after the main entry points into
- // the native implementations. They can be used to establish and cleanup
- // 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; }
-
- virtual JSValue invokeMethod(ExecState*, const MethodList&, const ArgList& args) = 0;
-
- 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; }
- virtual bool getOwnPropertyDescriptor(JSObject*, ExecState*, const Identifier&, PropertyDescriptor&) { return false; }
- virtual void put(JSObject*, ExecState*, const Identifier&, JSValue, PutPropertySlot&) { }
-
-protected:
- virtual void virtualBegin() { }
- virtual void virtualEnd() { }
- virtual RuntimeObjectImp* newRuntimeObject(ExecState*);
-
- RefPtr<RootObject> m_rootObject;
-
-private:
- RuntimeObjectImp* m_runtimeObject;
-};
-
-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 unsigned int getLength() const = 0;
-
-protected:
- RefPtr<RootObject> m_rootObject;
-};
-
-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;
-
} // namespace Bindings
} // namespace JSC
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 3624ba5..0000000
--- a/WebCore/bridge/jni/jni_runtime.cpp
+++ /dev/null
@@ -1,553 +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 "CString.h"
-#include "StringBuilder.h"
-#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;
-using namespace WebCore;
-
-
-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->m_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->m_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(StringBuilder& builder, const char* className)
-{
- ASSERT(JSLock::lockCount() > 0);
-
- char *result, *cp = strdup(className);
-
- result = cp;
- while (*cp) {
- if (*cp == '.')
- *cp = '/';
- cp++;
- }
-
- builder.append(result);
-
- free(result);
-}
-
-const char *JavaMethod::signature() const
-{
- if (!_signature) {
- JSLock lock(SilenceAssertionsOnly);
-
- StringBuilder signatureBuilder;
- signatureBuilder.append("(");
- 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(";");
- }
- }
-
- String signatureString = signatureBuilder.toString();
- _signature = strdup(signatureString.utf8().data());
- }
-
- 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->m_instance);
- _type = strdup(type);
- m_rootObject = rootObject;
-}
-
-JavaArray::~JavaArray ()
-{
- free ((void *)_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(_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 5c0dc66..0000000
--- a/WebCore/bridge/jni/jni_runtime.h
+++ /dev/null
@@ -1,172 +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 "JavaInstanceJSC.h"
-#include "jni_utility.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 () : _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;
-
- const JavaString& name() const { return _name; }
- 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();
-
- const JavaString& name() const { return _name; }
- 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->m_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/jsc/JavaClassJSC.cpp b/WebCore/bridge/jni/jsc/JavaClassJSC.cpp
index c003255..350c8ae 100644
--- a/WebCore/bridge/jni/jsc/JavaClassJSC.cpp
+++ b/WebCore/bridge/jni/jsc/JavaClassJSC.cpp
@@ -28,9 +28,8 @@
#if ENABLE(MAC_JAVA_BRIDGE)
+#include "JNIUtility.h"
#include "JSDOMWindow.h"
-#include "jni_runtime.h"
-#include "jni_utility.h"
#include <runtime/Identifier.h>
#include <runtime/JSLock.h>
diff --git a/WebCore/bridge/jni/jsc/JavaClassJSC.h b/WebCore/bridge/jni/jsc/JavaClassJSC.h
index 0c5983c..b20781b 100644
--- a/WebCore/bridge/jni/jsc/JavaClassJSC.h
+++ b/WebCore/bridge/jni/jsc/JavaClassJSC.h
@@ -28,7 +28,7 @@
#if ENABLE(MAC_JAVA_BRIDGE)
-#include "jni_runtime.h"
+#include "JNIBridge.h"
#include <wtf/HashMap.h>
namespace JSC {
diff --git a/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp b/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp
index 17e0147..d9e0f60 100644
--- a/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp
+++ b/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp
@@ -28,10 +28,10 @@
#if ENABLE(MAC_JAVA_BRIDGE)
+#include "JNIBridge.h"
+#include "JNIUtility.h"
+#include "JNIUtilityPrivate.h"
#include "JavaClassJSC.h"
-#include "jni_runtime.h"
-#include "jni_utility.h"
-#include "jni_utility_private.h"
#include "runtime_object.h"
#include "runtime_root.h"
#include <runtime/ArgList.h>
diff --git a/WebCore/bridge/jni/jsc/JavaStringJSC.h b/WebCore/bridge/jni/jsc/JavaStringJSC.h
index d3ed56b..720f887 100644
--- a/WebCore/bridge/jni/jsc/JavaStringJSC.h
+++ b/WebCore/bridge/jni/jsc/JavaStringJSC.h
@@ -26,8 +26,8 @@
#ifndef JavaStringJSC_h
#define JavaStringJSC_h
+#include "JNIUtility.h"
#include "JavaInstanceJSC.h"
-#include "jni_utility.h"
#include <runtime/JSLock.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/WebCore/bridge/jni/v8/JavaClassV8.cpp b/WebCore/bridge/jni/v8/JavaClassV8.cpp
new file mode 100644
index 0000000..c29cf86
--- /dev/null
+++ b/WebCore/bridge/jni/v8/JavaClassV8.cpp
@@ -0,0 +1,114 @@
+/*
+ * 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:
+ * * 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 "JavaClassV8.h"
+
+#include "JNIUtility.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);
+ m_name = strdup(classNameC);
+ releaseCharactersForJString(className, classNameC);
+
+ int i;
+ JNIEnv* env = getJNIEnv();
+
+ // Get the fields
+ jarray fields = (jarray)callJNIMethod<jobject>(aClass, "getFields", "()[Ljava/lang/reflect/Field;");
+ 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
+ {
+ m_fields.set(aField->name().UTF8String(), aField);
+ }
+ env->DeleteLocalRef(aJField);
+ }
+
+ // Get the methods
+ jarray methods = (jarray)callJNIMethod<jobject>(aClass, "getMethods", "()[Ljava/lang/reflect/Method;");
+ 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
+ MethodList* methodList;
+ {
+ methodList = m_methods.get(aMethod->name().UTF8String());
+ if (!methodList) {
+ methodList = new 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*)m_name);
+
+ deleteAllValues(m_fields);
+ m_fields.clear();
+
+ 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;
+ }
+ m_methods.clear();
+}
+
+MethodList JavaClass::methodsNamed(const char* name) const
+{
+ MethodList* methodList = m_methods.get(name);
+
+ if (methodList)
+ return *methodList;
+ return MethodList();
+}
+
+JavaField* JavaClass::fieldNamed(const char* name) const
+{
+ return m_fields.get(name);
+}
diff --git a/WebCore/bridge/jni/v8/JavaClassV8.h b/WebCore/bridge/jni/v8/JavaClassV8.h
new file mode 100644
index 0000000..12cdf93
--- /dev/null
+++ b/WebCore/bridge/jni/v8/JavaClassV8.h
@@ -0,0 +1,62 @@
+/*
+ * 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:
+ * * 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 JavaClassV8_h
+#define JavaClassV8_h
+
+#include "PlatformString.h"
+#include "StringHash.h"
+#include "jni_runtime.h"
+#include <wtf/HashMap.h>
+#include <wtf/Vector.h>
+
+namespace JSC {
+
+namespace Bindings {
+
+typedef Vector<JavaMethod*> MethodList;
+typedef HashMap<WebCore::String, MethodList*> MethodListMap;
+typedef HashMap<WebCore::String, JavaField*> FieldMap;
+
+class JavaClass {
+public:
+ JavaClass(jobject anInstance);
+ ~JavaClass();
+
+ MethodList methodsNamed(const char* name) const;
+ JavaField* fieldNamed(const char* name) const;
+
+private:
+ const char* m_name;
+ MethodListMap m_methods;
+ FieldMap m_fields;
+};
+
+} // namespace Bindings
+
+} // namespace JSC
+
+#endif // JavaClassV8_h
diff --git a/WebCore/bridge/jni/v8/JavaInstanceV8.cpp b/WebCore/bridge/jni/v8/JavaInstanceV8.cpp
new file mode 100644
index 0000000..13d4984
--- /dev/null
+++ b/WebCore/bridge/jni/v8/JavaInstanceV8.cpp
@@ -0,0 +1,168 @@
+/*
+ * 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 "JavaInstanceV8.h"
+
+#include "JNIUtility.h"
+#include "JavaClassV8.h"
+#include "jni_runtime.h"
+
+#include <assert.h>
+#include <utils/Log.h>
+
+#define LOG_TAG "v8binding"
+
+using namespace JSC::Bindings;
+
+JavaInstance::JavaInstance(jobject instance)
+{
+ m_instance = new JObjectWrapper(instance);
+ m_class = 0;
+}
+
+JavaInstance::~JavaInstance()
+{
+ m_instance = 0;
+ delete m_class;
+}
+
+JavaClass* JavaInstance::getClass() const
+{
+ if (!m_class) {
+ m_class = new JavaClass(javaInstance());
+ }
+ return m_class;
+}
+
+bool JavaInstance::invokeMethod(const char* methodName, const NPVariant* args, int count, NPVariant* resultValue)
+{
+ 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
+ // fundamental problem is that JavaScript doesn have the
+ // 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* method = 0;
+ for (size_t methodIndex = 0; methodIndex < numMethods; methodIndex++) {
+ aMethod = methodList[methodIndex];
+ if (aMethod->numParameters() == count) {
+ method = aMethod;
+ break;
+ }
+ }
+ if (!method) {
+ LOGW("unable to find an appropiate method\n");
+ return false;
+ }
+
+ 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;
+ }
+ }
+
+ convertJValueToNPVariant(result, jMethod->JNIReturnType(), jMethod->returnType(), resultValue);
+ free(jArgs);
+
+ return true;
+}
+
+JObjectWrapper::JObjectWrapper(jobject instance)
+ : m_refCount(0)
+{
+ assert(instance);
+
+ // Cache the JNIEnv used to get the global ref for this java instanace.
+ // It'll be used to delete the reference.
+ m_env = getJNIEnv();
+
+ m_instance = m_env->NewGlobalRef(instance);
+
+ LOGV("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() {
+ LOGV("deleting global ref %p\n", m_instance);
+ m_env->DeleteGlobalRef(m_instance);
+}
diff --git a/WebCore/bridge/jni/v8/JavaInstanceV8.h b/WebCore/bridge/jni/v8/JavaInstanceV8.h
new file mode 100644
index 0000000..dcd51e8
--- /dev/null
+++ b/WebCore/bridge/jni/v8/JavaInstanceV8.h
@@ -0,0 +1,99 @@
+/*
+ * 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 JavaInstanceV8_h
+#define JavaInstanceV8_h
+
+#include "JNIUtilityPrivate.h"
+
+#include <JavaVM/jni.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+using namespace WTF;
+
+namespace JSC {
+
+namespace Bindings {
+
+class JavaClass;
+
+class JObjectWrapper {
+friend class RefPtr<JObjectWrapper>;
+friend class JavaField;
+friend class JavaInstance;
+
+public:
+ jobject instance() const { return m_instance; }
+ void setInstance(jobject instance) { m_instance = instance; }
+
+protected:
+ JObjectWrapper(jobject instance);
+ ~JObjectWrapper();
+
+ void ref() { m_refCount++; }
+ void deref()
+ {
+ if (!(--m_refCount))
+ delete this;
+ }
+
+ jobject m_instance;
+
+private:
+ JNIEnv* m_env;
+ unsigned int m_refCount;
+};
+
+class JavaInstance : public RefCounted<JavaInstance> {
+public:
+ JavaInstance(jobject instance);
+ virtual ~JavaInstance();
+
+ JavaClass* getClass() const;
+
+ bool invokeMethod(const char* name, const NPVariant* args, int argsCount, NPVariant* result);
+
+ 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
+ // any needed state.
+ void begin() { virtualBegin(); }
+ void end() { virtualEnd(); }
+
+protected:
+ RefPtr<JObjectWrapper> m_instance;
+ mutable JavaClass* m_class;
+
+ virtual void virtualBegin() {}
+ virtual void virtualEnd() {}
+};
+
+} // namespace Bindings
+
+} // namespace JSC
+
+#endif // JavaInstanceV8_h
diff --git a/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp b/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp
new file mode 100644
index 0000000..636d075
--- /dev/null
+++ b/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp
@@ -0,0 +1,166 @@
+/*
+ * Copyright 2009, 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.
+ */
+
+
+#include "config.h"
+#include "JavaNPObjectV8.h"
+
+#include "JNIUtility.h"
+#include "JavaClassV8.h"
+#include "JavaInstanceV8.h"
+#include "jni_runtime.h"
+#include "npruntime_impl.h"
+
+namespace JSC {
+
+namespace Bindings {
+
+static NPObject* AllocJavaNPObject(NPP, NPClass*)
+{
+ JavaNPObject* obj = static_cast<JavaNPObject*>(malloc(sizeof(JavaNPObject)));
+ if (!obj)
+ return 0;
+ bzero(obj, sizeof(JavaNPObject));
+ return reinterpret_cast<NPObject*>(obj);
+}
+
+static void FreeJavaNPObject(NPObject* npobj)
+{
+ JavaNPObject* obj = reinterpret_cast<JavaNPObject*>(npobj);
+ obj->m_instance = 0; // free does not call the destructor
+ free(obj);
+}
+
+static NPClass JavaNPObjectClass = {
+ NP_CLASS_STRUCT_VERSION,
+ AllocJavaNPObject, // allocate,
+ FreeJavaNPObject, // free,
+ 0, // invalidate
+ JavaNPObject_HasMethod,
+ JavaNPObject_Invoke,
+ 0, // invokeDefault,
+ JavaNPObject_HasProperty,
+ JavaNPObject_GetProperty,
+ 0, // setProperty
+ 0, // removeProperty
+ 0, // enumerate
+ 0 // construct
+};
+
+
+NPObject* JavaInstanceToNPObject(JavaInstance* instance) {
+ JavaNPObject* object = reinterpret_cast<JavaNPObject*>(_NPN_CreateObject(0, &JavaNPObjectClass));
+ object->m_instance = instance;
+ return reinterpret_cast<NPObject*>(object);
+}
+
+
+// Returns null if obj is not a wrapper of JavaInstance
+JavaInstance* ExtractJavaInstance(NPObject* obj) {
+ if (obj->_class == &JavaNPObjectClass) {
+ return reinterpret_cast<JavaNPObject*>(obj)->m_instance.get();
+ }
+ return 0;
+}
+
+bool JavaNPObject_HasMethod(NPObject* obj, NPIdentifier identifier) {
+ JavaInstance* instance = ExtractJavaInstance(obj);
+ if (!instance)
+ return false;
+ NPUTF8* name = _NPN_UTF8FromIdentifier(identifier);
+ if (!name)
+ return false;
+
+ instance->begin();
+ bool result = (instance->getClass()->methodsNamed(name).size() > 0);
+ instance->end();
+
+ // TODO: use NPN_MemFree
+ free(name);
+
+ return result;
+}
+
+bool JavaNPObject_Invoke(NPObject* obj, NPIdentifier identifier, const NPVariant* args, uint32_t argCount, NPVariant* result) {
+ JavaInstance* instance = ExtractJavaInstance(obj);
+ if (!instance)
+ return false;
+ NPUTF8* name = _NPN_UTF8FromIdentifier(identifier);
+ if (!name)
+ return false;
+
+ instance->begin();
+ bool r = instance->invokeMethod(name, args, argCount, result);
+ instance->end();
+
+ // TODO: use NPN_MemFree
+ free(name);
+ return r;
+}
+
+bool JavaNPObject_HasProperty(NPObject* obj, NPIdentifier identifier) {
+ JavaInstance* instance = ExtractJavaInstance(obj);
+ if (!instance)
+ return false;
+ NPUTF8* name = _NPN_UTF8FromIdentifier(identifier);
+ if (!name)
+ return false;
+ instance->begin();
+ bool result = instance->getClass()->fieldNamed(name);
+ instance->end();
+ free(name);
+ return result;
+}
+
+bool JavaNPObject_GetProperty(NPObject* obj, NPIdentifier identifier, NPVariant* result) {
+ VOID_TO_NPVARIANT(*result);
+ JavaInstance* instance = ExtractJavaInstance(obj);
+ if (!instance)
+ return false;
+ NPUTF8* name = _NPN_UTF8FromIdentifier(identifier);
+ if (!name)
+ return false;
+
+ instance->begin();
+ JavaField* field = instance->getClass()->fieldNamed(name);
+ instance->end();
+ free(name); // TODO: use NPN_MemFree
+
+ if (!field)
+ return false;
+
+ jvalue value = getJNIField(instance->javaInstance(),
+ field->getJNIType(),
+ field->name().UTF8String(),
+ field->type());
+
+ convertJValueToNPVariant(value, field->getJNIType(), field->type(), result);
+
+ return true;
+}
+
+} // namespace Bindings
+
+} // namespace JSC
diff --git a/WebCore/bridge/jni/v8/JavaNPObjectV8.h b/WebCore/bridge/jni/v8/JavaNPObjectV8.h
new file mode 100644
index 0000000..c36ef70
--- /dev/null
+++ b/WebCore/bridge/jni/v8/JavaNPObjectV8.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2010, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 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 JavaNPObjectV8_h
+#define JavaNPObjectV8_h
+
+#include "jni_runtime.h"
+#include "npruntime.h"
+#include <JavaVM/jni.h>
+#include <wtf/RefPtr.h>
+
+
+namespace JSC {
+
+namespace Bindings {
+
+class JavaInstance;
+
+struct JavaNPObject {
+ NPObject m_object;
+ RefPtr<JavaInstance> m_instance;
+};
+
+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);
+
+} // namespace Bindings
+
+} // namespace JSC
+
+#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/Bridge.cpp b/WebCore/bridge/jsc/BridgeJSC.cpp
index 2daf3eb..ed582d3 100644
--- a/WebCore/bridge/Bridge.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
@@ -24,7 +25,7 @@
*/
#include "config.h"
-#include "Bridge.h"
+#include "BridgeJSC.h"
#include "runtime_object.h"
#include "runtime_root.h"
diff --git a/WebCore/bridge/jsc/BridgeJSC.h b/WebCore/bridge/jsc/BridgeJSC.h
new file mode 100644
index 0000000..8e2cb2b
--- /dev/null
+++ b/WebCore/bridge/jsc/BridgeJSC.h
@@ -0,0 +1,151 @@
+/*
+ * 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 BridgeJSC_h
+#define BridgeJSC_h
+
+#if USE(JSC)
+
+#include <runtime/JSString.h>
+#include <wtf/HashMap.h>
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+
+namespace JSC {
+
+class ArgList;
+class Identifier;
+class JSGlobalObject;
+class PropertyNameArray;
+class RuntimeObjectImp;
+
+namespace Bindings {
+
+class Instance;
+class Method;
+class RootObject;
+
+typedef Vector<Method*> MethodList;
+
+class Field {
+public:
+ virtual JSValue valueFromInstance(ExecState*, const Instance*) const = 0;
+ virtual void setValueToInstance(ExecState*, const Instance*, JSValue) const = 0;
+
+ virtual ~Field() { }
+};
+
+class Class : public Noncopyable {
+public:
+ virtual MethodList methodsNamed(const Identifier&, Instance*) const = 0;
+ virtual Field* fieldNamed(const Identifier&, Instance*) const = 0;
+ virtual JSValue fallbackObject(ExecState*, Instance*, const Identifier&) { return jsUndefined(); }
+
+ virtual ~Class() { }
+};
+
+typedef void (*KJSDidExecuteFunctionPtr)(ExecState*, JSObject* rootObject);
+
+class Instance : public RefCounted<Instance> {
+public:
+ Instance(PassRefPtr<RootObject>);
+
+ static void setDidExecuteFunction(KJSDidExecuteFunctionPtr func);
+ static KJSDidExecuteFunctionPtr didExecuteFunction();
+
+ // These functions are called before and after the main entry points into
+ // the native implementations. They can be used to establish and cleanup
+ // 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; }
+
+ virtual JSValue invokeMethod(ExecState*, const MethodList&, const ArgList& args) = 0;
+
+ 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; }
+ virtual bool getOwnPropertyDescriptor(JSObject*, ExecState*, const Identifier&, PropertyDescriptor&) { return false; }
+ virtual void put(JSObject*, ExecState*, const Identifier&, JSValue, PutPropertySlot&) { }
+
+protected:
+ virtual void virtualBegin() { }
+ virtual void virtualEnd() { }
+ virtual RuntimeObjectImp* newRuntimeObject(ExecState*);
+
+ RefPtr<RootObject> m_rootObject;
+
+private:
+ RuntimeObjectImp* m_runtimeObject;
+};
+
+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 unsigned int getLength() const = 0;
+
+protected:
+ RefPtr<RootObject> m_rootObject;
+};
+
+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;
+
+} // namespace Bindings
+
+} // namespace JSC
+
+#endif // USE(JSC)
+
+#endif
diff --git a/WebCore/config.h b/WebCore/config.h
index 8fbed4f..6fa1f40 100644
--- a/WebCore/config.h
+++ b/WebCore/config.h
@@ -80,7 +80,6 @@
#define WEBCORE_NAVIGATOR_VENDOR "Google Inc."
// This must be defined before we include FastMalloc.h, below.
#define USE_SYSTEM_MALLOC 1
-#define ANDROID_MOBILE // change can be merged back to WebKit.org for MOBILE
#define LOG_DISABLED 1
#include <wtf/Assertions.h>
// Central place to set which optional features Android uses.
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index f146761..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"
@@ -371,9 +374,6 @@ Document::Document(Frame* frame, bool isXHTML)
, m_hasOpenDatabases(false)
#endif
, m_usingGeolocation(false)
-#ifdef ANDROID_MOBILE
- , mExtraLayoutDelay(0)
-#endif
#if ENABLE(WML)
, m_containsWMLContent(false)
#endif
@@ -431,6 +431,7 @@ Document::Document(Frame* frame, bool isXHTML)
m_processingLoadEvent = false;
m_startTime = currentTime();
m_overMinimumLayoutThreshold = false;
+ m_extraLayoutDelay = 0;
initSecurityContext();
initDNSPrefetch();
@@ -1486,18 +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
- Page* ownerPage = page();
- if (ownerPage && (m_frame == ownerPage->mainFrame())) {
- 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
@@ -1881,13 +1870,13 @@ bool Document::shouldScheduleLayout()
int Document::minimumLayoutDelay()
{
if (m_overMinimumLayoutThreshold)
- return 0;
+ return m_extraLayoutDelay;
int elapsed = elapsedTime();
m_overMinimumLayoutThreshold = elapsed > cLayoutScheduleThreshold;
// We'll want to schedule the timer to fire at the minimum layout threshold.
- return max(0, cLayoutScheduleThreshold - elapsed);
+ return max(0, cLayoutScheduleThreshold - elapsed) + m_extraLayoutDelay;
}
int Document::elapsedTime() const
@@ -2260,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
@@ -3064,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
@@ -3104,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&)
@@ -4675,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 3d0582c..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(); }
@@ -523,6 +529,10 @@ public:
void setParsing(bool);
bool parsing() const { return m_bParsing; }
int minimumLayoutDelay();
+
+ // This method is used by Android.
+ void setExtraLayoutDelay(int delay) { m_extraLayoutDelay = delay; }
+
bool shouldScheduleLayout();
int elapsedTime() const;
@@ -620,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); }
@@ -815,11 +826,6 @@ public:
void updateFocusAppearanceSoon();
void cancelFocusAppearanceUpdate();
-#ifdef ANDROID_MOBILE
- void setExtraLayoutDelay(int delay) { mExtraLayoutDelay = delay; }
- int extraLayoutDelay() { return mExtraLayoutDelay; }
-#endif
-
// FF method for accessing the selection added for compatability.
DOMSelection* getSelection() const;
@@ -938,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; }
@@ -1091,9 +1086,11 @@ private:
typedef std::pair<Vector<DocumentMarker>, Vector<IntRect> > MarkerMapVectorPair;
typedef HashMap<RefPtr<Node>, MarkerMapVectorPair*> MarkerMap;
MarkerMap m_markers;
+
#if !PLATFORM(ANDROID)
mutable AXObjectCache* m_axObjectCache;
#endif
+
Timer<Document> m_updateFocusAppearanceTimer;
Element* m_cssTarget;
@@ -1103,6 +1100,10 @@ private:
HashSet<RefPtr<HistoryItem> > m_associatedHistoryItems;
double m_startTime;
bool m_overMinimumLayoutThreshold;
+ // This is used to increase the minimum delay between re-layouts. It is set
+ // using setExtraLayoutDelay to modify the minimum delay used at different
+ // points during the lifetime of the Document.
+ int m_extraLayoutDelay;
Vector<std::pair<ScriptElementData*, CachedResourceHandle<CachedScript> > > m_scriptsToExecuteSoon;
Timer<Document> m_executeScriptSoonTimer;
@@ -1115,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;
@@ -1195,10 +1196,6 @@ private:
bool m_usingGeolocation;
-#ifdef ANDROID_MOBILE
- int mExtraLayoutDelay;
-#endif
-
#if ENABLE(WML)
bool m_containsWMLContent;
#endif
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/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index 163424d..acfe51f 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -340,11 +340,11 @@ bool HTMLInputElement::stepMismatch() const
// double's fractional part size is DBL_MAN_DIG-bit. If the current
// value is greater than step*2^DBL_MANT_DIG, the following fmod() makes
// no sense.
- if (doubleValue / pow(2, DBL_MANT_DIG) > step)
+ if (doubleValue / pow(2.0, DBL_MANT_DIG) > step)
return false;
double remainder = fmod(doubleValue, step);
// Accepts errors in lower 7-bit.
- double acceptableError = step / pow(2, DBL_MANT_DIG - 7);
+ double acceptableError = step / pow(2.0, DBL_MANT_DIG - 7);
return acceptableError < remainder && remainder < (step - acceptableError);
}
// Non-RANGE types should be rejected by getAllowedValueStep().
diff --git a/WebCore/html/HTMLTextAreaElement.cpp b/WebCore/html/HTMLTextAreaElement.cpp
index 8d8208d..0e8350c 100644
--- a/WebCore/html/HTMLTextAreaElement.cpp
+++ b/WebCore/html/HTMLTextAreaElement.cpp
@@ -95,7 +95,7 @@ bool HTMLTextAreaElement::saveFormControlState(String& result) const
void HTMLTextAreaElement::restoreFormControlState(const String& state)
{
- setDefaultValue(state);
+ setValue(state);
}
void HTMLTextAreaElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
diff --git a/WebCore/html/HTMLTokenizer.cpp b/WebCore/html/HTMLTokenizer.cpp
index 3ca6958..a552442 100644
--- a/WebCore/html/HTMLTokenizer.cpp
+++ b/WebCore/html/HTMLTokenizer.cpp
@@ -1849,11 +1849,7 @@ void HTMLTokenizer::timerFired(Timer<HTMLTokenizer>*)
printf("Beginning timer write at time %d\n", m_doc->elapsedTime());
#endif
-#ifdef ANDROID_MOBILE
- if (m_doc->view() && m_doc->view()->layoutPending() && !m_doc->minimumLayoutDelay() && !m_doc->extraLayoutDelay()) {
-#else
if (m_doc->view() && m_doc->view()->layoutPending() && !m_doc->minimumLayoutDelay()) {
-#endif
// Restart the timer and let layout win. This is basically a way of ensuring that the layout
// timer has higher priority than our timer.
m_timer.startOneShot(0);
diff --git a/WebCore/loader/CachedImage.cpp b/WebCore/loader/CachedImage.cpp
index a91f126..780d7ee 100644
--- a/WebCore/loader/CachedImage.cpp
+++ b/WebCore/loader/CachedImage.cpp
@@ -252,7 +252,7 @@ inline void CachedImage::createImage()
}
#endif
m_image = BitmapImage::create(this);
-#if PLATFORM(SGL)
+#if PLATFORM(ANDROID)
m_image->setURL(url());
#endif
}
diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp
index 4a6ca3d..e07ee92 100644
--- a/WebCore/loader/FrameLoader.cpp
+++ b/WebCore/loader/FrameLoader.cpp
@@ -1743,12 +1743,7 @@ void FrameLoader::setFirstPartyForCookies(const KURL& url)
// This does the same kind of work that didOpenURL does, except it relies on the fact
// that a higher level already checked that the URLs match and the scrolling is the right thing to do.
-#if PLATFORM(ANDROID)
-// TODO: Upstream to webkit.org
-void FrameLoader::loadInSameDocument(const KURL& url, SerializedScriptValue* stateObject, bool isNewNavigation, bool suppressAddToHistory)
-#else
void FrameLoader::loadInSameDocument(const KURL& url, SerializedScriptValue* stateObject, bool isNewNavigation)
-#endif
{
// If we have a state object, we cannot also be a new navigation.
ASSERT(!stateObject || (stateObject && !isNewNavigation));
@@ -1756,12 +1751,7 @@ void FrameLoader::loadInSameDocument(const KURL& url, SerializedScriptValue* sta
// Update the data source's request with the new URL to fake the URL change
m_frame->document()->setURL(url);
documentLoader()->replaceRequestURLForSameDocumentNavigation(url);
-#if PLATFORM(ANDROID)
- // TODO: Upstream to webkit.org
- if (isNewNavigation && !shouldTreatURLAsSameAsCurrent(url) && !stateObject && !suppressAddToHistory) {
-#else
if (isNewNavigation && !shouldTreatURLAsSameAsCurrent(url) && !stateObject) {
-#endif
// NB: must happen after replaceRequestURLForSameDocumentNavigation(), since we add
// based on the current request. Must also happen before we openURL and displace the
// scroll position, since adding the BF item will save away scroll state.
@@ -3478,14 +3468,7 @@ void FrameLoader::continueFragmentScrollAfterNavigationPolicy(const ResourceRequ
return;
bool isRedirect = m_quickRedirectComing || policyChecker()->loadType() == FrameLoadTypeRedirectWithLockedBackForwardList;
-#ifdef ANDROID_USER_GESTURE
- // Do not add history items for a fragment scroll not initiated by the
- // user. http://bugs.webkit.org/show_bug.cgi?id=30224
- bool isUserInitiated = isProcessingUserGesture() || request.getUserGesture();
- loadInSameDocument(request.url(), 0, !isRedirect, !isUserInitiated);
-#else
loadInSameDocument(request.url(), 0, !isRedirect);
-#endif
}
bool FrameLoader::shouldScrollToAnchor(bool isFormSubmission, FrameLoadType loadType, const KURL& url)
@@ -3773,12 +3756,7 @@ void FrameLoader::navigateWithinDocument(HistoryItem* item)
history()->setCurrentItem(item);
// loadInSameDocument() actually changes the URL and notifies load delegates of a "fake" load
-#if PLATFORM(ANDROID)
- // TODO: Upstream to webkit.org
- loadInSameDocument(item->url(), item->stateObject(), false, false);
-#else
loadInSameDocument(item->url(), item->stateObject(), false);
-#endif
// Restore user view state from the current history item here since we don't do a normal load.
// Even though we just manually set the current history item, this ASSERT verifies nothing
diff --git a/WebCore/loader/FrameLoader.h b/WebCore/loader/FrameLoader.h
index 03a1175..875736f 100644
--- a/WebCore/loader/FrameLoader.h
+++ b/WebCore/loader/FrameLoader.h
@@ -439,12 +439,7 @@ private:
Frame* loadSubframe(HTMLFrameOwnerElement*, const KURL&, const String& name, const String& referrer);
-#if PLATFORM(ANDROID)
- // TODO: Upstream to webkit.org
- void loadInSameDocument(const KURL&, SerializedScriptValue* stateObject, bool isNewNavigation, bool suppressAddToHistory);
-#else
void loadInSameDocument(const KURL&, SerializedScriptValue* stateObject, bool isNewNavigation);
-#endif
void provisionalLoadStarted();
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/FrameView.cpp b/WebCore/page/FrameView.cpp
index b338017..b533bad 100644
--- a/WebCore/page/FrameView.cpp
+++ b/WebCore/page/FrameView.cpp
@@ -1151,11 +1151,7 @@ void FrameView::scheduleRelayout()
m_frame->ownerRenderer()->setNeedsLayoutAndPrefWidthsRecalc();
#endif
-#ifdef ANDROID_MOBILE
- int delay = m_frame->document()->minimumLayoutDelay() + m_frame->document()->extraLayoutDelay();
-#else
int delay = m_frame->document()->minimumLayoutDelay();
-#endif
if (m_layoutTimer.isActive() && m_delayedLayout && !delay)
unscheduleRelayout();
if (m_layoutTimer.isActive())
@@ -1209,11 +1205,7 @@ void FrameView::scheduleRelayoutOfSubtree(RenderObject* relayoutRoot)
}
}
} else {
-#ifdef ANDROID_MOBILE
- int delay = m_frame->document()->minimumLayoutDelay() + m_frame->document()->extraLayoutDelay();
-#else
int delay = m_frame->document()->minimumLayoutDelay();
-#endif
m_layoutRoot = relayoutRoot;
m_delayedLayout = delay != 0;
m_layoutTimer.startOneShot(delay * 0.001);
diff --git a/WebCore/page/Geolocation.cpp b/WebCore/page/Geolocation.cpp
index 5fbad47..cc5cc93 100644
--- a/WebCore/page/Geolocation.cpp
+++ b/WebCore/page/Geolocation.cpp
@@ -39,10 +39,44 @@
#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 "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)
@@ -87,15 +121,15 @@ void Geolocation::GeoNotifier::timerFired(Timer<GeoNotifier>*)
{
m_timer.stop();
- // Cache our pointer to the Geolocation object, as this GeoNotifier object
+ // Protect this GeoNotifier object, since it
// could be deleted by a call to clearWatch in a callback.
- Geolocation* geolocation = m_geolocation;
+ RefPtr<GeoNotifier> protect(this);
if (m_fatalError) {
if (m_errorCallback)
m_errorCallback->handleEvent(m_fatalError.get());
// This will cause this notifier to be deleted.
- geolocation->fatalErrorOccurred(this);
+ m_geolocation->fatalErrorOccurred(this);
return;
}
@@ -104,7 +138,7 @@ void Geolocation::GeoNotifier::timerFired(Timer<GeoNotifier>*)
// Clear the cached position in case this is a watch request, which
// will continue to run.
m_cachedPosition = 0;
- geolocation->requestReturnedCachedPosition(this);
+ m_geolocation->requestReturnedCachedPosition(this);
return;
}
@@ -112,7 +146,7 @@ void Geolocation::GeoNotifier::timerFired(Timer<GeoNotifier>*)
RefPtr<PositionError> error = PositionError::create(PositionError::TIMEOUT, "Timeout expired");
m_errorCallback->handleEvent(error.get());
}
- geolocation->requestTimedOut(this);
+ m_geolocation->requestTimedOut(this);
}
void Geolocation::Watchers::set(int id, PassRefPtr<GeoNotifier> prpNotifier)
@@ -305,7 +339,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 +363,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 +371,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 +445,7 @@ void Geolocation::fatalErrorOccurred(Geolocation::GeoNotifier* notifier)
m_watchers.remove(notifier);
if (!hasListeners())
- m_service->stopUpdating();
+ stopUpdating();
}
void Geolocation::requestTimedOut(GeoNotifier* notifier)
@@ -400,7 +454,7 @@ void Geolocation::requestTimedOut(GeoNotifier* notifier)
m_oneShots.remove(notifier);
if (!hasListeners())
- m_service->stopUpdating();
+ stopUpdating();
}
void Geolocation::requestReturnedCachedPosition(GeoNotifier* notifier)
@@ -408,11 +462,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,19 +490,23 @@ void Geolocation::clearWatch(int watchId)
m_watchers.remove(watchId);
if (!hasListeners())
- m_service->stopUpdating();
+ stopUpdating();
}
void Geolocation::suspend()
{
+#if !ENABLE(CLIENT_BASED_GEOLOCATION)
if (hasListeners())
m_service->suspend();
+#endif
}
void Geolocation::resume()
{
+#if !ENABLE(CLIENT_BASED_GEOLOCATION)
if (hasListeners())
m_service->resume();
+#endif
}
void Geolocation::setIsAllowed(bool allowed)
@@ -497,7 +555,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 +611,7 @@ void Geolocation::handleError(PositionError* error)
sendError(watchersCopy, error);
if (!hasListeners())
- m_service->stopUpdating();
+ stopUpdating();
}
void Geolocation::requestPermission()
@@ -575,12 +632,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 +655,7 @@ void Geolocation::geolocationServicePositionChanged(GeolocationService* service)
void Geolocation::makeSuccessCallbacks()
{
- ASSERT(m_service->lastPosition());
+ ASSERT(m_currentPosition);
ASSERT(isAllowed());
Vector<RefPtr<GeoNotifier> > oneShotsCopy;
@@ -613,23 +669,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..3006b29 100644
--- a/WebCore/page/Geolocation.h
+++ b/WebCore/page/Geolocation.h
@@ -34,11 +34,11 @@
#include "PositionErrorCallback.h"
#include "PositionOptions.h"
#include "Timer.h"
-#include <wtf/Platform.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassRefPtr.h>
+#include <wtf/Platform.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
@@ -48,8 +48,16 @@ namespace WebCore {
class Frame;
class CachedPositionManager;
+#if ENABLE(CLIENT_BASED_GEOLOCATION)
+class GeolocationPosition;
+class GeolocationError;
+#endif
-class Geolocation : public GeolocationServiceClient, public EventListener {
+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>);
@@ -65,7 +73,7 @@ public:
void suspend();
void resume();
-
+
void setIsAllowed(bool);
bool isAllowed() const { return m_allowGeolocation == Yes; }
bool isDenied() const { return m_allowGeolocation == No; }
@@ -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..968e854
--- /dev/null
+++ b/WebCore/page/GeolocationController.cpp
@@ -0,0 +1,86 @@
+/*
+ * 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)
+{
+ if (!m_observers.contains(observer))
+ return;
+
+ 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/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/Timer.cpp b/WebCore/platform/Timer.cpp
index 4804540..ea3effd 100644
--- a/WebCore/platform/Timer.cpp
+++ b/WebCore/platform/Timer.cpp
@@ -37,11 +37,6 @@
#include <wtf/HashSet.h>
#include <wtf/Vector.h>
-#if PLATFORM(ANDROID)
-#include "stl_iterator_base.h"
-#include "heap.h"
-#endif
-
using namespace std;
namespace WebCore {
diff --git a/WebCore/platform/android/GeolocationServiceAndroid.cpp b/WebCore/platform/android/GeolocationServiceAndroid.cpp
index 43a8f5f..3ffb9b9 100644
--- a/WebCore/platform/android/GeolocationServiceAndroid.cpp
+++ b/WebCore/platform/android/GeolocationServiceAndroid.cpp
@@ -28,6 +28,7 @@
#include "GeolocationServiceBridge.h"
#include "Geoposition.h"
+#include "PlatformBridge.h"
#include "PositionError.h"
#include "PositionOptions.h"
@@ -83,8 +84,13 @@ bool GeolocationServiceAndroid::startUpdating(PositionOptions* options)
if (options->enableHighAccuracy())
m_javaBridge->setEnableGps(true);
- if (!haveJavaBridge)
- m_javaBridge->start();
+ // We need only start the service when it's first created.
+ if (!haveJavaBridge) {
+ // If the browser is paused, don't start the service. It will be started
+ // when we get the call to resume.
+ if (!PlatformBridge::isWebViewPaused())
+ m_javaBridge->start();
+ }
return true;
}
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/PlatformBridge.h b/WebCore/platform/android/PlatformBridge.h
index 9adb314..cf9f561 100644
--- a/WebCore/platform/android/PlatformBridge.h
+++ b/WebCore/platform/android/PlatformBridge.h
@@ -27,13 +27,62 @@
#define PlatformBridge_h
#include "KURL.h"
+#include "npapi.h"
#include "PlatformString.h"
#include <wtf/Vector.h>
+// V8 bindings use the ARRAYSIZE_UNSAFE macro. This macro was copied
+// from http://src.chromium.org/viewvc/chrome/trunk/src/base/basictypes.h
+//
+// ARRAYSIZE_UNSAFE performs essentially the same calculation as arraysize,
+// but can be used on anonymous types or types defined inside
+// functions. It's less safe than arraysize as it accepts some
+// (although not all) pointers. Therefore, you should use arraysize
+// whenever possible.
+//
+// The expression ARRAYSIZE_UNSAFE(a) is a compile-time constant of type
+// size_t.
+//
+// ARRAYSIZE_UNSAFE catches a few type errors. If you see a compiler error
+//
+// "warning: division by zero in ..."
+//
+// when using ARRAYSIZE_UNSAFE, you are (wrongfully) giving it a pointer.
+// You should only use ARRAYSIZE_UNSAFE on statically allocated arrays.
+//
+// The following comments are on the implementation details, and can
+// be ignored by the users.
+//
+// ARRAYSIZE_UNSAFE(arr) works by inspecting sizeof(arr) (the # of bytes in
+// the array) and sizeof(*(arr)) (the # of bytes in one array
+// element). If the former is divisible by the latter, perhaps arr is
+// indeed an array, in which case the division result is the # of
+// elements in the array. Otherwise, arr cannot possibly be an array,
+// and we generate a compiler error to prevent the code from
+// compiling.
+//
+// Since the size of bool is implementation-defined, we need to cast
+// !(sizeof(a) & sizeof(*(a))) to size_t in order to ensure the final
+// result has type size_t.
+//
+// This macro is not perfect as it wrongfully accepts certain
+// pointers, namely where the pointer size is divisible by the pointee
+// size. Since all our code has to go through a 32-bit compiler,
+// where a pointer is 4 bytes, this means all pointers to a type whose
+// size is 3 or greater than 4 will be (righteously) rejected.
+
+#define ARRAYSIZE_UNSAFE(a) \
+ ((sizeof(a) / sizeof(*(a))) / \
+ static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
+
+
+class NPObject;
+
namespace WebCore {
class FrameView;
+class Widget;
// An interface to the embedding layer, which has the ability to answer
// questions about the system and so on...
@@ -50,6 +99,15 @@ public:
// KeyGenerator
static WTF::Vector<String> getSupportedKeyStrengthList();
static String getSignedPublicKeyAndChallengeString(unsigned index, const String& challenge, const KURL&);
+ // Cookies
+ static void setCookies(const KURL&, const String& value);
+ static String cookies(const KURL&);
+ static bool cookiesEnabled();
+ // Plugin
+ static NPObject* pluginScriptableObject(Widget*);
+ // Popups
+ static bool popupsAllowed(NPP);
+
// These ids need to be in sync with the constants in BrowserFrame.java
enum rawResId {
NoDomain = 1,
@@ -67,6 +125,9 @@ public:
static void immediateRepaint(const FrameView* view);
#endif // USE(ACCELERATED_COMPOSITING)
+ // Whether the WebView is paused.
+ static bool isWebViewPaused();
};
+
}
#endif // PlatformBridge_h
diff --git a/WebCore/platform/network/android/Cookie.cpp b/WebCore/platform/android/PlatformTouchEventAndroid.cpp
index 3d10e4a..e4af8a3 100644
--- a/WebCore/platform/network/android/Cookie.cpp
+++ b/WebCore/platform/android/PlatformTouchEventAndroid.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2007, 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
@@ -24,34 +24,22 @@
*/
#include "config.h"
+#include "PlatformTouchEvent.h"
-#include "CookieClient.h"
-#include "JavaSharedClient.h"
-
-using namespace android;
+#if ENABLE(TOUCH_EVENTS)
namespace WebCore {
-class Document;
-
-void setCookies(Document*, const KURL& url, const String& value)
+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)
{
- if (JavaSharedClient::GetCookieClient())
- JavaSharedClient::GetCookieClient()->setCookies(url, value);
+ m_touchPoints.append(PlatformTouchPoint(absolutePagePos, state));
}
-String cookies(const Document* , const KURL& url)
-{
- if (JavaSharedClient::GetCookieClient())
- return JavaSharedClient::GetCookieClient()->cookies(url);
- return String();
}
-bool cookiesEnabled(const Document* )
-{
- if (JavaSharedClient::GetCookieClient())
- return JavaSharedClient::GetCookieClient()->cookiesEnabled();
- return false;
-}
-
-}
+#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 fb9293c..9741ad5 100644
--- a/WebCore/platform/android/TemporaryLinkStubs.cpp
+++ b/WebCore/platform/android/TemporaryLinkStubs.cpp
@@ -81,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;
diff --git a/WebCore/platform/graphics/BitmapImage.h b/WebCore/platform/graphics/BitmapImage.h
index a07daf2..0031df6 100644
--- a/WebCore/platform/graphics/BitmapImage.h
+++ b/WebCore/platform/graphics/BitmapImage.h
@@ -148,7 +148,7 @@ public:
virtual bool getHBITMAPOfSize(HBITMAP, LPSIZE);
#endif
-#if PLATFORM(SGL)
+#if PLATFORM(ANDROID)
virtual void setURL(const String& str);
#endif
diff --git a/WebCore/platform/graphics/FloatPoint.h b/WebCore/platform/graphics/FloatPoint.h
index 7d32bcf..45a1e83 100644
--- a/WebCore/platform/graphics/FloatPoint.h
+++ b/WebCore/platform/graphics/FloatPoint.h
@@ -100,7 +100,7 @@ public:
operator BPoint() const;
#endif
-#if (PLATFORM(SKIA) || PLATFORM(SGL))
+#if PLATFORM(SKIA)
operator SkPoint() const;
FloatPoint(const SkPoint&);
#endif
diff --git a/WebCore/platform/graphics/FloatRect.h b/WebCore/platform/graphics/FloatRect.h
index 4b4694f..2dc854d 100644
--- a/WebCore/platform/graphics/FloatRect.h
+++ b/WebCore/platform/graphics/FloatRect.h
@@ -55,7 +55,7 @@ class wxRect2DDouble;
class BRect;
#endif
-#if (PLATFORM(SKIA) || PLATFORM(SGL))
+#if PLATFORM(SKIA)
struct SkRect;
#endif
@@ -149,7 +149,7 @@ public:
operator BRect() const;
#endif
-#if (PLATFORM(SKIA) || PLATFORM(SGL))
+#if PLATFORM(SKIA)
FloatRect(const SkRect&);
operator SkRect() const;
#endif
diff --git a/WebCore/platform/graphics/Gradient.cpp b/WebCore/platform/graphics/Gradient.cpp
index 77a0d21..204a2b6 100644
--- a/WebCore/platform/graphics/Gradient.cpp
+++ b/WebCore/platform/graphics/Gradient.cpp
@@ -161,7 +161,7 @@ void Gradient::setGradientSpaceTransform(const TransformationMatrix& gradientSpa
setPlatformGradientSpaceTransform(gradientSpaceTransformation);
}
-#if !PLATFORM(SKIA)
+#if !(PLATFORM(SKIA) && !PLATFORM(ANDROID))
void Gradient::setPlatformGradientSpaceTransform(const TransformationMatrix&)
{
}
diff --git a/WebCore/platform/graphics/Gradient.h b/WebCore/platform/graphics/Gradient.h
index 7f01251..011a2cd 100644
--- a/WebCore/platform/graphics/Gradient.h
+++ b/WebCore/platform/graphics/Gradient.h
@@ -46,13 +46,15 @@ typedef QGradient* PlatformGradient;
#elif PLATFORM(CAIRO)
typedef struct _cairo_pattern cairo_pattern_t;
typedef cairo_pattern_t* PlatformGradient;
-#elif PLATFORM(ANDROID) && PLATFORM(SGL)
+#elif PLATFORM(SKIA)
+#if PLATFORM(ANDROID)
#include "SkShader.h"
typedef class PlatformGradientRec* PlatformGradient;
-#elif PLATFORM(SKIA)
+#else
class SkShader;
typedef class SkShader* PlatformGradient;
typedef class SkShader* PlatformPattern;
+#endif
#else
typedef void* PlatformGradient;
#endif
@@ -86,13 +88,11 @@ namespace WebCore {
struct ColorStop;
const Vector<ColorStop>& getStops() const;
#else
-
-#if PLATFORM(ANDROID) && PLATFORM(SGL)
+#if PLATFORM(ANDROID)
SkShader* getShader(SkShader::TileMode);
#endif
PlatformGradient platformGradient();
#endif
-
struct ColorStop {
float stop;
float red;
diff --git a/WebCore/platform/graphics/GraphicsContext.cpp b/WebCore/platform/graphics/GraphicsContext.cpp
index fee05ee..e80004f 100644
--- a/WebCore/platform/graphics/GraphicsContext.cpp
+++ b/WebCore/platform/graphics/GraphicsContext.cpp
@@ -518,7 +518,7 @@ void GraphicsContext::fillRect(const FloatRect& rect, Generator& generator)
generator.fill(this, rect);
}
-#if !PLATFORM(SKIA)
+#if !(PLATFORM(SKIA) && !PLATFORM(ANDROID))
void GraphicsContext::setPlatformFillGradient(Gradient*)
{
}
@@ -536,7 +536,7 @@ void GraphicsContext::setPlatformStrokePattern(Pattern*)
}
#endif
-#if !PLATFORM(CG) && !PLATFORM(SKIA)
+#if !PLATFORM(CG) && !(PLATFORM(SKIA) && !PLATFORM(ANDROID))
// Implement this if you want to go ahead and push the drawing mode into your native context
// immediately.
void GraphicsContext::setPlatformTextDrawingMode(int mode)
@@ -544,7 +544,7 @@ void GraphicsContext::setPlatformTextDrawingMode(int mode)
}
#endif
-#if !PLATFORM(QT) && !PLATFORM(CAIRO) && !PLATFORM(SKIA) && !PLATFORM(HAIKU)
+#if !PLATFORM(QT) && !PLATFORM(CAIRO) && !(PLATFORM(SKIA) && !PLATFORM(ANDROID)) && !PLATFORM(HAIKU)
void GraphicsContext::setPlatformStrokeStyle(const StrokeStyle&)
{
}
diff --git a/WebCore/platform/graphics/GraphicsContext.h b/WebCore/platform/graphics/GraphicsContext.h
index 96a6221..ecf2101 100644
--- a/WebCore/platform/graphics/GraphicsContext.h
+++ b/WebCore/platform/graphics/GraphicsContext.h
@@ -46,12 +46,6 @@ QT_BEGIN_NAMESPACE
class QPainter;
QT_END_NAMESPACE
typedef QPainter PlatformGraphicsContext;
-#elif PLATFORM(SGL)
-namespace WebCore {
-class PlatformGraphicsContext;
-}
-class SkPaint;
-struct SkPoint;
#elif PLATFORM(WX)
class wxGCDC;
class wxWindowDC;
@@ -72,7 +66,15 @@ class wxWindowDC;
typedef wxWindowDC PlatformGraphicsContext;
#endif
#elif PLATFORM(SKIA)
+#if PLATFORM(ANDROID)
+namespace WebCore {
+class PlatformGraphicsContext;
+}
+class SkPaint;
+struct SkPoint;
+#else
typedef class PlatformContextSkia PlatformGraphicsContext;
+#endif
#elif PLATFORM(HAIKU)
class BView;
typedef BView PlatformGraphicsContext;
@@ -190,7 +192,7 @@ namespace WebCore {
void applyFillPattern();
#endif
-#if PLATFORM(SGL)
+#if PLATFORM(ANDROID)
// initialize a paint for bitmaps
void setupBitmapPaint(SkPaint*);
// initialize a paint for filling
@@ -204,7 +206,7 @@ namespace WebCore {
bool willFill() const;
// returns true if there is a valid (non-transparent) stroke color
bool willStroke() const;
-
+
// may return NULL, since we lazily allocate the path. This is the path
// that is drawn by drawPath()
const SkPath* getCurrPath() const;
diff --git a/WebCore/platform/graphics/Image.h b/WebCore/platform/graphics/Image.h
index aef6577..f25169b 100644
--- a/WebCore/platform/graphics/Image.h
+++ b/WebCore/platform/graphics/Image.h
@@ -148,7 +148,7 @@ public:
virtual bool getHBITMAPOfSize(HBITMAP, LPSIZE) { return false; }
#endif
-#if PLATFORM(SGL)
+#if PLATFORM(ANDROID)
virtual void setURL(const String& str) {}
#endif
diff --git a/WebCore/platform/graphics/ImageSource.h b/WebCore/platform/graphics/ImageSource.h
index 19c7bf7..083c7b0 100644
--- a/WebCore/platform/graphics/ImageSource.h
+++ b/WebCore/platform/graphics/ImageSource.h
@@ -45,12 +45,14 @@ QT_END_NAMESPACE
#elif PLATFORM(CAIRO)
struct _cairo_surface;
typedef struct _cairo_surface cairo_surface_t;
-#elif PLATFORM(ANDROID) && PLATFORM(SGL)
+#elif PLATFORM(SKIA)
+#if PLATFORM(ANDROID)
#include "SkString.h"
class SkBitmapRef;
class PrivateAndroidImageSourceRec;
-#elif PLATFORM(SKIA)
+#else
class NativeImageSkia;
+#endif
#elif PLATFORM(HAIKU)
class BBitmap;
#elif PLATFORM(WINCE)
@@ -70,14 +72,14 @@ typedef CGImageRef NativeImagePtr;
class ImageDecoderQt;
typedef ImageDecoderQt* NativeImageSourcePtr;
typedef QPixmap* NativeImagePtr;
-#elif PLATFORM(ANDROID)
-#if PLATFORM(SGL)
+#elif PLATFORM(SKIA)
+#if PLATFORM(ANDROID)
class String;
#ifdef ANDROID_ANIMATED_GIF
class ImageDecoder;
#endif
struct NativeImageSourcePtr {
- SkString m_url;
+ SkString m_url;
PrivateAndroidImageSourceRec* m_image;
#ifdef ANDROID_ANIMATED_GIF
ImageDecoder* m_gifDecoder;
@@ -85,7 +87,7 @@ struct NativeImageSourcePtr {
};
typedef const Vector<char>* NativeBytePtr;
typedef SkBitmapRef* NativeImagePtr;
-#elif PLATFORM(SKIA) // ANDROID
+#else
class ImageDecoder;
typedef ImageDecoder* NativeImageSourcePtr;
typedef NativeImageSkia* NativeImagePtr;
@@ -101,8 +103,6 @@ typedef wxBitmap* NativeImagePtr;
#endif
#elif PLATFORM(CAIRO)
typedef cairo_surface_t* NativeImagePtr;
-#elif PLATFORM(SKIA)
-typedef NativeImageSkia* NativeImagePtr;
#elif PLATFORM(HAIKU)
typedef BBitmap* NativeImagePtr;
#elif PLATFORM(WINCE)
@@ -166,11 +166,9 @@ public:
bool frameIsCompleteAtIndex(size_t); // Whether or not the frame is completely decoded.
#if PLATFORM(ANDROID)
-#if PLATFORM(SGL)
void clearURL();
void setURL(const String& url);
#endif
-#endif
private:
#if PLATFORM(ANDROID)
// FIXME: This is protected only to allow ImageSourceSkia to set ICO decoder
diff --git a/WebCore/platform/graphics/IntPoint.h b/WebCore/platform/graphics/IntPoint.h
index afbfb46..ab5f3ec 100644
--- a/WebCore/platform/graphics/IntPoint.h
+++ b/WebCore/platform/graphics/IntPoint.h
@@ -63,7 +63,7 @@ class BPoint;
class wxPoint;
#endif
-#if (PLATFORM(SKIA) || PLATFORM(SGL))
+#if PLATFORM(SKIA)
struct SkPoint;
struct SkIPoint;
#endif
@@ -133,7 +133,7 @@ public:
operator wxPoint() const;
#endif
-#if (PLATFORM(SKIA) || PLATFORM(SGL))
+#if PLATFORM(SKIA)
IntPoint(const SkIPoint&);
operator SkIPoint() const;
operator SkPoint() const;
diff --git a/WebCore/platform/graphics/IntRect.h b/WebCore/platform/graphics/IntRect.h
index cd912ff..97b21bc 100644
--- a/WebCore/platform/graphics/IntRect.h
+++ b/WebCore/platform/graphics/IntRect.h
@@ -57,7 +57,7 @@ class BRect;
class wxRect;
#endif
-#if (PLATFORM(SKIA) || PLATFORM(SGL))
+#if PLATFORM(SKIA)
struct SkRect;
struct SkIRect;
#endif
@@ -155,7 +155,7 @@ public:
operator CGRect() const;
#endif
-#if (PLATFORM(SKIA) || PLATFORM(SGL))
+#if PLATFORM(SKIA)
IntRect(const SkIRect&);
operator SkRect() const;
operator SkIRect() const;
diff --git a/WebCore/platform/graphics/Path.h b/WebCore/platform/graphics/Path.h
index fef5ad2..6618fb7 100644
--- a/WebCore/platform/graphics/Path.h
+++ b/WebCore/platform/graphics/Path.h
@@ -39,9 +39,6 @@ QT_BEGIN_NAMESPACE
class QPainterPath;
QT_END_NAMESPACE
typedef QPainterPath PlatformPath;
-#elif PLATFORM(SGL)
-class SkPath;
-typedef SkPath PlatformPath;
#elif PLATFORM(WX) && USE(WXGC)
class wxGraphicsPath;
typedef wxGraphicsPath PlatformPath;
diff --git a/WebCore/platform/graphics/Pattern.h b/WebCore/platform/graphics/Pattern.h
index 2f1192c..aa0a357 100644
--- a/WebCore/platform/graphics/Pattern.h
+++ b/WebCore/platform/graphics/Pattern.h
@@ -39,7 +39,7 @@ typedef CGPatternRef PlatformPatternPtr;
#elif PLATFORM(CAIRO)
#include <cairo.h>
typedef cairo_pattern_t* PlatformPatternPtr;
-#elif PLATFORM(SKIA) || PLATFORM(SGL)
+#elif PLATFORM(SKIA)
class SkShader;
typedef SkShader* PlatformPatternPtr;
#elif PLATFORM(QT)
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index 6901f52..fa012b0 100644
--- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -337,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/MediaPlayerPrivateAndroid.h b/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h
index 29ef11c..19bfcd1 100644
--- a/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h
+++ b/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h
@@ -89,6 +89,7 @@ public:
void onPrepared(int duration, int width, int height);
void onEnded();
void onPosterFetched(SkBitmap*);
+ void onTimeupdate(int position);
private:
// Android-specific methods and fields.
static MediaPlayerPrivateInterface* create(MediaPlayer* player);
@@ -107,6 +108,7 @@ private:
float m_currentTime;
bool m_paused;
+ bool m_hasVideo;
MediaPlayer::ReadyState m_readyState;
MediaPlayer::NetworkState m_networkState;
diff --git a/WebCore/platform/graphics/skia/NativeImageSkia.cpp b/WebCore/platform/graphics/skia/NativeImageSkia.cpp
index 477be05..2411897 100644
--- a/WebCore/platform/graphics/skia/NativeImageSkia.cpp
+++ b/WebCore/platform/graphics/skia/NativeImageSkia.cpp
@@ -30,7 +30,7 @@
#include "config.h"
-#if PLATFORM(SKIA)
+#if !PLATFORM(ANDROID)
#include "skia/ext/image_operations.h"
#endif
@@ -65,10 +65,11 @@ bool NativeImageSkia::hasResizedBitmap(int w, int h) const
SkBitmap NativeImageSkia::resizedBitmap(int w, int h) const
{
-#if PLATFORM(SKIA)
+#if !PLATFORM(ANDROID)
if (m_resizedImage.width() != w || m_resizedImage.height() != h)
m_resizedImage = skia::ImageOperations::Resize(*this, skia::ImageOperations::RESIZE_LANCZOS3, w, h);
#endif
+
return m_resizedImage;
}
diff --git a/WebCore/platform/graphics/transforms/TransformationMatrix.h b/WebCore/platform/graphics/transforms/TransformationMatrix.h
index 33f9afe..802ad3c 100644
--- a/WebCore/platform/graphics/transforms/TransformationMatrix.h
+++ b/WebCore/platform/graphics/transforms/TransformationMatrix.h
@@ -37,7 +37,7 @@
#include <cairo.h>
#elif PLATFORM(QT)
#include <QTransform>
-#elif PLATFORM(SKIA) || PLATFORM(SGL)
+#elif PLATFORM(SKIA)
#include <SkMatrix.h>
#elif PLATFORM(WX) && USE(WXGC)
#include <wx/graphics.h>
@@ -301,7 +301,7 @@ public:
operator cairo_matrix_t() const;
#elif PLATFORM(QT)
operator QTransform() const;
-#elif PLATFORM(SKIA) || PLATFORM(SGL)
+#elif PLATFORM(SKIA)
operator SkMatrix() const;
#elif PLATFORM(WX) && USE(WXGC)
operator wxGraphicsMatrix() const;
diff --git a/WebCore/platform/image-decoders/ImageDecoder.h b/WebCore/platform/image-decoders/ImageDecoder.h
index 08f4aa2..535efa1 100644
--- a/WebCore/platform/image-decoders/ImageDecoder.h
+++ b/WebCore/platform/image-decoders/ImageDecoder.h
@@ -36,8 +36,7 @@
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
-#if (PLATFORM(SKIA) || PLATFORM(SGL))
-// TODO(benm): ANDROID: Can we define PLATFORM(SKIA) instead of PLATFORM(SGL) before upstreaming?
+#if PLATFORM(SKIA)
#include "NativeImageSkia.h"
#elif PLATFORM(QT)
#include <QImage>
@@ -58,7 +57,7 @@ namespace WebCore {
DisposeOverwriteBgcolor, // Clear frame to transparent
DisposeOverwritePrevious, // Clear frame to previous framebuffer contents
};
-#if (PLATFORM(SKIA) || PLATFORM(QT) || PLATFORM(SGL))
+#if PLATFORM(SKIA) || PLATFORM(QT)
typedef uint32_t PixelData;
#else
typedef unsigned PixelData;
@@ -102,7 +101,7 @@ namespace WebCore {
memcpy(getAddr(startX, destY), startAddr, rowBytes);
}
-#if (PLATFORM(SKIA) || PLATFORM(SGL))
+#if PLATFORM(ANDROID)
NativeImageSkia& bitmap() { return m_bitmap; }
const NativeImageSkia& bitmap() const { return m_bitmap; }
#endif
@@ -148,7 +147,7 @@ namespace WebCore {
inline PixelData* getAddr(int x, int y)
{
-#if (PLATFORM(SKIA) || PLATFORM(SGL))
+#if PLATFORM(SKIA)
return m_bitmap.getAddr32(x, y);
#elif PLATFORM(QT)
return reinterpret_cast<QRgb*>(m_image.scanLine(y)) + x;
@@ -173,7 +172,7 @@ namespace WebCore {
}
}
-#if (PLATFORM(SKIA) || PLATFORM(SGL))
+#if PLATFORM(SKIA)
NativeImageSkia m_bitmap;
#elif PLATFORM(QT)
mutable QImage m_image;
diff --git a/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp b/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp
index 6acaed5..96342fa 100644
--- a/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp
+++ b/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp
@@ -26,8 +26,7 @@
#include "config.h"
#include "ImageDecoder.h"
-
-#if PLATFORM(SGL)
+#if PLATFORM(ANDROID)
#include "SkBitmapRef.h"
#endif
@@ -85,7 +84,7 @@ bool RGBA32Buffer::setSize(int newWidth, int newHeight)
NativeImagePtr RGBA32Buffer::asNewNativeImage() const
{
-#if PLATFORM(SGL)
+#if PLATFORM(ANDROID)
return new SkBitmapRef(m_bitmap);
#else
return new NativeImageSkia(m_bitmap);
diff --git a/WebCore/platform/network/NetworkStateNotifier.h b/WebCore/platform/network/NetworkStateNotifier.h
index a630ccd..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();
@@ -78,12 +87,13 @@ private:
HANDLE m_waitHandle;
OVERLAPPED m_overlapped;
-#elif PLATFORM(ANDROID)
-public:
- void networkStateChange(bool online);
-
#elif PLATFORM(CHROMIUM)
NetworkStateNotifierPrivate p;
+
+#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/ResourceHandle.h b/WebCore/platform/network/ResourceHandle.h
index e7f6092..b764add 100644
--- a/WebCore/platform/network/ResourceHandle.h
+++ b/WebCore/platform/network/ResourceHandle.h
@@ -170,7 +170,7 @@ public:
friend LRESULT __stdcall ResourceHandleWndProc(HWND, unsigned message, WPARAM, LPARAM);
#endif
-#if PLATFORM(QT) || USE(CURL) || USE(SOUP) || defined(ANDROID)
+#if PLATFORM(QT) || USE(CURL) || USE(SOUP) || PLATFORM(ANDROID)
ResourceHandleInternal* getInternal() { return d.get(); }
#endif
diff --git a/WebCore/platform/network/ResourceHandleInternal.h b/WebCore/platform/network/ResourceHandleInternal.h
index f7135ee..328fc89 100644
--- a/WebCore/platform/network/ResourceHandleInternal.h
+++ b/WebCore/platform/network/ResourceHandleInternal.h
@@ -133,9 +133,6 @@ namespace WebCore {
, m_needsSiteSpecificQuirks(false)
, m_currentMacChallenge(nil)
#endif
-#if PLATFORM(ANDROID)
- , m_loader(0)
-#endif
, m_failureTimer(loader, &ResourceHandle::fireFailure)
{
const KURL& url = m_request.url();
diff --git a/WebCore/platform/network/android/AuthenticationChallenge.h b/WebCore/platform/network/android/AuthenticationChallenge.h
index e272d60..954bfd8 100644
--- a/WebCore/platform/network/android/AuthenticationChallenge.h
+++ b/WebCore/platform/network/android/AuthenticationChallenge.h
@@ -31,8 +31,6 @@
namespace WebCore {
-class ResourceHandle;
-
class AuthenticationChallenge : public AuthenticationChallengeBase {
};
diff --git a/WebCore/platform/network/android/CookieClient.h b/WebCore/platform/network/android/CookieJarAndroid.cpp
index be2963e..ba4b5dc 100644
--- a/WebCore/platform/network/android/CookieClient.h
+++ b/WebCore/platform/network/android/CookieJarAndroid.cpp
@@ -23,24 +23,27 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef COOKIE_CLIENT_H
-#define COOKIE_CLIENT_H
+#include "config.h"
-#include "KURL.h"
-#include "PlatformString.h"
+#include "CookieJar.h"
-using namespace WebCore;
+#include "PlatformBridge.h"
-namespace android {
+namespace WebCore {
-class CookieClient {
+void setCookies(Document*, const KURL& url, const String& value)
+{
+ PlatformBridge::setCookies(url, value);
+}
+
+String cookies(const Document*, const KURL& url)
+{
+ return PlatformBridge::cookies(url);
+}
-public:
- virtual ~CookieClient() {}
- virtual void setCookies(const KURL& url, const String& value) = 0;
- virtual String cookies(const KURL& url) = 0;
- virtual bool cookiesEnabled() = 0;
-};
+bool cookiesEnabled(const Document*)
+{
+ return PlatformBridge::cookiesEnabled();
+}
}
-#endif
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/android/PluginPackageAndroid.cpp b/WebCore/plugins/android/PluginPackageAndroid.cpp
index 2019b5c..ff672f4 100644
--- a/WebCore/plugins/android/PluginPackageAndroid.cpp
+++ b/WebCore/plugins/android/PluginPackageAndroid.cpp
@@ -25,18 +25,18 @@
*/
#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 "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>
@@ -190,45 +190,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",
@@ -286,8 +247,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;
}
@@ -395,22 +355,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 ed7a694..41dc668 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,9 +208,14 @@ void PluginView::handleTouchEvent(TouchEvent* event)
evt.data.touch.modifiers = 0; // todo
- // convert to coordinates that are relative to the plugin.
- IntPoint localPos = roundedIntPoint(m_element->renderer()->absoluteToLocal(
- IntPoint(event->pageX(), event->pageY())));
+ // 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();
@@ -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.
- IntPoint localPos = roundedIntPoint(m_element->renderer()->absoluteToLocal(
- IntPoint(event->pageX(), event->pageY())));
+ // 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())
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/rendering/RenderBlockLineLayout.cpp b/WebCore/rendering/RenderBlockLineLayout.cpp
index 8517d6d..4d209de 100644
--- a/WebCore/rendering/RenderBlockLineLayout.cpp
+++ b/WebCore/rendering/RenderBlockLineLayout.cpp
@@ -852,6 +852,8 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintTop, i
// and text align is auto, or justify or left in LTR, or right in RTL, we
// will wrap text around screen width so that it doesn't need to scroll
// horizontally when reading a paragraph.
+ // In case the line height is less than the font size, we skip
+ // the text wrapping since this will cause text overlapping.
const Settings* settings = document()->settings();
bool doTextWrap = settings && settings->layoutAlgorithm() == Settings::kLayoutFitColumnToScreen;
if (doTextWrap) {
@@ -862,7 +864,10 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintTop, i
// width as it may cause text to overlap.
bool positioned = isPositioned();
EFloat cssfloat = style()->floating();
+ const int lineHeight = style()->computedLineHeight();
+ const int fontSize = style()->fontSize();
doTextWrap = autowrap && !positioned &&
+ (fontSize <= lineHeight) &&
(((dir == LTR && cssfloat != FRIGHT) ||
(dir == RTL && cssfloat != FLEFT)) &&
((ta == TAAUTO) || (ta == JUSTIFY) ||
diff --git a/WebCore/rendering/RenderPartObject.cpp b/WebCore/rendering/RenderPartObject.cpp
index f864c00..8e9118e 100644
--- a/WebCore/rendering/RenderPartObject.cpp
+++ b/WebCore/rendering/RenderPartObject.cpp
@@ -322,10 +322,15 @@ void RenderPartObject::layout()
#ifdef FLATTEN_IFRAME
RenderPart::calcWidth();
RenderPart::calcHeight();
+ // Calculate the styled dimensions by subtracting the border and padding.
+ int extraWidth = paddingLeft() + paddingRight() + borderLeft() + borderRight();
+ int extraHeight = paddingTop() + paddingBottom() + borderTop() + borderBottom();
+ int styleWidth = width() - extraWidth;
+ int styleHeight = height() - extraHeight;
// Some IFrames have a width and/or height of 1 when they are meant to be
// hidden. If that is the case, do not try to expand.
- if (node()->hasTagName(iframeTag) && widget() && widget()->isFrameView()
- && width() > 1 && height() > 1) {
+ if (node()->hasTagName(iframeTag) && widget() && widget()->isFrameView() &&
+ styleWidth > 1 && styleHeight > 1) {
HTMLIFrameElement* element = static_cast<HTMLIFrameElement*>(node());
bool scrolling = element->scrollingMode() != ScrollbarAlwaysOff;
bool widthIsFixed = style()->width().isFixed();
@@ -336,15 +341,11 @@ void RenderPartObject::layout()
if (scrolling || !widthIsFixed || !heightIsFixed) {
FrameView* view = static_cast<FrameView*>(widget());
RenderView* root = view ? view->frame()->contentRenderer() : NULL;
- RenderPart* owner = view->frame()->ownerRenderer();
- if (root && style()->visibility() != HIDDEN
- && (!owner || owner->style()->visibility() != HIDDEN)) {
+ if (root && style()->visibility() != HIDDEN) {
// Update the dimensions to get the correct minimum preferred
// width
updateWidgetPosition();
- int extraWidth = paddingLeft() + paddingRight() + borderLeft() + borderRight();
- int extraHeight = paddingTop() + paddingBottom() + borderTop() + borderBottom();
// Use the preferred width if it is larger and only if
// scrollbars are visible or the width style is not fixed.
if (scrolling || !widthIsFixed)
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/WebCore/svg/graphics/SVGPaintServer.cpp b/WebCore/svg/graphics/SVGPaintServer.cpp
index 728ff1b..6b81f72 100644
--- a/WebCore/svg/graphics/SVGPaintServer.cpp
+++ b/WebCore/svg/graphics/SVGPaintServer.cpp
@@ -38,7 +38,7 @@
#include "SVGStyledElement.h"
#include "SVGURIReference.h"
-#if PLATFORM(SKIA)
+#if PLATFORM(SKIA) && !PLATFORM(ANDROID)
#include "PlatformContextSkia.h"
#endif
@@ -184,7 +184,7 @@ void SVGPaintServer::renderPath(GraphicsContext*& context, const RenderObject* p
context->strokePath();
}
-#if PLATFORM(SKIA)
+#if PLATFORM(SKIA) && !PLATFORM(ANDROID)
void SVGPaintServer::teardown(GraphicsContext*& context, const RenderObject*, SVGPaintTargetType, bool) const
{
// FIXME: Move this into the GraphicsContext