2015-05-03 19:32:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-01-30 01:31:29 +00:00
|
|
|
|
2014-02-27 10:51:14 +00:00
|
|
|
#ifndef mozilla_dom_MessageEvent_h_
|
|
|
|
#define mozilla_dom_MessageEvent_h_
|
2008-01-30 01:31:29 +00:00
|
|
|
|
2014-03-05 00:37:43 +00:00
|
|
|
#include "mozilla/dom/Event.h"
|
2015-10-08 16:44:58 +00:00
|
|
|
#include "mozilla/dom/BindingUtils.h"
|
2008-01-30 01:31:29 +00:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
|
2013-09-11 14:10:01 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2014-02-27 10:51:14 +00:00
|
|
|
|
2014-06-19 00:57:51 +00:00
|
|
|
struct MessageEventInit;
|
2013-11-05 14:16:26 +00:00
|
|
|
class MessagePort;
|
2017-03-10 01:50:13 +00:00
|
|
|
class OwningWindowProxyOrMessagePortOrServiceWorker;
|
|
|
|
class ServiceWorker;
|
2018-01-26 21:08:59 +00:00
|
|
|
class WindowProxyOrMessagePortOrServiceWorker;
|
2015-03-16 20:23:42 +00:00
|
|
|
|
2008-01-30 01:31:29 +00:00
|
|
|
/**
|
2008-05-02 19:26:47 +00:00
|
|
|
* Implements the MessageEvent event, used for cross-document messaging and
|
|
|
|
* server-sent events.
|
2008-01-30 01:31:29 +00:00
|
|
|
*
|
|
|
|
* See http://www.whatwg.org/specs/web-apps/current-work/#messageevent for
|
|
|
|
* further details.
|
|
|
|
*/
|
2016-01-30 17:05:36 +00:00
|
|
|
class MessageEvent final : public Event
|
2008-01-30 01:31:29 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-02-27 10:51:14 +00:00
|
|
|
MessageEvent(EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetEvent* aEvent);
|
2013-05-02 09:12:45 +00:00
|
|
|
|
2008-01-30 01:31:29 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2014-03-05 00:37:43 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MessageEvent, Event)
|
2008-01-30 01:31:29 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-03-13 20:18:36 +00:00
|
|
|
|
2014-06-11 20:26:52 +00:00
|
|
|
void GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData,
|
|
|
|
ErrorResult& aRv);
|
2016-01-30 17:05:36 +00:00
|
|
|
void GetOrigin(nsAString&) const;
|
|
|
|
void GetLastEventId(nsAString&) const;
|
2017-03-10 01:50:13 +00:00
|
|
|
void GetSource(Nullable<OwningWindowProxyOrMessagePortOrServiceWorker>& aValue) const;
|
2013-03-13 20:18:36 +00:00
|
|
|
|
2016-10-25 05:48:05 +00:00
|
|
|
void GetPorts(nsTArray<RefPtr<MessagePort>>& aPorts);
|
2013-03-13 20:18:36 +00:00
|
|
|
|
2014-02-27 10:51:14 +00:00
|
|
|
static already_AddRefed<MessageEvent>
|
2014-06-16 16:52:00 +00:00
|
|
|
Constructor(const GlobalObject& aGlobal,
|
2013-09-11 14:10:01 +00:00
|
|
|
const nsAString& aType,
|
2014-02-27 10:51:14 +00:00
|
|
|
const MessageEventInit& aEventInit,
|
|
|
|
ErrorResult& aRv);
|
2013-09-11 14:10:01 +00:00
|
|
|
|
2015-01-15 16:58:40 +00:00
|
|
|
static already_AddRefed<MessageEvent>
|
|
|
|
Constructor(EventTarget* aEventTarget,
|
|
|
|
const nsAString& aType,
|
2017-03-10 01:50:13 +00:00
|
|
|
const MessageEventInit& aEventInit);
|
2015-01-15 16:58:40 +00:00
|
|
|
|
2015-10-08 16:44:58 +00:00
|
|
|
void InitMessageEvent(JSContext* aCx, const nsAString& aType, bool aCanBubble,
|
|
|
|
bool aCancelable, JS::Handle<JS::Value> aData,
|
|
|
|
const nsAString& aOrigin, const nsAString& aLastEventId,
|
2017-03-10 01:50:13 +00:00
|
|
|
const Nullable<WindowProxyOrMessagePortOrServiceWorker>& aSource,
|
2016-10-25 05:48:05 +00:00
|
|
|
const Sequence<OwningNonNull<MessagePort>>& aPorts);
|
2015-10-08 16:44:58 +00:00
|
|
|
|
2014-07-08 21:23:17 +00:00
|
|
|
protected:
|
|
|
|
~MessageEvent();
|
|
|
|
|
2008-01-30 01:31:29 +00:00
|
|
|
private:
|
2013-06-18 10:00:37 +00:00
|
|
|
JS::Heap<JS::Value> mData;
|
2008-02-27 03:48:54 +00:00
|
|
|
nsString mOrigin;
|
2008-05-02 19:26:47 +00:00
|
|
|
nsString mLastEventId;
|
2017-03-10 01:50:13 +00:00
|
|
|
RefPtr<nsPIDOMWindowOuter> mWindowSource;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<MessagePort> mPortSource;
|
2018-01-26 21:08:59 +00:00
|
|
|
RefPtr<ServiceWorker> mServiceWorkerSource;
|
2016-10-13 13:19:24 +00:00
|
|
|
|
|
|
|
nsTArray<RefPtr<MessagePort>> mPorts;
|
2008-01-30 01:31:29 +00:00
|
|
|
};
|
|
|
|
|
2014-02-27 10:51:14 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_MessageEvent_h_
|