MIDIMessageEvent.h (1947B)
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 <cstdint> 11 12 #include "js/RootingAPI.h" 13 #include "mozilla/AlreadyAddRefed.h" 14 #include "mozilla/TimeStamp.h" 15 #include "mozilla/dom/Event.h" 16 #include "nsCycleCollectionParticipant.h" 17 #include "nsISupports.h" 18 #include "nsStringFwd.h" 19 #include "nsTArray.h" 20 21 struct JSContext; 22 namespace mozilla::dom { 23 struct MIDIMessageEventInit; 24 25 /** 26 * Event that fires whenever a MIDI message is received by the MIDIInput object. 27 * 28 */ 29 class MIDIMessageEvent final : public Event { 30 public: 31 NS_DECL_ISUPPORTS_INHERITED 32 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MIDIMessageEvent, 33 Event) 34 protected: 35 explicit MIDIMessageEvent(mozilla::dom::EventTarget* aOwner); 36 37 JS::Heap<JSObject*> mData; 38 39 public: 40 virtual MIDIMessageEvent* AsMIDIMessageEvent(); 41 virtual JSObject* WrapObjectInternal( 42 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; 43 static already_AddRefed<MIDIMessageEvent> Constructor( 44 EventTarget* aOwner, const class TimeStamp& aReceivedTime, 45 const nsTArray<uint8_t>& aData); 46 47 static already_AddRefed<MIDIMessageEvent> Constructor( 48 const GlobalObject& aGlobal, const nsAString& aType, 49 const MIDIMessageEventInit& aEventInitDict, ErrorResult& aRv); 50 51 // Getter for message data 52 void GetData(JSContext* cx, JS::MutableHandle<JSObject*> aData, 53 ErrorResult& aRv); 54 55 private: 56 ~MIDIMessageEvent(); 57 nsTArray<uint8_t> mRawData; 58 }; 59 60 } // namespace mozilla::dom 61 62 #endif // mozilla_dom_MIDIMessageEvent_h