Bumping manifests a=b2g-bump
[gecko.git] / dom / events / InputEvent.cpp
blobcaf6e0c6ba44bcf09ed7cb05e6b9b0661c6f2158
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"
8 #include "prtime.h"
10 namespace mozilla {
11 namespace dom {
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");
22 if (aEvent) {
23 mEventIsInternal = false;
24 } else {
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)
36 bool
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,
46 ErrorResult& aRv)
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);
56 return e.forget();
59 } // namespace dom
60 } // namespace mozilla
62 using namespace mozilla;
63 using namespace mozilla::dom;
65 nsresult
66 NS_NewDOMInputEvent(nsIDOMEvent** aInstancePtrResult,
67 EventTarget* aOwner,
68 nsPresContext* aPresContext,
69 InternalEditorInputEvent* aEvent)
71 InputEvent* it = new InputEvent(aOwner, aPresContext, aEvent);
72 NS_ADDREF(it);
73 *aInstancePtrResult = static_cast<Event*>(it);
74 return NS_OK;