Commit 9c3bcda0 authored by andersca@apple.com's avatar andersca@apple.com
Browse files

Add support for NP_HasMethod and NP_Invoke

https://bugs.webkit.org/show_bug.cgi?id=48882

Reviewed by Adam Roben.

WebKit2:

* Platform/CoreIPC/HandleMessage.h:
(CoreIPC::callMemberFunction):
Add new overload.

* Shared/Plugins/NPObjectMessageReceiver.cpp:
(WebKit::NPObjectMessageReceiver::hasMethod):
Call hasMethod and return the result.

(WebKit::NPObjectMessageReceiver::invoke):
Convert the arguments, call invoke and return the result.

(WebKit::NPObjectMessageReceiver::getProperty):
Release the converted variant.

* Shared/Plugins/NPObjectMessageReceiver.messages.in:
Add HasMethod and Invoke messages.

* Shared/Plugins/NPObjectProxy.cpp:
(WebKit::NPObjectProxy::hasMethod):
Send the HasMethod message.

(WebKit::NPObjectProxy::invoke):
Send the Invoke message.

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

(WebKit::NPObjectProxy::NP_Invoke):
Call invoke.

LayoutTests:

Remove now passing tests.

* platform/mac-wk2/Skipped:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71183 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3cf68b35
2010-11-02 Anders Carlsson <andersca@apple.com>
Reviewed by Adam Roben.
Add support for NP_HasMethod and NP_Invoke
https://bugs.webkit.org/show_bug.cgi?id=48882
Remove now passing tests.
* platform/mac-wk2/Skipped:
2010-11-02 Simon Fraser <simon.fraser@apple.com>
 
Reviewed by Dan Bernstein.
......@@ -1717,8 +1717,6 @@ http/tests/plugins/npapi-response-headers.html
plugins/destroy-during-npp-new.html
plugins/destroy-stream-twice.html
plugins/embed-inside-object.html
plugins/get-empty-url.html
plugins/get-file-url.html
plugins/get-javascript-url.html
plugins/get-url-with-iframe-target.html
plugins/geturl-replace-query.html
......@@ -1744,7 +1742,6 @@ plugins/npruntime/get-property-return-value.html
plugins/npruntime/identifier-conversion.html
plugins/npruntime/invoke-browserfuncs.html
plugins/npruntime/invoke-default.html
plugins/npruntime/invoke.html
plugins/npruntime/npruntime.html
plugins/npruntime/object-from-destroyed-plugin.html
plugins/npruntime/plugin-scriptable-object-invoke-default.html
......
2010-11-02 Anders Carlsson <andersca@apple.com>
Reviewed by Adam Roben.
Add support for NP_HasMethod and NP_Invoke
https://bugs.webkit.org/show_bug.cgi?id=48882
* Platform/CoreIPC/HandleMessage.h:
(CoreIPC::callMemberFunction):
Add new overload.
* Shared/Plugins/NPObjectMessageReceiver.cpp:
(WebKit::NPObjectMessageReceiver::hasMethod):
Call hasMethod and return the result.
(WebKit::NPObjectMessageReceiver::invoke):
Convert the arguments, call invoke and return the result.
(WebKit::NPObjectMessageReceiver::getProperty):
Release the converted variant.
* Shared/Plugins/NPObjectMessageReceiver.messages.in:
Add HasMethod and Invoke messages.
* Shared/Plugins/NPObjectProxy.cpp:
(WebKit::NPObjectProxy::hasMethod):
Send the HasMethod message.
(WebKit::NPObjectProxy::invoke):
Send the Invoke message.
(WebKit::NPObjectProxy::NP_HasMethod):
Call hasMethod.
(WebKit::NPObjectProxy::NP_Invoke):
Call invoke.
2010-11-02 Anders Carlsson <andersca@apple.com>
 
Reviewed by Sam Weinig.
......
......@@ -103,6 +103,12 @@ void callMemberFunction(const Arguments2<P1, P2>& args, Arguments1<R1>& replyArg
(object->*function)(args.argument1, args.argument2, replyArgs.argument1);
}
template<typename C, typename MF, typename P1, typename P2, typename R1, typename R2>
void callMemberFunction(const Arguments2<P1, P2>& args, Arguments2<R1, R2>& replyArgs, C* object, MF function)
{
(object->*function)(args.argument1, args.argument2, replyArgs.argument1, replyArgs.argument2);
}
template<typename C, typename MF, typename P1, typename P2, typename P3, typename R1>
void callMemberFunction(const Arguments3<P1, P2, P3>& args, Arguments1<R1>& replyArgs, C* object, MF function)
{
......
......@@ -60,6 +60,43 @@ void NPObjectMessageReceiver::deallocate()
delete this;
}
void NPObjectMessageReceiver::hasMethod(const NPIdentifierData& methodNameData, bool& returnValue)
{
if (!m_npObject->_class->hasMethod) {
returnValue = false;
return;
}
returnValue = m_npObject->_class->hasMethod(m_npObject, methodNameData.createNPIdentifier());
}
void NPObjectMessageReceiver::invoke(const NPIdentifierData& methodNameData, const Vector<NPVariantData>& argumentsData, bool& returnValue, NPVariantData& resultData)
{
if (!m_npObject->_class->invoke) {
returnValue = false;
return;
}
Vector<NPVariant> arguments;
for (size_t i = 0; i < argumentsData.size(); ++i)
arguments.append(m_npRemoteObjectMap->npVariantDataToNPVariant(argumentsData[i]));
NPVariant result;
returnValue = m_npObject->_class->invoke(m_npObject, methodNameData.createNPIdentifier(), arguments.data(), arguments.size(), &result);
if (!returnValue)
return;
// Convert the NPVariant to an NPVariantData.
resultData = m_npRemoteObjectMap->npVariantToNPVariantData(result);
// Release all arguments.
for (size_t i = 0; i < argumentsData.size(); ++i)
releaseNPVariantValue(&arguments[i]);
// And release the result.
releaseNPVariantValue(&result);
}
void NPObjectMessageReceiver::hasProperty(const NPIdentifierData& propertyNameData, bool& returnValue)
{
if (!m_npObject->_class->hasProperty) {
......@@ -84,6 +121,9 @@ void NPObjectMessageReceiver::getProperty(const NPIdentifierData& propertyNameDa
// Convert the NPVariant to an NPVariantData.
resultData = m_npRemoteObjectMap->npVariantToNPVariantData(result);
// And release the result.
releaseNPVariantValue(&result);
}
} // namespace WebKit
......
......@@ -53,6 +53,8 @@ private:
// Message handlers.
void deallocate();
void hasMethod(const NPIdentifierData&, bool& returnValue);
void invoke(const NPIdentifierData&, const Vector<NPVariantData>& argumentsData, bool& returnValue, NPVariantData& resultData);
void hasProperty(const NPIdentifierData&, bool& returnValue);
void getProperty(const NPIdentifierData&, bool& returnValue, NPVariantData& resultData);
......
......@@ -24,6 +24,8 @@
messages -> NPObjectMessageReceiver {
Deallocate() -> ()
HasMethod(WebKit::NPIdentifierData methodName) -> (bool returnValue)
Invoke(WebKit::NPIdentifierData methodName, Vector<WebKit::NPVariantData> argumentsData) -> (bool returnValue, WebKit::NPVariantData resultData)
HasProperty(WebKit::NPIdentifierData propertyName) -> (bool returnValue)
GetProperty(WebKit::NPIdentifierData propertyName) -> (bool returnValue, WebKit::NPVariantData resultData)
}
......
......@@ -27,6 +27,7 @@
#include "NPObjectProxy.h"
#include "ArgumentCoders.h"
#include "Connection.h"
#include "NPIdentifierData.h"
#include "NPObjectMessageReceiverMessages.h"
......@@ -84,6 +85,44 @@ void NPObjectProxy::initialize(NPRemoteObjectMap* npRemoteObjectMap, uint64_t np
m_npObjectID = npObjectID;
}
bool NPObjectProxy::hasMethod(NPIdentifier methodName)
{
if (!m_npRemoteObjectMap)
return false;
NPIdentifierData methodNameData = NPIdentifierData::fromNPIdentifier(methodName);
bool returnValue = false;
if (!m_npRemoteObjectMap->connection()->sendSync(Messages::NPObjectMessageReceiver::HasMethod(methodNameData), Messages::NPObjectMessageReceiver::HasMethod::Reply(returnValue), m_npObjectID))
return false;
return returnValue;
}
bool NPObjectProxy::invoke(NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)
{
if (!m_npRemoteObjectMap)
return false;
NPIdentifierData methodNameData = NPIdentifierData::fromNPIdentifier(methodName);
Vector<NPVariantData> argumentsData;
for (uint32_t i = 0; i < argumentCount; ++i)
argumentsData.append(m_npRemoteObjectMap->npVariantToNPVariantData(arguments[i]));
bool returnValue = false;
NPVariantData resultData;
if (!m_npRemoteObjectMap->connection()->sendSync(Messages::NPObjectMessageReceiver::Invoke(methodNameData, argumentsData), Messages::NPObjectMessageReceiver::Invoke::Reply(returnValue, resultData), m_npObjectID))
return false;
if (!returnValue)
return false;
*result = m_npRemoteObjectMap->npVariantDataToNPVariant(resultData);
return true;
}
bool NPObjectProxy::hasProperty(NPIdentifier propertyName)
{
if (!m_npRemoteObjectMap)
......@@ -153,16 +192,14 @@ void NPObjectProxy::NP_Deallocate(NPObject* npObject)
delete npObjectProxy;
}
bool NPObjectProxy::NP_HasMethod(NPObject*, NPIdentifier methodName)
bool NPObjectProxy::NP_HasMethod(NPObject* npObject, NPIdentifier methodName)
{
notImplemented();
return false;
return toNPObjectProxy(npObject)->hasMethod(methodName);
}
bool NPObjectProxy::NP_Invoke(NPObject*, NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)
bool NPObjectProxy::NP_Invoke(NPObject* npObject, NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)
{
notImplemented();
return false;
return toNPObjectProxy(npObject)->invoke(methodName, arguments, argumentCount, result);
}
bool NPObjectProxy::NP_InvokeDefault(NPObject*, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)
......
......@@ -57,6 +57,8 @@ private:
void initialize(NPRemoteObjectMap* npRemoteObjectMap, uint64_t npObjectID);
bool hasMethod(NPIdentifier methodName);
bool invoke(NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result);
bool hasProperty(NPIdentifier propertyName);
bool getProperty(NPIdentifier propertyName, NPVariant* result);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment