Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/events/TransitionEvent.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/dom/TransitionEvent.h"
8
#include "mozilla/ContentEvents.h"
9
#include "prtime.h"
10
11
namespace mozilla {
12
namespace dom {
13
14
TransitionEvent::TransitionEvent(EventTarget* aOwner,
15
                                 nsPresContext* aPresContext,
16
                                 InternalTransitionEvent* aEvent)
17
  : Event(aOwner, aPresContext,
18
          aEvent ? aEvent : new InternalTransitionEvent(false, eVoidEvent))
19
0
{
20
0
  if (aEvent) {
21
0
    mEventIsInternal = false;
22
0
  }
23
0
  else {
24
0
    mEventIsInternal = true;
25
0
    mEvent->mTime = PR_Now();
26
0
  }
27
0
}
28
29
// static
30
already_AddRefed<TransitionEvent>
31
TransitionEvent::Constructor(const GlobalObject& aGlobal,
32
                             const nsAString& aType,
33
                             const TransitionEventInit& aParam,
34
                             ErrorResult& aRv)
35
0
{
36
0
  nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
37
0
  RefPtr<TransitionEvent> e = new TransitionEvent(t, nullptr, nullptr);
38
0
  bool trusted = e->Init(t);
39
0
40
0
  e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
41
0
42
0
  InternalTransitionEvent* internalEvent = e->mEvent->AsTransitionEvent();
43
0
  internalEvent->mPropertyName = aParam.mPropertyName;
44
0
  internalEvent->mElapsedTime = aParam.mElapsedTime;
45
0
  internalEvent->mPseudoElement = aParam.mPseudoElement;
46
0
47
0
  e->SetTrusted(trusted);
48
0
  e->SetComposed(aParam.mComposed);
49
0
  return e.forget();
50
0
}
51
52
void
53
TransitionEvent::GetPropertyName(nsAString& aPropertyName) const
54
0
{
55
0
  aPropertyName = mEvent->AsTransitionEvent()->mPropertyName;
56
0
}
57
58
float
59
TransitionEvent::ElapsedTime()
60
0
{
61
0
  return mEvent->AsTransitionEvent()->mElapsedTime;
62
0
}
63
64
void
65
TransitionEvent::GetPseudoElement(nsAString& aPseudoElement) const
66
0
{
67
0
  aPseudoElement = mEvent->AsTransitionEvent()->mPseudoElement;
68
0
}
69
70
} // namespace dom
71
} // namespace mozilla
72
73
using namespace mozilla;
74
using namespace mozilla::dom;
75
76
already_AddRefed<TransitionEvent>
77
NS_NewDOMTransitionEvent(EventTarget* aOwner,
78
                         nsPresContext* aPresContext,
79
                         InternalTransitionEvent* aEvent)
80
0
{
81
0
  RefPtr<TransitionEvent> it =
82
0
    new TransitionEvent(aOwner, aPresContext, aEvent);
83
0
  return it.forget();
84
0
}