TimeEvent.h (1786B)
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 DOM_SMIL_TIMEEVENT_H_ 8 #define DOM_SMIL_TIMEEVENT_H_ 9 10 #include "mozilla/dom/Event.h" 11 #include "mozilla/dom/Nullable.h" 12 #include "mozilla/dom/TimeEventBinding.h" 13 #include "mozilla/dom/WindowProxyHolder.h" 14 #include "nsDocShell.h" 15 16 class nsGlobalWindowInner; 17 18 namespace mozilla::dom { 19 20 class TimeEvent final : public Event { 21 public: 22 TimeEvent(EventTarget* aOwner, nsPresContext* aPresContext, 23 InternalSMILTimeEvent* aEvent); 24 25 // nsISupports interface: 26 NS_DECL_ISUPPORTS_INHERITED 27 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TimeEvent, Event) 28 29 JSObject* WrapObjectInternal(JSContext* aCx, 30 JS::Handle<JSObject*> aGivenProto) override { 31 return TimeEvent_Binding::Wrap(aCx, this, aGivenProto); 32 } 33 34 void InitTimeEvent(const nsAString& aType, nsGlobalWindowInner* aView, 35 int32_t aDetail); 36 37 int32_t Detail() const { return mDetail; } 38 39 Nullable<WindowProxyHolder> GetView() const { 40 if (!mView) { 41 return nullptr; 42 } 43 return WindowProxyHolder(mView->GetBrowsingContext()); 44 } 45 46 TimeEvent* AsTimeEvent() final { return this; } 47 48 private: 49 ~TimeEvent() = default; 50 51 nsCOMPtr<nsPIDOMWindowOuter> mView; 52 int32_t mDetail; 53 }; 54 55 } // namespace mozilla::dom 56 57 already_AddRefed<mozilla::dom::TimeEvent> NS_NewDOMTimeEvent( 58 mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, 59 mozilla::InternalSMILTimeEvent* aEvent); 60 61 #endif // DOM_SMIL_TIMEEVENT_H_