Implement document load tracking.

Improves on the state of the art for #1416. Images, XHR, stylesheets, and scripts now block the document load event from firing, and DOMContentLoaded is dispatched after parsing is complete.
OK. I'm slightly worried about 1:1 objects, because when working on Gecko, there have been occasions when I've hoped nsScriptLoader was part of nsDocument and, more importantly, have hoped that nsDocShell and nsDocLoader were just one class.

That is, considering the level of intertwingularity that's expected here, I'm not convinced that it's worthwhile to have a constellation of 1:1 classes instead of just 1big class for each thing that counts as an indivisible thing in the Web Platform.