Changeset 1000

Show
Ignore:
Timestamp:
07/30/08 03:57:41 (1 month ago)
Author:
MaierMan
Message:

make makeObserver better

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/chrome/content/common/overlayFunctions.js

    r993 r1000  
    605605function DTA_makeObserver(obj) { 
    606606        // nsiSupports 
    607         obj.__QueryInterface = obj.QueryInterface; 
     607        let __QueryInterface = obj.QueryInterface; 
    608608        obj.QueryInterface = function(iid) { 
    609                 if ( 
    610                         iid.equals(Components.interfaces.nsISupports) 
    611                         || iid.equals(Components.interfaces.nsISupportsWeakReference) 
    612                         || iid.equals(Components.interfaces.nsIWeakReference) 
    613                         || iid.equals(Components.interfaces.nsiObserver) 
    614                 ) { 
    615                         return this; 
    616                 } 
    617                 if (this.__QueryInterface) { 
    618                         return this.__QueryInterface(iid); 
    619                 } 
    620                 throw Components.results.NS_ERROR_NO_INTERFACE; 
     609                try { 
     610                        if ( 
     611                                iid.equals(Components.interfaces.nsISupports) 
     612                                || iid.equals(Components.interfaces.nsISupportsWeakReference) 
     613                                || iid.equals(Components.interfaces.nsIWeakReference) 
     614                                || iid.equals(Components.interfaces.nsiObserver) 
     615                        ) { 
     616                                return obj; 
     617                        } 
     618                        if (__QueryInterface) { 
     619                                debug("calling original: " + iid); 
     620                                return __QueryInterface.call(this, iid); 
     621                        } 
     622                        throw Components.results.NS_ERROR_NO_INTERFACE; 
     623                } 
     624                catch (ex) { 
     625                        debug("requested interface not available: " + iid); 
     626                        throw ex; 
     627                } 
    621628        }; 
    622629        // nsiWeakReference 
    623630        obj.QueryReferent = function(iid) { 
    624                 return this
     631                return obj.QueryInterface(iid)
    625632        }; 
    626633        // nsiSupportsWeakReference 
    627634        obj.GetWeakReference = function() { 
    628                 return this
     635                return obj
    629636        };       
    630637}