Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/smil/TimeEvent.cpp
Line
Count
Source (jump to first uncovered line)
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
#include "mozilla/ContentEvents.h"
8
#include "mozilla/dom/TimeEvent.h"
9
#include "nsIDocShell.h"
10
#include "nsIInterfaceRequestorUtils.h"
11
#include "nsPresContext.h"
12
#include "nsGlobalWindow.h"
13
14
namespace mozilla {
15
namespace dom {
16
17
TimeEvent::TimeEvent(EventTarget* aOwner,
18
                     nsPresContext* aPresContext,
19
                     InternalSMILTimeEvent* aEvent)
20
  : Event(aOwner, aPresContext,
21
          aEvent ? aEvent : new InternalSMILTimeEvent(false, eVoidEvent))
22
  , mDetail(mEvent->AsSMILTimeEvent()->mDetail)
23
0
{
24
0
  if (aEvent) {
25
0
    mEventIsInternal = false;
26
0
  } else {
27
0
    mEventIsInternal = true;
28
0
  }
29
0
30
0
  if (mPresContext) {
31
0
    nsCOMPtr<nsIDocShell> docShell = mPresContext->GetDocShell();
32
0
    if (docShell) {
33
0
      mView = docShell->GetWindow();
34
0
    }
35
0
  }
36
0
}
37
38
NS_IMPL_CYCLE_COLLECTION_INHERITED(TimeEvent, Event,
39
                                   mView)
40
41
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(TimeEvent, Event)
42
43
void
44
TimeEvent::InitTimeEvent(const nsAString& aType, nsGlobalWindowInner* aView,
45
                         int32_t aDetail)
46
0
{
47
0
  NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
48
0
49
0
  Event::InitEvent(aType, false /*doesn't bubble*/, false /*can't cancel*/);
50
0
  mDetail = aDetail;
51
0
  mView = aView ? aView->GetOuterWindow() : nullptr;
52
0
}
53
54
} // namespace dom
55
} // namespace mozilla
56
57
using namespace mozilla;
58
using namespace mozilla::dom;
59
60
already_AddRefed<TimeEvent>
61
NS_NewDOMTimeEvent(EventTarget* aOwner,
62
                   nsPresContext* aPresContext,
63
                   InternalSMILTimeEvent* aEvent)
64
0
{
65
0
  RefPtr<TimeEvent> it = new TimeEvent(aOwner, aPresContext, aEvent);
66
0
  return it.forget();
67
0
}