[geary/wip/728002-webkit2: 75/105] Enable accessing javascriptcore objects from web extensions.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/728002-webkit2: 75/105] Enable accessing javascriptcore objects from web extensions.
- Date: Sun, 1 Jan 2017 23:56:10 +0000 (UTC)
commit 1ae3c8ee948457d68ad69f100f0dee79676fb411
Author: Michael James Gratton <mike vee net>
Date: Fri Nov 25 16:19:47 2016 +1100
Enable accessing javascriptcore objects from web extensions.
* src/CMakeLists.txt: Also generate a custom Also generate a custom
webkit2gtk-web-extension-4.0 VAPI that re-includes javascriptcore
objects, so they can be access from the web extension.
* bindings/metadata/WebKit2WebExtension-4.0-custom.vala,
bindings/metadata/WebKit2WebExtension-4.0.metadata: Include in-tree
metadata for web extension VAPI, update to all access to JS obejcts.
* bindings/vapi/javascriptcore-4.0.vapi: Add a bunch of useful additional
objects and method.
.../metadata/WebKit2WebExtension-4.0-custom.vala | 5 ++
bindings/metadata/WebKit2WebExtension-4.0.metadata | 9 +++
bindings/vapi/javascriptcore-4.0.vapi | 53 +++++++++++++++++++-
src/CMakeLists.txt | 19 +++++++-
4 files changed, 84 insertions(+), 2 deletions(-)
---
diff --git a/bindings/metadata/WebKit2WebExtension-4.0-custom.vala
b/bindings/metadata/WebKit2WebExtension-4.0-custom.vala
new file mode 100644
index 0000000..a994a77
--- /dev/null
+++ b/bindings/metadata/WebKit2WebExtension-4.0-custom.vala
@@ -0,0 +1,5 @@
+namespace WebKit {
+ namespace DOM {
+ public delegate void EventTargetFunc (WebKit.DOM.EventTarget target, WebKit.DOM.Event event);
+ }
+}
diff --git a/bindings/metadata/WebKit2WebExtension-4.0.metadata
b/bindings/metadata/WebKit2WebExtension-4.0.metadata
new file mode 100644
index 0000000..c496dba
--- /dev/null
+++ b/bindings/metadata/WebKit2WebExtension-4.0.metadata
@@ -0,0 +1,9 @@
+DOM* parent="WebKit.DOM" name="DOM(.+)"
+
+DOMEventTarget.add_event_listener skip
+_ContextMenu skip
+_ContextMenuItem skip
+
+Frame.get_javascript_* nullable=false unowned=true
+
+DOMEventTarget.add_event_listener_with_closure.handler type="owned WebKit.DOM.EventTargetFunc"
diff --git a/bindings/vapi/javascriptcore-4.0.vapi b/bindings/vapi/javascriptcore-4.0.vapi
index fd64630..027d781 100644
--- a/bindings/vapi/javascriptcore-4.0.vapi
+++ b/bindings/vapi/javascriptcore-4.0.vapi
@@ -5,18 +5,69 @@ namespace JS {
[CCode (cname = "JSGlobalContextRef")]
[SimpleType]
- public struct GlobalContext {
+ public struct GlobalContext : Context {
+
+ [CCode (cname = "JSValueIsBoolean")]
+ public bool is_boolean(JS.Value value);
[CCode (cname = "JSValueIsNumber")]
public bool is_number(JS.Value value);
+ [CCode (cname = "JSValueToBoolean")]
+ public bool to_boolean(JS.Value value);
+
[CCode (cname = "JSValueToNumber")]
public double to_number(JS.Value value, out JS.Value exception);
+ [CCode (cname = "JSGlobalContextRelease")]
+ public bool release();
+ }
+
+ [CCode (cname = "JSContextRef")]
+ [SimpleType]
+ public struct Context {
+
+ [CCode (cname = "JSEvaluateScript")]
+ public Value evaluate_script(String script,
+ Object? thisObject,
+ String? sourceURL,
+ int startingLineNumber,
+ out Value? exception);
+
+ [CCode (cname = "JSObjectMakeFunction")]
+ public Object make_function(String? name,
+ [CCode (array_length_pos=1.5)]
+ String[]? parameterNames,
+ String body,
+ String? sourceURL,
+ int startingLineNumber,
+ out Value? exception);
+
+ [CCode (cname = "JSObjectCallAsFunction")]
+ public Value call_as_function(Object object,
+ Object? thisObject,
+ [CCode (array_length_pos=2.5)]
+ Value[]? arguments,
+ out Value? exception);
+
+ }
+
+ [CCode (cname = "JSObjectRef")]
+ [SimpleType]
+ public struct Object {
}
[CCode (cname = "JSValueRef")]
[SimpleType]
public struct Value {
}
+
+ [CCode (cname = "JSStringRef", ref_function = "JSStringRetain", unref_function = "JSStringRelease")]
+ [SimpleType]
+ public struct String {
+
+ [CCode (cname = "JSStringCreateWithUTF8CString")]
+ public String.create_with_utf8_cstring(string str);
+
+ }
}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ed5a90f..df9e6fa 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -544,10 +544,13 @@ set(CLIENT_PACKAGES
${EXTRA_CLIENT_PACKAGES}
)
+# webkit2gtk-web-extension-4.0 is included as custom VAPI below
set(WEB_PROCESS_PACKAGES
geary-engine
gee-0.8
gtk+-3.0
+ javascriptcore-4.0
+ libsoup-2.4
webkit2gtk-web-extension-4.0
)
@@ -641,7 +644,9 @@ target_link_libraries(geary-engine m ${DEPS_LIBRARIES} sqlite3-unicodesn)
# WebKit2GTK VAPI generation
#################################################
add_custom_target(webkit2gtk-vapi
- DEPENDS "${CMAKE_BINARY_DIR}/src/webkit2gtk-4.0.vapi"
+ DEPENDS
+ "${CMAKE_BINARY_DIR}/src/webkit2gtk-4.0.vapi"
+ "${CMAKE_BINARY_DIR}/src/webkit2gtk-web-extension-4.0.vapi"
)
add_custom_command(
OUTPUT
@@ -654,6 +659,18 @@ add_custom_command(
COMMAND
vapigen --library=webkit2gtk-4.0 --pkg gtk+-3.0 --pkg libsoup-2.4 --pkg javascriptcore-4.0
--vapidir=${CMAKE_SOURCE_DIR}/bindings/vapi --metadatadir=${CMAKE_SOURCE_DIR}/bindings/metadata
--directory=${CMAKE_BINARY_DIR}/src `${PKG_CONFIG_EXECUTABLE} --variable=girdir
gobject-introspection-1.0`/WebKit2-4.0.gir
)
+add_custom_command(
+ OUTPUT
+ "${CMAKE_BINARY_DIR}/src/webkit2gtk-web-extension-4.0.vapi"
+ DEPENDS
+ "${CMAKE_SOURCE_DIR}/bindings/metadata/WebKit2WebExtension-4.0.metadata"
+ "${CMAKE_SOURCE_DIR}/bindings/metadata/WebKit2WebExtension-4.0-custom.vala"
+ "${CMAKE_SOURCE_DIR}/bindings/vapi/javascriptcore-4.0.vapi"
+ WORKING_DIRECTORY
+ "${CMAKE_SOURCE_DIR}/bindings/metadata"
+ COMMAND
+ vapigen --library=webkit2gtk-web-extension-4.0 --pkg gtk+-3.0 --pkg libsoup-2.4 --pkg
javascriptcore-4.0 --vapidir=${CMAKE_SOURCE_DIR}/bindings/vapi
--metadatadir=${CMAKE_SOURCE_DIR}/bindings/metadata --directory=${CMAKE_BINARY_DIR}/src
`${PKG_CONFIG_EXECUTABLE} --variable=girdir gobject-introspection-1.0`/WebKit2WebExtension-4.0.gir
WebKit2WebExtension-4.0-custom.vala
+)
# Client library (static lib used for building client and unit tests)
#################################################
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]