Split it up and use helper functions.
Created attachment 243208 [details] patch
Comment on attachment 243208 [details] patch Nice. r=me
https://trac.webkit.org/r177229