Make ErrorEvent::new take cancelable and bubbling enums
auto merge of #4372 : thiagopnts/servo/errorevent, r=Ms2ger

Fixes #4174.
script: Improve dirty propagation and fix script-layout synchronization.

This fixes race conditions whereby layout and script could be running
simultaneously.
script: Add some workarounds for image cache task races