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.

     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))
    18 {
    19   NS_ASSERTION(mEvent->eventStructType == NS_EDITOR_INPUT_EVENT,
    20                "event type mismatch");
    22   if (aEvent) {
    23     mEventIsInternal = false;
    24   } else {
    25     mEventIsInternal = true;
    26     mEvent->time = PR_Now();
    27   }
    28 }
    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()
    38 {
    39   return mEvent->AsEditorInputEvent()->mIsComposing;
    40 }
    42 already_AddRefed<InputEvent>
    43 InputEvent::Constructor(const GlobalObject& aGlobal,
    44                         const nsAString& aType,
    45                         const InputEventInit& aParam,
    46                         ErrorResult& aRv)
    47 {
    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();
    57 }
    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)
    70 {
    71   InputEvent* it = new InputEvent(aOwner, aPresContext, aEvent);
    72   NS_ADDREF(it);
    73   *aInstancePtrResult = static_cast<Event*>(it);
    74   return NS_OK;
    75 }

mercurial