dom/events/InputEvent.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "mozilla/dom/InputEvent.h"
michael@0 7 #include "mozilla/TextEvents.h"
michael@0 8 #include "prtime.h"
michael@0 9
michael@0 10 namespace mozilla {
michael@0 11 namespace dom {
michael@0 12
michael@0 13 InputEvent::InputEvent(EventTarget* aOwner,
michael@0 14 nsPresContext* aPresContext,
michael@0 15 InternalEditorInputEvent* aEvent)
michael@0 16 : UIEvent(aOwner, aPresContext,
michael@0 17 aEvent ? aEvent : new InternalEditorInputEvent(false, 0, nullptr))
michael@0 18 {
michael@0 19 NS_ASSERTION(mEvent->eventStructType == NS_EDITOR_INPUT_EVENT,
michael@0 20 "event type mismatch");
michael@0 21
michael@0 22 if (aEvent) {
michael@0 23 mEventIsInternal = false;
michael@0 24 } else {
michael@0 25 mEventIsInternal = true;
michael@0 26 mEvent->time = PR_Now();
michael@0 27 }
michael@0 28 }
michael@0 29
michael@0 30 NS_IMPL_ADDREF_INHERITED(InputEvent, UIEvent)
michael@0 31 NS_IMPL_RELEASE_INHERITED(InputEvent, UIEvent)
michael@0 32
michael@0 33 NS_INTERFACE_MAP_BEGIN(InputEvent)
michael@0 34 NS_INTERFACE_MAP_END_INHERITING(UIEvent)
michael@0 35
michael@0 36 bool
michael@0 37 InputEvent::IsComposing()
michael@0 38 {
michael@0 39 return mEvent->AsEditorInputEvent()->mIsComposing;
michael@0 40 }
michael@0 41
michael@0 42 already_AddRefed<InputEvent>
michael@0 43 InputEvent::Constructor(const GlobalObject& aGlobal,
michael@0 44 const nsAString& aType,
michael@0 45 const InputEventInit& aParam,
michael@0 46 ErrorResult& aRv)
michael@0 47 {
michael@0 48 nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
michael@0 49 nsRefPtr<InputEvent> e = new InputEvent(t, nullptr, nullptr);
michael@0 50 bool trusted = e->Init(t);
michael@0 51 aRv = e->InitUIEvent(aType, aParam.mBubbles, aParam.mCancelable,
michael@0 52 aParam.mView, aParam.mDetail);
michael@0 53 InternalEditorInputEvent* internalEvent = e->mEvent->AsEditorInputEvent();
michael@0 54 internalEvent->mIsComposing = aParam.mIsComposing;
michael@0 55 e->SetTrusted(trusted);
michael@0 56 return e.forget();
michael@0 57 }
michael@0 58
michael@0 59 } // namespace dom
michael@0 60 } // namespace mozilla
michael@0 61
michael@0 62 using namespace mozilla;
michael@0 63 using namespace mozilla::dom;
michael@0 64
michael@0 65 nsresult
michael@0 66 NS_NewDOMInputEvent(nsIDOMEvent** aInstancePtrResult,
michael@0 67 EventTarget* aOwner,
michael@0 68 nsPresContext* aPresContext,
michael@0 69 InternalEditorInputEvent* aEvent)
michael@0 70 {
michael@0 71 InputEvent* it = new InputEvent(aOwner, aPresContext, aEvent);
michael@0 72 NS_ADDREF(it);
michael@0 73 *aInstancePtrResult = static_cast<Event*>(it);
michael@0 74 return NS_OK;
michael@0 75 }

mercurial