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

Jump to navigation Jump to search
Line 83: Line 83:
http://lxr.mozilla.org/seamonkey/source/dom/public/nsIScriptGlobalObject.h
http://lxr.mozilla.org/seamonkey/source/dom/public/nsIScriptGlobalObject.h


nsGlobalWindow is the main implemention of nsIScriptGlobalObject, but XUL and XBL have a few.
<tt>nsGlobalWindow</tt> is the main implemention of <tt>nsIScriptGlobalObject</tt>, but XUL and XBL have a few.


* nsIScriptGlobalObject remains a single object (ie, not per language).  It will keep a list of "nsIScriptContext *ctx, void *global" items, one for each language.  New methods:
* <tt>nsIScriptGlobalObject</tt> remains a single object (ie, not per language).  It keeps an array of <tt>nsIScriptContext</tt> objects and <tt>void *</tt> globals for each supported language.  Methods <tt>GetContext</tt> and <tt>GetGlobalJSObject</tt> have been replaced with <tt>GetLanguageContext</tt> and <tt>GetLanguageGlobal</tt>, both of which take the language ID as a param. The places still tied to JS explicitly pass <tt>nsIProgrammingLanguage::JAVASCRIPT</tt> when necessary.
  nsIScriptContext *GetLanguageContext(PRUint32 lang_id);
  void *GetLanguageGlobal(PRUint32 lang_id);
GetContext()/GetGlobalJSObject() will be removed and replaced with "GetLanguageContext(nsIProgrammingLanguage::JAVASCRIPT, ...)" in the few places that remain tied to JS.


* New method EnsureScriptEnvironment(PRUint32 langID) to ensure the nsIScriptGlobal is initialized for a specific language.  This may be called at any time - whenever someone needs to run a script in a language.
* New method <tt>EnsureScriptEnvironment(PRUint32 langID)</tt> to ensure the nsIScriptGlobal is initialized for a specific language.  This may be called at any time - whenever someone needs to run a script in a language.


* New method to set and get "properties" - nsGlobalWindow does this for JS.  Setting a property should presumably set it in all languages (via the global attached to the context).  Getting is tricker - what if the property is in a different language?  Or in multiple languages?
* New method to set and get "properties" - nsGlobalWindow does this for JS.  Setting a property should presumably set it in all languages (via the global attached to the context).  Getting is tricker - what if the property is in a different language?  Or in multiple languages?
32

edits

Navigation menu