Mozilla has added a new ability in NPRuntime: enumerate the members of an object's class. This can be seen at the Mozilla bug in the URL field. This functionality will generally improve NPRuntime communication in both directions (browser to client and client to browser).
There are two interfaces: NPN_Enumerate and NPClass::enumerate. Under the covers, there are two aspects to implement: (1) expose to NPRuntime clients (using either interface) the ability to enumerate WebKit JS objects, and (2) expose to WebKit JS scripts the ability to enumerate NPRuntime objects (e.g. using for-in loops) for which clients have provided an NPClass::enumerate.
See bug 13029, in which we are attempting to add support for HTTP response headers through the NPAPI. If that patch is landed, then WebKit will be returning 18 for minor version via NPN_GetVersion, but will be missing NPN_Enumerate and NPClass::enumerate, which were added in minor version 17. The proposed patch for bug 13029 is working around this by providing a NULL pointer in NPNetscapeFuncs::enumerate, and declaring version 1 in NPClass::structVersion. This is not a great situation, but we want to solve bug 13029 without having to wait for an enumeration implementation, and the NPAPI has a lousy flat versioning scheme. If and when enumeration support is added, assuming the bug 13029 patch has landed, remember to do the following:
- Fill in non-NULL pointers for NPNetscapeFuncs::enumerate in WebNetscapePluginPackage -load (two places, CFM and Mach).
- In npapi.h, remove the "not implemented" comment at NPVERS_HAS_NPRUNTIME_ENUMERATION.
- In npruntime.h, redefine NP_CLASS_STRUCT_VERSION as 2 and add the enumerate member of NPClass at the end.
- Anywhere NPClass structs are used, remove hard-coded versions of 1 and replace with NP_CLASS_STRUCT_VERSION, and fill in the enumerate member.
Update: bug 13029 may end up nicely disconnecting from this bug. Discussion on plugin-futures has resulted in a proposal to change response headers to be NPAPI version 17, and NPRuntime enumeration to version 18. If things work out that way, then this bug becomes about adding a new feature, without needing to remove any previous hacks like the NULL pointers referenced above.
Final decision on plugin-futures was to in fact make NPRuntime enumeration be NPAPI version 18:
#define NPVERS_HAS_RESPONSE_HEADERS 17
#define NPVERS_HAS_NPOBJECT_ENUM 18
Was this already done? <http://trac.webkit.org/projects/webkit/changeset/20613> looks like an implementation of this feature.
It sure was!