This source file includes following definitions.
- initMessageEvent
- data
- origin
- releaseChannels
#include "config.h"
#include "WebDOMMessageEvent.h"
#include "WebFrame.h"
#include "WebFrameImpl.h"
#include "WebSerializedScriptValue.h"
#include "bindings/v8/SerializedScriptValue.h"
#include "core/dom/Document.h"
#include "core/events/MessageEvent.h"
#include "core/dom/MessagePort.h"
#include "core/frame/DOMWindow.h"
#include "public/platform/WebString.h"
using namespace WebCore;
namespace blink {
void WebDOMMessageEvent::initMessageEvent(const WebString& type, bool canBubble, bool cancelable, const WebSerializedScriptValue& messageData, const WebString& origin, const WebFrame* sourceFrame, const WebString& lastEventId, const WebMessagePortChannelArray& webChannels)
{
ASSERT(m_private.get());
ASSERT(isMessageEvent());
DOMWindow* window = 0;
if (sourceFrame)
window = toWebFrameImpl(sourceFrame)->frame()->domWindow();
OwnPtr<MessagePortArray> ports;
if (sourceFrame)
ports = MessagePort::toMessagePortArray(window->document(), webChannels);
unwrap<MessageEvent>()->initMessageEvent(type, canBubble, cancelable, messageData, origin, lastEventId, window, ports.release());
}
WebSerializedScriptValue WebDOMMessageEvent::data() const
{
return WebSerializedScriptValue(constUnwrap<MessageEvent>()->dataAsSerializedScriptValue());
}
WebString WebDOMMessageEvent::origin() const
{
return WebString(constUnwrap<MessageEvent>()->origin());
}
WebMessagePortChannelArray WebDOMMessageEvent::releaseChannels()
{
MessagePortChannelArray* channels = constUnwrap<MessageEvent>()->channels();
WebMessagePortChannelArray webChannels(channels ? channels->size() : 0);
if (channels) {
for (size_t i = 0; i < channels->size(); ++i)
webChannels[i] = (*channels)[i].leakPtr();
}
return webChannels;
}
}