An empty autocorrection context is expected to have a marked text range of, emphasis mine, NSMakeRange(**NSNotFound**, 0) NOT, again emphasis mine, NSMakeRange(**WTF::notFound**, 0). Subtle detail here: NSNotFound is equal to INT_MAX, but WTF::notFound = static_cast<size_t>(-1). Clients, like TextInput don't know that NSMakeRange(WTF::notFound, 0) represent the empty range. They only know that NSMakeRange(NSNotFound, 0) represents the empty range.
Note that -[WKAutocorrectionContext emptyAutocorrectionContext:] just turns around and calls -[WKAutocorrectionContext autocorrectionContextWithWebContext:] so it's actually the latter that has the bug, but who would duplicate code when they could just call -[WKAutocorrectionContext emptyAutocorrectionContext:] 😀.
Created attachment 367832 [details]
Comment on attachment 367832 [details]
Clearing flags on attachment: 367832
Committed r244473: <https://trac.webkit.org/changeset/244473>
All reviewed patches have been landed. Closing bug.