Bug 1077345 part.2 Add TextComposition::CloneAndDispatchAs() for dispatching WidgetCompositionEvent only whose message is different from original composition event r=smaug

This commit is contained in:
Masayuki Nakano 2014-11-25 14:02:30 +09:00
parent 45cdb47081
commit 33d0d1a3b6
2 changed files with 29 additions and 10 deletions

View File

@ -80,21 +80,32 @@ TextComposition::MaybeDispatchCompositionUpdate(
if (mLastData == aCompositionEvent->mData) {
return true;
}
CloneAndDispatchAs(aCompositionEvent, NS_COMPOSITION_UPDATE);
return IsValidStateForComposition(aCompositionEvent->widget);
}
WidgetCompositionEvent compositionUpdate(aCompositionEvent->mFlags.mIsTrusted,
NS_COMPOSITION_UPDATE,
aCompositionEvent->widget);
compositionUpdate.time = aCompositionEvent->time;
compositionUpdate.timeStamp = aCompositionEvent->timeStamp;
compositionUpdate.mData = aCompositionEvent->mData;
compositionUpdate.mFlags.mIsSynthesizedForTests =
void
TextComposition::CloneAndDispatchAs(
const WidgetCompositionEvent* aCompositionEvent,
uint32_t aMessage)
{
MOZ_ASSERT(IsValidStateForComposition(aCompositionEvent->widget),
"Should be called only when it's safe to dispatch an event");
WidgetCompositionEvent compositionEvent(aCompositionEvent->mFlags.mIsTrusted,
aMessage, aCompositionEvent->widget);
compositionEvent.time = aCompositionEvent->time;
compositionEvent.timeStamp = aCompositionEvent->timeStamp;
compositionEvent.mData = aCompositionEvent->mData;
compositionEvent.mFlags.mIsSynthesizedForTests =
aCompositionEvent->mFlags.mIsSynthesizedForTests;
nsEventStatus status = nsEventStatus_eConsumeNoDefault;
mLastData = compositionUpdate.mData;
if (aMessage == NS_COMPOSITION_UPDATE) {
mLastData = compositionEvent.mData;
}
EventDispatcher::Dispatch(mNode, mPresContext,
&compositionUpdate, nullptr, &status, nullptr);
return IsValidStateForComposition(aCompositionEvent->widget);
&compositionEvent, nullptr, &status, nullptr);
}
void

View File

@ -275,6 +275,14 @@ private:
bool MaybeDispatchCompositionUpdate(
const WidgetCompositionEvent* aCompositionEvent);
/**
* CloneAndDispatchAs() dispatches a composition event which is
* duplicateed from aCompositionEvent and set the aMessage.
*/
void CloneAndDispatchAs(
const WidgetCompositionEvent* aCompositionEvent,
uint32_t aMessage);
/**
* If IME has already dispatched compositionend event but it was discarded
* by PresShell due to not safe to dispatch, this returns true.