Commit 81b64be9 authored by Alberto Garcia's avatar Alberto Garcia
Browse files

New upstream version 2.24.1

parent 4c43c795
......@@ -106,6 +106,16 @@ else ()
set(WTF_CPU_UNKNOWN 1)
endif ()
#---------------------------
# Make sure SSE2 is present.
#---------------------------
if (WTF_CPU_X86)
include(FindSSE2)
if (NOT SSE2_SUPPORT_FOUND)
message(FATAL_ERROR "SSE2 support is required to compile WebKit")
endif ()
endif ()
# -----------------------------------------------------------------------------
# Determine the operating system
# -----------------------------------------------------------------------------
......
......@@ -552,6 +552,10 @@ parameters and <em class="parameter"><code>user_data</code></em>
as parameter.</p>
<p>This function creates the constructor, which needs to be added to an object as a property to be able to use it. Use
<a class="link" href="JSCContext.html#jsc-context-set-value" title="jsc_context_set_value ()"><code class="function">jsc_context_set_value()</code></a> to make the constructor available in the global object.</p>
<p>Note that the value returned by <em class="parameter"><code>callback</code></em>
is adopted by <em class="parameter"><code>jsc_class</code></em>
, and the <a href="../glib/glib-Datasets.html#GDestroyNotify"><span class="type">GDestroyNotify</span></a> passed to
<a class="link" href="JSCContext.html#jsc-context-register-class" title="jsc_context_register_class ()"><code class="function">jsc_context_register_class()</code></a> is responsible for disposing of it.</p>
<p><span class="annotation">[<acronym title="Exposed in C code, not necessarily available in other languages."><span class="acronym">skip</span></acronym>]</span></p>
<div class="refsect3">
<a name="jsc-class-add-constructor.parameters"></a><h4>Parameters</h4>
......@@ -638,6 +642,10 @@ parameters and <em class="parameter"><code>user_data</code></em>
as parameter.</p>
<p>This function creates the constructor, which needs to be added to an object as a property to be able to use it. Use
<a class="link" href="JSCContext.html#jsc-context-set-value" title="jsc_context_set_value ()"><code class="function">jsc_context_set_value()</code></a> to make the constructor available in the global object.</p>
<p>Note that the value returned by <em class="parameter"><code>callback</code></em>
is adopted by <em class="parameter"><code>jsc_class</code></em>
, and the <a href="../glib/glib-Datasets.html#GDestroyNotify"><span class="type">GDestroyNotify</span></a> passed to
<a class="link" href="JSCContext.html#jsc-context-register-class" title="jsc_context_register_class ()"><code class="function">jsc_context_register_class()</code></a> is responsible for disposing of it.</p>
<p><span class="annotation">[<acronym title="Rename the original symbol's name to SYMBOL."><span class="acronym">rename-to</span></acronym> jsc_class_add_constructor]</span></p>
<div class="refsect3">
<a name="jsc-class-add-constructorv.parameters"></a><h4>Parameters</h4>
......@@ -722,6 +730,10 @@ is cleared in the <a class="link" href="JSCClass.html" title="JSCClass"><span cl
as parameter.</p>
<p>This function creates the constructor, which needs to be added to an object as a property to be able to use it. Use
<a class="link" href="JSCContext.html#jsc-context-set-value" title="jsc_context_set_value ()"><code class="function">jsc_context_set_value()</code></a> to make the constructor available in the global object.</p>
<p>Note that the value returned by <em class="parameter"><code>callback</code></em>
is adopted by <em class="parameter"><code>jsc_class</code></em>
, and the <a href="../glib/glib-Datasets.html#GDestroyNotify"><span class="type">GDestroyNotify</span></a> passed to
<a class="link" href="JSCContext.html#jsc-context-register-class" title="jsc_context_register_class ()"><code class="function">jsc_context_register_class()</code></a> is responsible for disposing of it.</p>
<div class="refsect3">
<a name="jsc-class-add-constructor-variadic.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
......@@ -795,6 +807,11 @@ jsc_class_add_method (<em class="parameter"><code><a class="link" href="JSCClass
is called with
<em class="parameter"><code>user_data</code></em>
as parameter.</p>
<p>Note that the value returned by <em class="parameter"><code>callback</code></em>
must be transfer full. In case of non-refcounted boxed types, you should use
<a href="../gobject/gobject-Type-Information.html#G-TYPE-POINTER:CAPS"><code class="literal">G_TYPE_POINTER</code></a> instead of the actual boxed <a href="../gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> to ensure that the instance owned by <a class="link" href="JSCClass.html" title="JSCClass"><span class="type">JSCClass</span></a> is used.
If you really want to return a new copy of the boxed type, use <span class="type">JSC_TYPE_VALUE</span> and return a <a class="link" href="JSCValue.html" title="JSCValue"><span class="type">JSCValue</span></a> created
with <a class="link" href="JSCValue.html#jsc-value-new-object" title="jsc_value_new_object ()"><code class="function">jsc_value_new_object()</code></a> that receives the copy as the instance parameter.</p>
<p><span class="annotation">[<acronym title="Exposed in C code, not necessarily available in other languages."><span class="acronym">skip</span></acronym>]</span></p>
<div class="refsect3">
<a name="jsc-class-add-method.parameters"></a><h4>Parameters</h4>
......@@ -875,6 +892,11 @@ jsc_class_add_methodv (<em class="parameter"><code><a class="link" href="JSCClas
is called with
<em class="parameter"><code>user_data</code></em>
as parameter.</p>
<p>Note that the value returned by <em class="parameter"><code>callback</code></em>
must be transfer full. In case of non-refcounted boxed types, you should use
<a href="../gobject/gobject-Type-Information.html#G-TYPE-POINTER:CAPS"><code class="literal">G_TYPE_POINTER</code></a> instead of the actual boxed <a href="../gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> to ensure that the instance owned by <a class="link" href="JSCClass.html" title="JSCClass"><span class="type">JSCClass</span></a> is used.
If you really want to return a new copy of the boxed type, use <span class="type">JSC_TYPE_VALUE</span> and return a <a class="link" href="JSCValue.html" title="JSCValue"><span class="type">JSCValue</span></a> created
with <a class="link" href="JSCValue.html#jsc-value-new-object" title="jsc_value_new_object ()"><code class="function">jsc_value_new_object()</code></a> that receives the copy as the instance parameter.</p>
<p><span class="annotation">[<acronym title="Rename the original symbol's name to SYMBOL."><span class="acronym">rename-to</span></acronym> jsc_class_add_method]</span></p>
<div class="refsect3">
<a name="jsc-class-add-methodv.parameters"></a><h4>Parameters</h4>
......@@ -953,6 +975,11 @@ with the method arguments and then <em class="parameter"><code>user_data</code><
<em class="parameter"><code>destroy_notify</code></em>
is called with <em class="parameter"><code>user_data</code></em>
as parameter.</p>
<p>Note that the value returned by <em class="parameter"><code>callback</code></em>
must be transfer full. In case of non-refcounted boxed types, you should use
<a href="../gobject/gobject-Type-Information.html#G-TYPE-POINTER:CAPS"><code class="literal">G_TYPE_POINTER</code></a> instead of the actual boxed <a href="../gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> to ensure that the instance owned by <a class="link" href="JSCClass.html" title="JSCClass"><span class="type">JSCClass</span></a> is used.
If you really want to return a new copy of the boxed type, use <span class="type">JSC_TYPE_VALUE</span> and return a <a class="link" href="JSCValue.html" title="JSCValue"><span class="type">JSCValue</span></a> created
with <a class="link" href="JSCValue.html#jsc-value-new-object" title="jsc_value_new_object ()"><code class="function">jsc_value_new_object()</code></a> that receives the copy as the instance parameter.</p>
<div class="refsect3">
<a name="jsc-class-add-method-variadic.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
......@@ -1024,6 +1051,11 @@ by the value to be set and then <em class="parameter"><code>user_data</code></em
<a class="link" href="JSCClass.html" title="JSCClass"><span class="type">JSCClass</span></a> context, <em class="parameter"><code>destroy_notify</code></em>
is called with <em class="parameter"><code>user_data</code></em>
as parameter.</p>
<p>Note that the value returned by <em class="parameter"><code>getter</code></em>
must be transfer full. In case of non-refcounted boxed types, you should use
<a href="../gobject/gobject-Type-Information.html#G-TYPE-POINTER:CAPS"><code class="literal">G_TYPE_POINTER</code></a> instead of the actual boxed <a href="../gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> to ensure that the instance owned by <a class="link" href="JSCClass.html" title="JSCClass"><span class="type">JSCClass</span></a> is used.
If you really want to return a new copy of the boxed type, use <span class="type">JSC_TYPE_VALUE</span> and return a <a class="link" href="JSCValue.html" title="JSCValue"><span class="type">JSCValue</span></a> created
with <a class="link" href="JSCValue.html#jsc-value-new-object" title="jsc_value_new_object ()"><code class="function">jsc_value_new_object()</code></a> that receives the copy as the instance parameter.</p>
<div class="refsect3">
<a name="jsc-class-add-property.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
......
......@@ -1107,7 +1107,10 @@ jsc_value_new_object (<em class="parameter"><code><a class="link" href="JSCConte
is <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> a new empty object is created.
When <em class="parameter"><code>instance</code></em>
is provided, <em class="parameter"><code>jsc_class</code></em>
must be provided too.</p>
must be provided too. <em class="parameter"><code>jsc_class</code></em>
takes ownership of
<em class="parameter"><code>instance</code></em>
that will be freed by the <a href="../glib/glib-Datasets.html#GDestroyNotify"><span class="type">GDestroyNotify</span></a> passed to <a class="link" href="JSCContext.html#jsc-context-register-class" title="jsc_context_register_class ()"><code class="function">jsc_context_register_class()</code></a>.</p>
<div class="refsect3">
<a name="jsc-value-new-object.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
......@@ -1125,7 +1128,7 @@ When <em class="parameter"><code>instance</code></em>
<tr>
<td class="parameter_name"><p>instance</p></td>
<td class="parameter_description"><p>an object instance or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL may be passed as the value in, out, in-out; or as a return value."><span class="acronym">nullable</span></acronym>]</span></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL may be passed as the value in, out, in-out; or as a return value."><span class="acronym">nullable</span></acronym>][<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>jsc_class</p></td>
......@@ -1650,6 +1653,11 @@ When the property is cleared in the <a class="link" href="JSCClass.html" title="
<em class="parameter"><code>user_data</code></em>
as parameter. This is equivalent to JavaScript <code class="function">Object.defineProperty()</code>
when used with an accessor descriptor.</p>
<p>Note that the value returned by <em class="parameter"><code>getter</code></em>
must be fully transferred. In case of boxed types, you could use
<a href="../gobject/gobject-Type-Information.html#G-TYPE-POINTER:CAPS"><code class="literal">G_TYPE_POINTER</code></a> instead of the actual boxed <a href="../gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> to ensure that the instance owned by <a class="link" href="JSCClass.html" title="JSCClass"><span class="type">JSCClass</span></a> is used.
If you really want to return a new copy of the boxed type, use <span class="type">JSC_TYPE_VALUE</span> and return a <a class="link" href="JSCValue.html" title="JSCValue"><span class="type">JSCValue</span></a> created
with <a class="link" href="JSCValue.html#jsc-value-new-object" title="jsc_value_new_object ()"><code class="function">jsc_value_new_object()</code></a> that receives the copy as instance parameter.</p>
<div class="refsect3">
<a name="jsc-value-object-define-property-accessor.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
......@@ -1729,6 +1737,11 @@ cleared in <em class="parameter"><code>context</code></em>
, <em class="parameter"><code>destroy_notify</code></em>
is called with <em class="parameter"><code>user_data</code></em>
as parameter.</p>
<p>Note that the value returned by <em class="parameter"><code>callback</code></em>
must be fully transferred. In case of boxed types, you could use
<a href="../gobject/gobject-Type-Information.html#G-TYPE-POINTER:CAPS"><code class="literal">G_TYPE_POINTER</code></a> instead of the actual boxed <a href="../gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> to ensure that the instance owned by <a class="link" href="JSCClass.html" title="JSCClass"><span class="type">JSCClass</span></a> is used.
If you really want to return a new copy of the boxed type, use <span class="type">JSC_TYPE_VALUE</span> and return a <a class="link" href="JSCValue.html" title="JSCValue"><span class="type">JSCValue</span></a> created
with <a class="link" href="JSCValue.html#jsc-value-new-object" title="jsc_value_new_object ()"><code class="function">jsc_value_new_object()</code></a> that receives the copy as instance parameter.</p>
<p><span class="annotation">[<acronym title="Exposed in C code, not necessarily available in other languages."><span class="acronym">skip</span></acronym>]</span></p>
<div class="refsect3">
<a name="jsc-value-new-function.parameters"></a><h4>Parameters</h4>
......@@ -1813,6 +1826,11 @@ cleared in <em class="parameter"><code>context</code></em>
, <em class="parameter"><code>destroy_notify</code></em>
is called with <em class="parameter"><code>user_data</code></em>
as parameter.</p>
<p>Note that the value returned by <em class="parameter"><code>callback</code></em>
must be fully transferred. In case of boxed types, you could use
<a href="../gobject/gobject-Type-Information.html#G-TYPE-POINTER:CAPS"><code class="literal">G_TYPE_POINTER</code></a> instead of the actual boxed <a href="../gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> to ensure that the instance owned by <a class="link" href="JSCClass.html" title="JSCClass"><span class="type">JSCClass</span></a> is used.
If you really want to return a new copy of the boxed type, use <span class="type">JSC_TYPE_VALUE</span> and return a <a class="link" href="JSCValue.html" title="JSCValue"><span class="type">JSCValue</span></a> created
with <a class="link" href="JSCValue.html#jsc-value-new-object" title="jsc_value_new_object ()"><code class="function">jsc_value_new_object()</code></a> that receives the copy as instance parameter.</p>
<p><span class="annotation">[<acronym title="Rename the original symbol's name to SYMBOL."><span class="acronym">rename-to</span></acronym> jsc_value_new_function]</span></p>
<div class="refsect3">
<a name="jsc-value-new-functionv.parameters"></a><h4>Parameters</h4>
......@@ -1895,6 +1913,11 @@ When the function is cleared in <em class="parameter"><code>context</code></em>
, <em class="parameter"><code>destroy_notify</code></em>
is called with <em class="parameter"><code>user_data</code></em>
as parameter.</p>
<p>Note that the value returned by <em class="parameter"><code>callback</code></em>
must be fully transferred. In case of boxed types, you could use
<a href="../gobject/gobject-Type-Information.html#G-TYPE-POINTER:CAPS"><code class="literal">G_TYPE_POINTER</code></a> instead of the actual boxed <a href="../gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> to ensure that the instance owned by <a class="link" href="JSCClass.html" title="JSCClass"><span class="type">JSCClass</span></a> is used.
If you really want to return a new copy of the boxed type, use <span class="type">JSC_TYPE_VALUE</span> and return a <a class="link" href="JSCValue.html" title="JSCValue"><span class="type">JSCValue</span></a> created
with <a class="link" href="JSCValue.html#jsc-value-new-object" title="jsc_value_new_object ()"><code class="function">jsc_value_new_object()</code></a> that receives the copy as instance parameter.</p>
<div class="refsect3">
<a name="jsc-value-new-function-variadic.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
......
......@@ -14,7 +14,7 @@
<div class="titlepage">
<div>
<div><table class="navigation" id="top" width="100%" cellpadding="2" cellspacing="0"><tr><th valign="middle"><p class="title">JavaScriptCore GLib Reference Manual</p></th></tr></table></div>
<div><p class="releaseinfo">for JavaScriptCore 2.24.0</p></div>
<div><p class="releaseinfo">for JavaScriptCore 2.24.1</p></div>
</div>
<hr>
</div>
......
......@@ -175,7 +175,7 @@ have included when compiling your code.</p>
<hr>
<div class="refsect2">
<a name="JSC-MICRO-VERSION:CAPS"></a><h3>JSC_MICRO_VERSION</h3>
<pre class="programlisting">#define JSC_MICRO_VERSION (0)
<pre class="programlisting">#define JSC_MICRO_VERSION (1)
</pre>
</div>
</div>
......
......@@ -14,7 +14,7 @@
<div class="titlepage">
<div>
<div><table class="navigation" id="top" width="100%" cellpadding="2" cellspacing="0"><tr><th valign="middle"><p class="title">WebKitGTK Reference Manual</p></th></tr></table></div>
<div><p class="releaseinfo">for WebKitGTK 2.24.0</p></div>
<div><p class="releaseinfo">for WebKitGTK 2.24.1</p></div>
</div>
<hr>
</div>
......
......@@ -213,7 +213,7 @@ against at application run time.</p>
<hr>
<div class="refsect2">
<a name="WEBKIT-MICRO-VERSION:CAPS"></a><h3>WEBKIT_MICRO_VERSION</h3>
<pre class="programlisting">#define WEBKIT_MICRO_VERSION (0)
<pre class="programlisting">#define WEBKIT_MICRO_VERSION (1)
</pre>
<p>Like <a class="link" href="webkit2gtk-4.0-WebKitVersion.html#webkit-get-micro-version" title="webkit_get_micro_version ()"><code class="function">webkit_get_micro_version()</code></a>, but from the headers used at
application compile time, rather than from the library linked
......
......@@ -986,8 +986,10 @@ If <em class="parameter"><code>element</code></em>
webkit_dom_element_html_input_element_set_editing_value
(<em class="parameter"><code><a class="link" href="WebKitDOMElement.html" title="WebKitDOMElement"><span class="type">WebKitDOMElement</span></a> *element</code></em>,
<em class="parameter"><code>const <span class="type">char</span> *value</code></em>);</pre>
<p>Set editing value of an HTML input element. If <em class="parameter"><code>element</code></em>
is not an HTML input element this function does nothing.</p>
<p>Set the value of an HTML input element as if it had been edited by
the user, triggering a change event. If <em class="parameter"><code>element</code></em>
is not an HTML input
element this function does nothing.</p>
<div class="refsect3">
<a name="webkit-dom-element-html-input-element-set-editing-value.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
......
......@@ -14,7 +14,7 @@
<div class="titlepage">
<div>
<div><table class="navigation" id="top" width="100%" cellpadding="2" cellspacing="0"><tr><th valign="middle"><p class="title">WebKitDOMGTK+ Reference Manual</p></th></tr></table></div>
<div><p class="releaseinfo">for WebKitDOMGTK+ 2.24.0</p></div>
<div><p class="releaseinfo">for WebKitDOMGTK+ 2.24.1</p></div>
</div>
<hr>
</div>
......
=================
WebKitGTK 2.24.1
=================
What's new in WebKitGTK 2.24.1?
- Do not allow changes in active URI before provisional load starts for non-API requests.
- Stop the threaded compositor when the page is not visible or layer tree state is frozen.
- Use WebKit HTTP source element again for adaptive streaming fragments downloading.
- Properly handle empty resources in webkit_web_resource_get_data().
- Add quirk to ensure outlook.live.com uses the modern UI.
- Fix methods returing GObject or boxed types in JavaScriptCore GLib API.
- Ensure callback data is passed to functions and constructors with no parameters in JavaScriptCore GLib API.
- Fix rendering of complex text when the font uses x,y origins.
- Fix sound loop with Google Hangouts and WhatsApp notifications.
- Fix the build with GStreamer 1.12.5 and GST GL enabled.
- Detect SSE2 at compile time.
- Fix several crashes and rendering issues.
- Security fixes: CVE-2019-6251.
=================
WebKitGTK 2.24.0
=================
......
......@@ -57,7 +57,7 @@ inline void setException(JSC::ExecState* exec, JSValueRef* returnedExceptionRef,
if (returnedExceptionRef)
*returnedExceptionRef = toRef(exec, exception);
#if ENABLE(REMOTE_INSPECTOR)
VM& vm = exec->vm();
JSC::VM& vm = exec->vm();
vm.vmEntryGlobalObject(exec)->inspectorController().reportAPIException(exec, JSC::Exception::create(vm, exception));
#endif
}
......
......@@ -204,6 +204,7 @@ JSObjectRef JSCCallbackFunction::construct(JSContextRef callerContext, size_t ar
switch (g_type_fundamental(G_VALUE_TYPE(&returnValue))) {
case G_TYPE_POINTER:
case G_TYPE_BOXED:
case G_TYPE_OBJECT:
if (auto* ptr = returnValue.data[0].v_pointer)
return toRef(jscClassGetOrCreateJSWrapper(m_class.get(), ptr));
......
......@@ -554,8 +554,14 @@ JSCClass* jsc_class_get_parent(JSCClass* jscClass)
static GRefPtr<JSCValue> jscClassCreateConstructor(JSCClass* jscClass, const char* name, GCallback callback, gpointer userData, GDestroyNotify destroyNotify, GType returnType, Optional<Vector<GType>>&& parameters)
{
// If the constructor doesn't have arguments, we need to swap the fake instance and user data to ensure
// user data is the first parameter and fake instance ignored.
GRefPtr<GClosure> closure;
if (parameters && parameters->isEmpty() && userData)
closure = adoptGRef(g_cclosure_new_swap(callback, userData, reinterpret_cast<GClosureNotify>(reinterpret_cast<GCallback>(destroyNotify))));
else
closure = adoptGRef(g_cclosure_new(callback, userData, reinterpret_cast<GClosureNotify>(reinterpret_cast<GCallback>(destroyNotify))));
JSCClassPrivate* priv = jscClass->priv;
GRefPtr<GClosure> closure = adoptGRef(g_cclosure_new(callback, userData, reinterpret_cast<GClosureNotify>(reinterpret_cast<GCallback>(destroyNotify))));
JSC::ExecState* exec = toJS(jscContextGetJSContext(priv->context));
JSC::VM& vm = exec->vm();
JSC::JSLockHolder locker(vm);
......@@ -589,6 +595,9 @@ static GRefPtr<JSCValue> jscClassCreateConstructor(JSCClass* jscClass, const cha
* This function creates the constructor, which needs to be added to an object as a property to be able to use it. Use
* jsc_context_set_value() to make the constructor available in the global object.
*
* Note that the value returned by @callback is adopted by @jsc_class, and the #GDestroyNotify passed to
* jsc_context_register_class() is responsible for disposing of it.
*
* Returns: (transfer full): a #JSCValue representing the class constructor.
*/
JSCValue* jsc_class_add_constructor(JSCClass* jscClass, const char* name, GCallback callback, gpointer userData, GDestroyNotify destroyNotify, GType returnType, unsigned paramCount, ...)
......@@ -635,6 +644,9 @@ JSCValue* jsc_class_add_constructor(JSCClass* jscClass, const char* name, GCallb
* This function creates the constructor, which needs to be added to an object as a property to be able to use it. Use
* jsc_context_set_value() to make the constructor available in the global object.
*
* Note that the value returned by @callback is adopted by @jsc_class, and the #GDestroyNotify passed to
* jsc_context_register_class() is responsible for disposing of it.
*
* Returns: (transfer full): a #JSCValue representing the class constructor.
*/
JSCValue* jsc_class_add_constructorv(JSCClass* jscClass, const char* name, GCallback callback, gpointer userData, GDestroyNotify destroyNotify, GType returnType, unsigned parametersCount, GType* parameterTypes)
......@@ -676,6 +688,9 @@ JSCValue* jsc_class_add_constructorv(JSCClass* jscClass, const char* name, GCall
* This function creates the constructor, which needs to be added to an object as a property to be able to use it. Use
* jsc_context_set_value() to make the constructor available in the global object.
*
* Note that the value returned by @callback is adopted by @jsc_class, and the #GDestroyNotify passed to
* jsc_context_register_class() is responsible for disposing of it.
*
* Returns: (transfer full): a #JSCValue representing the class constructor.
*/
JSCValue* jsc_class_add_constructor_variadic(JSCClass* jscClass, const char* name, GCallback callback, gpointer userData, GDestroyNotify destroyNotify, GType returnType)
......@@ -722,6 +737,11 @@ static void jscClassAddMethod(JSCClass* jscClass, const char* name, GCallback ca
* @callback is called receiving the class instance as first parameter, followed by the method parameters and then
* @user_data as last parameter. When the method is cleared in the #JSCClass context, @destroy_notify is called with
* @user_data as parameter.
*
* Note that the value returned by @callback must be transfer full. In case of non-refcounted boxed types, you should use
* %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used.
* If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created
* with jsc_value_new_object() that receives the copy as the instance parameter.
*/
void jsc_class_add_method(JSCClass* jscClass, const char* name, GCallback callback, gpointer userData, GDestroyNotify destroyNotify, GType returnType, unsigned paramCount, ...)
{
......@@ -758,6 +778,11 @@ void jsc_class_add_method(JSCClass* jscClass, const char* name, GCallback callba
* @callback is called receiving the class instance as first parameter, followed by the method parameters and then
* @user_data as last parameter. When the method is cleared in the #JSCClass context, @destroy_notify is called with
* @user_data as parameter.
*
* Note that the value returned by @callback must be transfer full. In case of non-refcounted boxed types, you should use
* %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used.
* If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created
* with jsc_value_new_object() that receives the copy as the instance parameter.
*/
void jsc_class_add_methodv(JSCClass* jscClass, const char* name, GCallback callback, gpointer userData, GDestroyNotify destroyNotify, GType returnType, unsigned parametersCount, GType *parameterTypes)
{
......@@ -790,6 +815,11 @@ void jsc_class_add_methodv(JSCClass* jscClass, const char* name, GCallback callb
* @callback is called receiving the class instance as first parameter, followed by a #GPtrArray of #JSCValue<!-- -->s
* with the method arguments and then @user_data as last parameter. When the method is cleared in the #JSCClass context,
* @destroy_notify is called with @user_data as parameter.
*
* Note that the value returned by @callback must be transfer full. In case of non-refcounted boxed types, you should use
* %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used.
* If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created
* with jsc_value_new_object() that receives the copy as the instance parameter.
*/
void jsc_class_add_method_variadic(JSCClass* jscClass, const char* name, GCallback callback, gpointer userData, GDestroyNotify destroyNotify, GType returnType)
{
......@@ -816,6 +846,11 @@ void jsc_class_add_method_variadic(JSCClass* jscClass, const char* name, GCallba
* value needs to be set, @setter is called receiving the the class instance as first parameter, followed
* by the value to be set and then @user_data as the last parameter. When the property is cleared in the
* #JSCClass context, @destroy_notify is called with @user_data as parameter.
*
* Note that the value returned by @getter must be transfer full. In case of non-refcounted boxed types, you should use
* %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used.
* If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created
* with jsc_value_new_object() that receives the copy as the instance parameter.
*/
void jsc_class_add_property(JSCClass* jscClass, const char* name, GType propertyType, GCallback getter, GCallback setter, gpointer userData, GDestroyNotify destroyNotify)
{
......
......@@ -21,6 +21,7 @@
#include "JSCValue.h"
#include "APICast.h"
#include "APIUtils.h"
#include "JSCCallbackFunction.h"
#include "JSCClassPrivate.h"
#include "JSCContextPrivate.h"
......@@ -587,11 +588,12 @@ gboolean jsc_value_is_array(JSCValue* value)
/**
* jsc_value_new_object:
* @context: a #JSCContext
* @instance: (nullable): an object instance or %NULL
* @instance: (nullable) (transfer full): an object instance or %NULL
* @jsc_class: (nullable): the #JSCClass of @instance
*
* Create a new #JSCValue from @instance. If @instance is %NULL a new empty object is created.
* When @instance is provided, @jsc_class must be provided too.
* When @instance is provided, @jsc_class must be provided too. @jsc_class takes ownership of
* @instance that will be freed by the #GDestroyNotify passed to jsc_context_register_class().
*
* Returns: (transfer full): a #JSCValue.
*/
......@@ -1036,19 +1038,34 @@ void jsc_value_object_define_property_data(JSCValue* value, const char* property
g_return_if_fail(propertyName);
JSCValuePrivate* priv = value->priv;
GRefPtr<JSCValue> descriptor = adoptGRef(jsc_value_new_object(priv->context.get(), nullptr, nullptr));
GRefPtr<JSCValue> trueValue = adoptGRef(jsc_value_new_boolean(priv->context.get(), TRUE));
if (flags & JSC_VALUE_PROPERTY_CONFIGURABLE)
jsc_value_object_set_property(descriptor.get(), "configurable", trueValue.get());
if (flags & JSC_VALUE_PROPERTY_ENUMERABLE)
jsc_value_object_set_property(descriptor.get(), "enumerable", trueValue.get());
if (propertyValue)
jsc_value_object_set_property(descriptor.get(), "value", propertyValue);
if (flags & JSC_VALUE_PROPERTY_WRITABLE)
jsc_value_object_set_property(descriptor.get(), "writable", trueValue.get());
GRefPtr<JSCValue> object = adoptGRef(jsc_context_get_value(priv->context.get(), "Object"));
GRefPtr<JSCValue> result = adoptGRef(jsc_value_object_invoke_method(object.get(), "defineProperty",
JSC_TYPE_VALUE, value, G_TYPE_STRING, propertyName, JSC_TYPE_VALUE, descriptor.get(), G_TYPE_NONE));
auto* jsContext = jscContextGetJSContext(priv->context.get());
JSC::ExecState* exec = toJS(jsContext);
JSC::VM& vm = exec->vm();
JSC::JSLockHolder locker(vm);
auto scope = DECLARE_CATCH_SCOPE(vm);
JSC::JSValue jsValue = toJS(exec, priv->jsValue);
JSC::JSObject* object = jsValue.toObject(exec);
JSValueRef exception = nullptr;
if (handleExceptionIfNeeded(scope, exec, &exception) == ExceptionStatus::DidThrow) {
jscContextHandleExceptionIfNeeded(priv->context.get(), exception);
return;
}
auto name = OpaqueJSString::tryCreate(String::fromUTF8(propertyName));
if (!name)
return;
JSC::PropertyDescriptor descriptor;
descriptor.setValue(toJS(exec, propertyValue->priv->jsValue));
descriptor.setEnumerable(flags & JSC_VALUE_PROPERTY_ENUMERABLE);
descriptor.setConfigurable(flags & JSC_VALUE_PROPERTY_CONFIGURABLE);
descriptor.setWritable(flags & JSC_VALUE_PROPERTY_WRITABLE);
object->methodTable(vm)->defineOwnProperty(object, exec, name->identifier(&vm), descriptor, true);
if (handleExceptionIfNeeded(scope, exec, &exception) == ExceptionStatus::DidThrow) {
jscContextHandleExceptionIfNeeded(priv->context.get(), exception);
return;
}
}
/**
......@@ -1067,6 +1084,11 @@ void jsc_value_object_define_property_data(JSCValue* value, const char* property
* When the property is cleared in the #JSCClass context, @destroy_notify is called with
* @user_data as parameter. This is equivalent to JavaScript <function>Object.defineProperty()</function>
* when used with an accessor descriptor.
*
* Note that the value returned by @getter must be fully transferred. In case of boxed types, you could use
* %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used.
* If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created
* with jsc_value_new_object() that receives the copy as instance parameter.
*/
void jsc_value_object_define_property_accessor(JSCValue* value, const char* propertyName, JSCValuePropertyFlags flags, GType propertyType, GCallback getter, GCallback setter, gpointer userData, GDestroyNotify destroyNotify)
{
......@@ -1076,38 +1098,55 @@ void jsc_value_object_define_property_accessor(JSCValue* value, const char* prop
g_return_if_fail(getter || setter);
JSCValuePrivate* priv = value->priv;
GRefPtr<JSCValue> descriptor = adoptGRef(jsc_value_new_object(priv->context.get(), nullptr, nullptr));
GRefPtr<JSCValue> trueValue = adoptGRef(jsc_value_new_boolean(priv->context.get(), TRUE));
if (flags & JSC_VALUE_PROPERTY_CONFIGURABLE)
jsc_value_object_set_property(descriptor.get(), "configurable", trueValue.get());
if (flags & JSC_VALUE_PROPERTY_ENUMERABLE)
jsc_value_object_set_property(descriptor.get(), "enumerable", trueValue.get());
JSC::ExecState* exec = toJS(jscContextGetJSContext(priv->context.get()));
auto* jsContext = jscContextGetJSContext(priv->context.get());
JSC::ExecState* exec = toJS(jsContext);
JSC::VM& vm = exec->vm();
JSC::JSLockHolder locker(vm);
auto scope = DECLARE_CATCH_SCOPE(vm);
JSC::JSValue jsValue = toJS(exec, priv->jsValue);
JSC::JSObject* object = jsValue.toObject(exec);
JSValueRef exception = nullptr;
if (handleExceptionIfNeeded(scope, exec, &exception) == ExceptionStatus::DidThrow) {
jscContextHandleExceptionIfNeeded(priv->context.get(), exception);
return;
}
auto name = OpaqueJSString::tryCreate(String::fromUTF8(propertyName));
if (!name)
return;
JSC::PropertyDescriptor descriptor;
descriptor.setEnumerable(flags & JSC_VALUE_PROPERTY_ENUMERABLE);
descriptor.setConfigurable(flags & JSC_VALUE_PROPERTY_CONFIGURABLE);
if (getter) {
GRefPtr<GClosure> closure = adoptGRef(g_cclosure_new(getter, userData, reinterpret_cast<GClosureNotify>(reinterpret_cast<GCallback>(destroyNotify))));
auto* functionObject = toRef(JSC::JSCCallbackFunction::create(vm, exec->lexicalGlobalObject(), "get"_s,
JSC::JSCCallbackFunction::Type::Method, nullptr, WTFMove(closure), propertyType, Vector<GType> { }));
GRefPtr<JSCValue> function = jscContextGetOrCreateValue(priv->context.get(), functionObject);
jsc_value_object_set_property(descriptor.get(), "get", function.get());
auto function = JSC::JSCCallbackFunction::create(vm, exec->lexicalGlobalObject(), "get"_s,
JSC::JSCCallbackFunction::Type::Method, nullptr, WTFMove(closure), propertyType, Vector<GType> { });
descriptor.setGetter(function);
}
if (setter) {
GRefPtr<GClosure> closure = adoptGRef(g_cclosure_new(setter, userData, getter ? nullptr : reinterpret_cast<GClosureNotify>(reinterpret_cast<GCallback>(destroyNotify))));
auto* functionObject = toRef(JSC::JSCCallbackFunction::create(vm, exec->lexicalGlobalObject(), "set"_s,
JSC::JSCCallbackFunction::Type::Method, nullptr, WTFMove(closure), G_TYPE_NONE, Vector<GType> { propertyType }));
GRefPtr<JSCValue> function = jscContextGetOrCreateValue(priv->context.get(), functionObject);
jsc_value_object_set_property(descriptor.get(), "set", function.get());
auto function = JSC::JSCCallbackFunction::create(vm, exec->lexicalGlobalObject(), "set"_s,
JSC::JSCCallbackFunction::Type::Method, nullptr, WTFMove(closure), G_TYPE_NONE, Vector<GType> { propertyType });
descriptor.setSetter(function);
}
object->methodTable(vm)->defineOwnProperty(object, exec, name->identifier(&vm), descriptor, true);
if (handleExceptionIfNeeded(scope, exec, &exception) == ExceptionStatus::DidThrow) {
jscContextHandleExceptionIfNeeded(priv->context.get(), exception);
return;
}
GRefPtr<JSCValue> object = adoptGRef(jsc_context_get_value(priv->context.get(), "Object"));
GRefPtr<JSCValue> result = adoptGRef(jsc_value_object_invoke_method(object.get(), "defineProperty",
JSC_TYPE_VALUE, value, G_TYPE_STRING, propertyName, JSC_TYPE_VALUE, descriptor.get(), G_TYPE_NONE));
}
static GRefPtr<JSCValue> jscValueFunctionCreate(JSCContext* context, const char* name, GCallback callback, gpointer userData, GDestroyNotify destroyNotify, GType returnType, Optional<Vector<GType>>&& parameters)
{
GRefPtr<GClosure> closure = adoptGRef(g_cclosure_new(callback, userData, reinterpret_cast<GClosureNotify>(reinterpret_cast<GCallback>(destroyNotify))));
GRefPtr<GClosure> closure;
// If the function doesn't have arguments, we need to swap the fake instance and user data to ensure
// user data is the first parameter and fake instance ignored.
if (parameters && parameters->isEmpty() && userData)
closure = adoptGRef(g_cclosure_new_swap(callback, userData, reinterpret_cast<GClosureNotify>(reinterpret_cast<GCallback>(destroyNotify))));
else
closure = adoptGRef(g_cclosure_new(callback, userData, reinterpret_cast<GClosureNotify>(reinterpret_cast<GCallback>(destroyNotify))));
JSC::ExecState* exec = toJS(jscContextGetJSContext(context));
JSC::VM& vm = exec->vm();
JSC::JSLockHolder locker(vm);
......@@ -1132,6 +1171,11 @@ static GRefPtr<JSCValue> jscValueFunctionCreate(JSCContext* context, const char*
* receiving the function parameters and then @user_data as last parameter. When the function is
* cleared in @context, @destroy_notify is called with @user_data as parameter.
*
* Note that the value returned by @callback must be fully transferred. In case of boxed types, you could use
* %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used.
* If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created
* with jsc_value_new_object() that receives the copy as instance parameter.
*
* Returns: (transfer full): a #JSCValue.
*/
JSCValue* jsc_value_new_function(JSCContext* context, const char* name, GCallback callback, gpointer userData, GDestroyNotify destroyNotify, GType returnType, unsigned paramCount, ...)
......@@ -1168,6 +1212,11 @@ JSCValue* jsc_value_new_function(JSCContext* context, const char* name, GCallbac
* receiving the function parameters and then @user_data as last parameter. When the function is
* cleared in @context, @destroy_notify is called with @user_data as parameter.
*
* Note that the value returned by @callback must be fully transferred. In case of boxed types, you could use
* %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used.
* If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created
* with jsc_value_new_object() that receives the copy as instance parameter.
*
* Returns: (transfer full): a #JSCValue.
*/
JSCValue* jsc_value_new_functionv(JSCContext* context, const char* name, GCallback callback, gpointer userData, GDestroyNotify destroyNotify, GType returnType, unsigned parametersCount, GType *parameterTypes)
......@@ -1200,6 +1249,11 @@ JSCValue* jsc_value_new_functionv(JSCContext* context, const char* name, GCallba