Breaking the grip JS has on the DOM: Difference between revisions

Jump to navigation Jump to search
Line 59: Line 59:
=== nsIScriptContext ===
=== nsIScriptContext ===


* The ownership model of the "void *" objects returned from nsIScriptContext must be clarified and made more explicit.  The "WrapNative" process, which is used to locate a language native object "bound" to a DOM object pointer is tied up with this.
* The ownership model of the <tt>void *</tt> objects returned from <tt>nsIScriptContext</tt> must be clarified and made more explicit.  The "WrapNative" process, which is used to locate a language native object "bound" to a DOM object pointer is tied up with this.


* Existing JSObject replaced with void
* Existing <tt>JSObject</tt> replaced with <tt>void</tt>


* Existing "char *version" replaced with "PRUint32 version".  nsILanguageRuntime able to convert a char * version string into the flags.
* Existing <tt>char *version</tt> replaced with <tt>PRUint32 version</tt>New method on <tt>nsILanguageRuntime</tt> to convert a <tt>char * version</tt> string into the flags.


* Existing "void *aScopeObject" (ExecuteScript/EvaluateStringWithValue/CompileScript), is *not* replaced with nsIScriptGlobalObject.  This is a change from earlier versions of this document - nsXBLProtoImplField and a few others pass an explicit aScriptObject which is not the same as associated with the nsIScriptGlobal.
* New <tt>FinalizeClasses</tt> method - JS implementation does the <tt>ClearScope/ClearWatchpointsForObject/ClearRegExpStatistics</tt> dance.


* FinalizeClasses method - JS does the ClearScope/ClearWatchpointsForObject/ClearRegExpStatistics?
* <tt>nsIArray</tt> to be used in place of <tt>jsval</tt> argc/argv used now.  <tt>CompileEventHandler</tt> needs to pass an array of event arg names (currently limited to 1), and support for onerror must be added (which is the only known event to not have a single param).  There is a new <tt>nsJSArgArray</tt> object that "wraps" a <tt>jsval argv</tt> object into an <tt>nsIArray</tt> - but also supports a private interface for getting the original <tt>jsval</tt> array.  Thus, js->js calls do not convert elements in the array - objects are only converted when <tt>nsIArray</tt> methods are directly used (eg, when another language sees the array)


* nsIArray to be used in place of jsval argc/argv used now.  CompileEventHandler needs to pass an array of event arg names (currently limited to 1), and support for onerror must be added (which is the only known event to not have a single param)
* <tt>CompileEventHandler</tt> now takes an array of arg names - this is because the <tt>onerror</tt> event takes 3 params.  <tt>nsContentUtils::GetEventArgName()</tt> renamed to <tt>GetEventArgNames()</tt> with params changed accordingly, and returns 3 names for 'onerror'.


* Maybe some kind of "SetProperty" function - as needed by nsGlobalWindow - "arguments", "navigator" etc. http://lxr.mozilla.org/seamonkey/source/dom/src/base/nsGlobalWindow.cpp#871 [Not sure this is needed. IMO we should make "arguments" be XPCOM objects, i.e. [nsIArray -- markh] and we'd finally be able to get to the arguments passed to window.open() from *any* language. "navigator" is just a property of a window like all others, except that there's some JS:isms around it that I think we can easily ignore for Python -- jst]
* A new <tt>SetProperty</tt> method has been added, currently used only to set <tt>window.arguments</tt>. Note that <tt>BindCompiledEventHandler()</tt> changes make these 2 functions almost identical in concept, so these could possibly be merged. Alternatively, now we use <tt>nsIArray</tt> for window arguments, we could possibly add <tt>arguments</tt> as an XPCOM property on the DOM object itself, meaning <tt>SetProperty()</tt> could go away.


* SetTerminationFunction needs thinking through - this does *not* seem to be a per-language thing.  Maybe could be on the nsIDOMContextStackItem proposed below?  Only few callers though.
* <tt>SetTerminationFunction</tt> needs thinking through - this does *not* seem to be a per-language thing, but is used only for JS GC, so that the script global is notified when the JS global object is collectedThis needs more thinking through, or possibly just moved privately inside the JS implementation.


* New method:<br>void *GetNativeGlobal() to return the "global object" used by nsIScriptGlobalWindow (previously stored in mJSObject) for this context.  nsIScriptGlobalObject calls this method during language init to setup its environment.
* New method <tt>void *GetNativeGlobal()</tt> to return the "global object" used by <tt>nsIScriptGlobalWindow</tt> (previously stored in <tt>mJSObject</tt>) for this context.  <tt>nsIScriptGlobalObject</tt> calls this method during language init to setup its environment.


* New Serialize and Deserialize methods added.
* New <tt>Serialize</tt> and <tt>Deserialize</tt> methods added with <tt>nsXULPrototypeScript</tt> delegating to the context.


=== nsIScriptGlobalObject and nsGlobalWindow ===
=== nsIScriptGlobalObject and nsGlobalWindow ===
32

edits

Navigation menu