Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / smil / TimeEvent.cpp
blobcbb6e72d925ea6cd7296167fd8a85c009227c3de
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/. */
7 #include "mozilla/ContentEvents.h"
8 #include "mozilla/dom/TimeEvent.h"
9 #include "nsIDocShell.h"
10 #include "nsIInterfaceRequestorUtils.h"
11 #include "nsPresContext.h"
12 #include "nsGlobalWindowInner.h"
14 namespace mozilla::dom {
16 TimeEvent::TimeEvent(EventTarget* aOwner, nsPresContext* aPresContext,
17 InternalSMILTimeEvent* aEvent)
18 : Event(aOwner, aPresContext,
19 aEvent ? aEvent : new InternalSMILTimeEvent(false, eVoidEvent)),
20 mDetail(mEvent->AsSMILTimeEvent()->mDetail) {
21 if (aEvent) {
22 mEventIsInternal = false;
23 } else {
24 mEventIsInternal = true;
27 if (mPresContext) {
28 nsCOMPtr<nsIDocShell> docShell = mPresContext->GetDocShell();
29 if (docShell) {
30 mView = docShell->GetWindow();
35 NS_IMPL_CYCLE_COLLECTION_INHERITED(TimeEvent, Event, mView)
37 NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(TimeEvent, Event)
39 void TimeEvent::InitTimeEvent(const nsAString& aType,
40 nsGlobalWindowInner* aView, int32_t aDetail) {
41 NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
43 Event::InitEvent(aType, false /*doesn't bubble*/, false /*can't cancel*/);
44 mDetail = aDetail;
45 mView = aView ? aView->GetOuterWindow() : nullptr;
48 } // namespace mozilla::dom
50 using namespace mozilla;
51 using namespace mozilla::dom;
53 already_AddRefed<TimeEvent> NS_NewDOMTimeEvent(EventTarget* aOwner,
54 nsPresContext* aPresContext,
55 InternalSMILTimeEvent* aEvent) {
56 return do_AddRef(new TimeEvent(aOwner, aPresContext, aEvent));