diff options
Diffstat (limited to 'Source/WebCore/bindings/js/ScriptGlobalObject.cpp')
-rw-r--r-- | Source/WebCore/bindings/js/ScriptGlobalObject.cpp | 65 |
1 files changed, 20 insertions, 45 deletions
diff --git a/Source/WebCore/bindings/js/ScriptGlobalObject.cpp b/Source/WebCore/bindings/js/ScriptGlobalObject.cpp index a8b5a620f..2275ff939 100644 --- a/Source/WebCore/bindings/js/ScriptGlobalObject.cpp +++ b/Source/WebCore/bindings/js/ScriptGlobalObject.cpp @@ -31,63 +31,38 @@ #include "config.h" #include "ScriptGlobalObject.h" -#include "JSDOMBinding.h" -#include <bindings/ScriptObject.h> -#include <runtime/JSLock.h> - -#if ENABLE(INSPECTOR) +#include "JSDOMConvert.h" +#include "JSDOMExceptionHandling.h" #include "JSInspectorFrontendHost.h" -#endif +#include <runtime/IdentifierInlines.h> using namespace JSC; namespace WebCore { -static bool handleException(JSC::ExecState* scriptState) -{ - if (!scriptState->hadException()) - return true; - - reportException(scriptState, scriptState->exception()); - return false; -} - -bool ScriptGlobalObject::set(JSC::ExecState* scriptState, const char* name, const Deprecated::ScriptObject& value) -{ - JSLockHolder lock(scriptState); - scriptState->lexicalGlobalObject()->putDirect(scriptState->vm(), Identifier(scriptState, name), value.jsObject()); - return handleException(scriptState); -} - -#if ENABLE(INSPECTOR) -bool ScriptGlobalObject::set(JSC::ExecState* scriptState, const char* name, InspectorFrontendHost* value) +bool ScriptGlobalObject::set(ExecState& scriptState, const char* name, InspectorFrontendHost& value) { - JSLockHolder lock(scriptState); - JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject()); - globalObject->putDirect(scriptState->vm(), Identifier(scriptState, name), toJS(scriptState, globalObject, value)); - return handleException(scriptState); -} -#endif // ENABLE(INSPECTOR) - -bool ScriptGlobalObject::get(JSC::ExecState* scriptState, const char* name, Deprecated::ScriptObject& value) -{ - JSLockHolder lock(scriptState); - JSValue jsValue = scriptState->lexicalGlobalObject()->get(scriptState, Identifier(scriptState, name)); - if (!jsValue) - return false; - - if (!jsValue.isObject()) + auto& vm = scriptState.vm(); + JSLockHolder lock(vm); + auto scope = DECLARE_CATCH_SCOPE(vm); + auto& globalObject = *jsCast<JSDOMGlobalObject*>(scriptState.lexicalGlobalObject()); + globalObject.putDirect(vm, Identifier::fromString(&vm, name), toJS<IDLInterface<InspectorFrontendHost>>(scriptState, globalObject, value)); + if (UNLIKELY(scope.exception())) { + reportException(&scriptState, scope.exception()); return false; - - value = Deprecated::ScriptObject(scriptState, asObject(jsValue)); + } return true; } -bool ScriptGlobalObject::remove(JSC::ExecState* scriptState, const char* name) +bool ScriptGlobalObject::get(ExecState& scriptState, const char* name, JSObject*& object) { - JSLockHolder lock(scriptState); - scriptState->lexicalGlobalObject()->methodTable()->deleteProperty(scriptState->lexicalGlobalObject(), scriptState, Identifier(scriptState, name)); - return handleException(scriptState); + auto& vm = scriptState.vm(); + JSLockHolder lock(vm); + JSValue value = scriptState.lexicalGlobalObject()->get(&scriptState, Identifier::fromString(&vm, name)); + if (!value || !value.isObject()) + return false; + object = asObject(value); + return true; } } // namespace WebCore |