I am under the impression that WebKit is a more general framework into which multiple JavaScript engines can be plugged. Most prominently, we have both Apple's JavaScriptCore, and Google's V8.
Has 开发者_如何学Goanyone tried to plug in Mozilla's Rhino? If they haven't, can you point me to some brief resources on what is involved? (I'm very unlikely to take this on by myself, but I am interested in how the WebKit extension points in this area are structured, just for curiosity's sake.)
Also, if my understanding of the relationship between WebKit, JavaScriptCore, and V8 is incorrect, setting me straight there would make a fine answer.
Ignoring the many issues that come from supporting multiple js engines in webkit, there is a lot of work into supporting any js engine.
The majority of the DOM bindings are automatically generated, but the scripts that do this (and do it correctly) are large, complex and completely different for every target (there are dom bindings in webkit for JSC, V8, Objective-C and gtk). That said the existence of > 2 sets of bindings should be an indication that supporting an additional set of binding would not be too difficult (largely time, rather than mind-f*cking).
The problem with JS in particular is that the browser inherently has to be able to interact with it in more ways (script tags and the like). This is mostly abstracted out from the core engine, but there's a lot of logic that would need to be implemented which would be difficult, and it's still not guaranteed to work. Lastly V8 was designed with webkit as an embedding target so it supported the weird stuff the webkit needs, and there's no guarantee that spidermonkey, rhino, or any other engine would be able to provide them.
精彩评论