Closed Bug 547457 Opened 14 years ago Closed 6 years ago

Consider using Components method to define fast native QueryInterface for JS components

Categories

(Core :: XPConnect, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED INACTIVE

People

(Reporter: WeirdAl, Unassigned)

Details

99% of the time, a JavaScript component's QueryInterface method is pretty straight forward.  QueryInterface gets called a lot, though.

The idea is that XPConnect could have a hashtable of JS-based components, where the value is an array of IIDs a component defines as "I support these interfaces."  XPConnect wouldn't have to call into JS land to execute the QueryInterface call then - it would have the supported IID's right there.

Here's some sample code:

function Component() {
  Components.defineQueryInterface(this, [
    "nsIDOMEventListener"
  ]);
}
Component.prototype = {
  // ...

  // nsISupports
  QueryInterface: function(aIID) {
    // With the above defineQueryInterface call, this method never gets called.
    if (aIID.equals(Components.interfaces.nsIDOMEventListener) ||
        aIID.equals(Components.interfaces.nsISupports))
      return this;
    return null; // XPConnect will throw NO_INTERFACE
  }
}

nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject or nsXPCWrappedJSClass::DelegatedQueryInterface would be a good place to ask this hashtable for any objects which registered themselves for native QI.

I'm not sure if this is needed or even a good idea.  It's just an idea that I'm throwing out here, to see if it would stick.
OS: Windows 7 → All
Hardware: x86 → All
Per policy at https://wiki.mozilla.org/Bug_Triage/Projects/Bug_Handling/Bug_Husbandry#Inactive_Bugs. If this bug is not an enhancement request or a bug not present in a supported release of Firefox, then it may be reopened.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → INACTIVE
You need to log in before you can comment on or make changes to this bug.