1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_MIDIMessageEvent_h 8 #define mozilla_dom_MIDIMessageEvent_h 9 10 #include "mozilla/Attributes.h" 11 #include "mozilla/ErrorResult.h" 12 #include "mozilla/TimeStamp.h" 13 #include "mozilla/dom/BindingUtils.h" 14 #include "mozilla/dom/Event.h" 15 #include "mozilla/dom/MIDIMessageEventBinding.h" 16 17 struct JSContext; 18 namespace mozilla { 19 namespace dom { 20 21 /** 22 * Event that fires whenever a MIDI message is received by the MIDIInput object. 23 * 24 */ 25 class MIDIMessageEvent final : public Event { 26 public: 27 NS_DECL_ISUPPORTS_INHERITED 28 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MIDIMessageEvent, 29 Event) 30 protected: 31 explicit MIDIMessageEvent(mozilla::dom::EventTarget* aOwner); 32 33 JS::Heap<JSObject*> mData; 34 35 public: 36 virtual MIDIMessageEvent* AsMIDIMessageEvent(); 37 virtual JSObject* WrapObjectInternal( 38 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; 39 static already_AddRefed<MIDIMessageEvent> Constructor( 40 EventTarget* aOwner, const class TimeStamp& aReceivedTime, 41 const nsTArray<uint8_t>& aData); 42 43 static already_AddRefed<MIDIMessageEvent> Constructor( 44 const GlobalObject& aGlobal, const nsAString& aType, 45 const MIDIMessageEventInit& aEventInitDict, ErrorResult& aRv); 46 47 // Getter for message data 48 void GetData(JSContext* cx, JS::MutableHandle<JSObject*> aData, 49 ErrorResult& aRv); 50 51 private: 52 ~MIDIMessageEvent(); 53 nsTArray<uint8_t> mRawData; 54 }; 55 56 } // namespace dom 57 } // namespace mozilla 58 59 #endif // mozilla_dom_MIDIMessageEvent_h 60