]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.eclipse.swt.win32.win32.x86_64/library/webkit_win32_custom.cpp
Work around SWT 4.13 - 4.18 Win32 DnD bug 567422
[simantics/platform.git] / bundles / org.eclipse.swt.win32.win32.x86_64 / library / webkit_win32_custom.cpp
1 /*******************************************************************************
2  * Copyright (c) 2010, 2011 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14
15 #include "swt.h"
16 #include "webkit_win32.h"
17 #include "webkit_win32_stats.h"
18
19 #define WebKit_win32_NATIVE(func) Java_org_eclipse_swt_internal_webkit_WebKit_1win32_##func
20
21 #ifndef NO_willPerformClientRedirectToURL_1CALLBACK
22 static jintLong willPerformClientRedirectToURL_CALLBACK;
23 static HRESULT CALLBACK willPerformClientRedirectToURL(void* ppVTable, jintLong webView, BSTR url, double delaySeconds, DATE fireDate, jintLong frame)
24 {
25         return ((HRESULT (CALLBACK *)(void*, jintLong, BSTR, double*, DATE*, jintLong))willPerformClientRedirectToURL_CALLBACK)(ppVTable, webView, url, &delaySeconds, &fireDate, frame);
26 }
27 extern "C" JNIEXPORT jintLong JNICALL WebKit_win32_NATIVE(willPerformClientRedirectToURL_1CALLBACK) (JNIEnv *env, jclass that, jintLong func);
28 JNIEXPORT jintLong JNICALL WebKit_win32_NATIVE(willPerformClientRedirectToURL_1CALLBACK) (JNIEnv *env, jclass that, jintLong func)
29 {
30         willPerformClientRedirectToURL_CALLBACK = func;
31         return (jintLong)willPerformClientRedirectToURL;
32 }
33 #endif
34
35 #ifndef NO_JSObjectCallAsFunctionProc_1CALLBACK
36 static jintLong JSObjectCallAsFunctionProc_CALLBACK;
37 static JSValueRef JSObjectCallAsFunctionProc(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
38 {
39         return ((JSValueRef (CALLBACK *)(JSContextRef, JSObjectRef, JSObjectRef, size_t, const JSValueRef[], JSValueRef*))JSObjectCallAsFunctionProc_CALLBACK)(ctx, function, thisObject, argumentCount, arguments, exception);
40 }
41 extern "C" JNIEXPORT jintLong JNICALL WebKit_win32_NATIVE(JSObjectCallAsFunctionProc_1CALLBACK) (JNIEnv *env, jclass that, jintLong func);
42 JNIEXPORT jintLong JNICALL WebKit_win32_NATIVE(JSObjectCallAsFunctionProc_1CALLBACK) (JNIEnv *env, jclass that, jintLong func)
43 {
44         JSObjectCallAsFunctionProc_CALLBACK = func;
45         return (jintLong)JSObjectCallAsFunctionProc;
46 }
47 #endif
48
49 #ifndef NO_JSObjectGetPropertyProc_1CALLBACK
50 static jintLong JSObjectGetPropertyProc_CALLBACK;
51 static JSValueRef JSObjectGetPropertyProc(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
52 {
53         return ((JSValueRef (CALLBACK *)(JSContextRef, JSObjectRef, JSStringRef, JSValueRef*))JSObjectGetPropertyProc_CALLBACK)(ctx, object, propertyName, exception);
54 }
55 extern "C" JNIEXPORT jintLong JNICALL WebKit_win32_NATIVE(JSObjectGetPropertyProc_1CALLBACK) (JNIEnv *env, jclass that, jintLong func);
56 JNIEXPORT jintLong JNICALL WebKit_win32_NATIVE(JSObjectGetPropertyProc_1CALLBACK) (JNIEnv *env, jclass that, jintLong func)
57 {
58         JSObjectGetPropertyProc_CALLBACK = func;
59         return (jintLong)JSObjectGetPropertyProc;
60 }
61 #endif
62
63 #ifndef NO_JSObjectHasPropertyProc_1CALLBACK
64 static jintLong JSObjectHasPropertyProc_CALLBACK;
65 static bool JSObjectHasPropertyProc(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName)
66 {
67         return ((bool (CALLBACK *)(JSContextRef, JSObjectRef, JSStringRef))JSObjectHasPropertyProc_CALLBACK)(ctx, object, propertyName);
68 }
69 extern "C" JNIEXPORT jintLong JNICALL WebKit_win32_NATIVE(JSObjectHasPropertyProc_1CALLBACK) (JNIEnv *env, jclass that, jintLong func);
70 JNIEXPORT jintLong JNICALL WebKit_win32_NATIVE(JSObjectHasPropertyProc_1CALLBACK) (JNIEnv *env, jclass that, jintLong func)
71 {
72         JSObjectHasPropertyProc_CALLBACK = func;
73         return (jintLong)JSObjectHasPropertyProc;
74 }
75 #endif
76
77 #ifndef NO_WebKitCreateInstance
78 extern "C" JNIEXPORT jint JNICALL WebKit_win32_NATIVE(WebKitCreateInstance)(JNIEnv *env, jclass that, jbyteArray arg0, jintLong arg1, jbyteArray arg2, jintLongArray arg3);
79 JNIEXPORT jint JNICALL WebKit_win32_NATIVE(WebKitCreateInstance)
80         (JNIEnv *env, jclass that, jbyteArray arg0, jintLong arg1, jbyteArray arg2, jintLongArray arg3)
81 {
82         jbyte *lparg0=NULL;
83         jbyte *lparg2=NULL;
84         jintLong *lparg3=NULL;
85         jint rc = 0;
86         WebKit_win32_NATIVE_ENTER(env, that, WebKitCreateInstance_FUNC);
87         if (arg0) if ((lparg0 = env->GetByteArrayElements(arg0, NULL)) == NULL) goto fail;
88         if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
89         if (arg3) if ((lparg3 = env->GetIntLongArrayElements(arg3, NULL)) == NULL) goto fail;
90 /*
91         rc = (jint)WebKitCreateInstance(lparg0, arg1, lparg2, lparg3);
92 */
93         {
94                 WebKit_LOAD_FUNCTION(fp, WebKitCreateInstance)
95                 if (fp) {
96                         rc = (jint)((jint (*)(jbyte *, jintLong, jbyte *, jintLong *))fp)(lparg0, arg1, lparg2, lparg3);
97                 }
98         }
99 fail:
100         if (arg3 && lparg3) env->ReleaseIntLongArrayElements(arg3, lparg3, 0);
101         if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
102         if (arg0 && lparg0) env->ReleaseByteArrayElements(arg0, lparg0, 0);
103         WebKit_win32_NATIVE_EXIT(env, that, WebKitCreateInstance_FUNC);
104         return rc;
105 }
106 #endif