mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 1189396 part.5 IMEContentObserver should cache selection at gets focus and every selection change r=smaug
This commit is contained in:
parent
d2cd0b82ed
commit
0ac9d740da
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user