diff --git a/JavaScriptCore/JSObjectRef.h b/JavaScriptCore/JSObjectRef.h index b0dbd78..e2caaea 100644 --- a/JavaScriptCore/JSObjectRef.h +++ b/JavaScriptCore/JSObjectRef.h @@ -91,6 +91,10 @@ derived class (the parent class) first, and the most derived class last. typedef void (*JSObjectInitializeCallback) (JSContextRef ctx, JSObjectRef object); +/* Extension of the above callback with the class that the method is being invoked for. */ +typedef void +(*JSObjectInitializeCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object); + /*! @typedef JSObjectFinalizeCallback @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. typedef void (*JSObjectFinalizeCallback) (JSObjectRef object); +/* Extension of the above callback with the class that the method is being invoked for. */ +typedef void +(*JSObjectFinalizeCallbackEx) (JSClassRef jsClass, JSObjectRef object); + /*! @typedef JSObjectHasPropertyCallback @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 typedef bool (*JSObjectHasPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); +/* Extension of the above callback with the class that the method is being invoked for. */ +typedef bool +(*JSObjectHasPropertyCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName); + /*! @typedef JSObjectGetPropertyCallback @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 typedef JSValueRef (*JSObjectGetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); +/* Extension of the above callback with the class that the method is being invoked for. */ +typedef JSValueRef +(*JSObjectGetPropertyCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + /*! @typedef JSObjectSetPropertyCallback @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 typedef bool (*JSObjectSetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); +/* Extension of the above callback with the class that the method is being invoked for. */ +typedef bool +(*JSObjectSetPropertyCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); + /*! @typedef JSObjectDeletePropertyCallback @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 typedef bool (*JSObjectDeletePropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); +/* Extension of the above callback with the class that the method is being invoked for. */ +typedef bool +(*JSObjectDeletePropertyCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + /*! @typedef JSObjectGetPropertyNamesCallback @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 typedef void (*JSObjectGetPropertyNamesCallback) (JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames); +/* Extension of the above callback with the class that the method is being invoked for. */ +typedef void +(*JSObjectGetPropertyNamesCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames); + /*! @typedef JSObjectCallAsFunctionCallback @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 typedef JSValueRef (*JSObjectCallAsFunctionCallback) (JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); +/* Extension of the above callback with the class and class name of the object being called as a function. +@discussion If this is a JSStaticFunctionEx, className will actually be the name of the function. +*/ +typedef JSValueRef +(*JSObjectCallAsFunctionCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSStringRef className, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + /*! @typedef JSObjectCallAsConstructorCallback @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 typedef JSObjectRef (*JSObjectCallAsConstructorCallback) (JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); +/* Extension of the above callback with the class that the method is being invoked for. */ +typedef JSObjectRef +(*JSObjectCallAsConstructorCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + /*! @typedef JSObjectHasInstanceCallback @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 typedef bool (*JSObjectHasInstanceCallback) (JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception); +/* Extension of the above callback with the class that the method is being invoked for. */ +typedef bool +(*JSObjectHasInstanceCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception); + /*! @typedef JSObjectConvertToTypeCallback @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 typedef JSValueRef (*JSObjectConvertToTypeCallback) (JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception); +/* Extension of the above callback with the class that the method is being invoked for. */ +typedef JSValueRef +(*JSObjectConvertToTypeCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSType type, JSValueRef* exception); + /*! @struct JSStaticValue @abstract This structure describes a statically declared value property. @@ -294,6 +340,14 @@ typedef struct { JSPropertyAttributes attributes; } JSStaticValue; +/* Extension of the above structure for use with class version 1000 */ +typedef struct { + const char* name; + JSObjectGetPropertyCallbackEx getPropertyEx; + JSObjectSetPropertyCallbackEx setPropertyEx; + JSPropertyAttributes attributes; +} JSStaticValueEx; + /*! @struct JSStaticFunction @abstract This structure describes a statically declared function property. @@ -307,6 +361,13 @@ typedef struct { JSPropertyAttributes attributes; } JSStaticFunction; +/* Extension of the above structure for use with class version 1000 */ +typedef struct { + const char* name; + JSObjectCallAsFunctionCallbackEx callAsFunctionEx; + JSPropertyAttributes attributes; +} JSStaticFunctionEx; + /*! @struct JSClassDefinition @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 A NULL callback specifies that the default object callback should substitute, except in the case of hasProperty, where it specifies that getProperty should substitute. */ typedef struct { - int version; /* current (and only) version is 0 */ + int version; /* default version is 0, use version 1000 for callbacks with extended class information */ JSClassAttributes attributes; const char* className; JSClassRef parentClass; - - const JSStaticValue* staticValues; - const JSStaticFunction* staticFunctions; - - JSObjectInitializeCallback initialize; - JSObjectFinalizeCallback finalize; - JSObjectHasPropertyCallback hasProperty; - JSObjectGetPropertyCallback getProperty; - JSObjectSetPropertyCallback setProperty; - JSObjectDeletePropertyCallback deleteProperty; - JSObjectGetPropertyNamesCallback getPropertyNames; - JSObjectCallAsFunctionCallback callAsFunction; - JSObjectCallAsConstructorCallback callAsConstructor; - JSObjectHasInstanceCallback hasInstance; - JSObjectConvertToTypeCallback convertToType; + + union { + /* version 0 */ + struct { + const JSStaticValue* staticValues; + const JSStaticFunction* staticFunctions; + JSObjectInitializeCallback initialize; + JSObjectFinalizeCallback finalize; + JSObjectHasPropertyCallback hasProperty; + JSObjectGetPropertyCallback getProperty; + JSObjectSetPropertyCallback setProperty; + JSObjectDeletePropertyCallback deleteProperty; + JSObjectGetPropertyNamesCallback getPropertyNames; + JSObjectCallAsFunctionCallback callAsFunction; + JSObjectCallAsConstructorCallback callAsConstructor; + JSObjectHasInstanceCallback hasInstance; + JSObjectConvertToTypeCallback convertToType; + }; + + /* version 1000 */ + struct { + const JSStaticValueEx* staticValuesEx; + const JSStaticFunctionEx* staticFunctionsEx; + JSObjectInitializeCallbackEx initializeEx; + JSObjectFinalizeCallbackEx finalizeEx; + JSObjectHasPropertyCallbackEx hasPropertyEx; + JSObjectGetPropertyCallbackEx getPropertyEx; + JSObjectSetPropertyCallbackEx setPropertyEx; + JSObjectDeletePropertyCallbackEx deletePropertyEx; + JSObjectGetPropertyNamesCallbackEx getPropertyNamesEx; + JSObjectCallAsFunctionCallbackEx callAsFunctionEx; + JSObjectCallAsConstructorCallbackEx callAsConstructorEx; + JSObjectHasInstanceCallbackEx hasInstanceEx; + JSObjectConvertToTypeCallbackEx convertToTypeEx; + }; + }; + + void* privateData; /* version 1000 only */ } JSClassDefinition; /*! @@ -396,6 +480,25 @@ JS_EXPORT JSClassRef JSClassRetain(JSClassRef jsClass); */ JS_EXPORT void JSClassRelease(JSClassRef jsClass); +/*! +@function +@abstract Retrieves the private data from a class reference, only possible with classes created with version 1000 (extended callbacks). +@param jsClass The class to get the data from +@result The private data on the class, or NULL, if not set +@discussion Only classes with version 1000 (extended callbacks) can store private data, for other classes always NULL will always be returned. +*/ +JS_EXPORT void* JSClassGetPrivate(JSClassRef jsClass); + +/*! +@function +@abstract Sets the private data on a class, only possible with classes created with version 1000 (extended callbacks). +@param jsClass The class to set the data on +@param data A void* to set as the private data for the class +@result true if the data has been set on the class, false if the class has not been created with version 1000 (extended callbacks) +@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. +*/ +JS_EXPORT bool JSClassSetPrivate(JSClassRef jsClass, void* data); + /*! @function @abstract Creates a JavaScript object. diff --git a/Ultralight/Bitmap.h b/Ultralight/Bitmap.h index 247b5d3..603deb9 100644 --- a/Ultralight/Bitmap.h +++ b/Ultralight/Bitmap.h @@ -144,13 +144,18 @@ class UExport Bitmap : public RefCounted { virtual uint32_t bpp() const = 0; /// - /// Get the number of bytes between each row (this is always >= width * bpp) + /// Get the number of bytes between each row of pixels. + /// + /// @note This value is usually calculated as width * bytes_per_pixel (bpp) + /// but it may be larger due to alignment rules in the allocator. /// virtual uint32_t row_bytes() const = 0; /// /// Get the size in bytes of the pixel buffer. /// + /// @note Size is calculated as row_bytes() * height(). + /// virtual size_t size() const = 0; /// diff --git a/Ultralight/CAPI.h b/Ultralight/CAPI.h index 764c273..5b04064 100644 --- a/Ultralight/CAPI.h +++ b/Ultralight/CAPI.h @@ -557,7 +557,7 @@ ULExport ULString ulSessionGetDiskPath(ULSession session); /// ULExport ULView ulCreateView(ULRenderer renderer, unsigned int width, unsigned int height, bool transparent, - ULSession session); + ULSession session, bool force_cpu_renderer); /// /// Destroy a View. @@ -654,12 +654,22 @@ ULExport void ulViewUnlockJSContext(ULView view); /// /// @param js_string The string of JavaScript to evaluate. /// -/// @param exception A string to store the exception in, if any. Pass NULL -/// if you don't care about exceptions. -/// -/// @note Don't destroy the returned string, it is owned by the View. This -/// value is reset with every call-- if you want to retain it you should -/// copy the result to a new string via ulCreateStringFromCopy(). +/// @param exception The address of a ULString to store a description of the +/// last exception. Pass NULL to ignore this. Don't destroy +/// the exception string returned, it's owned by the View. +/// +/// @note Don't destroy the returned string, it's owned by the View. This value +/// is reset with every call-- if you want to retain it you should copy +/// the result to a new string via ulCreateStringFromCopy(). +/// +/// @note An example of using this API: +///
+/// ULString script = ulCreateString("1 + 1"); +/// ULString exception; +/// ULString result = ulViewEvaluateScript(view, script, &exception); +/// /* Use the result ("2") and exception description (if any) here. */ +/// ulDestroyString(script); +////// ULExport ULString ulViewEvaluateScript(ULView view, ULString js_string, ULString* exception); diff --git a/Ultralight/KeyEvent.h b/Ultralight/KeyEvent.h index 203009b..202c78f 100644 --- a/Ultralight/KeyEvent.h +++ b/Ultralight/KeyEvent.h @@ -129,7 +129,7 @@ class UExport KeyEvent { /// This is a string identifying the key that was pressed. This can be /// generated from the virtual_key_code via the GetKeyIdentifierFromVirtualKeyCode() /// utility function. You can find the full list of key identifiers at: - ///