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
|
|
|
|
|
|
|
#include "nsIDOMMessageEvent.h"
|
|
|
|
#include "nsDOMEvent.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
|
2013-09-11 07:10:01 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2014-02-27 02:51:14 -08:00
|
|
|
|
2013-11-05 06:16:26 -08:00
|
|
|
class MessageEventInit;
|
|
|
|
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-02-27 02:51:14 -08:00
|
|
|
class MessageEvent : public nsDOMEvent,
|
|
|
|
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);
|
|
|
|
~MessageEvent();
|
2013-05-02 02:12:45 -07:00
|
|
|
|
2008-01-29 17:31:29 -08:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2014-02-27 02:51:14 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MessageEvent,
|
2011-05-23 11:53:31 -07:00
|
|
|
nsDOMEvent)
|
2008-01-29 17:31:29 -08:00
|
|
|
|
|
|
|
NS_DECL_NSIDOMMESSAGEEVENT
|
|
|
|
|
|
|
|
// Forward to base class
|
|
|
|
NS_FORWARD_TO_NSDOMEVENT
|
|
|
|
|
2013-04-25 09:29:54 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
2013-11-05 06:16:26 -08:00
|
|
|
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
2013-03-13 13:18:36 -07:00
|
|
|
|
2014-02-27 02:51:14 -08:00
|
|
|
JS::Value GetData(JSContext* aCx, 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
|
|
|
|
2014-02-27 02:51:14 -08:00
|
|
|
static already_AddRefed<MessageEvent>
|
|
|
|
Constructor(const GlobalObject& aGlobal, JSContext* aCx,
|
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
|
|
|
|
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_
|