mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 617298 - Make text extraction from child process slightly more reliable, r=jchen
This commit is contained in:
parent
c57eed566e
commit
735005552f
@ -257,12 +257,28 @@ public class GeckoInputConnection
|
||||
extract.selectionStart = mSelectionStart;
|
||||
extract.selectionEnd = mSelectionStart + mSelectionLength;
|
||||
|
||||
// bug 617298 - IME_GET_TEXT sometimes gives the wrong result due to
|
||||
// a stale cache. Use a set of three workarounds:
|
||||
// 1. Sleep for 20 milliseconds and hope the child updates us with the new text.
|
||||
// Very evil and, consequentially, most effective.
|
||||
try {
|
||||
Thread.sleep(20);
|
||||
} catch (InterruptedException e) {}
|
||||
|
||||
GeckoAppShell.sendEventToGecko(
|
||||
new GeckoEvent(GeckoEvent.IME_GET_TEXT, 0, Integer.MAX_VALUE));
|
||||
try {
|
||||
extract.startOffset = 0;
|
||||
extract.text = mQueryResult.take();
|
||||
|
||||
// 2. Make a guess about what the text actually is
|
||||
if (mComposing && extract.selectionEnd > extract.text.length())
|
||||
extract.text = extract.text.subSequence(0, mCompositionStart) + mComposingText;
|
||||
|
||||
// 3. If all else fails, make sure our selection indexes make sense
|
||||
extract.selectionStart = Math.min(extract.selectionStart, extract.text.length());
|
||||
extract.selectionEnd = Math.min(extract.selectionEnd, extract.text.length());
|
||||
|
||||
if ((flags & GET_EXTRACTED_TEXT_MONITOR) != 0)
|
||||
mUpdateRequest = req;
|
||||
return extract;
|
||||
|
Loading…
Reference in New Issue
Block a user