Port modern callback handling code from Gecko, and copy related WebIDL parser bits too.