See summary.
Created attachment 30110 [details] patch
Created attachment 30113 [details] patch2
Landed as http://trac.webkit.org/changeset/43517.