Delay unregistering handlers when a document is detached

When a document is detached, we need to unregister all event targets
within that document. Currently that is done too early, making it
possible for new handlers to get added into the registry before the
document is fully detached. This results in stale handlers getting left
in the registry, causing a crash an arbitrary amount of time later once
the registry is modified again.

This patch fixes the problem by clearing the registry immediately before
the document is actually detached, making it impossible for any new
handlers to be introduced.

BUG=393154

Review URL: https://codereview.chromium.org/415203003

git-svn-id: svn://svn.chromium.org/blink/trunk@178865 bbb929c8-8fbe-4397-9dbb-9b2b20218538