Skip to content

Commit 7f9de24

Browse files
committed
Update headers for 1.2.0-stable
1 parent c0a444b commit 7f9de24

File tree

5 files changed

+145
-26
lines changed

5 files changed

+145
-26
lines changed

JavaScriptCore/JSObjectRef.h

Lines changed: 119 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ derived class (the parent class) first, and the most derived class last.
9191
typedef void
9292
(*JSObjectInitializeCallback) (JSContextRef ctx, JSObjectRef object);
9393

94+
/* Extension of the above callback with the class that the method is being invoked for. */
95+
typedef void
96+
(*JSObjectInitializeCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object);
97+
9498
/*!
9599
@typedef JSObjectFinalizeCallback
96100
@abstract The callback invoked when an object is finalized (prepared for garbage collection). An object may be finalized on any thread.
@@ -109,6 +113,10 @@ all functions that have a JSContextRef parameter.
109113
typedef void
110114
(*JSObjectFinalizeCallback) (JSObjectRef object);
111115

116+
/* Extension of the above callback with the class that the method is being invoked for. */
117+
typedef void
118+
(*JSObjectFinalizeCallbackEx) (JSClassRef jsClass, JSObjectRef object);
119+
112120
/*!
113121
@typedef JSObjectHasPropertyCallback
114122
@abstract The callback invoked when determining whether an object has a property.
@@ -129,6 +137,10 @@ If this callback is NULL, the getProperty callback will be used to service hasPr
129137
typedef bool
130138
(*JSObjectHasPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);
131139

140+
/* Extension of the above callback with the class that the method is being invoked for. */
141+
typedef bool
142+
(*JSObjectHasPropertyCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName);
143+
132144
/*!
133145
@typedef JSObjectGetPropertyCallback
134146
@abstract The callback invoked when getting a property's value.
@@ -146,6 +158,10 @@ If this function returns NULL, the get request forwards to object's statically d
146158
typedef JSValueRef
147159
(*JSObjectGetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
148160

161+
/* Extension of the above callback with the class that the method is being invoked for. */
162+
typedef JSValueRef
163+
(*JSObjectGetPropertyCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
164+
149165
/*!
150166
@typedef JSObjectSetPropertyCallback
151167
@abstract The callback invoked when setting a property's value.
@@ -164,6 +180,10 @@ If this function returns false, the set request forwards to object's statically
164180
typedef bool
165181
(*JSObjectSetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
166182

183+
/* Extension of the above callback with the class that the method is being invoked for. */
184+
typedef bool
185+
(*JSObjectSetPropertyCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
186+
167187
/*!
168188
@typedef JSObjectDeletePropertyCallback
169189
@abstract The callback invoked when deleting a property.
@@ -181,6 +201,10 @@ If this function returns false, the delete request forwards to object's statical
181201
typedef bool
182202
(*JSObjectDeletePropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
183203

204+
/* Extension of the above callback with the class that the method is being invoked for. */
205+
typedef bool
206+
(*JSObjectDeletePropertyCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
207+
184208
/*!
185209
@typedef JSObjectGetPropertyNamesCallback
186210
@abstract The callback invoked when collecting the names of an object's properties.
@@ -198,6 +222,10 @@ Use JSPropertyNameAccumulatorAddName to add property names to accumulator. A cla
198222
typedef void
199223
(*JSObjectGetPropertyNamesCallback) (JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames);
200224

225+
/* Extension of the above callback with the class that the method is being invoked for. */
226+
typedef void
227+
(*JSObjectGetPropertyNamesCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames);
228+
201229
/*!
202230
@typedef JSObjectCallAsFunctionCallback
203231
@abstract The callback invoked when an object is called as a function.
@@ -219,6 +247,12 @@ If this callback is NULL, calling your object as a function will throw an except
219247
typedef JSValueRef
220248
(*JSObjectCallAsFunctionCallback) (JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
221249

250+
/* Extension of the above callback with the class and class name of the object being called as a function.
251+
@discussion If this is a JSStaticFunctionEx, className will actually be the name of the function.
252+
*/
253+
typedef JSValueRef
254+
(*JSObjectCallAsFunctionCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSStringRef className, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
255+
222256
/*!
223257
@typedef JSObjectCallAsConstructorCallback
224258
@abstract The callback invoked when an object is used as a constructor in a 'new' expression.
@@ -239,6 +273,10 @@ If this callback is NULL, using your object as a constructor in a 'new' expressi
239273
typedef JSObjectRef
240274
(*JSObjectCallAsConstructorCallback) (JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
241275

276+
/* Extension of the above callback with the class that the method is being invoked for. */
277+
typedef JSObjectRef
278+
(*JSObjectCallAsConstructorCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
279+
242280
/*!
243281
@typedef JSObjectHasInstanceCallback
244282
@abstract hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression.
@@ -260,6 +298,10 @@ Standard JavaScript practice calls for objects that implement the callAsConstruc
260298
typedef bool
261299
(*JSObjectHasInstanceCallback) (JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
262300

301+
/* Extension of the above callback with the class that the method is being invoked for. */
302+
typedef bool
303+
(*JSObjectHasInstanceCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
304+
263305
/*!
264306
@typedef JSObjectConvertToTypeCallback
265307
@abstract The callback invoked when converting an object to a particular JavaScript type.
@@ -279,6 +321,10 @@ This function is only invoked when converting an object to number or string. An
279321
typedef JSValueRef
280322
(*JSObjectConvertToTypeCallback) (JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception);
281323

324+
/* Extension of the above callback with the class that the method is being invoked for. */
325+
typedef JSValueRef
326+
(*JSObjectConvertToTypeCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSType type, JSValueRef* exception);
327+
282328
/*!
283329
@struct JSStaticValue
284330
@abstract This structure describes a statically declared value property.
@@ -294,6 +340,14 @@ typedef struct {
294340
JSPropertyAttributes attributes;
295341
} JSStaticValue;
296342

343+
/* Extension of the above structure for use with class version 1000 */
344+
typedef struct {
345+
const char* name;
346+
JSObjectGetPropertyCallbackEx getPropertyEx;
347+
JSObjectSetPropertyCallbackEx setPropertyEx;
348+
JSPropertyAttributes attributes;
349+
} JSStaticValueEx;
350+
297351
/*!
298352
@struct JSStaticFunction
299353
@abstract This structure describes a statically declared function property.
@@ -307,6 +361,13 @@ typedef struct {
307361
JSPropertyAttributes attributes;
308362
} JSStaticFunction;
309363

364+
/* Extension of the above structure for use with class version 1000 */
365+
typedef struct {
366+
const char* name;
367+
JSObjectCallAsFunctionCallbackEx callAsFunctionEx;
368+
JSPropertyAttributes attributes;
369+
} JSStaticFunctionEx;
370+
310371
/*!
311372
@struct JSClassDefinition
312373
@abstract This structure contains properties and callbacks that define a type of object. All fields other than the version field are optional. Any pointer may be NULL.
@@ -341,26 +402,49 @@ Standard JavaScript practice calls for storing function objects in prototypes, s
341402
A NULL callback specifies that the default object callback should substitute, except in the case of hasProperty, where it specifies that getProperty should substitute.
342403
*/
343404
typedef struct {
344-
int version; /* current (and only) version is 0 */
405+
int version; /* default version is 0, use version 1000 for callbacks with extended class information */
345406
JSClassAttributes attributes;
346407

347408
const char* className;
348409
JSClassRef parentClass;
349-
350-
const JSStaticValue* staticValues;
351-
const JSStaticFunction* staticFunctions;
352-
353-
JSObjectInitializeCallback initialize;
354-
JSObjectFinalizeCallback finalize;
355-
JSObjectHasPropertyCallback hasProperty;
356-
JSObjectGetPropertyCallback getProperty;
357-
JSObjectSetPropertyCallback setProperty;
358-
JSObjectDeletePropertyCallback deleteProperty;
359-
JSObjectGetPropertyNamesCallback getPropertyNames;
360-
JSObjectCallAsFunctionCallback callAsFunction;
361-
JSObjectCallAsConstructorCallback callAsConstructor;
362-
JSObjectHasInstanceCallback hasInstance;
363-
JSObjectConvertToTypeCallback convertToType;
410+
411+
union {
412+
/* version 0 */
413+
struct {
414+
const JSStaticValue* staticValues;
415+
const JSStaticFunction* staticFunctions;
416+
JSObjectInitializeCallback initialize;
417+
JSObjectFinalizeCallback finalize;
418+
JSObjectHasPropertyCallback hasProperty;
419+
JSObjectGetPropertyCallback getProperty;
420+
JSObjectSetPropertyCallback setProperty;
421+
JSObjectDeletePropertyCallback deleteProperty;
422+
JSObjectGetPropertyNamesCallback getPropertyNames;
423+
JSObjectCallAsFunctionCallback callAsFunction;
424+
JSObjectCallAsConstructorCallback callAsConstructor;
425+
JSObjectHasInstanceCallback hasInstance;
426+
JSObjectConvertToTypeCallback convertToType;
427+
};
428+
429+
/* version 1000 */
430+
struct {
431+
const JSStaticValueEx* staticValuesEx;
432+
const JSStaticFunctionEx* staticFunctionsEx;
433+
JSObjectInitializeCallbackEx initializeEx;
434+
JSObjectFinalizeCallbackEx finalizeEx;
435+
JSObjectHasPropertyCallbackEx hasPropertyEx;
436+
JSObjectGetPropertyCallbackEx getPropertyEx;
437+
JSObjectSetPropertyCallbackEx setPropertyEx;
438+
JSObjectDeletePropertyCallbackEx deletePropertyEx;
439+
JSObjectGetPropertyNamesCallbackEx getPropertyNamesEx;
440+
JSObjectCallAsFunctionCallbackEx callAsFunctionEx;
441+
JSObjectCallAsConstructorCallbackEx callAsConstructorEx;
442+
JSObjectHasInstanceCallbackEx hasInstanceEx;
443+
JSObjectConvertToTypeCallbackEx convertToTypeEx;
444+
};
445+
};
446+
447+
void* privateData; /* version 1000 only */
364448
} JSClassDefinition;
365449

366450
/*!
@@ -396,6 +480,25 @@ JS_EXPORT JSClassRef JSClassRetain(JSClassRef jsClass);
396480
*/
397481
JS_EXPORT void JSClassRelease(JSClassRef jsClass);
398482

483+
/*!
484+
@function
485+
@abstract Retrieves the private data from a class reference, only possible with classes created with version 1000 (extended callbacks).
486+
@param jsClass The class to get the data from
487+
@result The private data on the class, or NULL, if not set
488+
@discussion Only classes with version 1000 (extended callbacks) can store private data, for other classes always NULL will always be returned.
489+
*/
490+
JS_EXPORT void* JSClassGetPrivate(JSClassRef jsClass);
491+
492+
/*!
493+
@function
494+
@abstract Sets the private data on a class, only possible with classes created with version 1000 (extended callbacks).
495+
@param jsClass The class to set the data on
496+
@param data A void* to set as the private data for the class
497+
@result true if the data has been set on the class, false if the class has not been created with version 1000 (extended callbacks)
498+
@discussion Only classes with version 1000 (extended callbacks) can store private data, for other classes the function always fails. The set pointer is not touched by the engine.
499+
*/
500+
JS_EXPORT bool JSClassSetPrivate(JSClassRef jsClass, void* data);
501+
399502
/*!
400503
@function
401504
@abstract Creates a JavaScript object.

Ultralight/Bitmap.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,18 @@ class UExport Bitmap : public RefCounted {
144144
virtual uint32_t bpp() const = 0;
145145

146146
///
147-
/// Get the number of bytes between each row (this is always >= width * bpp)
147+
/// Get the number of bytes between each row of pixels.
148+
///
149+
/// @note This value is usually calculated as width * bytes_per_pixel (bpp)
150+
/// but it may be larger due to alignment rules in the allocator.
148151
///
149152
virtual uint32_t row_bytes() const = 0;
150153

151154
///
152155
/// Get the size in bytes of the pixel buffer.
153156
///
157+
/// @note Size is calculated as row_bytes() * height().
158+
///
154159
virtual size_t size() const = 0;
155160

156161
///

Ultralight/CAPI.h

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ ULExport ULString ulSessionGetDiskPath(ULSession session);
557557
///
558558
ULExport ULView ulCreateView(ULRenderer renderer, unsigned int width,
559559
unsigned int height, bool transparent,
560-
ULSession session);
560+
ULSession session, bool force_cpu_renderer);
561561

562562
///
563563
/// Destroy a View.
@@ -654,12 +654,22 @@ ULExport void ulViewUnlockJSContext(ULView view);
654654
///
655655
/// @param js_string The string of JavaScript to evaluate.
656656
///
657-
/// @param exception A string to store the exception in, if any. Pass NULL
658-
/// if you don't care about exceptions.
659-
///
660-
/// @note Don't destroy the returned string, it is owned by the View. This
661-
/// value is reset with every call-- if you want to retain it you should
662-
/// copy the result to a new string via ulCreateStringFromCopy().
657+
/// @param exception The address of a ULString to store a description of the
658+
/// last exception. Pass NULL to ignore this. Don't destroy
659+
/// the exception string returned, it's owned by the View.
660+
///
661+
/// @note Don't destroy the returned string, it's owned by the View. This value
662+
/// is reset with every call-- if you want to retain it you should copy
663+
/// the result to a new string via ulCreateStringFromCopy().
664+
///
665+
/// @note An example of using this API:
666+
/// <pre>
667+
/// ULString script = ulCreateString("1 + 1");
668+
/// ULString exception;
669+
/// ULString result = ulViewEvaluateScript(view, script, &exception);
670+
/// /* Use the result ("2") and exception description (if any) here. */
671+
/// ulDestroyString(script);
672+
/// </pre>
663673
///
664674
ULExport ULString ulViewEvaluateScript(ULView view, ULString js_string, ULString* exception);
665675

Ultralight/KeyEvent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class UExport KeyEvent {
129129
/// This is a string identifying the key that was pressed. This can be
130130
/// generated from the virtual_key_code via the GetKeyIdentifierFromVirtualKeyCode()
131131
/// utility function. You can find the full list of key identifiers at:
132-
/// <http://www.w3.org/TR/DOM-Level-3-Events/keyset.html>
132+
/// <https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/keyset.html>
133133
///
134134
String key_identifier;
135135

Ultralight/Renderer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ class UExport Renderer : public RefCounted {
9999
/// (nullable).
100100
///
101101
virtual Ref<View> CreateView(uint32_t width, uint32_t height,
102-
bool transparent, RefPtr<Session> session) = 0;
102+
bool transparent, RefPtr<Session> session,
103+
bool force_cpu_renderer = false) = 0;
103104

104105
///
105106
/// Update timers and dispatch internal callbacks. You should call this often

0 commit comments

Comments
 (0)