michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_MessageEvent_h_ michael@0: #define mozilla_dom_MessageEvent_h_ michael@0: michael@0: #include "mozilla/dom/Event.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "nsIDOMMessageEvent.h" michael@0: #include "mozilla/dom/MessagePortList.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class MessageEventInit; michael@0: class MessagePort; michael@0: class MessagePortBase; michael@0: class MessagePortList; michael@0: class OwningWindowProxyOrMessagePort; michael@0: michael@0: /** michael@0: * Implements the MessageEvent event, used for cross-document messaging and michael@0: * server-sent events. michael@0: * michael@0: * See http://www.whatwg.org/specs/web-apps/current-work/#messageevent for michael@0: * further details. michael@0: */ michael@0: class MessageEvent : public Event, michael@0: public nsIDOMMessageEvent michael@0: { michael@0: public: michael@0: MessageEvent(EventTarget* aOwner, michael@0: nsPresContext* aPresContext, michael@0: WidgetEvent* aEvent); michael@0: ~MessageEvent(); michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MessageEvent, Event) michael@0: michael@0: NS_DECL_NSIDOMMESSAGEEVENT michael@0: michael@0: // Forward to base class michael@0: NS_FORWARD_TO_EVENT michael@0: michael@0: virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: michael@0: void GetData(JSContext* aCx, JS::MutableHandle aData, michael@0: ErrorResult& aRv); michael@0: michael@0: void GetSource(Nullable& aValue) const; michael@0: michael@0: MessagePortList* GetPorts() michael@0: { michael@0: return mPorts; michael@0: } michael@0: michael@0: void SetPorts(MessagePortList* aPorts); michael@0: michael@0: // Non WebIDL methods michael@0: void SetSource(mozilla::dom::MessagePort* aPort) michael@0: { michael@0: mPortSource = aPort; michael@0: } michael@0: michael@0: void SetSource(nsPIDOMWindow* aWindow) michael@0: { michael@0: mWindowSource = aWindow; michael@0: } michael@0: michael@0: static already_AddRefed michael@0: Constructor(const GlobalObject& aGlobal, JSContext* aCx, michael@0: const nsAString& aType, michael@0: const MessageEventInit& aEventInit, michael@0: ErrorResult& aRv); michael@0: michael@0: private: michael@0: JS::Heap mData; michael@0: nsString mOrigin; michael@0: nsString mLastEventId; michael@0: nsCOMPtr mWindowSource; michael@0: nsRefPtr mPortSource; michael@0: nsRefPtr mPorts; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_dom_MessageEvent_h_