Friday, 29 June 2012

JavaScript

I have been asked to write a small introduction about the work i have
been doing to integrate javascript.

The handling of <script> elements has been added, this required a
refactoring of code in desktop/browser.c to correctly handle script
elements and attempt to execute them with the correct interpreter.

The script implementation is functional but incomplete and probably
ought to be split to add a full object factory for script
interpreters. A decision on handling of <noscript> elements and how
the parser options are set to handle these.

A simple javascript abstraction has been added allowing for
alternative javascript interpreters to be added in future. And an
initial implementation added for the spidermonkey interpreter/jit
(jsapi) this integration allows for javascript code to be correctly
gathered and executed from script tags.

What is now required is to add bindings to the javascript runtime for
all the DOM operations including the so called DOM0 objects like the
global window object and all the associated sub objects like
navigator, console etc.

I initially intended to use a tool to generate these bindings either
from web IDL or from a DSL but it has become apparent that the
existing tools (such as jsapigen) are grossly inadequate and rolling
our own requires so much domain specific code that simply writing the
bindings by hand with helper functions is massively less effort.

The Makefile.defaults currently has NETSURF_USE_JS and
NETSURF_USE_MOZJS set to NO thus disabling all javascript in normal
builds, simply overriding these to AUTO in Makefile.config and ensuring
you have the mozilla spidermonkey packages installed (libmozjs-dev or
similar) should be enough to compile with javascript support

Ongoing work is now concentrating on adding bindings and completing
their implementation. Although there is no explicit dependency on
specific versions of spidermonkey I am primarily basing my efforts on
the 1.8.5 releases as this are the most common version found in
distributions.

--
Regards Vincent
http://www.kyllikki.org/

No comments:

Post a Comment