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
|
|
|
|
2014-06-19 04:57:51 +04:00
|
|
|
struct MessageEventInit;
|
2013-11-05 18:16:26 +04:00
|
|
|
class MessagePort;
|
2015-11-10 09:31:41 +03:00
|
|
|
class OwningWindowProxyOrMessagePort;
|
2015-10-08 19:44:58 +03:00
|
|
|
class WindowProxyOrMessagePort;
|
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
|
|
|
|
|
|
|
// Forward to base class
|
2014-03-05 04:37:43 +04:00
|
|
|
NS_FORWARD_TO_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;
|
2015-11-10 09:31:41 +03:00
|
|
|
void GetSource(Nullable<OwningWindowProxyOrMessagePort>& 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>
|
2014-06-16 20:52:00 +04:00
|
|
|
Constructor(const GlobalObject& aGlobal,
|
2013-09-11 18:10:01 +04:00
|
|
|
const nsAString& aType,
|
2014-02-27 14:51:14 +04:00
|
|
|
const MessageEventInit& aEventInit,
|
|
|
|
ErrorResult& aRv);
|
2013-09-11 18:10:01 +04:00
|
|
|
|
2015-01-15 19:58:40 +03:00
|
|
|
static already_AddRefed<MessageEvent>
|
|
|
|
Constructor(EventTarget* aEventTarget,
|
|
|
|
const nsAString& aType,
|
|
|
|
const MessageEventInit& aEventInit,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
2015-10-08 19:44:58 +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<WindowProxyOrMessagePort>& 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;
|
2016-01-30 20:05:36 +03:00
|
|
|
RefPtr<nsPIDOMWindowInner> mWindowSource;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<MessagePort> mPortSource;
|
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_
|