1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "mozilla/dom/InputEvent.h"
7 #include "mozilla/TextEvents.h"
13 InputEvent::InputEvent(EventTarget
* aOwner
,
14 nsPresContext
* aPresContext
,
15 InternalEditorInputEvent
* aEvent
)
16 : UIEvent(aOwner
, aPresContext
,
17 aEvent
? aEvent
: new InternalEditorInputEvent(false, 0, nullptr))
19 NS_ASSERTION(mEvent
->mClass
== eEditorInputEventClass
,
20 "event type mismatch");
23 mEventIsInternal
= false;
25 mEventIsInternal
= true;
26 mEvent
->time
= PR_Now();
30 NS_IMPL_ADDREF_INHERITED(InputEvent
, UIEvent
)
31 NS_IMPL_RELEASE_INHERITED(InputEvent
, UIEvent
)
33 NS_INTERFACE_MAP_BEGIN(InputEvent
)
34 NS_INTERFACE_MAP_END_INHERITING(UIEvent
)
37 InputEvent::IsComposing()
39 return mEvent
->AsEditorInputEvent()->mIsComposing
;
42 already_AddRefed
<InputEvent
>
43 InputEvent::Constructor(const GlobalObject
& aGlobal
,
44 const nsAString
& aType
,
45 const InputEventInit
& aParam
,
48 nsCOMPtr
<EventTarget
> t
= do_QueryInterface(aGlobal
.GetAsSupports());
49 nsRefPtr
<InputEvent
> e
= new InputEvent(t
, nullptr, nullptr);
50 bool trusted
= e
->Init(t
);
51 aRv
= e
->InitUIEvent(aType
, aParam
.mBubbles
, aParam
.mCancelable
,
52 aParam
.mView
, aParam
.mDetail
);
53 InternalEditorInputEvent
* internalEvent
= e
->mEvent
->AsEditorInputEvent();
54 internalEvent
->mIsComposing
= aParam
.mIsComposing
;
55 e
->SetTrusted(trusted
);
60 } // namespace mozilla
62 using namespace mozilla
;
63 using namespace mozilla::dom
;
66 NS_NewDOMInputEvent(nsIDOMEvent
** aInstancePtrResult
,
68 nsPresContext
* aPresContext
,
69 InternalEditorInputEvent
* aEvent
)
71 InputEvent
* it
= new InputEvent(aOwner
, aPresContext
, aEvent
);
73 *aInstancePtrResult
= static_cast<Event
*>(it
);