Bug 1077345 part.3 Add WidgetCompositionEvent::CausesDOMTextEvent() and WidgetCompositionEvent::CausesDOMCompositionEndEvent() r=smaug

This commit is contained in:
Masayuki Nakano 2014-11-25 14:02:30 +09:00
Родитель 8dbdea703b
Коммит 9a6c0e03b6
5 изменённых файлов: 21 добавлений и 9 удалений

Просмотреть файл

@ -943,7 +943,7 @@ IMEStateManager::DispatchCompositionEvent(
// destroy the TextComposition with synthesized compositionend event.
if ((!aIsSynthesized ||
composition->WasNativeCompositionEndEventDiscarded()) &&
aCompositionEvent->message == NS_COMPOSITION_END) {
aCompositionEvent->CausesDOMCompositionEndEvent()) {
TextCompositionArray::index_type i =
sTextCompositions->IndexOf(aCompositionEvent->widget);
if (i != TextCompositionArray::NoIndex) {

Просмотреть файл

@ -122,7 +122,7 @@ TextComposition::OnCompositionEventDiscarded(
// runnable event? However, even if we do so, it might make native IME
// confused due to async modification. Especially when native IME is
// TSF.
if (aCompositionEvent->message != NS_COMPOSITION_END) {
if (!aCompositionEvent->CausesDOMCompositionEndEvent()) {
return;
}
@ -185,7 +185,7 @@ TextComposition::DispatchCompositionEvent(
}
}
if (aCompositionEvent->message == NS_COMPOSITION_CHANGE) {
if (aCompositionEvent->CausesDOMTextEvent()) {
if (!MaybeDispatchCompositionUpdate(aCompositionEvent)) {
return;
}
@ -200,13 +200,13 @@ TextComposition::DispatchCompositionEvent(
// Emulate editor behavior of compositionchange event (DOM text event) handler
// if no editor handles composition events.
if (aCompositionEvent->message == NS_COMPOSITION_CHANGE && !HasEditor()) {
if (aCompositionEvent->CausesDOMTextEvent() && !HasEditor()) {
EditorWillHandleCompositionChangeEvent(aCompositionEvent);
EditorDidHandleCompositionChangeEvent();
}
#ifdef DEBUG
else if (aCompositionEvent->message == NS_COMPOSITION_END) {
else if (aCompositionEvent->CausesDOMCompositionEndEvent()) {
MOZ_ASSERT(!mIsComposing, "Why is the editor still composing?");
MOZ_ASSERT(!HasEditor(), "Why does the editor still keep to hold this?");
}
@ -240,7 +240,7 @@ TextComposition::NotityUpdateComposition(
mCompositionStartOffset = 0;
}
mCompositionTargetOffset = mCompositionStartOffset;
} else if (aCompositionEvent->message == NS_COMPOSITION_CHANGE) {
} else if (aCompositionEvent->CausesDOMTextEvent()) {
mCompositionTargetOffset =
mCompositionStartOffset + aCompositionEvent->TargetClauseOffset();
} else {

Просмотреть файл

@ -1638,11 +1638,11 @@ TabParent::SendCompositionEvent(WidgetCompositionEvent& event)
return false;
}
if (event.message == NS_COMPOSITION_CHANGE) {
if (event.CausesDOMTextEvent()) {
return SendCompositionChangeEvent(event);
}
mIMEComposing = event.message != NS_COMPOSITION_END;
mIMEComposing = !event.CausesDOMCompositionEndEvent();
mIMECompositionStart = std::min(mIMESelectionAnchor, mIMESelectionFocus);
if (mIMECompositionEnding)
return true;
@ -1673,6 +1673,7 @@ TabParent::SendCompositionChangeEvent(WidgetCompositionEvent& event)
}
mIMESelectionAnchor = mIMESelectionFocus =
mIMECompositionStart + event.mData.Length();
mIMEComposing = !event.CausesDOMCompositionEndEvent();
event.mSeqno = ++mIMESeqno;
return PBrowserParent::SendCompositionEvent(event);

Просмотреть файл

@ -331,7 +331,8 @@ PuppetWidget::DispatchEvent(WidgetGUIEvent* event, nsEventStatus& aStatus)
aStatus = mAttachedWidgetListener->HandleEvent(event, mUseAttachedEvents);
}
if (event->message == NS_COMPOSITION_END) {
if (event->mClass == eCompositionEventClass &&
event->AsCompositionEvent()->CausesDOMCompositionEndEvent()) {
mIMEComposing = false;
}

Просмотреть файл

@ -342,6 +342,16 @@ public:
{
return mRanges ? mRanges->Length() : 0;
}
bool CausesDOMTextEvent() const
{
return message == NS_COMPOSITION_CHANGE;
}
bool CausesDOMCompositionEndEvent() const
{
return message == NS_COMPOSITION_END;
}
};
/******************************************************************************