mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 729774 part.2 nsGtkIMModule should store selected text which will be removed by first text event r=karlt
This commit is contained in:
parent
c29ddcb682
commit
84e76f90cd
@ -454,6 +454,10 @@ nsGtkIMModule::OnFocusChangeInGecko(bool aFocus)
|
||||
this, aFocus ? "YES" : "NO", GetCompositionStateName(),
|
||||
mIsIMFocused ? "YES" : "NO",
|
||||
mIgnoreNativeCompositionEvent ? "YES" : "NO"));
|
||||
|
||||
// We shouldn't carry over the removed string to another editor.
|
||||
mSelectedString.Truncate();
|
||||
|
||||
if (aFocus) {
|
||||
// If we failed to commit forcedely in previous focused editor,
|
||||
// we should reopen the gate for native signals in new focused editor.
|
||||
@ -1093,6 +1097,10 @@ nsGtkIMModule::DispatchCompositionStart()
|
||||
return false;
|
||||
}
|
||||
|
||||
// XXX The composition start point might be changed by composition events
|
||||
// even though we strongly hope it doesn't happen.
|
||||
// Every composition event should have the start offset for the result
|
||||
// because it may high cost if we query the offset every time.
|
||||
mCompositionStart = selection.mReply.mOffset;
|
||||
mDispatchedCompositionString.Truncate();
|
||||
|
||||
@ -1220,6 +1228,20 @@ nsGtkIMModule::DispatchTextEvent(const nsAString &aCompositionString,
|
||||
}
|
||||
}
|
||||
|
||||
// Store the selected string which will be removed by following text event.
|
||||
if (mCompositionState == eCompositionState_CompositionStartDispatched) {
|
||||
// XXX We should assume, for now, any web applications don't change
|
||||
// selection at handling this text event.
|
||||
nsQueryContentEvent querySelectedTextEvent(true,
|
||||
NS_QUERY_SELECTED_TEXT,
|
||||
mLastFocusedWindow);
|
||||
mLastFocusedWindow->DispatchEvent(&querySelectedTextEvent, status);
|
||||
if (querySelectedTextEvent.mSucceeded) {
|
||||
mSelectedString = querySelectedTextEvent.mReply.mString;
|
||||
mCompositionStart = querySelectedTextEvent.mReply.mOffset;
|
||||
}
|
||||
}
|
||||
|
||||
nsTextEvent textEvent(true, NS_TEXT_TEXT, mLastFocusedWindow);
|
||||
InitEvent(textEvent);
|
||||
|
||||
|
@ -169,6 +169,10 @@ protected:
|
||||
// was dispatched by compositionupdate event.
|
||||
nsString mDispatchedCompositionString;
|
||||
|
||||
// mSelectedString is the selected string which was removed by first
|
||||
// text event.
|
||||
nsString mSelectedString;
|
||||
|
||||
// OnKeyEvent() temporarily sets mProcessingKeyEvent to the given native
|
||||
// event.
|
||||
GdkEventKey* mProcessingKeyEvent;
|
||||
|
Loading…
Reference in New Issue
Block a user