mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
779efe1c1a
--HG-- rename : dom/events/nsDOMUIEvent.cpp => dom/events/UIEvent.cpp rename : dom/events/nsDOMUIEvent.h => dom/events/UIEvent.h
87 lines
2.5 KiB
C++
87 lines
2.5 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=2 sw=2 et tw=78: */
|
|
/* 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/. */
|
|
|
|
#include "nsDOMTextEvent.h"
|
|
#include "nsPrivateTextRange.h"
|
|
#include "prtime.h"
|
|
#include "mozilla/TextEvents.h"
|
|
|
|
using namespace mozilla;
|
|
using namespace mozilla::dom;
|
|
|
|
nsDOMTextEvent::nsDOMTextEvent(mozilla::dom::EventTarget* aOwner,
|
|
nsPresContext* aPresContext,
|
|
WidgetTextEvent* aEvent)
|
|
: UIEvent(aOwner, aPresContext,
|
|
aEvent ? aEvent : new WidgetTextEvent(false, 0, nullptr))
|
|
{
|
|
NS_ASSERTION(mEvent->eventStructType == NS_TEXT_EVENT, "event type mismatch");
|
|
|
|
if (aEvent) {
|
|
mEventIsInternal = false;
|
|
}
|
|
else {
|
|
mEventIsInternal = true;
|
|
mEvent->time = PR_Now();
|
|
}
|
|
|
|
//
|
|
// extract the IME composition string
|
|
//
|
|
WidgetTextEvent* te = mEvent->AsTextEvent();
|
|
mText = te->theText;
|
|
|
|
//
|
|
// build the range list -- ranges need to be DOM-ified since the
|
|
// IME transaction will hold a ref, the widget representation
|
|
// isn't persistent
|
|
//
|
|
mTextRange = new nsPrivateTextRangeList(te->rangeCount);
|
|
if (mTextRange) {
|
|
uint16_t i;
|
|
|
|
for(i = 0; i < te->rangeCount; i++) {
|
|
nsRefPtr<nsPrivateTextRange> tempPrivateTextRange = new
|
|
nsPrivateTextRange(te->rangeArray[i]);
|
|
|
|
if (tempPrivateTextRange) {
|
|
mTextRange->AppendTextRange(tempPrivateTextRange);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
NS_IMPL_ADDREF_INHERITED(nsDOMTextEvent, UIEvent)
|
|
NS_IMPL_RELEASE_INHERITED(nsDOMTextEvent, UIEvent)
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsDOMTextEvent)
|
|
NS_INTERFACE_MAP_ENTRY(nsIPrivateTextEvent)
|
|
NS_INTERFACE_MAP_END_INHERITING(UIEvent)
|
|
|
|
NS_METHOD nsDOMTextEvent::GetText(nsString& aText)
|
|
{
|
|
aText = mText;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_METHOD_(already_AddRefed<nsIPrivateTextRangeList>) nsDOMTextEvent::GetInputRange()
|
|
{
|
|
if (mEvent->message == NS_TEXT_TEXT) {
|
|
nsRefPtr<nsPrivateTextRangeList> textRange = mTextRange;
|
|
return textRange.forget();
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
nsresult NS_NewDOMTextEvent(nsIDOMEvent** aInstancePtrResult,
|
|
mozilla::dom::EventTarget* aOwner,
|
|
nsPresContext* aPresContext,
|
|
WidgetTextEvent* aEvent)
|
|
{
|
|
nsDOMTextEvent* it = new nsDOMTextEvent(aOwner, aPresContext, aEvent);
|
|
return CallQueryInterface(it, aInstancePtrResult);
|
|
}
|