diff options
Diffstat (limited to 'Source/WebCore/bridge/runtime_method.cpp')
-rw-r--r-- | Source/WebCore/bridge/runtime_method.cpp | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/Source/WebCore/bridge/runtime_method.cpp b/Source/WebCore/bridge/runtime_method.cpp index eb4ee9aa1..fe55f76dc 100644 --- a/Source/WebCore/bridge/runtime_method.cpp +++ b/Source/WebCore/bridge/runtime_method.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2003, 2008, 2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,10 +10,10 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -39,7 +39,7 @@ namespace JSC { using namespace Bindings; -const ClassInfo RuntimeMethod::s_info = { "RuntimeMethod", &InternalFunction::s_info, 0, 0, CREATE_METHOD_TABLE(RuntimeMethod) }; +WEBCORE_EXPORT const ClassInfo RuntimeMethod::s_info = { "RuntimeMethod", &InternalFunction::s_info, 0, CREATE_METHOD_TABLE(RuntimeMethod) }; RuntimeMethod::RuntimeMethod(JSGlobalObject* globalObject, Structure* structure, Method* method) // Callers will need to pass in the right global object corresponding to this native object "method". @@ -51,14 +51,17 @@ RuntimeMethod::RuntimeMethod(JSGlobalObject* globalObject, Structure* structure, void RuntimeMethod::finishCreation(VM& vm, const String& ident) { Base::finishCreation(vm, ident); - ASSERT(inherits(info())); + ASSERT(inherits(vm, info())); } -EncodedJSValue RuntimeMethod::lengthGetter(ExecState* exec, EncodedJSValue, EncodedJSValue thisValue, PropertyName) +EncodedJSValue RuntimeMethod::lengthGetter(ExecState* exec, EncodedJSValue thisValue, PropertyName) { - RuntimeMethod* thisObject = jsDynamicCast<RuntimeMethod*>(JSValue::decode(thisValue)); + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + RuntimeMethod* thisObject = jsDynamicDowncast<RuntimeMethod*>(vm, JSValue::decode(thisValue)); if (!thisObject) - return throwVMTypeError(exec); + return throwVMTypeError(exec, scope); return JSValue::encode(jsNumber(thisObject->m_method->numParameters())); } @@ -75,25 +78,28 @@ bool RuntimeMethod::getOwnPropertySlot(JSObject* object, ExecState* exec, Proper static EncodedJSValue JSC_HOST_CALL callRuntimeMethod(ExecState* exec) { - RuntimeMethod* method = static_cast<RuntimeMethod*>(exec->callee()); + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + RuntimeMethod* method = static_cast<RuntimeMethod*>(exec->jsCallee()); if (!method->method()) return JSValue::encode(jsUndefined()); RefPtr<Instance> instance; - JSValue thisValue = exec->hostThisValue(); - if (thisValue.inherits(RuntimeObject::info())) { + JSValue thisValue = exec->thisValue(); + if (thisValue.inherits(vm, RuntimeObject::info())) { RuntimeObject* runtimeObject = static_cast<RuntimeObject*>(asObject(thisValue)); instance = runtimeObject->getInternalInstance(); if (!instance) - return JSValue::encode(RuntimeObject::throwInvalidAccessError(exec)); + return JSValue::encode(RuntimeObject::throwInvalidAccessError(exec, scope)); } else { // Calling a runtime object of a plugin element? - if (thisValue.inherits(JSHTMLElement::info())) - instance = pluginInstance(jsCast<JSHTMLElement*>(asObject(thisValue))->impl()); + if (thisValue.inherits(vm, JSHTMLElement::info())) + instance = pluginInstance(jsCast<JSHTMLElement*>(asObject(thisValue))->wrapped()); if (!instance) - return throwVMTypeError(exec); + return throwVMTypeError(exec, scope); } ASSERT(instance); @@ -106,7 +112,7 @@ static EncodedJSValue JSC_HOST_CALL callRuntimeMethod(ExecState* exec) CallType RuntimeMethod::getCallData(JSCell*, CallData& callData) { callData.native.function = callRuntimeMethod; - return CallTypeHost; + return CallType::Host; } } |