Bug 1189396 part.5 IMEContentObserver should cache selection at gets focus and every selection change r=smaug

This commit is contained in:
Masayuki Nakano 2015-08-22 01:43:42 +09:00
parent d2cd0b82ed
commit 0ac9d740da

View File

@ -409,16 +409,11 @@ IMEContentObserver::NotifySelectionChanged(nsIDOMDocument* aDOMDocument,
nsISelection* aSelection,
int16_t aReason)
{
bool causedByComposition = IsEditorHandlingEventForComposition();
if (causedByComposition &&
!mUpdatePreference.WantChangesCausedByComposition()) {
return NS_OK;
}
int32_t count = 0;
nsresult rv = aSelection->GetRangeCount(&count);
NS_ENSURE_SUCCESS(rv, rv);
if (count > 0 && mWidget) {
bool causedByComposition = IsEditorHandlingEventForComposition();
bool causedBySelectionEvent = TextComposition::IsHandlingSelectionEvent();
MaybeNotifyIMEOfSelectionChange(causedByComposition,
causedBySelectionEvent);
@ -1067,6 +1062,8 @@ IMEContentObserver::FocusSetEvent::Run()
}
mIMEContentObserver->mIMEHasFocus = true;
// Initialize selection cache with the first selection data.
mIMEContentObserver->UpdateSelectionCache();
IMEStateManager::NotifyIME(IMENotification(NOTIFY_IME_OF_FOCUS),
mIMEContentObserver->mWidget);
return NS_OK;
@ -1093,6 +1090,14 @@ IMEContentObserver::SelectionChangeEvent::Run()
return NS_OK;
}
// If the IME doesn't want selection change notifications caused by
// composition, we should do nothing anymore.
if (mCausedByComposition &&
!mIMEContentObserver->
mUpdatePreference.WantChangesCausedByComposition()) {
return NS_OK;
}
// The state may be changed since querying content causes flushing layout.
if (!CanNotifyIME()) {
return NS_OK;