Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrant Gayed2011-10-03 18:57:16 +0000
committerGrant Gayed2011-10-03 18:57:16 +0000
commit01b9002aa980befd0c51529f45e05b950166ae2b (patch)
tree0c500578bce358c96871d359a2f1f0fb21065aba /bundles/org.eclipse.swt/Eclipse SWT WebKit
parentb1df683a63ba731de0add93dda58ad190689d7cb (diff)
downloadeclipse.platform.swt-01b9002aa980befd0c51529f45e05b950166ae2b.tar.gz
eclipse.platform.swt-01b9002aa980befd0c51529f45e05b950166ae2b.tar.xz
eclipse.platform.swt-01b9002aa980befd0c51529f45e05b950166ae2b.zip
Bug 350098 (part 1) - [hovering] "Enrich on click" is not working on
Indigo
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT WebKit')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk.c244
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_stats.c16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_stats.h12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java342
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/internal/webkit/WebKitGTK.java142
5 files changed, 648 insertions, 108 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk.c b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk.c
index 0fb36dff52..a326248cef 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk.c
@@ -1038,6 +1038,230 @@ JNIEXPORT jintLong JNICALL WebKitGTK_NATIVE(_1soup_1uri_1to_1string)
}
#endif
+#ifndef NO__1webkit_1dom_1event_1target_1add_1event_1listener
+JNIEXPORT jint JNICALL WebKitGTK_NATIVE(_1webkit_1dom_1event_1target_1add_1event_1listener)
+ (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jintLong arg2, jint arg3, jintLong arg4)
+{
+ jbyte *lparg1=NULL;
+ jint rc = 0;
+ WebKitGTK_NATIVE_ENTER(env, that, _1webkit_1dom_1event_1target_1add_1event_1listener_FUNC);
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+ rc = (jint)webkit_dom_event_target_add_event_listener(arg0, lparg1, arg2, arg3, arg4);
+*/
+ {
+ WebKitGTK_LOAD_FUNCTION(fp, webkit_dom_event_target_add_event_listener)
+ if (fp) {
+ rc = (jint)((jint (CALLING_CONVENTION*)(jintLong, jbyte *, jintLong, jint, jintLong))fp)(arg0, lparg1, arg2, arg3, arg4);
+ }
+ }
+fail:
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ WebKitGTK_NATIVE_EXIT(env, that, _1webkit_1dom_1event_1target_1add_1event_1listener_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1webkit_1dom_1mouse_1event_1get_1alt_1key
+JNIEXPORT jint JNICALL WebKitGTK_NATIVE(_1webkit_1dom_1mouse_1event_1get_1alt_1key)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jint rc = 0;
+ WebKitGTK_NATIVE_ENTER(env, that, _1webkit_1dom_1mouse_1event_1get_1alt_1key_FUNC);
+/*
+ rc = (jint)webkit_dom_mouse_event_get_alt_key(arg0);
+*/
+ {
+ WebKitGTK_LOAD_FUNCTION(fp, webkit_dom_mouse_event_get_alt_key)
+ if (fp) {
+ rc = (jint)((jint (CALLING_CONVENTION*)(jintLong))fp)(arg0);
+ }
+ }
+ WebKitGTK_NATIVE_EXIT(env, that, _1webkit_1dom_1mouse_1event_1get_1alt_1key_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1webkit_1dom_1mouse_1event_1get_1button
+JNIEXPORT jshort JNICALL WebKitGTK_NATIVE(_1webkit_1dom_1mouse_1event_1get_1button)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jshort rc = 0;
+ WebKitGTK_NATIVE_ENTER(env, that, _1webkit_1dom_1mouse_1event_1get_1button_FUNC);
+/*
+ rc = (jshort)webkit_dom_mouse_event_get_button(arg0);
+*/
+ {
+ WebKitGTK_LOAD_FUNCTION(fp, webkit_dom_mouse_event_get_button)
+ if (fp) {
+ rc = (jshort)((jshort (CALLING_CONVENTION*)(jintLong))fp)(arg0);
+ }
+ }
+ WebKitGTK_NATIVE_EXIT(env, that, _1webkit_1dom_1mouse_1event_1get_1button_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1webkit_1dom_1mouse_1event_1get_1ctrl_1key
+JNIEXPORT jint JNICALL WebKitGTK_NATIVE(_1webkit_1dom_1mouse_1event_1get_1ctrl_1key)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jint rc = 0;
+ WebKitGTK_NATIVE_ENTER(env, that, _1webkit_1dom_1mouse_1event_1get_1ctrl_1key_FUNC);
+/*
+ rc = (jint)webkit_dom_mouse_event_get_ctrl_key(arg0);
+*/
+ {
+ WebKitGTK_LOAD_FUNCTION(fp, webkit_dom_mouse_event_get_ctrl_key)
+ if (fp) {
+ rc = (jint)((jint (CALLING_CONVENTION*)(jintLong))fp)(arg0);
+ }
+ }
+ WebKitGTK_NATIVE_EXIT(env, that, _1webkit_1dom_1mouse_1event_1get_1ctrl_1key_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1webkit_1dom_1mouse_1event_1get_1meta_1key
+JNIEXPORT jint JNICALL WebKitGTK_NATIVE(_1webkit_1dom_1mouse_1event_1get_1meta_1key)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jint rc = 0;
+ WebKitGTK_NATIVE_ENTER(env, that, _1webkit_1dom_1mouse_1event_1get_1meta_1key_FUNC);
+/*
+ rc = (jint)webkit_dom_mouse_event_get_meta_key(arg0);
+*/
+ {
+ WebKitGTK_LOAD_FUNCTION(fp, webkit_dom_mouse_event_get_meta_key)
+ if (fp) {
+ rc = (jint)((jint (CALLING_CONVENTION*)(jintLong))fp)(arg0);
+ }
+ }
+ WebKitGTK_NATIVE_EXIT(env, that, _1webkit_1dom_1mouse_1event_1get_1meta_1key_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1webkit_1dom_1mouse_1event_1get_1screen_1x
+JNIEXPORT jlong JNICALL WebKitGTK_NATIVE(_1webkit_1dom_1mouse_1event_1get_1screen_1x)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jlong rc = 0;
+ WebKitGTK_NATIVE_ENTER(env, that, _1webkit_1dom_1mouse_1event_1get_1screen_1x_FUNC);
+/*
+ rc = (jlong)webkit_dom_mouse_event_get_screen_x(arg0);
+*/
+ {
+ WebKitGTK_LOAD_FUNCTION(fp, webkit_dom_mouse_event_get_screen_x)
+ if (fp) {
+ rc = (jlong)((jlong (CALLING_CONVENTION*)(jintLong))fp)(arg0);
+ }
+ }
+ WebKitGTK_NATIVE_EXIT(env, that, _1webkit_1dom_1mouse_1event_1get_1screen_1x_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1webkit_1dom_1mouse_1event_1get_1screen_1y
+JNIEXPORT jlong JNICALL WebKitGTK_NATIVE(_1webkit_1dom_1mouse_1event_1get_1screen_1y)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jlong rc = 0;
+ WebKitGTK_NATIVE_ENTER(env, that, _1webkit_1dom_1mouse_1event_1get_1screen_1y_FUNC);
+/*
+ rc = (jlong)webkit_dom_mouse_event_get_screen_y(arg0);
+*/
+ {
+ WebKitGTK_LOAD_FUNCTION(fp, webkit_dom_mouse_event_get_screen_y)
+ if (fp) {
+ rc = (jlong)((jlong (CALLING_CONVENTION*)(jintLong))fp)(arg0);
+ }
+ }
+ WebKitGTK_NATIVE_EXIT(env, that, _1webkit_1dom_1mouse_1event_1get_1screen_1y_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1webkit_1dom_1mouse_1event_1get_1shift_1key
+JNIEXPORT jint JNICALL WebKitGTK_NATIVE(_1webkit_1dom_1mouse_1event_1get_1shift_1key)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jint rc = 0;
+ WebKitGTK_NATIVE_ENTER(env, that, _1webkit_1dom_1mouse_1event_1get_1shift_1key_FUNC);
+/*
+ rc = (jint)webkit_dom_mouse_event_get_shift_key(arg0);
+*/
+ {
+ WebKitGTK_LOAD_FUNCTION(fp, webkit_dom_mouse_event_get_shift_key)
+ if (fp) {
+ rc = (jint)((jint (CALLING_CONVENTION*)(jintLong))fp)(arg0);
+ }
+ }
+ WebKitGTK_NATIVE_EXIT(env, that, _1webkit_1dom_1mouse_1event_1get_1shift_1key_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1webkit_1dom_1ui_1event_1get_1char_1code
+JNIEXPORT jlong JNICALL WebKitGTK_NATIVE(_1webkit_1dom_1ui_1event_1get_1char_1code)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jlong rc = 0;
+ WebKitGTK_NATIVE_ENTER(env, that, _1webkit_1dom_1ui_1event_1get_1char_1code_FUNC);
+/*
+ rc = (jlong)webkit_dom_ui_event_get_char_code(arg0);
+*/
+ {
+ WebKitGTK_LOAD_FUNCTION(fp, webkit_dom_ui_event_get_char_code)
+ if (fp) {
+ rc = (jlong)((jlong (CALLING_CONVENTION*)(jintLong))fp)(arg0);
+ }
+ }
+ WebKitGTK_NATIVE_EXIT(env, that, _1webkit_1dom_1ui_1event_1get_1char_1code_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1webkit_1dom_1ui_1event_1get_1detail
+JNIEXPORT jlong JNICALL WebKitGTK_NATIVE(_1webkit_1dom_1ui_1event_1get_1detail)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jlong rc = 0;
+ WebKitGTK_NATIVE_ENTER(env, that, _1webkit_1dom_1ui_1event_1get_1detail_FUNC);
+/*
+ rc = (jlong)webkit_dom_ui_event_get_detail(arg0);
+*/
+ {
+ WebKitGTK_LOAD_FUNCTION(fp, webkit_dom_ui_event_get_detail)
+ if (fp) {
+ rc = (jlong)((jlong (CALLING_CONVENTION*)(jintLong))fp)(arg0);
+ }
+ }
+ WebKitGTK_NATIVE_EXIT(env, that, _1webkit_1dom_1ui_1event_1get_1detail_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1webkit_1dom_1ui_1event_1get_1key_1code
+JNIEXPORT jlong JNICALL WebKitGTK_NATIVE(_1webkit_1dom_1ui_1event_1get_1key_1code)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jlong rc = 0;
+ WebKitGTK_NATIVE_ENTER(env, that, _1webkit_1dom_1ui_1event_1get_1key_1code_FUNC);
+/*
+ rc = (jlong)webkit_dom_ui_event_get_key_code(arg0);
+*/
+ {
+ WebKitGTK_LOAD_FUNCTION(fp, webkit_dom_ui_event_get_key_code)
+ if (fp) {
+ rc = (jlong)((jlong (CALLING_CONVENTION*)(jintLong))fp)(arg0);
+ }
+ }
+ WebKitGTK_NATIVE_EXIT(env, that, _1webkit_1dom_1ui_1event_1get_1key_1code_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1webkit_1download_1cancel
JNIEXPORT void JNICALL WebKitGTK_NATIVE(_1webkit_1download_1cancel)
(JNIEnv *env, jclass that, jintLong arg0)
@@ -1660,6 +1884,26 @@ fail:
}
#endif
+#ifndef NO__1webkit_1web_1view_1get_1dom_1document
+JNIEXPORT jintLong JNICALL WebKitGTK_NATIVE(_1webkit_1web_1view_1get_1dom_1document)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jintLong rc = 0;
+ WebKitGTK_NATIVE_ENTER(env, that, _1webkit_1web_1view_1get_1dom_1document_FUNC);
+/*
+ rc = (jintLong)webkit_web_view_get_dom_document(arg0);
+*/
+ {
+ WebKitGTK_LOAD_FUNCTION(fp, webkit_web_view_get_dom_document)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jintLong))fp)(arg0);
+ }
+ }
+ WebKitGTK_NATIVE_EXIT(env, that, _1webkit_1web_1view_1get_1dom_1document_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1webkit_1web_1view_1get_1load_1status
JNIEXPORT jint JNICALL WebKitGTK_NATIVE(_1webkit_1web_1view_1get_1load_1status)
(JNIEnv *env, jclass that, jintLong arg0)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_stats.c b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_stats.c
index fc12f79ed4..7da07562ba 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_stats.c
@@ -18,8 +18,8 @@
#ifdef NATIVE_STATS
-int WebKitGTK_nativeFunctionCount = 97;
-int WebKitGTK_nativeFunctionCallCount[97];
+int WebKitGTK_nativeFunctionCount = 109;
+int WebKitGTK_nativeFunctionCallCount[109];
char * WebKitGTK_nativeFunctionNames[] = {
"JSClassDefinition_1sizeof",
"_1JSClassCreate",
@@ -72,6 +72,17 @@ char * WebKitGTK_nativeFunctionNames[] = {
"_1soup_1uri_1free",
"_1soup_1uri_1new",
"_1soup_1uri_1to_1string",
+ "_1webkit_1dom_1event_1target_1add_1event_1listener",
+ "_1webkit_1dom_1mouse_1event_1get_1alt_1key",
+ "_1webkit_1dom_1mouse_1event_1get_1button",
+ "_1webkit_1dom_1mouse_1event_1get_1ctrl_1key",
+ "_1webkit_1dom_1mouse_1event_1get_1meta_1key",
+ "_1webkit_1dom_1mouse_1event_1get_1screen_1x",
+ "_1webkit_1dom_1mouse_1event_1get_1screen_1y",
+ "_1webkit_1dom_1mouse_1event_1get_1shift_1key",
+ "_1webkit_1dom_1ui_1event_1get_1char_1code",
+ "_1webkit_1dom_1ui_1event_1get_1detail",
+ "_1webkit_1dom_1ui_1event_1get_1key_1code",
"_1webkit_1download_1cancel",
"_1webkit_1download_1get_1current_1size",
"_1webkit_1download_1get_1status",
@@ -103,6 +114,7 @@ char * WebKitGTK_nativeFunctionNames[] = {
"_1webkit_1web_1view_1can_1go_1forward",
"_1webkit_1web_1view_1can_1show_1mime_1type",
"_1webkit_1web_1view_1execute_1script",
+ "_1webkit_1web_1view_1get_1dom_1document",
"_1webkit_1web_1view_1get_1load_1status",
"_1webkit_1web_1view_1get_1main_1frame",
"_1webkit_1web_1view_1get_1progress",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_stats.h b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_stats.h
index 26aeec72b0..f2210ece9d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_stats.h
@@ -80,6 +80,17 @@ typedef enum {
_1soup_1uri_1free_FUNC,
_1soup_1uri_1new_FUNC,
_1soup_1uri_1to_1string_FUNC,
+ _1webkit_1dom_1event_1target_1add_1event_1listener_FUNC,
+ _1webkit_1dom_1mouse_1event_1get_1alt_1key_FUNC,
+ _1webkit_1dom_1mouse_1event_1get_1button_FUNC,
+ _1webkit_1dom_1mouse_1event_1get_1ctrl_1key_FUNC,
+ _1webkit_1dom_1mouse_1event_1get_1meta_1key_FUNC,
+ _1webkit_1dom_1mouse_1event_1get_1screen_1x_FUNC,
+ _1webkit_1dom_1mouse_1event_1get_1screen_1y_FUNC,
+ _1webkit_1dom_1mouse_1event_1get_1shift_1key_FUNC,
+ _1webkit_1dom_1ui_1event_1get_1char_1code_FUNC,
+ _1webkit_1dom_1ui_1event_1get_1detail_FUNC,
+ _1webkit_1dom_1ui_1event_1get_1key_1code_FUNC,
_1webkit_1download_1cancel_FUNC,
_1webkit_1download_1get_1current_1size_FUNC,
_1webkit_1download_1get_1status_FUNC,
@@ -111,6 +122,7 @@ typedef enum {
_1webkit_1web_1view_1can_1go_1forward_FUNC,
_1webkit_1web_1view_1can_1show_1mime_1type_FUNC,
_1webkit_1web_1view_1execute_1script_FUNC,
+ _1webkit_1web_1view_1get_1dom_1document_FUNC,
_1webkit_1web_1view_1get_1load_1status_FUNC,
_1webkit_1web_1view_1get_1main_1frame_FUNC,
_1webkit_1web_1view_1get_1progress_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
index 9bd57205c3..952c776dc1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
@@ -33,7 +33,8 @@ class WebKit extends WebBrowser {
BrowserFunction eventFunction;
static int /*long*/ ExternalClass, PostString;
- static boolean LibraryLoaded;
+ static boolean HasDOMAPI, LibraryLoaded;
+ static Hashtable WindowMappings = new Hashtable ();
static final String ABOUT_BLANK = "about:blank"; //$NON-NLS-1$
static final String CHARSET_UTF8 = "UTF-8"; //$NON-NLS-1$
@@ -51,6 +52,7 @@ class WebKit extends WebBrowser {
static final int MAX_PORT = 65535;
static final int MAX_PROGRESS = 100;
static final int[] MIN_VERSION = {1, 2, 0};
+ static final int SENTINEL_KEYPRESS = -1;
static final char SEPARATOR_FILE = System.getProperty ("file.separator").charAt (0); //$NON-NLS-1$
static final int STOP_PROPOGATE = 1;
@@ -84,9 +86,10 @@ class WebKit extends WebBrowser {
static final String KEY_CHECK_SUBWINDOW = "org.eclipse.swt.internal.control.checksubwindow"; //$NON-NLS-1$
- // the following Callbacks are never freed
+ /* the following Callbacks are never freed */
static Callback Proc2, Proc3, Proc4, Proc5, Proc6;
static Callback JSObjectHasPropertyProc, JSObjectGetPropertyProc, JSObjectCallAsFunctionProc;
+ static Callback JSDOMEventProc;
static {
try {
@@ -112,6 +115,8 @@ class WebKit extends WebBrowser {
if (JSObjectGetPropertyProc.getAddress () == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
JSObjectCallAsFunctionProc = new Callback (WebKit.class, "JSObjectCallAsFunctionProc", 6); //$NON-NLS-1$
if (JSObjectCallAsFunctionProc.getAddress () == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+ JSDOMEventProc = new Callback (WebKit.class, "JSDOMEventProc", 3); //$NON-NLS-1$
+ if (JSDOMEventProc.getAddress () == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
NativeClearSessions = new Runnable () {
public void run () {
@@ -203,14 +208,14 @@ class WebKit extends WebBrowser {
}
}
-static Browser findBrowser (int /*long*/ webView) {
+static Browser FindBrowser (int /*long*/ webView) {
if (webView == 0) return null;
int /*long*/ parent = OS.gtk_widget_get_parent (webView);
parent = OS.gtk_widget_get_parent (parent);
return (Browser)Display.getCurrent ().findWidget (parent);
}
-static boolean isInstalled () {
+static boolean IsInstalled () {
if (!LibraryLoaded) return false;
// TODO webkit_check_version() should take care of the following, but for some
// reason this symbol is missing from the latest build. If it is present in
@@ -218,6 +223,9 @@ static boolean isInstalled () {
int major = WebKitGTK.webkit_major_version ();
int minor = WebKitGTK.webkit_minor_version ();
int micro = WebKitGTK.webkit_micro_version ();
+ HasDOMAPI = major > 1 ||
+ (major == 1 && minor > 4) ||
+ (major == 1 && minor == 4 && micro >= 0);
return major > MIN_VERSION[0] ||
(major == MIN_VERSION[0] && minor > MIN_VERSION[1]) ||
(major == MIN_VERSION[0] && minor == MIN_VERSION[1] && micro >= MIN_VERSION[2]);
@@ -230,7 +238,7 @@ static int /*long*/ JSObjectCallAsFunctionProc (int /*long*/ ctx, int /*long*/ f
int /*long*/ ptr = WebKitGTK.JSObjectGetPrivate (thisObject);
int /*long*/[] handle = new int /*long*/[1];
C.memmove (handle, ptr, C.PTR_SIZEOF);
- Browser browser = findBrowser (handle[0]);
+ Browser browser = FindBrowser (handle[0]);
if (browser == null) return 0;
WebKit webkit = (WebKit)browser.webBrowser;
return webkit.callJava (ctx, function, thisObject, argumentCount, arguments, exception);
@@ -259,8 +267,17 @@ static int /*long*/ JSObjectHasPropertyProc (int /*long*/ ctx, int /*long*/ obje
return WebKitGTK.JSStringIsEqualToUTF8CString (propertyName, bytes);
}
+static int /*long*/ JSDOMEventProc (int /*long*/ window, int /*long*/ event, int /*long*/ user_data) {
+ LONG webViewHandle = (LONG)WindowMappings.get (new LONG (window));
+ if (webViewHandle == null) return 0;
+ Browser browser = FindBrowser (webViewHandle.value);
+ if (browser == null) return 0;
+ WebKit webkit = (WebKit)browser.webBrowser;
+ return webkit.handleEvent (event, (int)user_data) ? 0 : 1;
+}
+
static int /*long*/ Proc (int /*long*/ handle, int /*long*/ user_data) {
- Browser browser = findBrowser (handle);
+ Browser browser = FindBrowser (handle);
if (browser == null) return 0;
WebKit webkit = (WebKit)browser.webBrowser;
return webkit.webViewProc (handle, user_data);
@@ -281,7 +298,7 @@ static int /*long*/ Proc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ u
} else {
webView = handle;
}
- Browser browser = findBrowser (webView);
+ Browser browser = FindBrowser (webView);
if (browser == null) return 0;
WebKit webkit = (WebKit)browser.webBrowser;
if (webView == handle) {
@@ -292,7 +309,7 @@ static int /*long*/ Proc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ u
}
static int /*long*/ Proc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ user_data) {
- Browser browser = findBrowser (handle);
+ Browser browser = FindBrowser (handle);
if (browser == null) return 0;
WebKit webkit = (WebKit)browser.webBrowser;
return webkit.webViewProc (handle, arg0, arg1, user_data);
@@ -305,7 +322,7 @@ static int /*long*/ Proc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ a
} else {
webView = handle;
}
- Browser browser = findBrowser (webView);
+ Browser browser = FindBrowser (webView);
if (browser == null) return 0;
WebKit webkit = (WebKit)browser.webBrowser;
if (webView == handle) {
@@ -316,7 +333,7 @@ static int /*long*/ Proc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ a
}
static int /*long*/ Proc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ arg3, int /*long*/ user_data) {
- Browser browser = findBrowser (handle);
+ Browser browser = FindBrowser (handle);
if (browser == null) return 0;
WebKit webkit = (WebKit)browser.webBrowser;
return webkit.webViewProc (handle, arg0, arg1, arg2, arg3, user_data);
@@ -550,7 +567,7 @@ public void create (Composite parent, int style) {
eventFunction = new BrowserFunction (browser, "HandleWebKitEvent") { //$NON-NLS-1$
public Object function(Object[] arguments) {
- return handleEvent (arguments) ? Boolean.TRUE : Boolean.FALSE;
+ return handleEventFromFunction (arguments) ? Boolean.TRUE : Boolean.FALSE;
};
};
@@ -565,17 +582,44 @@ public void create (Composite parent, int style) {
browser.setData (KEY_CHECK_SUBWINDOW, Boolean.FALSE);
}
-void addEventHandlers (boolean top) {
+void addEventHandlers (int /*long*/ web_view, boolean top) {
+ if (top && HasDOMAPI) {
+ int /*long*/ domDocument = WebKitGTK.webkit_web_view_get_dom_document (web_view);
+ if (domDocument != 0) {
+ WindowMappings.put (new LONG (domDocument), new LONG (web_view));
+ WebKitGTK.webkit_dom_event_target_add_event_listener (domDocument, WebKitGTK.dragstart, JSDOMEventProc.getAddress (), 0, SWT.DragDetect);
+ WebKitGTK.webkit_dom_event_target_add_event_listener (domDocument, WebKitGTK.keydown, JSDOMEventProc.getAddress (), 0, SWT.KeyDown);
+ WebKitGTK.webkit_dom_event_target_add_event_listener (domDocument, WebKitGTK.keypress, JSDOMEventProc.getAddress (), 0, SENTINEL_KEYPRESS);
+ WebKitGTK.webkit_dom_event_target_add_event_listener (domDocument, WebKitGTK.keyup, JSDOMEventProc.getAddress (), 0, SWT.KeyUp);
+ WebKitGTK.webkit_dom_event_target_add_event_listener (domDocument, WebKitGTK.mousedown, JSDOMEventProc.getAddress (), 0, SWT.MouseDown);
+ WebKitGTK.webkit_dom_event_target_add_event_listener (domDocument, WebKitGTK.mousemove, JSDOMEventProc.getAddress (), 0, SWT.MouseMove);
+ WebKitGTK.webkit_dom_event_target_add_event_listener (domDocument, WebKitGTK.mouseup, JSDOMEventProc.getAddress (), 0, SWT.MouseUp);
+ WebKitGTK.webkit_dom_event_target_add_event_listener (domDocument, WebKitGTK.mousewheel, JSDOMEventProc.getAddress (), 0, SWT.MouseWheel);
+
+ /*
+ * The following two lines are intentionally commented because they cannot be used to
+ * consistently send MouseEnter/MouseExit events until https://bugs.webkit.org/show_bug.cgi?id=35246
+ * is fixed.
+ */
+ //WebKitGTK.webkit_dom_event_target_add_event_listener (domWindow, WebKitGTK.mouseover, JSDOMEventProc.getAddress (), 0, SWT.MouseEnter);
+ //WebKitGTK.webkit_dom_event_target_add_event_listener (domWindow, WebKitGTK.mouseout, JSDOMEventProc.getAddress (), 0, SWT.MouseExit);
+ }
+ return;
+ }
+
+ /* install the JS call-out to the registered BrowserFunction */
+ StringBuffer buffer = new StringBuffer ("window.SWTkeyhandler = function SWTkeyhandler(e) {"); //$NON-NLS-1$
+ buffer.append ("try {e.returnValue = HandleWebKitEvent(e.type, e.keyCode, e.charCode, e.altKey, e.ctrlKey, e.shiftKey, e.metaKey);} catch (e) {}};"); //$NON-NLS-1$
+ execute (buffer.toString ());
+ buffer = new StringBuffer ("window.SWTmousehandler = function SWTmousehandler(e) {"); //$NON-NLS-1$
+ buffer.append ("try {e.returnValue = HandleWebKitEvent(e.type, e.screenX, e.screenY, e.detail, e.button, e.altKey, e.ctrlKey, e.shiftKey, e.metaKey, e.relatedTarget != null);} catch (e) {}};"); //$NON-NLS-1$
+ execute (buffer.toString ());
+
if (top) {
- StringBuffer buffer = new StringBuffer ("window.SWTkeyhandler = function SWTkeyhandler(e) {"); //$NON-NLS-1$
- buffer.append ("try {e.returnValue = HandleWebKitEvent(e.type, e.keyCode, e.charCode, e.altKey, e.ctrlKey, e.shiftKey, e.metaKey);} catch (e) {}};"); //$NON-NLS-1$
- buffer.append ("document.addEventListener('keydown', SWTkeyhandler, true);"); //$NON-NLS-1$
+ /* DOM API is not available, so add listener to top-level document */
+ buffer = new StringBuffer ("document.addEventListener('keydown', SWTkeyhandler, true);"); //$NON-NLS-1$
buffer.append ("document.addEventListener('keypress', SWTkeyhandler, true);"); //$NON-NLS-1$
buffer.append ("document.addEventListener('keyup', SWTkeyhandler, true);"); //$NON-NLS-1$
- execute (buffer.toString ());
-
- buffer = new StringBuffer ("window.SWTmousehandler = function SWTmousehandler(e) {"); //$NON-NLS-1$
- buffer.append ("try {e.returnValue = HandleWebKitEvent(e.type, e.screenX, e.screenY, e.detail, e.button + 1, e.altKey, e.ctrlKey, e.shiftKey, e.metaKey, e.relatedTarget != null);} catch (e) {}};"); //$NON-NLS-1$
buffer.append ("document.addEventListener('mousedown', SWTmousehandler, true);"); //$NON-NLS-1$
buffer.append ("document.addEventListener('mouseup', SWTmousehandler, true);"); //$NON-NLS-1$
buffer.append ("document.addEventListener('mousemove', SWTmousehandler, true);"); //$NON-NLS-1$
@@ -591,21 +635,23 @@ void addEventHandlers (boolean top) {
//buffer.append ("document.addEventListener('mouseout', SWTmousehandler, true);"); //$NON-NLS-1$
execute (buffer.toString ());
- } else {
- StringBuffer buffer = new StringBuffer ("for (var i = 0; i < frames.length; i++) {"); //$NON-NLS-1$
- buffer.append ("frames[i].document.addEventListener('keydown', window.SWTkeyhandler, true);"); //$NON-NLS-1$
- buffer.append ("frames[i].document.addEventListener('keypress', window.SWTkeyhandler, true);"); //$NON-NLS-1$
- buffer.append ("frames[i].document.addEventListener('keyup', window.SWTkeyhandler, true);"); //$NON-NLS-1$
- buffer.append ("frames[i].document.addEventListener('mousedown', window.SWTmousehandler, true);"); //$NON-NLS-1$
- buffer.append ("frames[i].document.addEventListener('mouseup', window.SWTmousehandler, true);"); //$NON-NLS-1$
- buffer.append ("frames[i].document.addEventListener('mousemove', window.SWTmousehandler, true);"); //$NON-NLS-1$
- buffer.append ("frames[i].document.addEventListener('mouseover', window.SWTmousehandler, true);"); //$NON-NLS-1$
- buffer.append ("frames[i].document.addEventListener('mouseout', window.SWTmousehandler, true);"); //$NON-NLS-1$
- buffer.append ("frames[i].document.addEventListener('mousewheel', window.SWTmousehandler, true);"); //$NON-NLS-1$
- buffer.append ("frames[i].document.addEventListener('dragstart', window.SWTmousehandler, true);"); //$NON-NLS-1$
- buffer.append ('}');
- execute (buffer.toString ());
- }
+ return;
+ }
+
+ /* add JS event listener in frames */
+ buffer = new StringBuffer ("for (var i = 0; i < frames.length; i++) {"); //$NON-NLS-1$
+ buffer.append ("frames[i].document.addEventListener('keydown', window.SWTkeyhandler, true);"); //$NON-NLS-1$
+ buffer.append ("frames[i].document.addEventListener('keypress', window.SWTkeyhandler, true);"); //$NON-NLS-1$
+ buffer.append ("frames[i].document.addEventListener('keyup', window.SWTkeyhandler, true);"); //$NON-NLS-1$
+ buffer.append ("frames[i].document.addEventListener('mousedown', window.SWTmousehandler, true);"); //$NON-NLS-1$
+ buffer.append ("frames[i].document.addEventListener('mouseup', window.SWTmousehandler, true);"); //$NON-NLS-1$
+ buffer.append ("frames[i].document.addEventListener('mousemove', window.SWTmousehandler, true);"); //$NON-NLS-1$
+ buffer.append ("frames[i].document.addEventListener('mouseover', window.SWTmousehandler, true);"); //$NON-NLS-1$
+ buffer.append ("frames[i].document.addEventListener('mouseout', window.SWTmousehandler, true);"); //$NON-NLS-1$
+ buffer.append ("frames[i].document.addEventListener('mousewheel', window.SWTmousehandler, true);"); //$NON-NLS-1$
+ buffer.append ("frames[i].document.addEventListener('dragstart', window.SWTmousehandler, true);"); //$NON-NLS-1$
+ buffer.append ('}');
+ execute (buffer.toString ());
}
public boolean back () {
@@ -735,17 +781,87 @@ public String getUrl () {
return url;
}
-boolean handleEvent (Object[] arguments) {
+boolean handleEvent (int /*long*/ event, int type) {
+ /*
+ * This method handles JS events that are received through the DOM
+ * listener API that was introduced in WebKitGTK 1.4.
+ */
+ String typeString = null;
+ boolean isMouseEvent = false;
+ switch (type) {
+ case SWT.DragDetect: {
+ typeString = "dragstart"; //$NON-NLS-1$
+ isMouseEvent = true;
+ break;
+ }
+ case SWT.MouseDown: {
+ typeString = "mousedown"; //$NON-NLS-1$
+ isMouseEvent = true;
+ break;
+ }
+ case SWT.MouseMove: {
+ typeString = "mousemove"; //$NON-NLS-1$
+ isMouseEvent = true;
+ break;
+ }
+ case SWT.MouseUp: {
+ typeString = "mouseup"; //$NON-NLS-1$
+ isMouseEvent = true;
+ break;
+ }
+ case SWT.MouseWheel: {
+ typeString = "mousewheel"; //$NON-NLS-1$
+ isMouseEvent = true;
+ break;
+ }
+ case SWT.KeyDown: {
+ typeString = "keydown"; //$NON-NLS-1$
+ break;
+ }
+ case SWT.KeyUp: {
+ typeString = "keyup"; //$NON-NLS-1$
+ break;
+ }
+ case SENTINEL_KEYPRESS: {
+ typeString = "keypress"; //$NON-NLS-1$
+ break;
+ }
+ }
+ if (isMouseEvent) {
+ int screenX = (int)WebKitGTK.webkit_dom_mouse_event_get_screen_x (event);
+ int screenY = (int)WebKitGTK.webkit_dom_mouse_event_get_screen_y (event);
+ int button = (int)WebKitGTK.webkit_dom_mouse_event_get_button (event) + 1;
+ boolean altKey = WebKitGTK.webkit_dom_mouse_event_get_alt_key (event) != 0;
+ boolean ctrlKey = WebKitGTK.webkit_dom_mouse_event_get_ctrl_key (event) != 0;
+ boolean shiftKey = WebKitGTK.webkit_dom_mouse_event_get_shift_key (event) != 0;
+ boolean metaKey = WebKitGTK.webkit_dom_mouse_event_get_meta_key (event) != 0;
+ int detail = (int)WebKitGTK.webkit_dom_ui_event_get_detail (event);
+ boolean hasRelatedTarget = false; //WebKitGTK.webkit_dom_mouse_event_get_related_target (event) != 0;
+ return handleMouseEvent(typeString, screenX, screenY, detail, button, altKey, ctrlKey, shiftKey, metaKey, hasRelatedTarget);
+ }
+
+ /* key event */
+ int keyCode = (int)WebKitGTK.webkit_dom_ui_event_get_key_code (event);
+ int charCode = (int)WebKitGTK.webkit_dom_ui_event_get_char_code (event);
+ boolean altKey = WebKitGTK.webkit_dom_mouse_event_get_alt_key (event) != 0;
+ boolean ctrlKey = WebKitGTK.webkit_dom_mouse_event_get_ctrl_key (event) != 0;
+ boolean shiftKey = WebKitGTK.webkit_dom_mouse_event_get_shift_key (event) != 0;
+ boolean metaKey = WebKitGTK.webkit_dom_mouse_event_get_meta_key (event) != 0;
+ return handleKeyEvent(typeString, keyCode, charCode, altKey, ctrlKey, shiftKey, metaKey);
+}
+
+boolean handleEventFromFunction (Object[] arguments) {
/*
- * DOM events are currently received by hooking DOM listeners
- * in javascript that invoke this method via a BrowserFunction.
- * It should be possible to replace this mechanism with more
- * typical callbacks from C once WebKitGTK enhancement request
- * https://bugs.webkit.org/show_bug.cgi?id=33590 is completed.
- * In the meantime, the argument lists received here are:
- *
- * For key events:
+ * Prior to WebKitGTK 1.4 there was no API for hooking DOM listeners.
+ * As a workaround, eventFunction was introduced to capture JS events
+ * and report them back to the java side. This method handles these
+ * events by extracting their arguments and passing them to the
+ * handleKeyEvent()/handleMouseEvent() event handler methods.
+ */
+
+ /*
+ * The arguments for key events are:
* argument 0: type (String)
* argument 1: keyCode (Double)
* argument 2: charCode (Double)
@@ -755,7 +871,7 @@ boolean handleEvent (Object[] arguments) {
* argument 6: metaKey (Boolean)
* returns doit
*
- * For mouse events
+ * The arguments for mouse events are:
* argument 0: type (String)
* argument 1: screenX (Double)
* argument 2: screenY (Double)
@@ -770,8 +886,33 @@ boolean handleEvent (Object[] arguments) {
*/
String type = (String)arguments[0];
+ if (type.equals (DOMEVENT_KEYDOWN) || type.equals (DOMEVENT_KEYPRESS) || type.equals (DOMEVENT_KEYUP)) {
+ return handleKeyEvent(
+ type,
+ ((Double)arguments[1]).intValue (),
+ ((Double)arguments[2]).intValue (),
+ ((Boolean)arguments[3]).booleanValue (),
+ ((Boolean)arguments[4]).booleanValue (),
+ ((Boolean)arguments[5]).booleanValue (),
+ ((Boolean)arguments[6]).booleanValue ());
+ }
+
+ return handleMouseEvent(
+ type,
+ ((Double)arguments[1]).intValue (),
+ ((Double)arguments[2]).intValue (),
+ ((Double)arguments[3]).intValue (),
+ ((Double)arguments[4]).intValue () + 1,
+ ((Boolean)arguments[5]).booleanValue (),
+ ((Boolean)arguments[6]).booleanValue (),
+ ((Boolean)arguments[7]).booleanValue (),
+ ((Boolean)arguments[8]).booleanValue (),
+ ((Boolean)arguments[9]).booleanValue ());
+}
+
+boolean handleKeyEvent (String type, int keyCode, int charCode, boolean altKey, boolean ctrlKey, boolean shiftKey, boolean metaKey) {
if (type.equals (DOMEVENT_KEYDOWN)) {
- int keyCode = translateKey (((Double)arguments[1]).intValue ());
+ keyCode = translateKey (keyCode);
lastKeyCode = keyCode;
switch (keyCode) {
case SWT.SHIFT:
@@ -820,11 +961,7 @@ boolean handleEvent (Object[] arguments) {
case SWT.TAB: keyEvent.character = SWT.TAB; break;
}
lastCharCode = keyEvent.character;
- keyEvent.stateMask =
- (((Boolean)arguments[3]).booleanValue () ? SWT.ALT : 0) |
- (((Boolean)arguments[4]).booleanValue () ? SWT.CTRL : 0) |
- (((Boolean)arguments[5]).booleanValue () ? SWT.SHIFT : 0) |
- (((Boolean)arguments[6]).booleanValue () ? SWT.COMMAND : 0);
+ keyEvent.stateMask = (altKey ? SWT.ALT : 0) | (ctrlKey ? SWT.CTRL : 0) | (shiftKey ? SWT.SHIFT : 0) | (metaKey ? SWT.COMMAND : 0);
keyEvent.stateMask &= ~keyCode; /* remove current keydown if it's a state key */
final int stateMask = keyEvent.stateMask;
if (!sendKeyEvent (keyEvent) || browser.isDisposed ()) return false;
@@ -855,8 +992,8 @@ boolean handleEvent (Object[] arguments) {
*/
if (lastKeyCode == 0) return true;
- lastCharCode = ((Double)arguments[2]).intValue ();
- if (((Boolean)arguments[4]).booleanValue () && (0 <= lastCharCode && lastCharCode <= 0x7F)) {
+ lastCharCode = charCode;
+ if (ctrlKey && (0 <= lastCharCode && lastCharCode <= 0x7F)) {
if ('a' <= lastCharCode && lastCharCode <= 'z') lastCharCode -= 'a' - 'A';
if (64 <= lastCharCode && lastCharCode <= 95) lastCharCode -= 64;
}
@@ -866,51 +1003,43 @@ boolean handleEvent (Object[] arguments) {
keyEvent.type = SWT.KeyDown;
keyEvent.keyCode = lastKeyCode;
keyEvent.character = (char)lastCharCode;
- keyEvent.stateMask =
- (((Boolean)arguments[3]).booleanValue () ? SWT.ALT : 0) |
- (((Boolean)arguments[4]).booleanValue () ? SWT.CTRL : 0) |
- (((Boolean)arguments[5]).booleanValue () ? SWT.SHIFT : 0) |
- (((Boolean)arguments[6]).booleanValue () ? SWT.COMMAND : 0);
+ keyEvent.stateMask = (altKey ? SWT.ALT : 0) | (ctrlKey ? SWT.CTRL : 0) | (shiftKey ? SWT.SHIFT : 0) | (metaKey ? SWT.COMMAND : 0);
return sendKeyEvent (keyEvent) && !browser.isDisposed ();
}
- if (type.equals(DOMEVENT_KEYUP)) {
- int keyCode = translateKey (((Double)arguments[1]).intValue ());
- if (keyCode == 0) {
- /* indicates a key for which key events are not sent */
- return true;
- }
- if (keyCode != lastKeyCode) {
- /* keyup does not correspond to the last keydown */
- lastKeyCode = keyCode;
- lastCharCode = 0;
- }
+ /* keyup */
- Event keyEvent = new Event ();
- keyEvent.widget = browser;
- keyEvent.type = SWT.KeyUp;
- keyEvent.keyCode = lastKeyCode;
- keyEvent.character = (char)lastCharCode;
- keyEvent.stateMask =
- (((Boolean)arguments[3]).booleanValue () ? SWT.ALT : 0) |
- (((Boolean)arguments[4]).booleanValue () ? SWT.CTRL : 0) |
- (((Boolean)arguments[5]).booleanValue () ? SWT.SHIFT : 0) |
- (((Boolean)arguments[6]).booleanValue () ? SWT.COMMAND : 0);
- switch (lastKeyCode) {
- case SWT.SHIFT:
- case SWT.CONTROL:
- case SWT.ALT:
- case SWT.COMMAND: {
- keyEvent.stateMask |= lastKeyCode;
- }
+ keyCode = translateKey (keyCode);
+ if (keyCode == 0) {
+ /* indicates a key for which key events are not sent */
+ return true;
+ }
+ if (keyCode != lastKeyCode) {
+ /* keyup does not correspond to the last keydown */
+ lastKeyCode = keyCode;
+ lastCharCode = 0;
+ }
+
+ Event keyEvent = new Event ();
+ keyEvent.widget = browser;
+ keyEvent.type = SWT.KeyUp;
+ keyEvent.keyCode = lastKeyCode;
+ keyEvent.character = (char)lastCharCode;
+ keyEvent.stateMask = (altKey ? SWT.ALT : 0) | (ctrlKey ? SWT.CTRL : 0) | (shiftKey ? SWT.SHIFT : 0) | (metaKey ? SWT.COMMAND : 0);
+ switch (lastKeyCode) {
+ case SWT.SHIFT:
+ case SWT.CONTROL:
+ case SWT.ALT:
+ case SWT.COMMAND: {
+ keyEvent.stateMask |= lastKeyCode;
}
- browser.notifyListeners (keyEvent.type, keyEvent);
- lastKeyCode = lastCharCode = 0;
- return keyEvent.doit && !browser.isDisposed ();
}
+ browser.notifyListeners (keyEvent.type, keyEvent);
+ lastKeyCode = lastCharCode = 0;
+ return keyEvent.doit && !browser.isDisposed ();
+}
- /* mouse events */
-
+boolean handleMouseEvent (String type, int screenX, int screenY, int detail, int button, boolean altKey, boolean ctrlKey, boolean shiftKey, boolean metaKey, boolean hasRelatedTarget) {
/*
* MouseOver and MouseOut events are fired any time the mouse enters or exits
* any element within the Browser. To ensure that SWT events are only
@@ -932,35 +1061,31 @@ boolean handleEvent (Object[] arguments) {
* coordinates relative to themselves rather than relative to their top-
* level page. Convert screen-relative coordinates to be browser-relative.
*/
- Point position = new Point (((Double)arguments[1]).intValue (), ((Double)arguments[2]).intValue ());
+ Point position = new Point (screenX, screenY);
position = browser.getDisplay ().map (null, browser, position);
Event mouseEvent = new Event ();
mouseEvent.widget = browser;
mouseEvent.x = position.x;
mouseEvent.y = position.y;
- int mask =
- (((Boolean)arguments[5]).booleanValue () ? SWT.ALT : 0) |
- (((Boolean)arguments[6]).booleanValue () ? SWT.CTRL : 0) |
- (((Boolean)arguments[7]).booleanValue () ? SWT.SHIFT : 0) |
- (((Boolean)arguments[8]).booleanValue () ? SWT.COMMAND : 0);
+ int mask = (altKey ? SWT.ALT : 0) | (ctrlKey ? SWT.CTRL : 0) | (shiftKey ? SWT.SHIFT : 0) | (metaKey ? SWT.COMMAND : 0);
mouseEvent.stateMask = mask;
if (type.equals (DOMEVENT_MOUSEDOWN)) {
mouseEvent.type = SWT.MouseDown;
- mouseEvent.count = ((Double)arguments[3]).intValue ();
- mouseEvent.button = ((Double)arguments[4]).intValue ();
+ mouseEvent.count = detail;
+ mouseEvent.button = button;
browser.notifyListeners (mouseEvent.type, mouseEvent);
if (browser.isDisposed ()) return true;
- if (((Double)arguments[3]).intValue () == 2) {
+ if (detail == 2) {
mouseEvent = new Event ();
mouseEvent.type = SWT.MouseDoubleClick;
mouseEvent.widget = browser;
mouseEvent.x = position.x;
mouseEvent.y = position.y;
mouseEvent.stateMask = mask;
- mouseEvent.count = ((Double)arguments[3]).intValue ();
- mouseEvent.button = ((Double)arguments[4]).intValue ();
+ mouseEvent.count = detail;
+ mouseEvent.button = button;
browser.notifyListeners (mouseEvent.type, mouseEvent);
}
return true;
@@ -968,13 +1093,13 @@ boolean handleEvent (Object[] arguments) {
if (type.equals (DOMEVENT_MOUSEUP)) {
mouseEvent.type = SWT.MouseUp;
- mouseEvent.count = ((Double)arguments[3]).intValue ();
- mouseEvent.button = ((Double)arguments[4]).intValue ();
+ mouseEvent.count = detail;
+ mouseEvent.button = button;
} else if (type.equals (DOMEVENT_MOUSEMOVE)) {
mouseEvent.type = SWT.MouseMove;
} else if (type.equals (DOMEVENT_MOUSEWHEEL)) {
mouseEvent.type = SWT.MouseWheel;
- mouseEvent.count = ((Double)arguments[3]).intValue ();
+ mouseEvent.count = detail;
/*
* The following is intentionally commented because MouseOver and MouseOut events
@@ -987,7 +1112,7 @@ boolean handleEvent (Object[] arguments) {
} else if (type.equals (DOMEVENT_DRAGSTART)) {
mouseEvent.type = SWT.DragDetect;
- mouseEvent.button = ((Double)arguments[4]).intValue () + 1;
+ mouseEvent.button = button;
switch (mouseEvent.button) {
case 1: mouseEvent.stateMask |= SWT.BUTTON1; break;
case 2: mouseEvent.stateMask |= SWT.BUTTON2; break;
@@ -1149,6 +1274,11 @@ void onDispose (Event e) {
((BrowserFunction)elements.nextElement ()).dispose (false);
}
functions = null;
+
+ if (eventFunction != null) {
+ eventFunction.dispose (false);
+ eventFunction = null;
+ }
C.free (webViewData);
postData = null;
@@ -1725,7 +1855,7 @@ int /*long*/ webkit_window_object_cleared (int /*long*/ web_view, int /*long*/ f
}
int /*long*/ mainFrame = WebKitGTK.webkit_web_view_get_main_frame (webView);
boolean top = mainFrame == frame;
- addEventHandlers (top);
+ addEventHandlers (web_view, top);
return 0;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/internal/webkit/WebKitGTK.java b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/internal/webkit/WebKitGTK.java
index 0b5818d6b8..f9523d7da2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/internal/webkit/WebKitGTK.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/internal/webkit/WebKitGTK.java
@@ -67,6 +67,16 @@ public class WebKitGTK extends C {
public static final byte[] x = ascii ("x"); // $NON-NLS-1$
public static final byte[] y = ascii ("y"); // $NON-NLS-1$
+ /** DOM events */
+ public static final byte[] dragstart = ascii ("dragstart"); // $NON-NLS-1$
+ public static final byte[] keydown = ascii ("keydown"); // $NON-NLS-1$
+ public static final byte[] keypress = ascii ("keypress"); // $NON-NLS-1$
+ public static final byte[] keyup = ascii ("keyup"); // $NON-NLS-1$
+ public static final byte[] mousedown = ascii ("mousedown"); // $NON-NLS-1$
+ public static final byte[] mousemove = ascii ("mousemove"); // $NON-NLS-1$
+ public static final byte[] mouseup = ascii ("mouseup"); // $NON-NLS-1$
+ public static final byte[] mousewheel = ascii ("mousewheel"); // $NON-NLS-1$
+
protected static byte [] ascii (String name) {
int length = name.length ();
char [] chars = new char [length];
@@ -590,6 +600,127 @@ public static final int /*long*/ soup_uri_to_string (int /*long*/ uri, int just_
/* --------------------- start WebKitGTK natives --------------------- */
/** @method flags=dynamic */
+public static final native int _webkit_dom_event_target_add_event_listener (int /*long*/ target, byte[] name, int /*long*/ handler, int bubble, int /*long*/ userData);
+public static final int webkit_dom_event_target_add_event_listener (int /*long*/ target, byte[] name, int /*long*/ handler, int bubble, int /*long*/ userData) {
+ lock.lock();
+ try {
+ return _webkit_dom_event_target_add_event_listener (target, name, handler, bubble, userData);
+ } finally {
+ lock.unlock();
+ }
+}
+
+/** @method flags=dynamic */
+public static final native int _webkit_dom_mouse_event_get_alt_key (int /*long*/ self);
+public static final int webkit_dom_mouse_event_get_alt_key (int /*long*/ self) {
+ lock.lock();
+ try {
+ return _webkit_dom_mouse_event_get_alt_key (self);
+ } finally {
+ lock.unlock();
+ }
+}
+
+/** @method flags=dynamic */
+public static final native short _webkit_dom_mouse_event_get_button (int /*long*/ self);
+public static final short webkit_dom_mouse_event_get_button (int /*long*/ self) {
+ lock.lock();
+ try {
+ return _webkit_dom_mouse_event_get_button (self);
+ } finally {
+ lock.unlock();
+ }
+}
+
+/** @method flags=dynamic */
+public static final native int _webkit_dom_mouse_event_get_ctrl_key (int /*long*/ self);
+public static final int webkit_dom_mouse_event_get_ctrl_key (int /*long*/ self) {
+ lock.lock();
+ try {
+ return _webkit_dom_mouse_event_get_ctrl_key (self);
+ } finally {
+ lock.unlock();
+ }
+}
+
+/** @method flags=dynamic */
+public static final native int _webkit_dom_mouse_event_get_meta_key (int /*long*/ self);
+public static final int webkit_dom_mouse_event_get_meta_key (int /*long*/ self) {
+ lock.lock();
+ try {
+ return _webkit_dom_mouse_event_get_meta_key (self);
+ } finally {
+ lock.unlock();
+ }
+}
+
+/** @method flags=dynamic */
+public static final native long _webkit_dom_mouse_event_get_screen_x (int /*long*/ self);
+public static final long webkit_dom_mouse_event_get_screen_x (int /*long*/ self) {
+ lock.lock();
+ try {
+ return _webkit_dom_mouse_event_get_screen_x (self);
+ } finally {
+ lock.unlock();
+ }
+}
+
+/** @method flags=dynamic */
+public static final native long _webkit_dom_mouse_event_get_screen_y (int /*long*/ self);
+public static final long webkit_dom_mouse_event_get_screen_y (int /*long*/ self) {
+ lock.lock();
+ try {
+ return _webkit_dom_mouse_event_get_screen_y (self);
+ } finally {
+ lock.unlock();
+ }
+}
+
+/** @method flags=dynamic */
+public static final native int _webkit_dom_mouse_event_get_shift_key (int /*long*/ self);
+public static final int webkit_dom_mouse_event_get_shift_key (int /*long*/ self) {
+ lock.lock();
+ try {
+ return _webkit_dom_mouse_event_get_shift_key (self);
+ } finally {
+ lock.unlock();
+ }
+}
+
+/** @method flags=dynamic */
+public static final native long _webkit_dom_ui_event_get_char_code (int /*long*/ self);
+public static final long webkit_dom_ui_event_get_char_code (int /*long*/ self) {
+ lock.lock();
+ try {
+ return _webkit_dom_ui_event_get_char_code (self);
+ } finally {
+ lock.unlock();
+ }
+}
+
+/** @method flags=dynamic */
+public static final native long _webkit_dom_ui_event_get_detail (int /*long*/ self);
+public static final long webkit_dom_ui_event_get_detail (int /*long*/ self) {
+ lock.lock();
+ try {
+ return _webkit_dom_ui_event_get_detail (self);
+ } finally {
+ lock.unlock();
+ }
+}
+
+/** @method flags=dynamic */
+public static final native long _webkit_dom_ui_event_get_key_code (int /*long*/ self);
+public static final long webkit_dom_ui_event_get_key_code (int /*long*/ self) {
+ lock.lock();
+ try {
+ return _webkit_dom_ui_event_get_key_code (self);
+ } finally {
+ lock.unlock();
+ }
+}
+
+/** @method flags=dynamic */
public static final native void _webkit_download_cancel (int /*long*/ download);
public static final void webkit_download_cancel (int /*long*/ download) {
lock.lock();
@@ -931,6 +1062,17 @@ public static final void webkit_web_view_execute_script (int /*long*/ web_view,
}
/** @method flags=dynamic */
+public static final native int /*long*/ _webkit_web_view_get_dom_document (int /*long*/ web_view);
+public static final int /*long*/ webkit_web_view_get_dom_document (int /*long*/ web_view) {
+ lock.lock();
+ try {
+ return _webkit_web_view_get_dom_document (web_view);
+ } finally {
+ lock.unlock();
+ }
+}
+
+/** @method flags=dynamic */
public static final native int _webkit_web_view_get_load_status (int /*long*/ web_view);
public static final int webkit_web_view_get_load_status (int /*long*/ web_view) {
lock.lock();

Back to the top