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