Top Description Inners Fields Constructors Methods
org.eclipse.swt.browser

pack-priv Class WebKit

extends WebBrowser
Class Inheritance
Imports
java.io.*, java.lang.reflect.*, java.net.*, java.nio.charset.*, java.time.*, java.util.*, java.util.concurrent.atomic.*, java.util.function.*, org.eclipse.swt.*, org.eclipse.swt.graphics.*, org.eclipse.swt.internal.*, org.eclipse.swt.internal.gtk.*, org.eclipse.swt.internal.gtk3.*, org.eclipse.swt.internal.gtk4.*, org.eclipse.swt.internal.webkit.*, .GdkRectangle, org.eclipse.swt.layout.*, org.eclipse.swt.widgets.*

VERSIONS: Versioning for webkit is somewhat confusing because it's trying to incorporate webkit, gtk and (various linux distribution) versions. The way they version webkitGTK is different from webkit. WebkitGTK: 2.5 is webkit2. [2.4-..) is Gtk3. Further, linux distributions might refer to webkit2 bindings linked against gtk3 differently. E.g on Fedora: webkitgtk4 = webkit2 / Gtk3 webkit2gtk3 = WebKit2/ Gtk3 Webkit2 loading: - Dynamic bindings are auto generated and linked when the @dynamic keyword is used in WebKitGTK.java Unlike in OS.java, you don't have to add any code saying what lib the dynamic method is linked to. It's auto-linked to webkit lib by default. - At no point should you have hard-compiled code, because this will cause crashes on older machines without webkit2. (the exception is the webextension, because it runs as a separate process and is only loaded dynamically). - Try to keep all of your logic in Java and avoid writing custom C-code. (I went down this pit). Because if you use native code, then you have to write dynamic native code (get function pointers, cast types etc.. big pain in the ass). - Don't try to add webkit2 include flags to pkg-config, as this will tie the swt-glue code to specific webkit versions. Thou shall not do this. EVENT_HANDLING_DOC: - On webkit2, signals are implemented via regular gtk mechanism, hook events and pass them along as we receive them. I haven't found a need to use the dom events, because webkitgtk seems to adequately meet the requirements via regular gtk events, but maybe I missed something? Who knows. setUrl(..) with 'post data' was implemented in a very hacky way, via native Java due to missing webkit2gtk api. It's the best that could be done at the time, but it could result in strange behavior like some webpages loading in funky ways if post-data is used. Some good resources that I found are as following: - Webkit2 reference: https://webkitgtk.org/reference/webkit2gtk/stable/ - To understand GDBus, consider reading this guide: http://www.cs.grinnell.edu/~rebelsky/Courses/CSC195/2013S/Outlines/ And then see the relevant reference I made in WebkitGDBus.java. Note, DBus is not the same as GDBus. GDBus is an implementation of the DBus protocol (with it's own quirks). - This is a good starting point for webkit2 extension reading: https://blogs.igalia.com/carlosgc/2013/09/10/webkit2gtk-web-process-extensions/ [April 2018] Note on WebKitContext: We only use a single webcontext, so WebKitGTK.webkit_web_context_get_default() works well for getting this when needed. ~May the force be with you.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
WebKit.Webkit2AsyncToSync

Webkit2 introduces async api.

Field Summary

Modifier and TypeField and Description
pack-priv static final String
pack-priv static final int
ASYNC_EXEC_TIMEOUT_MS

Timeout used for javascript execution / deadlock detection.

pack-priv static final int
pack-priv static boolean
bug522733FirstInstanceCreated

Workaround for bug 522733

pack-priv static final String
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final String
pack-priv static final String
pack-priv static final String
pack-priv static final String
pack-priv static final String
pack-priv static final String
pack-priv static final String
pack-priv static final String
pack-priv static final String
pack-priv static final String
pack-priv static final int
pack-priv static final int
pack-priv int
pack-priv static final int
pack-priv static boolean
pack-priv boolean
pack-priv static final String
pack-priv static final String
pack-priv boolean
pack-priv static final boolean
ignoreTls

Flag indicating whether TLS errors (like self-signed certificates) are to be ignored.

pack-priv static Callback
pack-priv static final byte[]
pack-priv static final String
pack-priv int
pack-priv int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final String
pack-priv static final int[]
pack-priv static final int
private static int
nonBlockingEvaluate

Webkit2: In a few situations, evaluate() should not wait for it's asynchronous callback to finish.

pack-priv static final int
pack-priv static final int
pack-priv static final String
pack-priv long
private static Browser
parentBrowser

Stores the browser which is opening a new browser window, during a WebKit create signal.

pack-priv static Callback
pack-priv static Callback
pack-priv static Callback
pack-priv static Callback
pack-priv static final String
pack-priv static final String
pack-priv static final String
pack-priv static final String
pack-priv static final String
pack-priv static Callback
pack-priv static final int
pack-priv static final char
pack-priv static final int
pack-priv static final byte[]
pack-priv static final String
pack-priv boolean
pack-priv long
pack-priv String
pack-priv URI
pack-priv String
pack-priv static final String
pack-priv static final String
pack-priv static AtomicInteger
w2_bug527738LastRequestCounter

Part of workaround in Bug 527738.

pack-priv static final int
pack-priv static Map<LONG, Integer>
pack-priv long
pack-priv static final int
Inherited from org.eclipse.swt.browser.WebBrowser:
authenticationListenersbrowsercloseWindowListenersCookieNameCookieResultCookieUrlCookieValueERROR_IDevaluateResultEXECUTE_IDfunctionsjsEnabledjsEnabledOnNextPageKeyTablelocationListenersNativeClearSessionsNativeGetCookieNativePendingCookiesNativeSetCookienextFunctionIndexopenWindowListenersprogressListenersstatusTextListenerstitleListenersvisibilityWindowListeners

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private void
addRequestHeaders(long requestHeaders, String[] headers)

public boolean
public boolean
pack-priv boolean
close(boolean showPrompters)

pack-priv static Object
convertToJava(long ctx, long value)

pack-priv void
convertUri(long
a long pointing to the URI in C string form (gchar *)
webkitUri
)

Converts a WebKit URI into a Java URI object.

public void
create(Composite parent, int style)

Implements abstract org.eclipse.swt.browser.WebBrowser.create.

public void
public void
public Object
public boolean
pack-priv static Browser
FindBrowser(long webView)

private void
fireProgressCompletedEvent()

This method is reached by: Webkit2: WebKitWebView load-changed signal - void user_function (WebKitWebView *web_view, WebKitLoadEvent load_event, gpointer user_data) - https://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#WebKitWebView-load-changed - Note: As there is no return value, safe to fire asynchronously.

public boolean
public String
private static String
pack-priv String
private static String
pack-priv static String
getString(long strPtr)

public String
public String
pack-priv boolean
handleDOMEvent(long event, int type)

pack-priv boolean
pack-priv boolean
handleKeyEvent(String type, int keyCode, int charCode, boolean altKey, boolean ctrlKey, boolean shiftKey, boolean metaKey)

pack-priv long
handleLoadCommitted(long uri, boolean top)

pack-priv boolean
handleMouseEvent(String type, int screenX, int screenY, int detail, int button, boolean altKey, boolean ctrlKey, boolean shiftKey, boolean metaKey, boolean hasRelatedTarget)

private static int[]
internalGetWebkitVersion()

Gets the webkit version, within an int[3] array with {major, minor, micro} version

private static String
public boolean
public boolean
pack-priv static boolean
private boolean
pack-priv static long
JSDOMEventProc(long arg0, long event, long user_data)

pack-priv void
pack-priv void
pack-priv void
pack-priv void
openDownloadWindow(final long webkitDownload, final String suggested_filename)

pack-priv static long
Proc(long handle, long user_data)

pack-priv static long
Proc(long handle, long arg0, long user_data)

pack-priv static long
Proc(long handle, long arg0, long arg1, long user_data)

pack-priv static long
Proc(long handle, long arg0, long arg1, long arg2, long user_data)

public void
pack-priv static long
RequestProc(long request, long user_data)

public boolean
setText(String html, boolean trusted)

Implements abstract org.eclipse.swt.browser.WebBrowser.setText.

public boolean
setUrl(String url, String postData, String[] headers)

Implements abstract org.eclipse.swt.browser.WebBrowser.setUrl.

public void
pack-priv void
pack-priv long
webkit_authenticate(long web_view, long request)

gboolean user_function (WebKitWebView *web_view, WebKitAuthenticationRequest *request, gpointer user_data) - https://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#WebKitWebView-authenticate

pack-priv long
webkit_close_web_view(long web_view)

WebKitWebView 'close' signal void user_function (WebKitWebView *web_view, gpointer user_data); // observe *no* return value.

pack-priv long
webkit_context_menu(long web_view, long context_menu, long eventXXX, long hit_test_result)

pack-priv long
webkit_create_web_view(long web_view, long frame)

pack-priv long
webkit_decide_policy(long web_view, long decision, int decision_type, long user_data)

pack-priv static long
webkit_download_decide_destination(long webKitDownload, long suggested_filename)

pack-priv static long
webkit_download_failed(long download)

pack-priv static long
webkit_download_finished(long download)

pack-priv static long
webkit_download_started(long webKitDownload)

pack-priv long
webkit_load_changed(long web_view, int status, long user_data)

pack-priv long
webkit_load_failed_tls(long web_view, long failing_uri, long certificate, long error)

Called in cases where a web page failed to load due to TLS errors (self-signed certificates, as an example).

pack-priv long
webkit_mouse_target_changed(long web_view, long hit_test_result, long modifiers)

WebkitWebView mouse-target-changed - void user_function (WebKitWebView *web_view, WebKitHitTestResult *hit_test_result, guint modifiers, gpointer user_data) - https://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#WebKitWebView-mouse-target-changed

pack-priv long
webkit_notify_progress(long web_view, long pspec)

Triggered by a change in property.

pack-priv long
webkit_notify_title(long web_view, long pspec)

Triggerd by webkit's 'notify::title' signal and forwarded to this function.

private int

Returns:

An integer value for the property is returned. For boolean settings, 0 indicates false, 1 indicates true. -1= is error.
webkit_settings_get
(byte[] property)

private int

Returns:

An integer value for the property is returned. For boolean settings, 0 indicates false, 1 indicates true
webkit_settings_get
(long settings, byte[] property)

private void
webkit_settings_set(byte[] property, int value)

pack-priv long
webkit_web_view_ready(long web_view)

Emitted after "create" on the newly created WebKitWebView when it should be displayed to the user.

pack-priv long
webViewProc(long handle, long user_data)

pack-priv long
webViewProc(long handle, long arg0, long user_data)

pack-priv long
webViewProc(long handle, long arg0, long arg1, long user_data)

pack-priv long
webViewProc(long handle, long arg0, long arg1, long arg2, long user_data)

Inherited from org.eclipse.swt.browser.WebBrowser:
addAuthenticationListeneraddCloseWindowListeneraddLocationListeneraddOpenWindowListeneraddProgressListeneraddStatusTextListeneraddTitleListeneraddVisibilityWindowListenerclearSessionsCreateErrorStringderegisterFunctionevaluateExtractErrorGetCookiegetDeleteFunctionStringgetNextFunctionIndexgetWebBrowserisFocusControlregisterFunctionremoveAuthenticationListenerremoveCloseWindowListenerremoveLocationListenerremoveOpenWindowListenerremoveProgressListenerremoveStatusTextListenerremoveTitleListenerremoveVisibilityWindowListenersendKeyEventsetBrowserSetCookieSetPendingCookiestranslateKeytranslateMnemonics