Changeset 64240 in webkit


Ignore:
Timestamp:
Jul 28, 2010 4:03:25 PM (14 years ago)
Author:
andersca@apple.com
Message:

Implement NPN_HasMethod
https://bugs.webkit.org/show_bug.cgi?id=43155

Reviewed by Sam Weinig.

WebKit2:

  • WebProcess/Plugins/NPJSObject.cpp:

(WebKit::NPJSObject::hasMethod):
Check if the JSObject has a property with the given name. If it does, check that the value is a function.

(WebKit::NPJSObject::hasProperty):
Add a JSLock.

(WebKit::NPJSObject::npClass):
Add some stubbed out functions.

(WebKit::NPJSObject::NP_HasMethod):
Call NPJSObject::hasMethod.

(WebKit::NPJSObject::NP_Invoke):
(WebKit::NPJSObject::NP_InvokeDefault):
(WebKit::NPJSObject::NP_SetProperty):
Stub out functions.

  • WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:

(WebKit::NPN_HasMethod):
Call the NPClass::hasMethod function.

LayoutTests:

  • platform/mac-wk2/Skipped:

Remove plugins/npruntime/invoke-browserfuncs.html.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r64237 r64240  
     12010-07-28  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Implement NPN_HasMethod
     6        https://bugs.webkit.org/show_bug.cgi?id=43155
     7
     8        * platform/mac-wk2/Skipped:
     9        Remove plugins/npruntime/invoke-browserfuncs.html.
     10       
    1112010-07-28  Adam Barth  <abarth@webkit.org>
    212
  • trunk/LayoutTests/platform/mac-wk2/Skipped

    r64235 r64240  
    14151415plugins/npruntime/enumerate.html
    14161416plugins/npruntime/get-property-return-value.html
    1417 plugins/npruntime/invoke-browserfuncs.html
    14181417plugins/npruntime/invoke-default.html
    14191418plugins/npruntime/invoke.html
  • trunk/WebKit2/ChangeLog

    r64238 r64240  
     12010-07-28  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Implement NPN_HasMethod
     6        https://bugs.webkit.org/show_bug.cgi?id=43155
     7
     8        * WebProcess/Plugins/NPJSObject.cpp:
     9        (WebKit::NPJSObject::hasMethod):
     10        Check if the JSObject has a property with the given name. If it does, check that the value is a function.
     11   
     12        (WebKit::NPJSObject::hasProperty):
     13        Add a JSLock.
     14
     15        (WebKit::NPJSObject::npClass):
     16        Add some stubbed out functions.
     17
     18        (WebKit::NPJSObject::NP_HasMethod):
     19        Call NPJSObject::hasMethod.
     20
     21        (WebKit::NPJSObject::NP_Invoke):
     22        (WebKit::NPJSObject::NP_InvokeDefault):
     23        (WebKit::NPJSObject::NP_SetProperty):
     24        Stub out functions.
     25
     26        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
     27        (WebKit::NPN_HasMethod):
     28        Call the NPClass::hasMethod function.
     29
    1302010-07-28  Brady Eidson  <beidson@apple.com>
    231
  • trunk/WebKit2/WebProcess/Plugins/NPJSObject.cpp

    r64231 r64240  
    8383}
    8484
    85 bool NPJSObject::hasProperty(NPIdentifier identifier)
    86 {
    87     IdentifierRep* identifierRep = static_cast<IdentifierRep*>(identifier);
    88    
     85bool NPJSObject::hasMethod(NPIdentifier methodName)
     86{
     87    IdentifierRep* identifierRep = static_cast<IdentifierRep*>(methodName);
     88
     89    if (!identifierRep->isString())
     90        return false;
     91
    8992    ExecState* exec = m_objectMap->globalExec();
    9093    if (!exec)
    9194        return false;
    92    
     95
     96    JSLock lock(SilenceAssertionsOnly);
     97
     98    JSValue value = m_jsObject->get(exec, identifierFromIdentifierRep(exec, identifierRep));   
     99    exec->clearException();
     100    if (!value.isObject())
     101        return false;
     102
     103    CallData callData;
     104    return value.toObject(exec)->getCallData(callData) != CallTypeNone;
     105}
     106
     107bool NPJSObject::hasProperty(NPIdentifier identifier)
     108{
     109    IdentifierRep* identifierRep = static_cast<IdentifierRep*>(identifier);
     110   
     111    ExecState* exec = m_objectMap->globalExec();
     112    if (!exec)
     113        return false;
     114   
     115    JSLock lock(SilenceAssertionsOnly);
     116
    93117    bool result;
    94118    if (identifierRep->isString())
     
    127151        NP_Allocate,
    128152        NP_Deallocate,
    129         0,
    130153        0,
    131         0,
    132         0,
     154        NP_HasMethod,
     155        NP_Invoke,
     156        NP_InvokeDefault,
    133157        NP_HasProperty,
    134158        NP_GetProperty,
    135         0,
     159        NP_SetProperty,
    136160        0,
    137161        0,
     
    155179}
    156180
     181bool NPJSObject::NP_HasMethod(NPObject* npObject, NPIdentifier methodName)
     182{
     183    return toNPJSObject(npObject)->hasMethod(methodName);
     184}
     185   
     186bool NPJSObject::NP_Invoke(NPObject*, NPIdentifier methodName, const NPVariant *arguments, uint32_t argumentCount, NPVariant *result)
     187{
     188    notImplemented();
     189    return false;
     190}
     191   
     192bool NPJSObject::NP_InvokeDefault(NPObject*, const NPVariant *arguments, uint32_t argumentCount, NPVariant *result)
     193{
     194    notImplemented();
     195    return false;
     196}
     197   
    157198bool NPJSObject::NP_HasProperty(NPObject* npObject, NPIdentifier propertyName)
    158199{
    159200    return toNPJSObject(npObject)->hasProperty(propertyName);
    160201}
    161    
     202
    162203bool NPJSObject::NP_GetProperty(NPObject* npObject, NPIdentifier propertyName, NPVariant* result)
    163204{
     
    165206}
    166207
     208bool NPJSObject::NP_SetProperty(NPObject*, NPIdentifier propertyName, const NPVariant* value)
     209{
     210    notImplemented();
     211    return false;
     212}
     213
    167214} // namespace WebKit
  • trunk/WebKit2/WebProcess/Plugins/NPJSObject.h

    r64167 r64240  
    6060    void initialize(NPRuntimeObjectMap*, JSC::JSObject* jsObject);
    6161
    62     bool hasProperty(NPIdentifier);
    63     bool getProperty(NPIdentifier, NPVariant* result);
     62    bool hasMethod(NPIdentifier methodName);
     63    bool hasProperty(NPIdentifier propertyName);
     64    bool getProperty(NPIdentifier propertyName, NPVariant* result);
    6465
    6566    static NPClass* npClass();
    6667    static NPObject* NP_Allocate(NPP, NPClass*);
    6768    static void NP_Deallocate(NPObject*);
    68     static bool NP_HasProperty(NPObject* npobj, NPIdentifier name);
    69     static bool NP_GetProperty(NPObject* npobj, NPIdentifier name, NPVariant* result);
     69    static bool NP_HasMethod(NPObject*, NPIdentifier methodName);
     70    static bool NP_Invoke(NPObject*, NPIdentifier methodName, const NPVariant *arguments, uint32_t argumentCount, NPVariant *result);
     71    static bool NP_InvokeDefault(NPObject*, const NPVariant *arguments, uint32_t argumentCount, NPVariant *result);
     72    static bool NP_HasProperty(NPObject*, NPIdentifier propertyName);
     73    static bool NP_GetProperty(NPObject*, NPIdentifier propertyName, NPVariant* result);
     74    static bool NP_SetProperty(NPObject*, NPIdentifier propertyName, const NPVariant* value);
    7075   
    7176    NPRuntimeObjectMap* m_objectMap;
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp

    r63756 r64240  
    572572}
    573573
    574 static bool NPN_HasProperty(NPP npp, NPObject *npObject, NPIdentifier propertyName)
     574static bool NPN_HasProperty(NPP, NPObject *npObject, NPIdentifier propertyName)
    575575{
    576576    if (npObject->_class->hasProperty)
     
    580580}
    581581
    582 static bool NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName)
    583 {
    584     notImplemented();
     582static bool NPN_HasMethod(NPP, NPObject *npObject, NPIdentifier methodName)
     583{
     584    if (npObject->_class->hasMethod)
     585        return npObject->_class->hasMethod(npObject, methodName);
     586
    585587    return false;
    586588}
Note: See TracChangeset for help on using the changeset viewer.