Note that while the code was written in 2014 (well after the iphone was released), someone tried to remove the code this year[1], and gave up because some sites now rely on this hack.
The code was added to the public WebKit source tree, but it wasn't written at the time. It was upstreamed from the internal fork of WebKit that Apple used for iOS.