Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/events/InputEvent.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/InputEvent.h"
8
#include "mozilla/TextEvents.h"
9
#include "prtime.h"
10
11
namespace mozilla {
12
namespace dom {
13
14
InputEvent::InputEvent(EventTarget* aOwner,
15
                       nsPresContext* aPresContext,
16
                       InternalEditorInputEvent* aEvent)
17
  : UIEvent(aOwner, aPresContext,
18
            aEvent ? aEvent :
19
                     new InternalEditorInputEvent(false, eVoidEvent, nullptr))
20
0
{
21
0
  NS_ASSERTION(mEvent->mClass == eEditorInputEventClass,
22
0
               "event type mismatch");
23
0
24
0
  if (aEvent) {
25
0
    mEventIsInternal = false;
26
0
  } else {
27
0
    mEventIsInternal = true;
28
0
    mEvent->mTime = PR_Now();
29
0
  }
30
0
}
31
32
bool
33
InputEvent::IsComposing()
34
0
{
35
0
  return mEvent->AsEditorInputEvent()->mIsComposing;
36
0
}
37
38
already_AddRefed<InputEvent>
39
InputEvent::Constructor(const GlobalObject& aGlobal,
40
                        const nsAString& aType,
41
                        const InputEventInit& aParam,
42
                        ErrorResult& aRv)
43
0
{
44
0
  nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
45
0
  RefPtr<InputEvent> e = new InputEvent(t, nullptr, nullptr);
46
0
  bool trusted = e->Init(t);
47
0
  e->InitUIEvent(aType, aParam.mBubbles, aParam.mCancelable, aParam.mView,
48
0
                 aParam.mDetail);
49
0
  InternalEditorInputEvent* internalEvent = e->mEvent->AsEditorInputEvent();
50
0
  internalEvent->mIsComposing = aParam.mIsComposing;
51
0
  e->SetTrusted(trusted);
52
0
  e->SetComposed(aParam.mComposed);
53
0
  return e.forget();
54
0
}
55
56
} // namespace dom
57
} // namespace mozilla
58
59
using namespace mozilla;
60
using namespace mozilla::dom;
61
62
already_AddRefed<InputEvent>
63
NS_NewDOMInputEvent(EventTarget* aOwner,
64
                    nsPresContext* aPresContext,
65
                    InternalEditorInputEvent* aEvent)
66
0
{
67
0
  RefPtr<InputEvent> it = new InputEvent(aOwner, aPresContext, aEvent);
68
0
  return it.forget();
69
0
}