• Bruce Long's avatar
    Windows Spellcheck: Init service on clicking in editable content · a98ae0da
    Bruce Long authored
    This is another incremental change towards the goal of having the
    spellcheck service initialized on demand, so that there is no
    performance hit from loading DLLs supporting the Windows platform
    spellchecker on browser startup. The previous change in this effort:
    
        2239682: Windows Spellcheck: Further work on delay init of
        spellcheck service
        https://chromium-review.googlesource.com/c/chromium/src/+/2239682
    
    listed the following remaining work to be done:
    
    1) In first run scenarios we would still need to load the dictionaries
    at browser startup, in order to assure that even if a user never uses
    spellcheck in their first browser session after installation,
    spellcheck will be enabled for their primary preferred language in the
    case where the language has Windows platform but not Hunspell support
    (a leading example being Arabic).
    2) On going to a page with editable content without first visiting
    the languages settings page, clicking in the editable content should
    initialize the spellcheck service in the browser process.
    3) On right-clicking in editable content to bring up the context menu,
    the spellcheck service needs to be instantiated in order to populate
    the languages presented in the spellcheck languages submenu.
    
    This CL accomplishes (2). When focus enters editable content, the
    method SpellCheckProvider::RequestTextChecking is called from
    Blink code in the renderer process. Previously if the spellcheck
    service was not initialized, the method would exit without performing
    a text check, because there were no native or Hunspell dictionaries
    loaded. Now a mojo call is made to asynchronously initialize the
    spellcheck service in the browser process. When the dictionaries are
    loaded, a callback is made to the renderer, and the text checking
    can continue as before.
    
    In all my testing so far this change also fixes (3) as a side effect,
    since I haven't discovered any way to bring up the context menu for
    editable content without putting the focus there, and gaining focus
    invokes a spellcheck request (scenario 2) and thus initializes the
    spellcheck service. So unless I am still missing some other scenario
    that is broken by delayed initialization, only scenario (1) needs
    to be fixed before the WinDelaySpellcheckServiceInit feature flag
    can be enabled by default.
    
    Bug: 1064351
    Change-Id: I972e76c3052f83f9e05d57086a7cb27e5d9f6ef5
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2283370Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
    Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
    Reviewed-by: default avatarGuillaume Jenkins <gujen@google.com>
    Commit-Queue: Bruce Long <brlong@microsoft.com>
    Cr-Commit-Position: refs/heads/master@{#787864}
    a98ae0da
spellcheck_provider_unittest.cc 26.4 KB