summaryrefslogtreecommitdiff
path: root/Source/WebCore/bindings/js/JSWorkerGlobalScopeCustom.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/bindings/js/JSWorkerGlobalScopeCustom.cpp')
-rw-r--r--Source/WebCore/bindings/js/JSWorkerGlobalScopeCustom.cpp98
1 files changed, 32 insertions, 66 deletions
diff --git a/Source/WebCore/bindings/js/JSWorkerGlobalScopeCustom.cpp b/Source/WebCore/bindings/js/JSWorkerGlobalScopeCustom.cpp
index d12d98e84..6663dfb7b 100644
--- a/Source/WebCore/bindings/js/JSWorkerGlobalScopeCustom.cpp
+++ b/Source/WebCore/bindings/js/JSWorkerGlobalScopeCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, 2009, 2011 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008-2009, 2011, 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
@@ -24,95 +24,61 @@
*/
#include "config.h"
-
#include "JSWorkerGlobalScope.h"
-#include "ExceptionCode.h"
-#include "JSDOMBinding.h"
-#include "JSDOMGlobalObject.h"
-#include "JSEventListener.h"
-#include "JSEventSource.h"
-#include "JSMessageChannel.h"
-#include "JSMessagePort.h"
-#include "JSWorkerLocation.h"
-#include "JSWorkerNavigator.h"
-#include "JSXMLHttpRequest.h"
+#include "JSDOMConvert.h"
#include "ScheduledAction.h"
#include "WorkerGlobalScope.h"
-#include "WorkerLocation.h"
-#include "WorkerNavigator.h"
-#include <interpreter/Interpreter.h>
-
-#if ENABLE(WEB_SOCKETS)
-#include "JSWebSocket.h"
-#endif
using namespace JSC;
namespace WebCore {
-void JSWorkerGlobalScope::visitChildren(JSCell* cell, SlotVisitor& visitor)
+void JSWorkerGlobalScope::visitAdditionalChildren(SlotVisitor& visitor)
{
- JSWorkerGlobalScope* thisObject = jsCast<JSWorkerGlobalScope*>(cell);
- ASSERT_GC_OBJECT_INHERITS(thisObject, info());
- COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
- ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
- Base::visitChildren(thisObject, visitor);
-
- if (WorkerLocation* location = thisObject->impl().optionalLocation())
+ if (auto* location = wrapped().optionalLocation())
visitor.addOpaqueRoot(location);
- if (WorkerNavigator* navigator = thisObject->impl().optionalNavigator())
+ if (auto* navigator = wrapped().optionalNavigator())
visitor.addOpaqueRoot(navigator);
-
- thisObject->impl().visitJSEventListeners(visitor);
-}
-
-bool JSWorkerGlobalScope::getOwnPropertySlotDelegate(ExecState* exec, PropertyName propertyName, PropertySlot& slot)
-{
- // Look for overrides before looking at any of our own properties.
- if (JSGlobalObject::getOwnPropertySlot(this, exec, propertyName, slot))
- return true;
- return false;
+ ScriptExecutionContext& context = wrapped();
+ visitor.addOpaqueRoot(&context);
+
+ // Normally JSEventTargetCustom.cpp's JSEventTarget::visitAdditionalChildren() would call this. But
+ // even though WorkerGlobalScope is an EventTarget, JSWorkerGlobalScope does not subclass
+ // JSEventTarget, so we need to do this here.
+ wrapped().visitJSEventListeners(visitor);
}
-JSValue JSWorkerGlobalScope::importScripts(ExecState* exec)
+JSValue JSWorkerGlobalScope::setTimeout(ExecState& state)
{
- if (!exec->argumentCount())
- return jsUndefined();
-
- Vector<String> urls;
- for (unsigned i = 0; i < exec->argumentCount(); i++) {
- urls.append(exec->uncheckedArgument(i).toString(exec)->value(exec));
- if (exec->hadException())
- return jsUndefined();
- }
- ExceptionCode ec = 0;
+ VM& vm = state.vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
- impl().importScripts(urls, ec);
- setDOMException(exec, ec);
- return jsUndefined();
-}
+ if (UNLIKELY(state.argumentCount() < 1))
+ return throwException(&state, scope, createNotEnoughArgumentsError(&state));
-JSValue JSWorkerGlobalScope::setTimeout(ExecState* exec)
-{
- OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, currentWorld(exec), impl().contentSecurityPolicy());
- if (exec->hadException())
- return jsUndefined();
+ std::unique_ptr<ScheduledAction> action = ScheduledAction::create(&state, globalObject()->world(), wrapped().contentSecurityPolicy());
+ RETURN_IF_EXCEPTION(scope, JSValue());
if (!action)
return jsNumber(0);
- int delay = exec->argument(1).toInt32(exec);
- return jsNumber(impl().setTimeout(action.release(), delay));
+ int delay = state.argument(1).toInt32(&state);
+ return jsNumber(wrapped().setTimeout(WTFMove(action), delay));
}
-JSValue JSWorkerGlobalScope::setInterval(ExecState* exec)
+JSValue JSWorkerGlobalScope::setInterval(ExecState& state)
{
- OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, currentWorld(exec), impl().contentSecurityPolicy());
- if (exec->hadException())
- return jsUndefined();
+ VM& vm = state.vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ if (UNLIKELY(state.argumentCount() < 1))
+ return throwException(&state, scope, createNotEnoughArgumentsError(&state));
+
+ std::unique_ptr<ScheduledAction> action = ScheduledAction::create(&state, globalObject()->world(), wrapped().contentSecurityPolicy());
+ RETURN_IF_EXCEPTION(scope, JSValue());
if (!action)
return jsNumber(0);
- int delay = exec->argument(1).toInt32(exec);
- return jsNumber(impl().setInterval(action.release(), delay));
+ int delay = state.argument(1).toInt32(&state);
+ return jsNumber(wrapped().setInterval(WTFMove(action), delay));
}
} // namespace WebCore