void setJSMessagePortOnmessage(ExecState* exec, JSObject* thisObject, JSValue value) { UNUSED_PARAM(exec); JSMessagePort* castedThis = static_cast<JSMessagePort*>(thisObject); MessagePort* imp = static_cast<MessagePort*>(castedThis->impl()); imp->setOnmessage(createJSAttributeEventListener(exec, value, thisObject)); }
JSValue JSC_HOST_CALL jsMessagePortPrototypeFunctionRemoveEventListener(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSMessagePort::s_info)) return throwError(exec, TypeError); JSMessagePort* castedThisObj = static_cast<JSMessagePort*>(asObject(thisValue)); return castedThisObj->removeEventListener(exec, args); }
EncodedJSValue JSC_HOST_CALL jsMessagePortPrototypeFunctionPostMessage(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSMessagePort::s_info)) return throwVMTypeError(exec); JSMessagePort* castedThis = static_cast<JSMessagePort*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSMessagePort::s_info); return JSValue::encode(castedThis->postMessage(exec)); }
bool JSMessagePortOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { JSMessagePort* jsMessagePort = static_cast<JSMessagePort*>(handle.get().asCell()); if (jsMessagePort->impl()->hasPendingActivity()) return true; if (!isObservable(jsMessagePort)) return false; MessagePort* root = jsMessagePort->impl(); return visitor.containsOpaqueRoot(root); }
JSValue JSC_HOST_CALL jsMessagePortPrototypeFunctionClose(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSMessagePort::s_info)) return throwError(exec, TypeError); JSMessagePort* castedThisObj = static_cast<JSMessagePort*>(asObject(thisValue)); MessagePort* imp = static_cast<MessagePort*>(castedThisObj->impl()); imp->close(); return jsUndefined(); }
JSValue jsMessagePortOnmessage(ExecState* exec, JSValue slotBase, const Identifier&) { JSMessagePort* castedThis = static_cast<JSMessagePort*>(asObject(slotBase)); UNUSED_PARAM(exec); MessagePort* imp = static_cast<MessagePort*>(castedThis->impl()); if (EventListener* listener = imp->onmessage()) { if (const JSEventListener* jsListener = JSEventListener::cast(listener)) { if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext())) return jsFunction; } } return jsNull(); }
void JSMessagePort::visitChildren(JSCell* cell, SlotVisitor& visitor) { JSMessagePort* thisObject = static_cast<JSMessagePort*>(cell); ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag); ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren()); Base::visitChildren(thisObject, visitor); // If we have a locally entangled port, we can directly mark it as reachable. Ports that are remotely entangled are marked in-use by markActiveObjectsForContext(). if (MessagePort* port = thisObject->m_impl->locallyEntangledPort()) visitor.addOpaqueRoot(port); thisObject->m_impl->visitJSEventListeners(visitor); }
JSValue JSC_HOST_CALL jsMessagePortPrototypeFunctionDispatchEvent(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSMessagePort::s_info)) return throwError(exec, TypeError); JSMessagePort* castedThisObj = static_cast<JSMessagePort*>(asObject(thisValue)); MessagePort* imp = static_cast<MessagePort*>(castedThisObj->impl()); ExceptionCode ec = 0; Event* evt = toEvent(args.at(0)); JSC::JSValue result = jsBoolean(imp->dispatchEvent(evt, ec)); setDOMException(exec, ec); return result; }
EncodedJSValue JSC_HOST_CALL jsMessagePortPrototypeFunctionRemoveEventListener(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSMessagePort::s_info)) return throwVMTypeError(exec); JSMessagePort* castedThis = static_cast<JSMessagePort*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSMessagePort::s_info); MessagePort* imp = static_cast<MessagePort*>(castedThis->impl()); if (exec->argumentCount() < 2) return throwVMError(exec, createTypeError(exec, "Not enough arguments")); JSValue listener = exec->argument(1); if (!listener.isObject()) return JSValue::encode(jsUndefined()); imp->removeEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)).get(), exec->argument(2).toBoolean(exec)); return JSValue::encode(jsUndefined()); }
EncodedJSValue JSC_HOST_CALL jsMessagePortPrototypeFunctionDispatchEvent(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSMessagePort::s_info)) return throwVMTypeError(exec); JSMessagePort* castedThis = static_cast<JSMessagePort*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSMessagePort::s_info); MessagePort* imp = static_cast<MessagePort*>(castedThis->impl()); if (exec->argumentCount() < 1) return throwVMError(exec, createTypeError(exec, "Not enough arguments")); ExceptionCode ec = 0; Event* evt(toEvent(exec->argument(0))); if (exec->hadException()) return JSValue::encode(jsUndefined()); JSC::JSValue result = jsBoolean(imp->dispatchEvent(evt, ec)); setDOMException(exec, ec); return JSValue::encode(result); }
void JSMessagePortOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) { JSMessagePort* jsMessagePort = static_cast<JSMessagePort*>(handle.get().asCell()); DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context); uncacheWrapper(world, jsMessagePort->impl(), jsMessagePort); }
JSValue jsMessagePortConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { JSMessagePort* domObject = static_cast<JSMessagePort*>(asObject(slotBase)); return JSMessagePort::getConstructor(exec, domObject->globalObject()); }