2008-01-30 04:31:29 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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"
|
2008-01-30 04:31:29 +03:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2014-03-05 04:37:43 +04:00
|
|
|
#include "nsIDOMMessageEvent.h"
|
2013-11-15 08:42:34 +04:00
|
|
|
#include "mozilla/dom/MessagePortList.h"
|
2008-01-30 04:31:29 +03:00
|
|
|
|
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;
|
|
|
|
class MessagePortBase;
|
2013-09-11 18:10:01 +04:00
|
|
|
class MessagePortList;
|
2013-09-17 19:16:02 +04:00
|
|
|
class OwningWindowProxyOrMessagePort;
|
2013-09-11 18:10:01 +04: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.
|
|
|
|
*/
|
2014-11-25 21:56:07 +03:00
|
|
|
class MessageEvent MOZ_FINAL : public Event,
|
|
|
|
public nsIDOMMessageEvent
|
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
|
|
|
|
|
|
|
NS_DECL_NSIDOMMESSAGEEVENT
|
|
|
|
|
|
|
|
// Forward to base class
|
2014-03-05 04:37:43 +04:00
|
|
|
NS_FORWARD_TO_EVENT
|
2008-01-30 04:31:29 +03:00
|
|
|
|
2014-10-18 03:16:58 +04:00
|
|
|
virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_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);
|
2013-03-14 00:18:36 +04:00
|
|
|
|
2014-02-27 14:51:14 +04:00
|
|
|
void GetSource(Nullable<OwningWindowProxyOrMessagePort>& aValue) const;
|
2013-03-14 00:18:36 +04:00
|
|
|
|
2014-02-27 14:51:14 +04:00
|
|
|
MessagePortList* GetPorts()
|
2013-03-14 00:18:36 +04:00
|
|
|
{
|
2013-09-11 18:10:01 +04:00
|
|
|
return mPorts;
|
2013-03-14 00:18:36 +04:00
|
|
|
}
|
|
|
|
|
2014-02-27 14:51:14 +04:00
|
|
|
void SetPorts(MessagePortList* aPorts);
|
2013-11-05 18:16:26 +04:00
|
|
|
|
2013-11-15 08:42:34 +04:00
|
|
|
// Non WebIDL methods
|
|
|
|
void SetSource(mozilla::dom::MessagePort* aPort)
|
|
|
|
{
|
|
|
|
mPortSource = aPort;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetSource(nsPIDOMWindow* aWindow)
|
|
|
|
{
|
|
|
|
mWindowSource = aWindow;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
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;
|
2013-09-11 18:10:01 +04:00
|
|
|
nsCOMPtr<nsIDOMWindow> mWindowSource;
|
2014-02-27 14:51:14 +04:00
|
|
|
nsRefPtr<MessagePortBase> mPortSource;
|
|
|
|
nsRefPtr<MessagePortList> 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_
|