Changeset 20613 in webkit


Ignore:
Timestamp:
Mar 30, 2007 10:29:50 AM (17 years ago)
Author:
andersca
Message:

JavaScriptCore:

Reviewed by Geoff.

Implement _NPN_Enumerate support.


  • JavaScriptCore.exp:
  • bindings/NP_jsobject.cpp: (_NPN_Enumerate):
  • bindings/c/c_instance.cpp: (KJS::Bindings::CInstance::getPropertyNames):
  • bindings/c/c_instance.h:
  • bindings/npapi.h:
  • bindings/npruntime.h:
  • bindings/npruntime_impl.h:
  • bindings/runtime.h: (KJS::Bindings::Instance::getPropertyNames):
  • bindings/runtime_object.cpp: (RuntimeObjectImp::getPropertyNames):
  • bindings/runtime_object.h: (KJS::RuntimeObjectImp::getInternalInstance):

LayoutTests:

Reviewed by Geoff.

Add enumeration test.


  • plugins/netscape-enumerate-expected.txt: Added.
  • plugins/netscape-enumerate.html: Added.

WebKit:

Reviewed by Geoff.

  • Plugins/WebNetscapePluginPackage.m: (-[WebNetscapePluginPackage load]): Initialize pushpopupsenabledstate, poppopupsenabledstate and enumerate.


  • Plugins/npapi.m: (NPN_PushPopupsEnabledState): (NPN_PopPopupsEnabledState): Add stubs for these functions.


  • Plugins/npfunctions.h: Add new methods to NPNetscapeFuncs.

WebKitTools:

Reviewed by Geoff.

  • DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj: Add TestObject.c and TestObject.h


  • DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c: (pluginGetProperty): Implement the testObject property.


(pluginInvoke):
Implement testEnumerate which takes an object and an array and enumerates
the properties of the object and adds them to the array.


(pluginAllocate):
Allocate the test object.


(pluginDeallocate):
Free the test object.


  • DumpRenderTree/TestNetscapePlugIn.subproj/TestObject.c: Added.
  • DumpRenderTree/TestNetscapePlugIn.subproj/TestObject.h: Added. Add a test object with two enumerable properties.
Location:
trunk
Files:
4 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r20569 r20613  
     12007-03-30  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Geoff.
     4
     5        Implement _NPN_Enumerate support.
     6       
     7        * JavaScriptCore.exp:
     8        * bindings/NP_jsobject.cpp:
     9        (_NPN_Enumerate):
     10        * bindings/c/c_instance.cpp:
     11        (KJS::Bindings::CInstance::getPropertyNames):
     12        * bindings/c/c_instance.h:
     13        * bindings/npapi.h:
     14        * bindings/npruntime.h:
     15        * bindings/npruntime_impl.h:
     16        * bindings/runtime.h:
     17        (KJS::Bindings::Instance::getPropertyNames):
     18        * bindings/runtime_object.cpp:
     19        (RuntimeObjectImp::getPropertyNames):
     20        * bindings/runtime_object.h:
     21        (KJS::RuntimeObjectImp::getInternalInstance):
     22
    1232007-03-28  Jeff Walden  <jwalden+code@mit.edu>
    224
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r20368 r20613  
    8585__NPN_CreateObject
    8686__NPN_DeallocateObject
     87__NPN_Enumerate
    8788__NPN_Evaluate
    8889__NPN_GetIntIdentifier
  • trunk/JavaScriptCore/bindings/NP_jsobject.cpp

    r20544 r20613  
    3131#include "npruntime_priv.h"
    3232#include "object.h"
     33#include "PropertyNameArray.h"
    3334#include "runtime_root.h"
    3435
     
    6566}
    6667
    67 static NPClass javascriptClass = { 1, jsAllocate, jsDeallocate, 0, 0, 0, 0, 0, 0, 0, 0 };
    68 static NPClass noScriptClass = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
     68static NPClass javascriptClass = { 1, jsAllocate, jsDeallocate, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
     69static NPClass noScriptClass = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    6970
    7071NPClass* NPScriptObjectClass = &javascriptClass;
     
    393394    }
    394395}
     396
     397bool _NPN_Enumerate(NPP npp, NPObject *o, NPIdentifier **identifier, uint32_t *count)
     398{
     399    if (o->_class == NPScriptObjectClass) {
     400        JavaScriptObject* obj = (JavaScriptObject*)o;
     401        if (!_isSafeScript(obj))
     402            return false;
     403       
     404        RootObject* rootObject = obj->rootObject;
     405        if (!rootObject || !rootObject->isValid())
     406            return false;
     407       
     408        ExecState* exec = rootObject->interpreter()->globalExec();
     409        JSLock lock;
     410        PropertyNameArray propertyNames;
     411
     412        obj->imp->getPropertyNames(exec, propertyNames);
     413        unsigned size = propertyNames.size();
     414        // FIXME: This should really call NPN_MemAlloc but that's in WebKit
     415        NPIdentifier *identifiers = static_cast<NPIdentifier*>(malloc(sizeof(NPIdentifier) * size));
     416       
     417        for (unsigned i = 0; i < size; i++)
     418            identifiers[i] = _NPN_GetStringIdentifier(propertyNames[i].ustring().UTF8String().c_str());
     419
     420        *identifier = identifiers;
     421        *count = size;
     422       
     423        return true;
     424    }
     425   
     426    if (NP_CLASS_STRUCT_VERSION_HAS_ENUM(o->_class) && o->_class->enumerate)
     427        return o->_class->enumerate(o, identifier, count);
     428   
     429    return false;
     430}
  • trunk/JavaScriptCore/bindings/c/c_instance.cpp

    r20104 r20613  
    3232#include "list.h"
    3333#include "npruntime_impl.h"
     34#include "PropertyNameArray.h"
    3435#include "runtime_root.h"
    3536#include <wtf/StringExtras.h>
     
    174175}
    175176
    176 }
    177 }
     177void CInstance::getPropertyNames(ExecState*, PropertyNameArray& nameArray)
     178{
     179    if (!NP_CLASS_STRUCT_VERSION_HAS_ENUM(_object->_class) ||
     180        !_object->_class->enumerate)
     181        return;
     182
     183    unsigned count;
     184    NPIdentifier* identifiers;
     185   
     186    {
     187        JSLock::DropAllLocks dropAllLocks;
     188        if (!_object->_class->enumerate(_object, &identifiers, &count))
     189            return;
     190    }
     191   
     192    for (unsigned i = 0; i < count; i++) {
     193        PrivateIdentifier* identifier = static_cast<PrivateIdentifier*>(identifiers[i]);
     194       
     195        if (identifier->isString)
     196            nameArray.add(identifierFromNPIdentifier(identifier->value.string));
     197        else
     198            nameArray.add(Identifier::from(identifier->value.number));
     199    }
     200         
     201    // FIXME: This should really call NPN_MemFree but that's in WebKit
     202    free(identifiers);
     203}
     204
     205}
     206}
  • trunk/JavaScriptCore/bindings/c/c_instance.h

    r20104 r20613  
    5555    virtual JSValue *invokeMethod (ExecState *exec, const MethodList &method, const List &args);
    5656    virtual JSValue *invokeDefaultMethod (ExecState *exec, const List &args);
     57    virtual void getPropertyNames(ExecState*, PropertyNameArray&);
    5758
    5859    JSValue *stringValue() const;
  • trunk/JavaScriptCore/bindings/npapi.h

    r15990 r20613  
    105105
    106106#define NP_VERSION_MAJOR 0
    107 #define NP_VERSION_MINOR 14
     107#define NP_VERSION_MINOR 17
    108108
    109109
     
    678678void        NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion);
    679679void        NPN_ForceRedraw(NPP instance);
     680void        NPN_PushPopupsEnabledState(NPP instance, NPBool enabled);
     681void        NPN_PopPopupsEnabledState(NPP instance);
    680682
    681683#ifdef __cplusplus
  • trunk/JavaScriptCore/bindings/npruntime.h

    r15146 r20613  
    247247typedef bool (*NPSetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, const NPVariant *value);
    248248typedef bool (*NPRemovePropertyFunctionPtr)(NPObject *npobj, NPIdentifier name);
     249typedef bool (*NPEnumerationFunctionPtr)(NPObject *npobj, NPIdentifier **value, uint32_t *count);
    249250
    250251/*
     
    263264    (The runtime will typically return immediately, with 0 or NULL, from an attempt to
    264265    dispatch to a NPObject, but this behavior should not be depended upon.)
     266   
     267    The NPEnumerationFunctionPtr function may pass an array of                 
     268    NPIdentifiers back to the caller. The callee allocs the memory of           
     269    the array using NPN_MemAlloc(), and it's the caller's responsibility       
     270    to release it using NPN_MemFree().           
    265271*/
    266272struct NPClass
     
    277283    NPSetPropertyFunctionPtr setProperty;
    278284    NPRemovePropertyFunctionPtr removeProperty;
     285    NPEnumerationFunctionPtr enumerate;
    279286};
    280287
    281 #define NP_CLASS_STRUCT_VERSION 1
     288#define NP_CLASS_STRUCT_VERSION      2
     289#define NP_CLASS_STRUCT_VERSION_ENUM 2                           
     290#define NP_CLASS_STRUCT_VERSION_HAS_ENUM(npclass)   \
     291    ((npclass)->structVersion >= NP_CLASS_STRUCT_VERSION_ENUM)
    282292
    283293struct NPObject {
     
    326336bool NPN_HasProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName);
    327337bool NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName);
     338bool NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier, uint32_t *count);
    328339
    329340/*
  • trunk/JavaScriptCore/bindings/npruntime_impl.h

    r14951 r20613  
    5353extern bool _NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName);
    5454extern void _NPN_SetException(NPObject *obj, const NPUTF8 *message);
     55extern bool _NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier, uint32_t *count);
    5556
    5657#ifdef __cplusplus
  • trunk/JavaScriptCore/bindings/runtime.h

    r20292 r20613  
    3636class Identifier;
    3737class List;
     38class PropertyNameArray;
    3839
    3940namespace Bindings {
     
    171172    virtual JSValue* invokeDefaultMethod(ExecState*, const List&) { return jsUndefined(); }
    172173   
     174    virtual void getPropertyNames(ExecState*, PropertyNameArray&) { }
     175
    173176    virtual JSValue* defaultValue(JSType hint) const = 0;
    174177   
  • trunk/JavaScriptCore/bindings/runtime_object.cpp

    r20104 r20613  
    195195}
    196196
     197void RuntimeObjectImp::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
     198{
     199    instance->begin();
     200    instance->getPropertyNames(exec, propertyNames);
     201    instance->end();
     202}
     203
  • trunk/JavaScriptCore/bindings/runtime_object.h

    r12840 r20613  
    4545    virtual bool implementsCall() const;
    4646    virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
     47    virtual void getPropertyNames(ExecState*, PropertyNameArray&);
     48
     49    Bindings::Instance *getInternalInstance() const { return instance.get(); }
    4750   
    48     Bindings::Instance *getInternalInstance() const { return instance.get(); }
    49 
    5051    static const ClassInfo info;
    5152
  • trunk/LayoutTests/ChangeLog

    r20608 r20613  
     12007-03-30  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Geoff.
     4
     5        Add enumeration test.
     6       
     7        * plugins/netscape-enumerate-expected.txt: Added.
     8        * plugins/netscape-enumerate.html: Added.
     9
    1102007-03-29  Geoffrey Garen  <ggaren@apple.com>
    211
  • trunk/WebKit/ChangeLog

    r20597 r20613  
     12007-03-30  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Geoff.
     4
     5        * Plugins/WebNetscapePluginPackage.m:
     6        (-[WebNetscapePluginPackage load]):
     7        Initialize pushpopupsenabledstate, poppopupsenabledstate and enumerate.
     8       
     9        * Plugins/npapi.m:
     10        (NPN_PushPopupsEnabledState):
     11        (NPN_PopPopupsEnabledState):
     12        Add stubs for these functions.
     13       
     14        * Plugins/npfunctions.h:
     15        Add new methods to NPNetscapeFuncs.
     16
    1172007-03-29  Geoffrey Garen  <ggaren@apple.com>
    218
  • trunk/WebKit/Plugins/WebNetscapePluginPackage.m

    r15902 r20613  
    378378        browserFuncs.getJavaEnv = (NPN_GetJavaEnvProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_GetJavaEnv);
    379379        browserFuncs.getJavaPeer = (NPN_GetJavaPeerProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_GetJavaPeer);
    380 
     380        browserFuncs.pushpopupsenabledstate = (NPN_PushPopupsEnabledStateProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_PushPopupsEnabledState);
     381        browserFuncs.poppopupsenabledstate = (NPN_PopPopupsEnabledStateProcPtr)tVectorForFunctionPointer((FunctionPointer)NPN_PopPopupsEnabledState);
     382       
    381383        browserFuncs.releasevariantvalue = (NPN_ReleaseVariantValueProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_ReleaseVariantValue);
    382384        browserFuncs.getstringidentifier = (NPN_GetStringIdentifierProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_GetStringIdentifier);
     
    395397        browserFuncs.removeproperty = (NPN_RemovePropertyProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_RemoveProperty);
    396398        browserFuncs.setexception = (NPN_SetExceptionProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_SetException);
    397 
     399        browserFuncs.enumerate = (NPN_EnumerateProcPtr)tVectorForFunctionPointer((FunctionPointer)_NPN_Enumerate);
     400       
    398401#if !LOG_DISABLED
    399402        CFAbsoluteTime mainStart = CFAbsoluteTimeGetCurrent();
     
    471474        browserFuncs.getJavaEnv = NPN_GetJavaEnv;
    472475        browserFuncs.getJavaPeer = NPN_GetJavaPeer;
    473 
     476        browserFuncs.pushpopupsenabledstate = NPN_PushPopupsEnabledState;
     477        browserFuncs.poppopupsenabledstate = NPN_PopPopupsEnabledState;
     478       
    474479        browserFuncs.releasevariantvalue = _NPN_ReleaseVariantValue;
    475480        browserFuncs.getstringidentifier = _NPN_GetStringIdentifier;
     
    488493        browserFuncs.removeproperty = _NPN_RemoveProperty;
    489494        browserFuncs.setexception = _NPN_SetException;
     495        browserFuncs.enumerate = _NPN_Enumerate;
    490496
    491497#if !LOG_DISABLED
  • trunk/WebKit/Plugins/npapi.m

    r14105 r20613  
    159159    return NULL;
    160160}
     161
     162void
     163NPN_PushPopupsEnabledState(NPP instance, NPBool enabled)
     164{
     165}
     166
     167void
     168NPN_PopPopupsEnabledState(NPP instance)
     169{
     170}
  • trunk/WebKit/Plugins/npfunctions.h

    r16235 r20613  
    3030typedef void* (*NPN_GetJavaEnvProcPtr)(void);
    3131typedef void* (*NPN_GetJavaPeerProcPtr)(NPP instance);
     32typedef void  (*NPN_PushPopupsEnabledStateProcPtr)(NPP instance, NPBool enabled);
     33typedef void  (*NPN_PopPopupsEnabledStateProcPtr)(NPP instance);
     34
    3235
    3336typedef void (*NPN_ReleaseVariantValueProcPtr) (NPVariant *variant);
     
    5255typedef bool (*NPN_RemovePropertyProcPtr) (NPP npp, NPObject *obj, NPIdentifier propertyName);
    5356typedef void (*NPN_SetExceptionProcPtr) (NPObject *obj, const NPUTF8 *message);
     57typedef bool (*NPN_EnumerateProcPtr) (NPP npp, NPObject *npobj, NPIdentifier **identifier, uint32_t *count);
    5458
    5559typedef NPError (*NPP_NewProcPtr)(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
     
    116120    NPN_ReleaseVariantValueProcPtr releasevariantvalue;
    117121    NPN_SetExceptionProcPtr setexception;
     122    NPN_PushPopupsEnabledStateProcPtr pushpopupsenabledstate;
     123    NPN_PopPopupsEnabledStateProcPtr poppopupsenabledstate;
     124    NPN_EnumerateProcPtr enumerate;
    118125} NPNetscapeFuncs;
    119126
  • trunk/WebKitTools/ChangeLog

    r20597 r20613  
     12007-03-30  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Geoff.
     4
     5        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
     6        Add TestObject.c and TestObject.h
     7       
     8        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c:
     9        (pluginGetProperty):
     10        Implement the testObject property.
     11       
     12        (pluginInvoke):
     13        Implement testEnumerate which takes an object and an array and enumerates
     14        the properties of the object and adds them to the array.
     15       
     16        (pluginAllocate):
     17        Allocate the test object.
     18       
     19        (pluginDeallocate):
     20        Free the test object.
     21       
     22        * DumpRenderTree/TestNetscapePlugIn.subproj/TestObject.c: Added.
     23        * DumpRenderTree/TestNetscapePlugIn.subproj/TestObject.h: Added.
     24        Add a test object with two enumerable properties.
     25
    1262007-03-29  Geoffrey Garen  <ggaren@apple.com>
    227
  • trunk/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj

    r20590 r20613  
    4040                14A6FB8B0971CAE5008B014F /* NavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 14A6FB890971CAE5008B014F /* NavigationController.m */; };
    4141                1A6CA8DE0B7122D100A24B62 /* ResourceLoadDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A6CA8640B7120CF00A24B62 /* ResourceLoadDelegate.m */; };
     42                1A8F02E70BB9B4EC008CFA34 /* TestObject.c in Sources */ = {isa = PBXBuildFile; fileRef = 1A8F024D0BB9B056008CFA34 /* TestObject.c */; };
     43                1A8F02E80BB9B4EC008CFA34 /* TestObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8F024C0BB9B056008CFA34 /* TestObject.h */; };
    4244                22181BD109DC8C4B008342E8 /* ObjCPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 22181BCD09DC8C4B008342E8 /* ObjCPlugin.h */; };
    4345                22181BD209DC8C4B008342E8 /* ObjCPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 22181BCE09DC8C4B008342E8 /* ObjCPlugin.m */; };
     
    106108                1A6CA8630B7120CF00A24B62 /* ResourceLoadDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadDelegate.h; sourceTree = "<group>"; };
    107109                1A6CA8640B7120CF00A24B62 /* ResourceLoadDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ResourceLoadDelegate.m; sourceTree = "<group>"; };
     110                1A8F024C0BB9B056008CFA34 /* TestObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestObject.h; sourceTree = "<group>"; };
     111                1A8F024D0BB9B056008CFA34 /* TestObject.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = TestObject.c; sourceTree = "<group>"; };
    108112                22181BCD09DC8C4B008342E8 /* ObjCPlugin.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ObjCPlugin.h; sourceTree = "<group>"; };
    109113                22181BCE09DC8C4B008342E8 /* ObjCPlugin.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = ObjCPlugin.m; sourceTree = "<group>"; };
     
    199203                                141BF446096A45C800E0753C /* PluginObject.c */,
    200204                                141BF447096A45C800E0753C /* PluginObject.h */,
     205                                1A8F024D0BB9B056008CFA34 /* TestObject.c */,
     206                                1A8F024C0BB9B056008CFA34 /* TestObject.h */,
    201207                                141BF448096A45C800E0753C /* Info.plist */,
    202208                        );
     
    265271                        files = (
    266272                                141BF453096A45EB00E0753C /* PluginObject.h in Headers */,
     273                                1A8F02E80BB9B4EC008CFA34 /* TestObject.h in Headers */,
    267274                        );
    268275                        runOnlyForDeploymentPostprocessing = 0;
     
    356363                        isa = PBXProject;
    357364                        buildConfigurationList = 149C29C308902C6D008A9EFC /* Build configuration list for PBXProject "DumpRenderTree" */;
    358                         compatibilityVersion = "Xcode 2.4";
    359365                        hasScannedForEncodings = 1;
    360366                        mainGroup = 08FB7794FE84155DC02AAC07 /* DumpRenderTree */;
     
    362368                        projectDirPath = "";
    363369                        projectRoot = "";
    364                         shouldCheckCompatibility = 1;
    365370                        targets = (
    366371                                A84F608D08B1370600E9745F /* All */,
     
    390395                                141BF44A096A45C800E0753C /* main.c in Sources */,
    391396                                141BF44B096A45C800E0753C /* PluginObject.c in Sources */,
     397                                1A8F02E70BB9B4EC008CFA34 /* TestObject.c in Sources */,
    392398                        );
    393399                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c

    r20597 r20613  
    3232 */
    3333
    34 #import "PluginObject.h"
     34#include "PluginObject.h"
     35
     36#include "TestObject.h"
     37#include <assert.h>
    3538
    3639static void pluginInvalidate(NPObject *obj);
     
    6972#define ID_PROPERTY_EVENT_LOGGING   1
    7073#define ID_PROPERTY_HAS_STREAM      2
    71 #define NUM_PROPERTY_IDENTIFIERS    3
     74#define ID_PROPERTY_TEST_OBJECT     3
     75#define NUM_PROPERTY_IDENTIFIERS    4
    7276
    7377static NPIdentifier pluginPropertyIdentifiers[NUM_PROPERTY_IDENTIFIERS];
     
    7579    "property",
    7680    "eventLoggingEnabled",
    77     "hasStream"
     81    "hasStream",
     82    "testObject"
    7883};
    7984
     
    8590#define ID_TEST_INVOKE_DEFAULT      5
    8691#define ID_DESTROY_STREAM           6
    87 #define NUM_METHOD_IDENTIFIERS      7
     92#define ID_TEST_ENUMERATE           7
     93#define NUM_METHOD_IDENTIFIERS      8
    8894
    8995static NPIdentifier pluginMethodIdentifiers[NUM_METHOD_IDENTIFIERS];
     
    95101    "getURLNotify",
    96102    "testInvokeDefault",
    97     "destroyStream"
     103    "destroyStream",
     104    "testEnumerate"
    98105};
    99106
     
    101108{
    102109    size_t length = NPVARIANT_TO_STRING(*variant).UTF8Length;
    103     NPUTF8* result = malloc(length + 1);
     110    NPUTF8* result = (NPUTF8*)malloc(length + 1);
    104111    memcpy(result, NPVARIANT_TO_STRING(*variant).UTF8Characters, length);
    105112    result[length] = '\0';
     
    139146    } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_HAS_STREAM]) {
    140147        BOOLEAN_TO_NPVARIANT(((PluginObject *)obj)->stream != 0, *variant);
     148        return true;
     149    } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_TEST_OBJECT]) {
     150        NPObject *testObject = ((PluginObject *)obj)->testObject;
     151        browser->retainobject(testObject);
     152        OBJECT_TO_NPVARIANT(testObject, *variant);
    141153        return true;
    142154    }
     
    181193        if (argCount > 0 && NPVARIANT_IS_STRING(args[0])) {
    182194            NPObject *windowScriptObject;
    183             browser->getvalue(obj->npp, NPPVpluginScriptableNPObject, &windowScriptObject);
     195            browser->getvalue(obj->npp, NPNVWindowNPObject, &windowScriptObject);
    184196
    185197            NPUTF8* callbackString = createCStringFromNPVariant(&args[0]);
     
    249261       
    250262        BOOLEAN_TO_NPVARIANT(retval, *result);
    251         return true;       
     263        return true;
     264    } else if (name == pluginMethodIdentifiers[ID_TEST_ENUMERATE]) {
     265        if (argCount == 2 && NPVARIANT_IS_OBJECT(args[0]) && NPVARIANT_IS_OBJECT(args[1])) {
     266            uint32_t count;           
     267            NPIdentifier* identifiers;
     268
     269            if (browser->enumerate(obj->npp, NPVARIANT_TO_OBJECT(args[0]), &identifiers, &count)) {
     270                NPObject* outArray = NPVARIANT_TO_OBJECT(args[1]);
     271                NPIdentifier pushIdentifier = browser->getstringidentifier("push");
     272               
     273                for (uint32_t i = 0; i < count; i++) {
     274                    NPUTF8* string = browser->utf8fromidentifier(identifiers[i]);
     275                   
     276                    if (!string)
     277                        continue;
     278                                       
     279                    NPVariant args[1];
     280                    STRINGZ_TO_NPVARIANT(string, args[0]);
     281                    NPVariant browserResult;
     282                     browser->invoke(obj->npp, outArray, pushIdentifier, args, 1, &browserResult);
     283                    browser->releasevariantvalue(&browserResult);
     284                }
     285               
     286                browser->memfree(identifiers);
     287            }
     288           
     289            VOID_TO_NPVARIANT(*result);
     290            return true;           
     291        }
    252292    } else if (name == pluginMethodIdentifiers[ID_DESTROY_STREAM]) {
    253293        assert(obj->stream);
     
    256296        return true;       
    257297    }
    258 
    259298    return false;
    260299}
     
    272311static NPObject *pluginAllocate(NPP npp, NPClass *theClass)
    273312{
    274     PluginObject *newInstance = malloc(sizeof(PluginObject));
     313    PluginObject *newInstance = (PluginObject*)malloc(sizeof(PluginObject));
    275314   
    276315    if (!identifiersInitialized) {
     
    280319
    281320    newInstance->npp = npp;
     321    newInstance->testObject = browser->createobject(npp, getTestClass());
    282322    newInstance->eventLogging = FALSE;
    283323    newInstance->stream = 0;
     
    286326}
    287327
    288 static void pluginDeallocate(NPObject *obj)
    289 {
    290     free(obj);
     328static void pluginDeallocate(NPObject *header)
     329{
     330    PluginObject* obj = (PluginObject*)header;
     331   
     332    browser->releaseobject(obj->testObject);
     333   
     334    free(header);
    291335}
    292336
     
    298342   
    299343    NPObject *windowScriptObject;
    300     browser->getvalue(object->npp, NPPVpluginScriptableNPObject, &windowScriptObject);
     344    browser->getvalue(object->npp, NPNVWindowNPObject, &windowScriptObject);
    301345   
    302346    NPIdentifier callbackIdentifier = notifyData;
  • trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h

    r20597 r20613  
    2626 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL
    2727 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
    28           OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE,
     28 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE,
    2929 REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND
    3030 WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR
     
    3939    NPObject header;
    4040    NPP npp;
    41     Boolean eventLogging;
     41    NPBool eventLogging;
     42    NPObject* testObject;
    4243    NPStream* stream;
    4344} PluginObject;
Note: See TracChangeset for help on using the changeset viewer.