dom/events/MessageEvent.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef mozilla_dom_MessageEvent_h_
michael@0 7 #define mozilla_dom_MessageEvent_h_
michael@0 8
michael@0 9 #include "mozilla/dom/Event.h"
michael@0 10 #include "nsCycleCollectionParticipant.h"
michael@0 11 #include "nsIDOMMessageEvent.h"
michael@0 12 #include "mozilla/dom/MessagePortList.h"
michael@0 13
michael@0 14 namespace mozilla {
michael@0 15 namespace dom {
michael@0 16
michael@0 17 class MessageEventInit;
michael@0 18 class MessagePort;
michael@0 19 class MessagePortBase;
michael@0 20 class MessagePortList;
michael@0 21 class OwningWindowProxyOrMessagePort;
michael@0 22
michael@0 23 /**
michael@0 24 * Implements the MessageEvent event, used for cross-document messaging and
michael@0 25 * server-sent events.
michael@0 26 *
michael@0 27 * See http://www.whatwg.org/specs/web-apps/current-work/#messageevent for
michael@0 28 * further details.
michael@0 29 */
michael@0 30 class MessageEvent : public Event,
michael@0 31 public nsIDOMMessageEvent
michael@0 32 {
michael@0 33 public:
michael@0 34 MessageEvent(EventTarget* aOwner,
michael@0 35 nsPresContext* aPresContext,
michael@0 36 WidgetEvent* aEvent);
michael@0 37 ~MessageEvent();
michael@0 38
michael@0 39 NS_DECL_ISUPPORTS_INHERITED
michael@0 40 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MessageEvent, Event)
michael@0 41
michael@0 42 NS_DECL_NSIDOMMESSAGEEVENT
michael@0 43
michael@0 44 // Forward to base class
michael@0 45 NS_FORWARD_TO_EVENT
michael@0 46
michael@0 47 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
michael@0 48
michael@0 49 void GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData,
michael@0 50 ErrorResult& aRv);
michael@0 51
michael@0 52 void GetSource(Nullable<OwningWindowProxyOrMessagePort>& aValue) const;
michael@0 53
michael@0 54 MessagePortList* GetPorts()
michael@0 55 {
michael@0 56 return mPorts;
michael@0 57 }
michael@0 58
michael@0 59 void SetPorts(MessagePortList* aPorts);
michael@0 60
michael@0 61 // Non WebIDL methods
michael@0 62 void SetSource(mozilla::dom::MessagePort* aPort)
michael@0 63 {
michael@0 64 mPortSource = aPort;
michael@0 65 }
michael@0 66
michael@0 67 void SetSource(nsPIDOMWindow* aWindow)
michael@0 68 {
michael@0 69 mWindowSource = aWindow;
michael@0 70 }
michael@0 71
michael@0 72 static already_AddRefed<MessageEvent>
michael@0 73 Constructor(const GlobalObject& aGlobal, JSContext* aCx,
michael@0 74 const nsAString& aType,
michael@0 75 const MessageEventInit& aEventInit,
michael@0 76 ErrorResult& aRv);
michael@0 77
michael@0 78 private:
michael@0 79 JS::Heap<JS::Value> mData;
michael@0 80 nsString mOrigin;
michael@0 81 nsString mLastEventId;
michael@0 82 nsCOMPtr<nsIDOMWindow> mWindowSource;
michael@0 83 nsRefPtr<MessagePortBase> mPortSource;
michael@0 84 nsRefPtr<MessagePortList> mPorts;
michael@0 85 };
michael@0 86
michael@0 87 } // namespace dom
michael@0 88 } // namespace mozilla
michael@0 89
michael@0 90 #endif // mozilla_dom_MessageEvent_h_

mercurial