diff options
Diffstat (limited to 'WebCore/bindings/js/JSWorkerContextBase.cpp')
-rw-r--r-- | WebCore/bindings/js/JSWorkerContextBase.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/WebCore/bindings/js/JSWorkerContextBase.cpp b/WebCore/bindings/js/JSWorkerContextBase.cpp index c71f45b..1e4df42 100644 --- a/WebCore/bindings/js/JSWorkerContextBase.cpp +++ b/WebCore/bindings/js/JSWorkerContextBase.cpp @@ -31,6 +31,8 @@ #include "JSWorkerContextBase.h" +#include "JSDedicatedWorkerContext.h" +#include "JSSharedWorkerContext.h" #include "JSWorkerContext.h" #include "WorkerContext.h" @@ -57,6 +59,11 @@ ScriptExecutionContext* JSWorkerContextBase::scriptExecutionContext() const return m_impl.get(); } +JSValue toJS(ExecState* exec, JSDOMGlobalObject*, WorkerContext* workerContext) +{ + return toJS(exec, workerContext); +} + JSValue toJS(ExecState*, WorkerContext* workerContext) { if (!workerContext) @@ -67,6 +74,38 @@ JSValue toJS(ExecState*, WorkerContext* workerContext) return script->workerContextWrapper(); } +JSDedicatedWorkerContext* toJSDedicatedWorkerContext(JSValue value) +{ + if (!value.isObject()) + return 0; + const ClassInfo* classInfo = asObject(value)->classInfo(); + if (classInfo == &JSDedicatedWorkerContext::s_info) + return static_cast<JSDedicatedWorkerContext*>(asObject(value)); + return 0; +} + +#if ENABLE(SHARED_WORKERS) +JSSharedWorkerContext* toJSSharedWorkerContext(JSValue value) +{ + if (!value.isObject()) + return 0; + const ClassInfo* classInfo = asObject(value)->classInfo(); + if (classInfo == &JSSharedWorkerContext::s_info) + return static_cast<JSSharedWorkerContext*>(asObject(value)); + return 0; +} +#endif + +JSWorkerContext* toJSWorkerContext(JSValue value) +{ + JSWorkerContext* context = toJSDedicatedWorkerContext(value); +#if ENABLE(SHARED_WORKERS) + if (!context) + context = toJSSharedWorkerContext(value); +#endif + return context; +} + } // namespace WebCore #endif // ENABLE(WORKERS) |