See summary.
Created attachment 27872 [details] Proposed patch.
Comment on attachment 27872 [details] Proposed patch. r=me
Committed in r41157.