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
|
|
|
|
2013-11-05 18:16:26 +04:00
|
|
|
class MessageEventInit;
|
|
|
|
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-03-05 04:37:43 +04:00
|
|
|
class MessageEvent : public Event,
|
2014-02-27 14:51:14 +04:00
|
|
|
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);
|
|
|
|
~MessageEvent();
|
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-04-09 02:27:18 +04:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2013-03-14 00:18:36 +04:00
|
|
|
|
2014-02-27 14:51:14 +04:00
|
|
|
JS::Value GetData(JSContext* aCx, 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>
|
|
|
|
Constructor(const GlobalObject& aGlobal, JSContext* aCx,
|
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
|
|
|
|
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_
|