JSEventTargetCustom.cpp [plain text]
#include "config.h"
#include "JSEventTarget.h"
#include "DOMWindow.h"
#include "EventTarget.h"
#include "EventTargetHeaders.h"
#include "EventTargetInterfaces.h"
#include "JSDOMWindow.h"
#include "JSEventListener.h"
#include "JSWindowProxy.h"
#include "JSWorkerGlobalScope.h"
#include "OffscreenCanvas.h"
#include "WorkerGlobalScope.h"
namespace WebCore {
using namespace JSC;
EventTarget* JSEventTarget::toWrapped(VM& vm, JSValue value)
{
if (value.inherits<JSWindowProxy>(vm))
return &jsCast<JSWindowProxy*>(asObject(value))->wrapped();
if (value.inherits<JSDOMWindow>(vm))
return &jsCast<JSDOMWindow*>(asObject(value))->wrapped();
if (value.inherits<JSWorkerGlobalScope>(vm))
return &jsCast<JSWorkerGlobalScope*>(asObject(value))->wrapped();
if (value.inherits<JSEventTarget>(vm))
return &jsCast<JSEventTarget*>(asObject(value))->wrapped();
return nullptr;
}
std::unique_ptr<JSEventTargetWrapper> jsEventTargetCast(VM& vm, JSValue thisValue)
{
if (auto* target = jsDynamicCast<JSEventTarget*>(vm, thisValue))
return std::make_unique<JSEventTargetWrapper>(target->wrapped(), *target);
if (auto* window = toJSDOMWindow(vm, thisValue))
return std::make_unique<JSEventTargetWrapper>(window->wrapped(), *window);
if (auto* scope = toJSWorkerGlobalScope(vm, thisValue))
return std::make_unique<JSEventTargetWrapper>(scope->wrapped(), *scope);
return nullptr;
}
void JSEventTarget::visitAdditionalChildren(SlotVisitor& visitor)
{
wrapped().visitJSEventListeners(visitor);
}
}