dom/events/CompositionEvent.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #include "mozilla/dom/CompositionEvent.h"
michael@0 8 #include "mozilla/TextEvents.h"
michael@0 9 #include "prtime.h"
michael@0 10
michael@0 11 namespace mozilla {
michael@0 12 namespace dom {
michael@0 13
michael@0 14 CompositionEvent::CompositionEvent(EventTarget* aOwner,
michael@0 15 nsPresContext* aPresContext,
michael@0 16 WidgetCompositionEvent* aEvent)
michael@0 17 : UIEvent(aOwner, aPresContext,
michael@0 18 aEvent ? aEvent : new WidgetCompositionEvent(false, 0, nullptr))
michael@0 19 {
michael@0 20 NS_ASSERTION(mEvent->eventStructType == NS_COMPOSITION_EVENT,
michael@0 21 "event type mismatch");
michael@0 22
michael@0 23 if (aEvent) {
michael@0 24 mEventIsInternal = false;
michael@0 25 } else {
michael@0 26 mEventIsInternal = true;
michael@0 27 mEvent->time = PR_Now();
michael@0 28
michael@0 29 // XXX compositionstart is cancelable in draft of DOM3 Events.
michael@0 30 // However, it doesn't make sence for us, we cannot cancel composition
michael@0 31 // when we sends compositionstart event.
michael@0 32 mEvent->mFlags.mCancelable = false;
michael@0 33 }
michael@0 34
michael@0 35 mData = mEvent->AsCompositionEvent()->data;
michael@0 36 // TODO: Native event should have locale information.
michael@0 37 }
michael@0 38
michael@0 39 NS_IMPL_ADDREF_INHERITED(CompositionEvent, UIEvent)
michael@0 40 NS_IMPL_RELEASE_INHERITED(CompositionEvent, UIEvent)
michael@0 41
michael@0 42 NS_INTERFACE_MAP_BEGIN(CompositionEvent)
michael@0 43 NS_INTERFACE_MAP_ENTRY(nsIDOMCompositionEvent)
michael@0 44 NS_INTERFACE_MAP_END_INHERITING(UIEvent)
michael@0 45
michael@0 46 NS_IMETHODIMP
michael@0 47 CompositionEvent::GetData(nsAString& aData)
michael@0 48 {
michael@0 49 aData = mData;
michael@0 50 return NS_OK;
michael@0 51 }
michael@0 52
michael@0 53 NS_IMETHODIMP
michael@0 54 CompositionEvent::GetLocale(nsAString& aLocale)
michael@0 55 {
michael@0 56 aLocale = mLocale;
michael@0 57 return NS_OK;
michael@0 58 }
michael@0 59
michael@0 60 NS_IMETHODIMP
michael@0 61 CompositionEvent::InitCompositionEvent(const nsAString& aType,
michael@0 62 bool aCanBubble,
michael@0 63 bool aCancelable,
michael@0 64 nsIDOMWindow* aView,
michael@0 65 const nsAString& aData,
michael@0 66 const nsAString& aLocale)
michael@0 67 {
michael@0 68 nsresult rv = UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, 0);
michael@0 69 NS_ENSURE_SUCCESS(rv, rv);
michael@0 70
michael@0 71 mData = aData;
michael@0 72 mLocale = aLocale;
michael@0 73 return NS_OK;
michael@0 74 }
michael@0 75
michael@0 76 } // namespace dom
michael@0 77 } // namespace mozilla
michael@0 78
michael@0 79 using namespace mozilla;
michael@0 80 using namespace mozilla::dom;
michael@0 81
michael@0 82 nsresult
michael@0 83 NS_NewDOMCompositionEvent(nsIDOMEvent** aInstancePtrResult,
michael@0 84 EventTarget* aOwner,
michael@0 85 nsPresContext* aPresContext,
michael@0 86 WidgetCompositionEvent* aEvent)
michael@0 87 {
michael@0 88 CompositionEvent* event = new CompositionEvent(aOwner, aPresContext, aEvent);
michael@0 89 return CallQueryInterface(event, aInstancePtrResult);
michael@0 90 }

mercurial