2008-01-29 17:31:29 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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-29 17:31:29 -08:00
|
|
|
|
2014-02-27 02:51:14 -08:00
|
|
|
#ifndef mozilla_dom_MessageEvent_h_
|
|
|
|
#define mozilla_dom_MessageEvent_h_
|
2008-01-29 17:31:29 -08:00
|
|
|
|
2014-03-04 16:37:43 -08:00
|
|
|
#include "mozilla/dom/Event.h"
|
2008-01-29 17:31:29 -08:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2014-03-04 16:37:43 -08:00
|
|
|
#include "nsIDOMMessageEvent.h"
|
2013-11-14 20:42:34 -08:00
|
|
|
#include "mozilla/dom/MessagePortList.h"
|
2008-01-29 17:31:29 -08:00
|
|
|
|
2013-09-11 07:10:01 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2014-02-27 02:51:14 -08:00
|
|
|
|
2014-06-18 17:57:51 -07:00
|
|
|
struct MessageEventInit;
|
2013-11-05 06:16:26 -08:00
|
|
|
class MessagePort;
|
|
|
|
class MessagePortBase;
|
2013-09-11 07:10:01 -07:00
|
|
|
class MessagePortList;
|
2013-09-17 08:16:02 -07:00
|
|
|
class OwningWindowProxyOrMessagePort;
|
2013-09-11 07:10:01 -07:00
|
|
|
|
2008-01-29 17:31:29 -08:00
|
|
|
/**
|
2008-05-02 12:26:47 -07:00
|
|
|
* Implements the MessageEvent event, used for cross-document messaging and
|
|
|
|
* server-sent events.
|
2008-01-29 17:31:29 -08:00
|
|
|
*
|
|
|
|
* See http://www.whatwg.org/specs/web-apps/current-work/#messageevent for
|
|
|
|
* further details.
|
|
|
|
*/
|
2014-11-25 10:56:07 -08:00
|
|
|
class MessageEvent MOZ_FINAL : public Event,
|
|
|
|
public nsIDOMMessageEvent
|
2008-01-29 17:31:29 -08:00
|
|
|
{
|
|
|
|
public:
|
2014-02-27 02:51:14 -08:00
|
|
|
MessageEvent(EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetEvent* aEvent);
|
2013-05-02 02:12:45 -07:00
|
|
|
|
2008-01-29 17:31:29 -08:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2014-03-04 16:37:43 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MessageEvent, Event)
|
2008-01-29 17:31:29 -08:00
|
|
|
|
|
|
|
NS_DECL_NSIDOMMESSAGEEVENT
|
|
|
|
|
|
|
|
// Forward to base class
|
2014-03-04 16:37:43 -08:00
|
|
|
NS_FORWARD_TO_EVENT
|
2008-01-29 17:31:29 -08:00
|
|
|
|
2014-10-17 16:16:58 -07:00
|
|
|
virtual JSObject* WrapObjectInternal(JSContext* aCx) MOZ_OVERRIDE;
|
2013-03-13 13:18:36 -07:00
|
|
|
|
2014-06-11 13:26:52 -07:00
|
|
|
void GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData,
|
|
|
|
ErrorResult& aRv);
|
2013-03-13 13:18:36 -07:00
|
|
|
|
2014-02-27 02:51:14 -08:00
|
|
|
void GetSource(Nullable<OwningWindowProxyOrMessagePort>& aValue) const;
|
2013-03-13 13:18:36 -07:00
|
|
|
|
2014-02-27 02:51:14 -08:00
|
|
|
MessagePortList* GetPorts()
|
2013-03-13 13:18:36 -07:00
|
|
|
{
|
2013-09-11 07:10:01 -07:00
|
|
|
return mPorts;
|
2013-03-13 13:18:36 -07:00
|
|
|
}
|
|
|
|
|
2014-02-27 02:51:14 -08:00
|
|
|
void SetPorts(MessagePortList* aPorts);
|
2013-11-05 06:16:26 -08:00
|
|
|
|
2013-11-14 20:42:34 -08:00
|
|
|
// Non WebIDL methods
|
|
|
|
void SetSource(mozilla::dom::MessagePort* aPort)
|
|
|
|
{
|
|
|
|
mPortSource = aPort;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetSource(nsPIDOMWindow* aWindow)
|
|
|
|
{
|
|
|
|
mWindowSource = aWindow;
|
|
|
|
}
|
|
|
|
|
2014-02-27 02:51:14 -08:00
|
|
|
static already_AddRefed<MessageEvent>
|
2014-06-16 09:52:00 -07:00
|
|
|
Constructor(const GlobalObject& aGlobal,
|
2013-09-11 07:10:01 -07:00
|
|
|
const nsAString& aType,
|
2014-02-27 02:51:14 -08:00
|
|
|
const MessageEventInit& aEventInit,
|
|
|
|
ErrorResult& aRv);
|
2013-09-11 07:10:01 -07:00
|
|
|
|
2014-07-08 14:23:17 -07:00
|
|
|
protected:
|
|
|
|
~MessageEvent();
|
|
|
|
|
2008-01-29 17:31:29 -08:00
|
|
|
private:
|
2013-06-18 03:00:37 -07:00
|
|
|
JS::Heap<JS::Value> mData;
|
2008-02-26 19:48:54 -08:00
|
|
|
nsString mOrigin;
|
2008-05-02 12:26:47 -07:00
|
|
|
nsString mLastEventId;
|
2013-09-11 07:10:01 -07:00
|
|
|
nsCOMPtr<nsIDOMWindow> mWindowSource;
|
2014-02-27 02:51:14 -08:00
|
|
|
nsRefPtr<MessagePortBase> mPortSource;
|
|
|
|
nsRefPtr<MessagePortList> mPorts;
|
2008-01-29 17:31:29 -08:00
|
|
|
};
|
|
|
|
|
2014-02-27 02:51:14 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_MessageEvent_h_
|