summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/v8/NPV8Object.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-05-26 10:11:43 +0100
committerSteve Block <steveblock@google.com>2010-05-27 11:14:42 +0100
commite78cbe89e6f337f2f1fe40315be88f742b547151 (patch)
treed778000b84a04f24bbad50c7fa66244365e960e9 /WebCore/bindings/v8/NPV8Object.cpp
parent7b582e96e4e909ed7dba1e07153d20fbddaec3f7 (diff)
downloadexternal_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.zip
external_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.tar.gz
external_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.tar.bz2
Merge WebKit at r60074: Initial merge by git
Change-Id: I18a2dc5439e36c928351ea829d8fb4e39b062fc7
Diffstat (limited to 'WebCore/bindings/v8/NPV8Object.cpp')
-rw-r--r--WebCore/bindings/v8/NPV8Object.cpp58
1 files changed, 32 insertions, 26 deletions
diff --git a/WebCore/bindings/v8/NPV8Object.cpp b/WebCore/bindings/v8/NPV8Object.cpp
index 56f9810..d8076f3 100644
--- a/WebCore/bindings/v8/NPV8Object.cpp
+++ b/WebCore/bindings/v8/NPV8Object.cpp
@@ -52,13 +52,7 @@
#include <v8.h>
#include <wtf/StringExtras.h>
-using WebCore::npObjectInternalFieldCount;
-using WebCore::toV8Context;
-using WebCore::toV8Proxy;
-using WebCore::V8DOMWrapper;
-using WebCore::V8GCController;
-using WebCore::V8Proxy;
-using WebCore::WrapperTypeInfo;
+using namespace WebCore;
namespace WebCore {
@@ -68,8 +62,6 @@ WrapperTypeInfo* npObjectTypeInfo()
return &typeInfo;
}
-}
-
// FIXME: Comments on why use malloc and free.
static NPObject* allocV8NPObject(NPP, NPClass*)
{
@@ -110,7 +102,7 @@ static v8::Local<v8::String> npIdentifierToV8Identifier(NPIdentifier name)
NPObject* v8ObjectToNPObject(v8::Handle<v8::Object> object)
{
- return reinterpret_cast<NPObject*>(object->GetPointerFromInternalField(WebCore::v8DOMWrapperObjectIndex));
+ return reinterpret_cast<NPObject*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex));
}
static NPClass V8NPObjectClass = { NP_CLASS_STRUCT_VERSION,
@@ -121,12 +113,12 @@ static NPClass V8NPObjectClass = { NP_CLASS_STRUCT_VERSION,
// NPAPI's npruntime functions.
NPClass* npScriptObjectClass = &V8NPObjectClass;
-NPObject* npCreateV8ScriptObject(NPP npp, v8::Handle<v8::Object> object, WebCore::DOMWindow* root)
+NPObject* npCreateV8ScriptObject(NPP npp, v8::Handle<v8::Object> object, DOMWindow* root)
{
// Check to see if this object is already wrapped.
if (object->InternalFieldCount() == npObjectInternalFieldCount) {
- WrapperTypeInfo* typeInfo = static_cast<WrapperTypeInfo*>(object->GetPointerFromInternalField(WebCore::v8DOMWrapperTypeIndex));
- if (typeInfo == WebCore::npObjectTypeInfo()) {
+ WrapperTypeInfo* typeInfo = static_cast<WrapperTypeInfo*>(object->GetPointerFromInternalField(v8DOMWrapperTypeIndex));
+ if (typeInfo == npObjectTypeInfo()) {
NPObject* returnValue = v8ObjectToNPObject(object);
_NPN_RetainObject(returnValue);
@@ -137,12 +129,14 @@ NPObject* npCreateV8ScriptObject(NPP npp, v8::Handle<v8::Object> object, WebCore
V8NPObject* v8npObject = reinterpret_cast<V8NPObject*>(_NPN_CreateObject(npp, &V8NPObjectClass));
v8npObject->v8Object = v8::Persistent<v8::Object>::New(object);
#ifndef NDEBUG
- V8GCController::registerGlobalHandle(WebCore::NPOBJECT, v8npObject, v8npObject->v8Object);
+ V8GCController::registerGlobalHandle(NPOBJECT, v8npObject, v8npObject->v8Object);
#endif
v8npObject->rootObject = root;
return reinterpret_cast<NPObject*>(v8npObject);
}
+} // namespace WebCore
+
bool _NPN_Invoke(NPP npp, NPObject* npObject, NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)
{
if (!npObject)
@@ -162,6 +156,14 @@ bool _NPN_Invoke(NPP npp, NPObject* npObject, NPIdentifier methodName, const NPV
if (!identifier->isString)
return false;
+ if (!strcmp(identifier->value.string, "eval")) {
+ if (argumentCount != 1)
+ return false;
+ if (arguments[0].type != NPVariantType_String)
+ return false;
+ return _NPN_Evaluate(npp, npObject, const_cast<NPString*>(&arguments[0].value.stringValue), result);
+ }
+
v8::HandleScope handleScope;
// FIXME: should use the plugin's owner frame as the security context.
v8::Handle<v8::Context> context = toV8Context(npp, npObject);
@@ -169,14 +171,7 @@ bool _NPN_Invoke(NPP npp, NPObject* npObject, NPIdentifier methodName, const NPV
return false;
v8::Context::Scope scope(context);
-
- if (methodName == _NPN_GetStringIdentifier("eval")) {
- if (argumentCount != 1)
- return false;
- if (arguments[0].type != NPVariantType_String)
- return false;
- return _NPN_Evaluate(npp, npObject, const_cast<NPString*>(&arguments[0].value.stringValue), result);
- }
+ ExceptionCatcher exceptionCatcher;
v8::Handle<v8::Value> functionObject = v8NpObject->v8Object->Get(v8::String::New(identifier->value.string));
if (functionObject.IsEmpty() || functionObject->IsNull()) {
@@ -229,6 +224,7 @@ bool _NPN_InvokeDefault(NPP npp, NPObject* npObject, const NPVariant* arguments,
return false;
v8::Context::Scope scope(context);
+ ExceptionCatcher exceptionCatcher;
// Lookup the function object and call it.
v8::Handle<v8::Object> functionObject(v8NpObject->v8Object);
@@ -255,7 +251,7 @@ bool _NPN_InvokeDefault(NPP npp, NPObject* npObject, const NPVariant* arguments,
bool _NPN_Evaluate(NPP npp, NPObject* npObject, NPString* npScript, NPVariant* result)
{
- bool popupsAllowed = WebCore::PlatformBridge::popupsAllowed(npp);
+ bool popupsAllowed = PlatformBridge::popupsAllowed(npp);
return _NPN_EvaluateHelper(npp, popupsAllowed, npObject, npScript, result);
}
@@ -277,13 +273,14 @@ bool _NPN_EvaluateHelper(NPP npp, bool popupsAllowed, NPObject* npObject, NPStri
ASSERT(proxy);
v8::Context::Scope scope(context);
+ ExceptionCatcher exceptionCatcher;
- WebCore::String filename;
+ String filename;
if (!popupsAllowed)
filename = "npscript";
- WebCore::String script = WebCore::String::fromUTF8(npScript->UTF8Characters, npScript->UTF8Length);
- v8::Local<v8::Value> v8result = proxy->evaluate(WebCore::ScriptSourceCode(script, WebCore::KURL(WebCore::ParsedURLString, filename)), 0);
+ String script = String::fromUTF8(npScript->UTF8Characters, npScript->UTF8Length);
+ v8::Local<v8::Value> v8result = proxy->evaluate(ScriptSourceCode(script, KURL(ParsedURLString, filename)), 0);
if (v8result.IsEmpty())
return false;
@@ -306,6 +303,7 @@ bool _NPN_GetProperty(NPP npp, NPObject* npObject, NPIdentifier propertyName, NP
return false;
v8::Context::Scope scope(context);
+ ExceptionCatcher exceptionCatcher;
v8::Handle<v8::Object> obj(object->v8Object);
v8::Local<v8::Value> v8result = obj->Get(npIdentifierToV8Identifier(propertyName));
@@ -340,6 +338,7 @@ bool _NPN_SetProperty(NPP npp, NPObject* npObject, NPIdentifier propertyName, co
return false;
v8::Context::Scope scope(context);
+ ExceptionCatcher exceptionCatcher;
v8::Handle<v8::Object> obj(object->v8Object);
obj->Set(npIdentifierToV8Identifier(propertyName),
@@ -367,6 +366,7 @@ bool _NPN_RemoveProperty(NPP npp, NPObject* npObject, NPIdentifier propertyName)
if (context.IsEmpty())
return false;
v8::Context::Scope scope(context);
+ ExceptionCatcher exceptionCatcher;
v8::Handle<v8::Object> obj(object->v8Object);
// FIXME: Verify that setting to undefined is right.
@@ -387,6 +387,7 @@ bool _NPN_HasProperty(NPP npp, NPObject* npObject, NPIdentifier propertyName)
if (context.IsEmpty())
return false;
v8::Context::Scope scope(context);
+ ExceptionCatcher exceptionCatcher;
v8::Handle<v8::Object> obj(object->v8Object);
return obj->Has(npIdentifierToV8Identifier(propertyName));
@@ -410,6 +411,7 @@ bool _NPN_HasMethod(NPP npp, NPObject* npObject, NPIdentifier methodName)
if (context.IsEmpty())
return false;
v8::Context::Scope scope(context);
+ ExceptionCatcher exceptionCatcher;
v8::Handle<v8::Object> obj(object->v8Object);
v8::Handle<v8::Value> prop = obj->Get(npIdentifierToV8Identifier(methodName));
@@ -439,6 +441,8 @@ void _NPN_SetException(NPObject* npObject, const NPUTF8 *message)
return;
v8::Context::Scope scope(context);
+ ExceptionCatcher exceptionCatcher;
+
V8Proxy::throwError(V8Proxy::GeneralError, message);
}
@@ -455,6 +459,7 @@ bool _NPN_Enumerate(NPP npp, NPObject* npObject, NPIdentifier** identifier, uint
if (context.IsEmpty())
return false;
v8::Context::Scope scope(context);
+ ExceptionCatcher exceptionCatcher;
v8::Handle<v8::Object> obj(object->v8Object);
@@ -509,6 +514,7 @@ bool _NPN_Construct(NPP npp, NPObject* npObject, const NPVariant* arguments, uin
if (context.IsEmpty())
return false;
v8::Context::Scope scope(context);
+ ExceptionCatcher exceptionCatcher;
// Lookup the constructor function.
v8::Handle<v8::Object> ctorObj(object->v8Object);