2011-09-22 02:17:40 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-09-22 02:17:40 -07:00
|
|
|
|
|
|
|
#include "nsDOMCompositionEvent.h"
|
2013-07-03 08:56:26 -07:00
|
|
|
#include "prtime.h"
|
2013-09-25 04:21:19 -07:00
|
|
|
#include "mozilla/TextEvents.h"
|
2011-09-22 02:17:40 -07:00
|
|
|
|
2013-10-01 00:23:00 -07:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2013-03-09 03:34:29 -08:00
|
|
|
nsDOMCompositionEvent::nsDOMCompositionEvent(mozilla::dom::EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
2013-10-01 00:23:00 -07:00
|
|
|
WidgetCompositionEvent* aEvent)
|
2013-03-09 03:34:29 -08:00
|
|
|
: nsDOMUIEvent(aOwner, aPresContext, aEvent ? aEvent :
|
2013-10-01 00:23:00 -07:00
|
|
|
new WidgetCompositionEvent(false, 0, nullptr))
|
2011-09-22 02:17:40 -07:00
|
|
|
{
|
|
|
|
NS_ASSERTION(mEvent->eventStructType == NS_COMPOSITION_EVENT,
|
|
|
|
"event type mismatch");
|
|
|
|
|
|
|
|
if (aEvent) {
|
2011-10-17 07:59:28 -07:00
|
|
|
mEventIsInternal = false;
|
2011-09-22 02:17:40 -07:00
|
|
|
} else {
|
2011-10-17 07:59:28 -07:00
|
|
|
mEventIsInternal = true;
|
2011-09-22 02:17:40 -07:00
|
|
|
mEvent->time = PR_Now();
|
|
|
|
|
|
|
|
// XXX compositionstart is cancelable in draft of DOM3 Events.
|
|
|
|
// However, it doesn't make sence for us, we cannot cancel composition
|
|
|
|
// when we sends compositionstart event.
|
2012-12-15 17:26:03 -08:00
|
|
|
mEvent->mFlags.mCancelable = false;
|
2011-09-22 02:17:40 -07:00
|
|
|
}
|
|
|
|
|
2013-10-17 23:10:25 -07:00
|
|
|
mData = mEvent->AsCompositionEvent()->data;
|
2011-09-22 02:17:40 -07:00
|
|
|
// TODO: Native event should have locale information.
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(nsDOMCompositionEvent, nsDOMUIEvent)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsDOMCompositionEvent, nsDOMUIEvent)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsDOMCompositionEvent)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCompositionEvent)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMCompositionEvent::GetData(nsAString& aData)
|
|
|
|
{
|
|
|
|
aData = mData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMCompositionEvent::GetLocale(nsAString& aLocale)
|
|
|
|
{
|
|
|
|
aLocale = mLocale;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMCompositionEvent::InitCompositionEvent(const nsAString& aType,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aCanBubble,
|
|
|
|
bool aCancelable,
|
2011-09-22 02:17:40 -07:00
|
|
|
nsIDOMWindow* aView,
|
|
|
|
const nsAString& aData,
|
|
|
|
const nsAString& aLocale)
|
|
|
|
{
|
|
|
|
nsresult rv =
|
|
|
|
nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, 0);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
mData = aData;
|
|
|
|
mLocale = aLocale;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewDOMCompositionEvent(nsIDOMEvent** aInstancePtrResult,
|
2013-03-09 03:34:29 -08:00
|
|
|
mozilla::dom::EventTarget* aOwner,
|
2011-09-22 02:17:40 -07:00
|
|
|
nsPresContext* aPresContext,
|
2013-10-01 00:23:00 -07:00
|
|
|
WidgetCompositionEvent* aEvent)
|
2011-09-22 02:17:40 -07:00
|
|
|
{
|
|
|
|
nsDOMCompositionEvent* event =
|
2013-03-09 03:34:29 -08:00
|
|
|
new nsDOMCompositionEvent(aOwner, aPresContext, aEvent);
|
2011-09-22 02:17:40 -07:00
|
|
|
return CallQueryInterface(event, aInstancePtrResult);
|
|
|
|
}
|