[webkit-dev] Javascript and WebCore

Alexander Cohen naftaly at me.com
Sun Oct 25 14:01:28 PDT 2009


On Oct 25, 2009, at 2:48 PM, Darin Adler wrote:

> On Oct 23, 2009, at 6:27 AM, Alexander Cohen wrote:
>
>> I've been looking into having WebCore support another scripting  
>> language other than Javascript. By going through the code, it seems  
>> pretty doable. Then i got to  inline scripts on event handlers and  
>> that's where it became a bit more complicated. It seems like  
>> JSEventListeners are mixed into normal HTML parsing which makes it  
>> really hard to actually add anything without either refactoring  
>> that complete section or just hacking it right into it ( checking  
>> for the type of script and dispatching to the right class ).
>
> Because of the many hooks added by Google engineers to replace  
> WebKit’s own JavaScript engine with their V8 project in Google  
> builds, there are already hooks to substitute a different engine  
> every single place WebKit interacts with the JavaScript engine, so  
> that should not be a problem.
>
> Your question seems to be less about implementation, and more about  
> the design. You mention checking the type of script, but how would  
> you do that? The syntax is onload="<script>" and the script language  
> is JavaScript. In other places in the syntax, such as in script  
> elements, the script language is explicit, but in these older legacy  
> places it’s not.
>
> Once you decide what you’re trying to do, perhaps I can help you  
> with the “how” question. But generally this seems to be a  
> challenging project, and I probably won’t be able to help much.

The hooks added by Google seems more to replace and not to add a  
scripting language. My goal is to add a scripting language. Up to now,  
i've been able to implement it pretty nicely in the <script> tag by  
using either the language or the type attribute. I've got a good part  
of the bindings working and can easily interact with the DOM just like  
i would in javascript.

In the events of a tag, i needed to add checks to see what type of  
script was being called. A lot if not all of the time, we will usually  
find a "javascript:" in the event code so i can also look there for my  
defined scripting language and call into the right code. My problem  
lies there mostly. At that point, it seems to be "understood" that it  
is javascript that will be run. At that point in the code, a function  
is called that returns a subclass of an EventListener  
( JSLazyEventListener ). That's also something i need to change in  
order for those functions to return just an EventListener so i can  
hook into my own subclass of EventListener. That is where i am right  
now, subclassing the EventListener.

The project is challenging but that's the whole point. I think i  
understand how i need to do it. I just wanted to ping the list and see  
if anyone had any tips or maybe even some sort of document describing  
the flow of function calls.

thx

AC


More information about the webkit-dev mailing list