MessageEvent::MessageEvent(const AtomicString& type, const MessageEventInit& initializer) : Event(type, initializer) , m_dataType(DataTypeScriptValue) , m_origin(initializer.origin) , m_lastEventId(initializer.lastEventId) , m_source(isValidSource(initializer.source.get()) ? initializer.source : nullptr) , m_ports(adoptPtrWillBeNoop(new MessagePortArray(initializer.ports))) { ASSERT(isValidSource(m_source.get())); }
MessageEvent::MessageEvent(const AtomicString& type, const MessageEventInit& initializer) : Event(type, initializer) , m_dataType(DataTypeScriptValue) , m_origin(initializer.origin) , m_lastEventId(initializer.lastEventId) , m_source(isValidSource(initializer.source.get()) ? initializer.source : 0) , m_ports(adoptPtr(new MessagePortArray(initializer.ports))) { ScriptWrappable::init(this); ASSERT(isValidSource(m_source.get())); }
PassRefPtrWillBeRawPtr<MessageEvent> MessageEvent::create(const AtomicString& type, const MessageEventInit& initializer, ExceptionState& exceptionState) { if (initializer.source.get() && !isValidSource(initializer.source.get())) { exceptionState.throwTypeError("The optional 'source' property is neither a Window nor MessagePort."); return nullptr; } return adoptRefWillBeNoop(new MessageEvent(type, initializer)); }
MessageEvent::MessageEvent(const AtomicString& type, const MessageEventInit& initializer) : Event(type, initializer) , m_dataType(DataTypeScriptValue) , m_source(nullptr) { if (initializer.hasData()) m_dataAsScriptValue = initializer.data(); if (initializer.hasOrigin()) m_origin = initializer.origin(); if (initializer.hasLastEventId()) m_lastEventId = initializer.lastEventId(); if (initializer.hasSource() && isValidSource(initializer.source())) m_source = initializer.source(); if (initializer.hasPorts()) m_ports = new MessagePortArray(initializer.ports()); ASSERT(isValidSource(m_source.get())); }
PassRefPtr<MessageEvent> MessageEvent::create(const AtomicString& type, const MessageEventInit& initializer, ExceptionState& exceptionState) { if (initializer.source.get() && !isValidSource(initializer.source.get())) { exceptionState.throwTypeError(ExceptionMessages::failedToConstruct("MessageEvent", "The optional 'source' property is neither a Window nor MessagePort.")); return 0; } return adoptRef(new MessageEvent(type, initializer)); }
MessageEvent::MessageEvent(const String& origin, const String& lastEventId, PassRefPtrWillBeRawPtr<EventTarget> source, PassOwnPtrWillBeRawPtr<MessagePortArray> ports) : Event(EventTypeNames::message, false, false) , m_dataType(DataTypeScriptValue) , m_origin(origin) , m_lastEventId(lastEventId) , m_source(source) , m_ports(ports) { ASSERT(isValidSource(m_source.get())); }
MessageEvent::MessageEvent(const AtomicString& type, const MessageEventInit& initializer) : Event(type, initializer) , m_dataType(DataTypeScriptValue) , m_dataAsScriptValue(initializer.data) , m_origin(initializer.origin) , m_lastEventId(initializer.lastEventId) , m_source(isValidSource(initializer.source.get()) ? initializer.source : nullptr) , m_ports(std::make_unique<MessagePortArray>(initializer.ports)) { }
MessageEvent::MessageEvent(PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, PassRefPtr<EventTarget> source, std::unique_ptr<MessagePortArray> ports) : Event(eventNames().messageEvent, false, false) , m_dataType(DataTypeSerializedScriptValue) , m_dataAsSerializedScriptValue(data) , m_origin(origin) , m_lastEventId(lastEventId) , m_source(source) , m_ports(WTFMove(ports)) { ASSERT(isValidSource(m_source.get())); }
MessageEvent::MessageEvent(const ScriptValue& data, const String& origin, const String& lastEventId, PassRefPtr<EventTarget> source, PassOwnPtr<MessagePortArray> ports) : Event(eventNames().messageEvent, false, false) , m_dataType(DataTypeScriptValue) , m_dataAsScriptValue(data) , m_origin(origin) , m_lastEventId(lastEventId) , m_source(source) , m_ports(ports) { ASSERT(isValidSource(m_source.get())); }
// searches a new source for the atom node head. // If a new source is found the function returns true. // Otherwise the function returns false and unfounded_ contains head // as well as atoms with no source that circularly depend on head. bool DefaultUnfoundedCheck::findSource(NodeId head) { assert(unfounded_.empty()); enqueueUnfounded(head); // unfounded, unless we find a new source VarVec noSourceYet; bool changed = false; const NodeId* bodyIt, *bodyEnd; while (!unfounded_.empty()) { head = unfounded_.front(); if (!atoms_[head].hasSource()) { // no source unfounded_.pop_front(); // note: current atom is still marked AtomNodeP headNode(graph_->getAtom(head)); for (bodyIt = headNode.node->bodies(), bodyEnd = headNode.node->bodies_end(); bodyIt != bodyEnd; ++bodyIt) { BodyNodeP bodyNode(graph_->getBody(*bodyIt)); if (!solver_->isFalse(bodyNode.node->lit)) { if (bodyNode.node->scc != headNode.node->scc || isValidSource(bodyNode)) { atoms_[head].ufs = 0; // found a new source, setSource(headNode, bodyNode); // set the new source propagateSource(); // and propagate it forward changed = true; // may source atoms in noSourceYet! break; } else { addUnsourced(bodyNode); } } } if (!atoms_[head].hasSource()) { noSourceYet.push_back(head);// no source found } } else { // head has a source dequeueUnfounded(); } } // while unfounded_.emtpy() == false unfounded_.clear(); if (changed) { // remove all atoms that have a source as they are not unfounded VarVec::iterator it; for (it = noSourceYet.begin(); it != noSourceYet.end(); ++it) { if ( atoms_[*it].hasSource() ) { atoms_[*it].ufs = 0; } else { unfounded_.push_back(*it); } } } else { // all atoms in noSourceYet are unfounded! noSourceYet.swap(unfounded_.vec_); } return unfounded_.empty(); }
MessageEvent::MessageEvent(PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, PassRefPtrWillBeRawPtr<EventTarget> source, PassOwnPtr<MessagePortChannelArray> channels) : Event(EventTypeNames::message, false, false) , m_dataType(DataTypeSerializedScriptValue) , m_dataAsSerializedScriptValue(data) , m_origin(origin) , m_lastEventId(lastEventId) , m_source(source) , m_channels(channels) { if (m_dataAsSerializedScriptValue) m_dataAsSerializedScriptValue->registerMemoryAllocatedWithCurrentScriptContext(); ASSERT(isValidSource(m_source.get())); }
MessageEvent::MessageEvent(PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, RawPtr<EventTarget> source, MessagePortArray* ports, const String& suborigin) : Event(EventTypeNames::message, false, false) , m_dataType(DataTypeSerializedScriptValue) , m_dataAsSerializedScriptValue(data) , m_origin(origin) , m_lastEventId(lastEventId) , m_source(source) , m_ports(ports) { if (m_dataAsSerializedScriptValue) m_dataAsSerializedScriptValue->registerMemoryAllocatedWithCurrentScriptContext(); ASSERT(isValidSource(m_source.get())); }