Refactor adding and removing named and IDed elements

This CL prepares us to register named and IDed elements on the document for
quick access by the global namespace polluters. By itself, this CL shouldn't
have any visible effects.

R=adamk@chromium.org
BUG=265009

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

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