Bug 197119

Summary: -[WKAutocorrectionContext emptyAutocorrectionContext:] generates invalid empty context
Product: WebKit Reporter: Daniel Bates <dbates>
Component: WebKit Misc.Assignee: Daniel Bates <dbates>
Status: RESOLVED FIXED    
Severity: Normal CC: megan_gardner, thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: iPhone / iPad   
OS: iOS 12   
Attachments:
Description Flags
Patch none

Description Daniel Bates 2019-04-19 14:35:32 PDT
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:] 😀.
Comment 1 Daniel Bates 2019-04-19 14:48:59 PDT
Created attachment 367832 [details]
Patch
Comment 2 Daniel Bates 2019-04-19 16:48:44 PDT
Comment on attachment 367832 [details]
Patch

Clearing flags on attachment: 367832

Committed r244473: <https://trac.webkit.org/changeset/244473>
Comment 3 Daniel Bates 2019-04-19 16:48:46 PDT
All reviewed patches have been landed.  Closing bug.
Comment 4 Radar WebKit Bug Importer 2019-04-19 16:49:21 PDT
<rdar://problem/50064006>