A <use> that points into another SVG document renders
the shape but never animates it. Three things had to line up for that:
SVGUseElement treats SMIL elements as disallowed, so they
are not cloned into the shadow tree at all.SVGSMILElement::BuildPendingResource() ignores any timed
element that lives inside a <use> shadow tree.Same-document <use> looked fine because the referenced
element animates and the instance inherits its SMIL properties -- only
external references were dead. The CL clones the animation elements (and the
<mpath> an <animateMotion> may
contain) so an instance is created in the shadow tree, and resolves a timed
element's target in its own tree scope instead of the referenced
element's originating scope. Per
SVG2
UseAnimations an instanced animation element may only affect a target in
the same node tree, so this keeps the animation in-tree and lets the clone
drive its instance; the style resolver then uses the instance's own SMIL
properties. Behind the default-on SvgUseInstanceAnimations kill
switch.
Because targeting is now scoped to the element's own tree, a shadow-tree animation can no longer reach out of its tree, so the inert guard added for crrev.com/c/8610829 (a security fix) is only retained for the feature-off path rather than being removed.
#target stays red.
#target stays
blue, never reached by the shadow-tree animation.
external/wpt/svg/animations/use-external-resource-animate.html:
pauses the timeline and seeks past the animation instead of sleeping, so it
is deterministic. Red with
--disable-blink-features=SvgUseInstanceAnimations, green
without.external/wpt/svg/animations/use-external-resource-animate-href.html:
an instanced <animate href="#target"> animates its
in-tree target green while a same-id light-tree element stays untouched --
proving the per-tree targeting required by the spec and the security fix.external/wpt/svg/animations + svg/animations +
svg/custom/use-on-use-with-child.svg: 514 tests, all as
expected; the 6 image-diff outliers in svg/custom fail
identically on a build without the patch (verified against pristine HEAD).