2015-05-03 22:32:37 +03: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 15:12:37 +04: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 04:31:29 +03:00
|
|
|
|
2014-02-27 14:51:14 +04:00
|
|
|
#ifndef mozilla_dom_MessageEvent_h_
|
|
|
|
#define mozilla_dom_MessageEvent_h_
|
2008-01-30 04:31:29 +03:00
|
|
|
|
2014-03-05 04:37:43 +04:00
|
|
|
#include "mozilla/dom/Event.h"
|
2015-10-08 19:44:58 +03:00
|
|
|
#include "mozilla/dom/BindingUtils.h"
|
2008-01-30 04:31:29 +03:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
|
2013-09-11 18:10:01 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2014-02-27 14:51:14 +04:00
|
|
|
|
2019-01-02 16:27:05 +03:00
|
|
|
class BrowsingContext;
|
2014-06-19 04:57:51 +04:00
|
|
|
struct MessageEventInit;
|
2013-11-05 18:16:26 +04:00
|
|
|
class MessagePort;
|
2017-03-10 04:50:13 +03:00
|
|
|
class OwningWindowProxyOrMessagePortOrServiceWorker;
|
|
|
|
class ServiceWorker;
|
2018-01-27 00:08:59 +03:00
|
|
|
class WindowProxyOrMessagePortOrServiceWorker;
|
2015-03-16 23:23:42 +03:00
|
|
|
|
2008-01-30 04:31:29 +03:00
|
|
|
/**
|
2008-05-02 23:26:47 +04:00
|
|
|
* Implements the MessageEvent event, used for cross-document messaging and
|
|
|
|
* server-sent events.
|
2008-01-30 04:31:29 +03:00
|
|
|
*
|
|
|
|
* See http://www.whatwg.org/specs/web-apps/current-work/#messageevent for
|
|
|
|
* further details.
|
|
|
|
*/
|
2016-01-30 20:05:36 +03:00
|
|
|
class MessageEvent final : public Event {
|
2008-01-30 04:31:29 +03:00
|
|
|
public:
|
2014-02-27 14:51:14 +04:00
|
|
|
MessageEvent(EventTarget* aOwner, nsPresContext* aPresContext,
|
|
|
|
WidgetEvent* aEvent);
|
2013-05-02 13:12:45 +04:00
|
|
|
|
2008-01-30 04:31:29 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2014-03-05 04:37:43 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MessageEvent, Event)
|
2008-01-30 04:31:29 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapObjectInternal(
|
|
|
|
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-03-14 00:18:36 +04:00
|
|
|
|
2014-06-12 00:26:52 +04:00
|
|
|
void GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData,
|
|
|
|
ErrorResult& aRv);
|
2016-01-30 20:05:36 +03:00
|
|
|
void GetOrigin(nsAString&) const;
|
|
|
|
void GetLastEventId(nsAString&) const;
|
2017-03-10 04:50:13 +03:00
|
|
|
void GetSource(
|
|
|
|
Nullable<OwningWindowProxyOrMessagePortOrServiceWorker>& aValue) const;
|
2013-03-14 00:18:36 +04:00
|
|
|
|
2016-10-25 08:48:05 +03:00
|
|
|
void GetPorts(nsTArray<RefPtr<MessagePort>>& aPorts);
|
2013-03-14 00:18:36 +04:00
|
|
|
|
2014-02-27 14:51:14 +04:00
|
|
|
static already_AddRefed<MessageEvent> Constructor(
|
2014-06-16 20:52:00 +04:00
|
|
|
const GlobalObject& aGlobal, const nsAString& aType,
|
2014-02-27 14:51:14 +04:00
|
|
|
const MessageEventInit& aEventInit, ErrorResult& aRv);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-01-15 19:58:40 +03:00
|
|
|
static already_AddRefed<MessageEvent> Constructor(
|
|
|
|
EventTarget* aEventTarget, const nsAString& aType,
|
2017-03-10 04:50:13 +03:00
|
|
|
const MessageEventInit& aEventInit);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-06-25 19:23:50 +03:00
|
|
|
void InitMessageEvent(
|
|
|
|
JSContext* aCx, const nsAString& aType, bool aCanBubble, bool aCancelable,
|
|
|
|
JS::Handle<JS::Value> aData, const nsAString& aOrigin,
|
|
|
|
const nsAString& aLastEventId,
|
|
|
|
const Nullable<WindowProxyOrMessagePortOrServiceWorker>& aSource,
|
|
|
|
const Sequence<OwningNonNull<MessagePort>>& aPorts) {
|
|
|
|
InitMessageEvent(aCx, aType, aCanBubble ? CanBubble::eYes : CanBubble::eNo,
|
|
|
|
aCancelable ? Cancelable::eYes : Cancelable::eNo, aData,
|
|
|
|
aOrigin, aLastEventId, aSource, aPorts);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InitMessageEvent(
|
|
|
|
JSContext* aCx, const nsAString& aType, mozilla::CanBubble,
|
|
|
|
mozilla::Cancelable, JS::Handle<JS::Value> aData,
|
2015-10-08 19:44:58 +03:00
|
|
|
const nsAString& aOrigin, const nsAString& aLastEventId,
|
2017-03-10 04:50:13 +03:00
|
|
|
const Nullable<WindowProxyOrMessagePortOrServiceWorker>& aSource,
|
2016-10-25 08:48:05 +03:00
|
|
|
const Sequence<OwningNonNull<MessagePort>>& aPorts);
|
2015-10-08 19:44:58 +03:00
|
|
|
|
2014-07-09 01:23:17 +04:00
|
|
|
protected:
|
|
|
|
~MessageEvent();
|
|
|
|
|
2008-01-30 04:31:29 +03:00
|
|
|
private:
|
2013-06-18 14:00:37 +04:00
|
|
|
JS::Heap<JS::Value> mData;
|
2008-02-27 06:48:54 +03:00
|
|
|
nsString mOrigin;
|
2008-05-02 23:26:47 +04:00
|
|
|
nsString mLastEventId;
|
2019-01-02 16:27:05 +03:00
|
|
|
RefPtr<BrowsingContext> mWindowSource;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<MessagePort> mPortSource;
|
2018-01-27 00:08:59 +03:00
|
|
|
RefPtr<ServiceWorker> mServiceWorkerSource;
|
2016-10-13 16:19:24 +03:00
|
|
|
|
|
|
|
nsTArray<RefPtr<MessagePort>> mPorts;
|
2008-01-30 04:31:29 +03:00
|
|
|
};
|
|
|
|
|
2014-02-27 14:51:14 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_MessageEvent_h_
|