Bug 1450250: Make <animate> target the light DOM parent, not the flattened tree parent. r=heycam

This matches Chrome:

  https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/svg/animation/svg_smil_element.cc?l=260&rcl=325eafc631f396944801f17675a7092b216d60ca

And we rely on that to animate <use> with SMIL, like:

<use href="#foo">
  <animate ...>
</use>

There, the flattened tree parent of the <animate> element is null, because <use>
is a shadow root without slots.

Similarly we need to skip the GetCtx check which seems unneeded, and also is not
correct since <animate> can animate when it's out of the flattened tree.

Differential Revision: https://phabricator.services.mozilla.com/D2194

MozReview-Commit-ID: 13hRCOj500n
This commit is contained in:
Emilio Cobos Álvarez 2018-07-17 19:09:15 +02:00
Родитель add2e33db0
Коммит 8eaddfbb80
1 изменённых файлов: 5 добавлений и 11 удалений

Просмотреть файл

@ -72,7 +72,10 @@ SVGAnimationElement::GetTargetElementContent()
"if we don't have an xlink:href or href attribute");
// No "href" or "xlink:href" attribute --> I should target my parent.
return GetFlattenedTreeParentElement();
//
// Note that we want to use GetParentElement instead of the flattened tree to
// allow <use><animate>, for example.
return GetParentElement();
}
bool
@ -168,15 +171,6 @@ SVGAnimationElement::BindToTree(nsIDocument* aDocument,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv,rv);
// XXXdholbert is GetCtx (as a check for SVG parent) still needed here?
if (!GetCtx()) {
// No use proceeding. We don't have an SVG parent (yet) so we won't be able
// to register ourselves etc. Maybe next time we'll have more luck.
// (This sort of situation will arise a lot when trees are being constructed
// piece by piece via script)
return NS_OK;
}
// Add myself to the animation controller's master set of animation elements.
if (nsIDocument* doc = GetComposedDoc()) {
nsSMILAnimationController* controller = doc->GetAnimationController();
@ -208,7 +202,7 @@ SVGAnimationElement::BindToTree(nsIDocument* aDocument,
void
SVGAnimationElement::UnbindFromTree(bool aDeep, bool aNullParent)
{
nsSMILAnimationController *controller = OwnerDoc()->GetAnimationController();
nsSMILAnimationController* controller = OwnerDoc()->GetAnimationController();
if (controller) {
controller->UnregisterAnimationElement(this);
}