1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 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 CustomEvent_h__ 8 #define CustomEvent_h__ 9 10 #include "mozilla/dom/Event.h" 11 12 namespace mozilla { 13 namespace dom { 14 15 struct CustomEventInit; 16 17 class CustomEvent final : public Event { 18 private: 19 virtual ~CustomEvent(); 20 21 JS::Heap<JS::Value> mDetail; 22 23 public: 24 explicit CustomEvent(mozilla::dom::EventTarget* aOwner, 25 nsPresContext* aPresContext = nullptr, 26 mozilla::WidgetEvent* aEvent = nullptr); 27 28 NS_DECL_ISUPPORTS_INHERITED 29 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(CustomEvent, Event) 30 31 static already_AddRefed<CustomEvent> Constructor( 32 const GlobalObject& aGlobal, const nsAString& aType, 33 const CustomEventInit& aParam); 34 35 virtual JSObject* WrapObjectInternal( 36 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; 37 AsCustomEvent()38 CustomEvent* AsCustomEvent() override { return this; } 39 40 void GetDetail(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval); 41 42 void InitCustomEvent(JSContext* aCx, const nsAString& aType, bool aCanBubble, 43 bool aCancelable, JS::Handle<JS::Value> aDetail); 44 }; 45 46 } // namespace dom 47 } // namespace mozilla 48 49 already_AddRefed<mozilla::dom::CustomEvent> NS_NewDOMCustomEvent( 50 mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, 51 mozilla::WidgetEvent* aEvent); 52 53 #endif // CustomEvent_h__ 54