• Darren Shen's avatar
    imf: Call SetComposition with empty composition when it is pending. · 3a6383c1
    Darren Shen authored
    During the handling of a key event, an IME may call SetComposition. IMF will
    delay the processing of SetComposition until the key event is handled.
    
    However, when a call to SetComposition("") is delayed, it is run as
    ClearComposition() when the key event is handled. This can cause issues because
    SetComposition("") has different behaviour from ClearComposition().
    Specifically, SetComposition("") deletes any selected text, whereas
    ClearComposition doesn't.
    
    The root cause is that the code uses empty composition text to indicate that
    there's a pending ClearComposition. So it's impossible to distinguish between a
    pending SetComposition("") from a ClearComposition().
    
    Fix this by putting the pending composition into an Optional, so that nullopt
    means ClearComposition and anything else is SetComposition.
    
    Bug: b/172284307
    Change-Id: Iec39e8124eab6bd897d543f66f1a4bdb71b3fe78
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2520556Reviewed-by: default avatarShu Chen <shuchen@chromium.org>
    Commit-Queue: Darren Shen <shend@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#825253}
    3a6383c1
input_method_chromeos.h 7.24 KB