summaryrefslogtreecommitdiff
path: root/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp')
-rw-r--r--Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp73
1 files changed, 49 insertions, 24 deletions
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp
index f33574018..aa75a920d 100644
--- a/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp
+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp
@@ -31,12 +31,11 @@
#include "JSNPObject.h"
#include "NPRuntimeObjectMap.h"
#include "NPRuntimeUtilities.h"
-#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/JSCInlines.h>
#include <JavaScriptCore/JSCellInlines.h>
#include <JavaScriptCore/JSLock.h>
#include <JavaScriptCore/JSObject.h>
#include <JavaScriptCore/StrongInlines.h>
-#include <JavaScriptCore/StructureInlines.h>
#include <WebCore/Frame.h>
#include <WebCore/IdentifierRep.h>
#include <wtf/text/WTFString.h>
@@ -49,7 +48,7 @@ namespace WebKit {
NPJSObject* NPJSObject::create(VM& vm, NPRuntimeObjectMap* objectMap, JSObject* jsObject)
{
// We should never have a JSNPObject inside an NPJSObject.
- ASSERT(!jsObject->inherits(JSNPObject::info()));
+ ASSERT(!jsObject->inherits(vm, JSNPObject::info()));
NPJSObject* npJSObject = toNPJSObject(createNPObject(0, npClass()));
npJSObject->initialize(vm, objectMap, jsObject);
@@ -88,7 +87,7 @@ static Identifier identifierFromIdentifierRep(ExecState* exec, IdentifierRep* id
const char* string = identifierRep->string();
int length = strlen(string);
- return Identifier(exec, String::fromUTF8WithLatin1Fallback(string, length).impl());
+ return Identifier::fromString(exec, String::fromUTF8WithLatin1Fallback(string, length));
}
bool NPJSObject::hasMethod(NPIdentifier methodName)
@@ -102,13 +101,15 @@ bool NPJSObject::hasMethod(NPIdentifier methodName)
if (!exec)
return false;
- JSLockHolder lock(exec);
+ VM& vm = exec->vm();
+ JSLockHolder lock(vm);
+ auto scope = DECLARE_CATCH_SCOPE(vm);
JSValue value = m_jsObject->get(exec, identifierFromIdentifierRep(exec, identifierRep));
- exec->clearException();
+ scope.clearException();
CallData callData;
- return getCallData(value, callData) != CallTypeNone;
+ return getCallData(value, callData) != CallType::None;
}
bool NPJSObject::invoke(NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)
@@ -148,7 +149,9 @@ bool NPJSObject::hasProperty(NPIdentifier identifier)
if (!exec)
return false;
- JSLockHolder lock(exec);
+ VM& vm = exec->vm();
+ JSLockHolder lock(vm);
+ auto scope = DECLARE_CATCH_SCOPE(vm);
bool result;
if (identifierRep->isString())
@@ -156,7 +159,7 @@ bool NPJSObject::hasProperty(NPIdentifier identifier)
else
result = m_jsObject->hasProperty(exec, identifierRep->number());
- exec->clearException();
+ scope.clearException();
return result;
}
@@ -168,7 +171,10 @@ bool NPJSObject::getProperty(NPIdentifier propertyName, NPVariant* result)
if (!exec)
return false;
- JSLockHolder lock(exec);
+ VM& vm = exec->vm();
+ JSLockHolder lock(vm);
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+
JSValue jsResult;
if (identifierRep->isString())
jsResult = m_jsObject->get(exec, identifierFromIdentifierRep(exec, identifierRep));
@@ -176,7 +182,7 @@ bool NPJSObject::getProperty(NPIdentifier propertyName, NPVariant* result)
jsResult = m_jsObject->get(exec, identifierRep->number());
m_objectMap->convertJSValueToNPVariant(exec, jsResult, *result);
- exec->clearException();
+ scope.clearException();
return true;
}
@@ -188,7 +194,9 @@ bool NPJSObject::setProperty(NPIdentifier propertyName, const NPVariant* value)
if (!exec)
return false;
- JSLockHolder lock(exec);
+ VM& vm = exec->vm();
+ JSLockHolder lock(vm);
+ auto scope = DECLARE_CATCH_SCOPE(vm);
JSValue jsValue = m_objectMap->convertNPVariantToJSValue(exec, m_objectMap->globalObject(), *value);
if (identifierRep->isString()) {
@@ -196,7 +204,7 @@ bool NPJSObject::setProperty(NPIdentifier propertyName, const NPVariant* value)
m_jsObject->methodTable()->put(m_jsObject.get(), exec, identifierFromIdentifierRep(exec, identifierRep), jsValue, slot);
} else
m_jsObject->methodTable()->putByIndex(m_jsObject.get(), exec, identifierRep->number(), jsValue, false);
- exec->clearException();
+ scope.clearException();
return true;
}
@@ -209,26 +217,29 @@ bool NPJSObject::removeProperty(NPIdentifier propertyName)
if (!exec)
return false;
- JSLockHolder lock(exec);
+ VM& vm = exec->vm();
+ JSLockHolder lock(vm);
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+
if (identifierRep->isString()) {
Identifier identifier = identifierFromIdentifierRep(exec, identifierRep);
if (!m_jsObject->hasProperty(exec, identifier)) {
- exec->clearException();
+ scope.clearException();
return false;
}
m_jsObject->methodTable()->deleteProperty(m_jsObject.get(), exec, identifier);
} else {
if (!m_jsObject->hasProperty(exec, identifierRep->number())) {
- exec->clearException();
+ scope.clearException();
return false;
}
m_jsObject->methodTable()->deletePropertyByIndex(m_jsObject.get(), exec, identifierRep->number());
}
- exec->clearException();
+ scope.clearException();
return true;
}
@@ -240,8 +251,8 @@ bool NPJSObject::enumerate(NPIdentifier** identifiers, uint32_t* identifierCount
JSLockHolder lock(exec);
- PropertyNameArray propertyNames(exec);
- m_jsObject->methodTable()->getPropertyNames(m_jsObject.get(), exec, propertyNames, ExcludeDontEnumProperties);
+ PropertyNameArray propertyNames(exec, PropertyNameMode::Strings);
+ m_jsObject->methodTable()->getPropertyNames(m_jsObject.get(), exec, propertyNames, EnumerationMode());
NPIdentifier* nameIdentifiers = npnMemNewArray<NPIdentifier>(propertyNames.size());
@@ -260,11 +271,13 @@ bool NPJSObject::construct(const NPVariant* arguments, uint32_t argumentCount, N
if (!exec)
return false;
- JSLockHolder lock(exec);
+ VM& vm = exec->vm();
+ JSLockHolder lock(vm);
+ auto scope = DECLARE_CATCH_SCOPE(vm);
ConstructData constructData;
ConstructType constructType = getConstructData(m_jsObject.get(), constructData);
- if (constructType == ConstructTypeNone)
+ if (constructType == ConstructType::None)
return false;
// Convert the passed in arguments.
@@ -276,16 +289,19 @@ bool NPJSObject::construct(const NPVariant* arguments, uint32_t argumentCount, N
// Convert and return the new object.
m_objectMap->convertJSValueToNPVariant(exec, value, *result);
- exec->clearException();
+ scope.clearException();
return true;
}
bool NPJSObject::invoke(ExecState* exec, JSGlobalObject* globalObject, JSValue function, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)
{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+
CallData callData;
CallType callType = getCallData(function, callData);
- if (callType == CallTypeNone)
+ if (callType == CallType::None)
return false;
// Convert the passed in arguments.
@@ -295,9 +311,18 @@ bool NPJSObject::invoke(ExecState* exec, JSGlobalObject* globalObject, JSValue f
JSValue value = JSC::call(exec, function, callType, callData, m_jsObject.get(), argumentList);
+ if (UNLIKELY(scope.exception())) {
+ scope.clearException();
+ return false;
+ }
+
// Convert and return the result of the function call.
m_objectMap->convertJSValueToNPVariant(exec, value, *result);
- exec->clearException();
+
+ if (UNLIKELY(scope.exception())) {
+ scope.clearException();
+ return false;
+ }
return true;
}