Pressing cmd+esc will invoke the webview complete: method, that will popup a list of words that complete the text typed so far. This functionality only works if you hit cmd-esc after the last word on the page, or if you type cmd-esc while within a word. It doesn't work if you hit cmd-esc at the end of a word that is not the last one. In the attached sample hit cmd-esc when the cursor is just after "one", you will get a NSBeep(). If you hit cmd-esc with the cursor after "three" it will work. A rough guess is that this happens because -[WebTextCompleteController doCompletion] is calling [bridge rangeByExpandingSelectionWithGranularity:WebSelectByWord] that doesn't work when a space follows the cursor. The spelling suggestion functionality appears to be filtered away by safari, so it's not testable with a plain web page.
Created attachment 3007 [details] test case Create a cocoa app in xcode, replace main.m with the attachment and add the WebKit.framework to the project.
Confirmed with ToT (running Blot)
Created attachment 4490 [details] proposed patch (use rangeByAlteringCurrentSelection) I have also thought about changing rangeByExpandingSelectionWithGranularity: to work in this case, but this seems to require quite a number of changes to how a selection's affinity is set in various places, which may or may not be desirable...
Created attachment 4491 [details] proposed patch (use rangeByAlteringCurrentSelection) An unrelated change sneaked into the patch...
Comment on attachment 4491 [details] proposed patch (use rangeByAlteringCurrentSelection) Looks fine. r=me