Improve handling of duplicate id's for SVG resources
This CL attempts to fix the known issues with duplicate id's and SVG
resources. There are a variety of cases where this fails, and the added
tests attempt to cover those as well as possible.
The know bugs generally stem from:
* Resources being registered in (layout) tree order after style
recalc. This for instance mean that any later defined resources
will shadow any earlier appearing resource (which would the correct
* Removing a resource container does not consider that there could now
be another resource that is no longer shadowed by the one removed.
Together with the above, this also meant that removing a resource
from the DOM could invalidate, and break, all occurences of said
This CL attempts to handle the above by factoring the result of
getElementById into the equation, considering it to be "the truth" when
possible/required. The new methods registerResource and
unregisterResource form the basis of this, codifying the two basic
operations on which the tracking is built. The tracking of the
'registered' flag from LayoutSVGResourceContainer is now handled by
SVGTreeScopeResources. While this flag could be considered an
optimization at this point, DCHECKs are added to attempt to keep it
true to it's purpose.