Please make sure you can check the following two boxes:
[x] I have read the CONTRIBUTING document
[x] My code follows the code style of this project
Contribution Type
What types of changes does your code introduce? Put an x in all the boxes that apply:
[ ] Bug fix (non-breaking change which fixes an issue, please reference the issue id)
[x] New feature (non-breaking change which adds functionality, make sure to open an associated issue first)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
[ ] My change requires a change to the documentation
[ ] I have updated the documentation accordingly
[x] I have added tests to cover my changes
[x] All new and existing tests passed
Description
This PR adds support for the Image constructor as described here.
Since this constructor does not directly link to the HTMLImageElement constructor, I have added a new "constructor function" way of adding constructors to the Window object:
Added DomConstructorFunctionInstance which stores a reference to the constructor function and calls it when Jint calls the Construct function.
Added DomConstructorFunctionAttribute to decorate any methods that need to be treated as a constructor function.
Added methods in the EngineExtensions, EngineInstance and CreatorCache to find any decorated constructor functions and add them to the Window object.
Added new extension method to WindowExtensions which handles the Image constructor call and returns a new IHtmlImageElement instance.
Types of Changes
Prerequisites
Please make sure you can check the following two boxes:
Contribution Type
What types of changes does your code introduce? Put an
x
in all the boxes that apply:Description
This PR adds support for the
Image
constructor as described here.Since this constructor does not directly link to the
HTMLImageElement
constructor, I have added a new "constructor function" way of adding constructors to theWindow
object:DomConstructorFunctionInstance
which stores a reference to the constructor function and calls it when Jint calls theConstruct
function.DomConstructorFunctionAttribute
to decorate any methods that need to be treated as a constructor function.EngineExtensions
,EngineInstance
andCreatorCache
to find any decorated constructor functions and add them to theWindow
object.WindowExtensions
which handles theImage
constructor call and returns a newIHtmlImageElement
instance.Image
constructor.