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.
This commit is contained in:
parent
3a3b5d0bff
commit
8d13bf1922
4 changed files with 84 additions and 2 deletions
5
bindings/metadata/WebKit2WebExtension-4.0-custom.vala
Normal file
5
bindings/metadata/WebKit2WebExtension-4.0-custom.vala
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
namespace WebKit {
|
||||||
|
namespace DOM {
|
||||||
|
public delegate void EventTargetFunc (WebKit.DOM.EventTarget target, WebKit.DOM.Event event);
|
||||||
|
}
|
||||||
|
}
|
||||||
9
bindings/metadata/WebKit2WebExtension-4.0.metadata
Normal file
9
bindings/metadata/WebKit2WebExtension-4.0.metadata
Normal file
|
|
@ -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"
|
||||||
|
|
@ -5,18 +5,69 @@ namespace JS {
|
||||||
|
|
||||||
[CCode (cname = "JSGlobalContextRef")]
|
[CCode (cname = "JSGlobalContextRef")]
|
||||||
[SimpleType]
|
[SimpleType]
|
||||||
public struct GlobalContext {
|
public struct GlobalContext : Context {
|
||||||
|
|
||||||
|
[CCode (cname = "JSValueIsBoolean")]
|
||||||
|
public bool is_boolean(JS.Value value);
|
||||||
|
|
||||||
[CCode (cname = "JSValueIsNumber")]
|
[CCode (cname = "JSValueIsNumber")]
|
||||||
public bool is_number(JS.Value value);
|
public bool is_number(JS.Value value);
|
||||||
|
|
||||||
|
[CCode (cname = "JSValueToBoolean")]
|
||||||
|
public bool to_boolean(JS.Value value);
|
||||||
|
|
||||||
[CCode (cname = "JSValueToNumber")]
|
[CCode (cname = "JSValueToNumber")]
|
||||||
public double to_number(JS.Value value, out JS.Value exception);
|
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")]
|
[CCode (cname = "JSValueRef")]
|
||||||
[SimpleType]
|
[SimpleType]
|
||||||
public struct Value {
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -544,10 +544,13 @@ set(CLIENT_PACKAGES
|
||||||
${EXTRA_CLIENT_PACKAGES}
|
${EXTRA_CLIENT_PACKAGES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# webkit2gtk-web-extension-4.0 is included as custom VAPI below
|
||||||
set(WEB_PROCESS_PACKAGES
|
set(WEB_PROCESS_PACKAGES
|
||||||
geary-engine
|
geary-engine
|
||||||
gee-0.8
|
gee-0.8
|
||||||
gtk+-3.0
|
gtk+-3.0
|
||||||
|
javascriptcore-4.0
|
||||||
|
libsoup-2.4
|
||||||
webkit2gtk-web-extension-4.0
|
webkit2gtk-web-extension-4.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -641,7 +644,9 @@ target_link_libraries(geary-engine m ${DEPS_LIBRARIES} sqlite3-unicodesn)
|
||||||
# WebKit2GTK VAPI generation
|
# WebKit2GTK VAPI generation
|
||||||
#################################################
|
#################################################
|
||||||
add_custom_target(webkit2gtk-vapi
|
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(
|
add_custom_command(
|
||||||
OUTPUT
|
OUTPUT
|
||||||
|
|
@ -654,6 +659,18 @@ add_custom_command(
|
||||||
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
|
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)
|
# Client library (static lib used for building client and unit tests)
|
||||||
#################################################
|
#################################################
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue