ToggleEvent.h (1786B)
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 DOM_TOGGLEEVENT_H_ 8 #define DOM_TOGGLEEVENT_H_ 9 10 #include "mozilla/EventForwards.h" 11 #include "mozilla/dom/Event.h" 12 #include "mozilla/dom/ToggleEventBinding.h" 13 14 namespace mozilla::dom { 15 16 class ToggleEvent : public Event { 17 public: 18 explicit ToggleEvent(EventTarget* aOwner); 19 ToggleEvent* AsToggleEvent() override { return this; } 20 21 NS_DECL_ISUPPORTS_INHERITED 22 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ToggleEvent, Event) 23 24 JSObject* WrapObjectInternal(JSContext* aCx, 25 JS::Handle<JSObject*> aGivenProto) override { 26 return ToggleEvent_Binding::Wrap(aCx, this, aGivenProto); 27 } 28 29 static already_AddRefed<ToggleEvent> Constructor( 30 mozilla::dom::EventTarget* aOwner, const nsAString& aType, 31 const ToggleEventInit& aEventInitDict); 32 33 static already_AddRefed<ToggleEvent> Constructor( 34 const GlobalObject& aGlobal, const nsAString& aType, 35 const ToggleEventInit& aEventInitDict); 36 37 void GetOldState(nsString& aRetVal) const; 38 39 void GetNewState(nsString& aRetVal) const; 40 41 void SetSource(Element* aSource); 42 Element* GetSource(); 43 44 protected: 45 ~ToggleEvent() = default; 46 47 private: 48 nsString mOldState; 49 nsString mNewState; 50 RefPtr<Element> mSource; 51 }; 52 53 already_AddRefed<mozilla::dom::ToggleEvent> NS_NewDOMToggleEvent( 54 mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, 55 mozilla::WidgetGUIEvent* aEvent); 56 57 } // namespace mozilla::dom 58 59 #endif // DOM_TOGGLEEVENT_H_