зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1077345 part.3 Add WidgetCompositionEvent::CausesDOMTextEvent() and WidgetCompositionEvent::CausesDOMCompositionEndEvent() r=smaug
This commit is contained in:
Родитель
8dbdea703b
Коммит
9a6c0e03b6
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
|
|
Загрузка…
Ссылка в новой задаче