Commit 97501194 authored by fs's avatar fs Committed by Commit bot

Block animation of the SVGScriptElement

'href' should not be animatable for SVGScriptElements, but currently is.
This will "break" animation of 'className' on the same element.

R=mkwst@chromium.org,pdr@chromium.org
BUG=679291

Review-Url: https://codereview.chromium.org/2618323002
Cr-Commit-Position: refs/heads/master@{#442915}
parent e5cfe692
<!DOCTYPE html>
<title>SVGScriptElement.href should not be animatable</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
var foo = 42;
async_test(t => {
window.onload = () => {
var s = document.createElementNS('http://www.w3.org/2000/svg', 'script');
s.onload = t.unreached_func('Should not get a load event');
s.id = 'x';
document.querySelector('svg').appendChild(s);
requestAnimationFrame(_ => {
requestAnimationFrame(t.step_func_done(_ => {
assert_equals(foo, 42);
}));
});
};
});
</script>
<svg xmlns:xlink="http://www.w3.org/1999/xlink">
<set href="#x" attributeName="href" to="resources/set-foo.js"/>
<set href="#x" attributeName="xlink:href" to="resources/set-foo.js"/>
<animate href="#x" attributeName="href" to="resources/set-foo.js" dur="0.01s"/>
<animate href="#x" attributeName="xlink:href" to="resources/set-foo.js" dur="0.01s"/>
</svg>
......@@ -192,6 +192,14 @@ void SVGAnimateElement::resolveTargetProperty() {
? cssPropertyID(attributeName().localName())
: CSSPropertyInvalid;
}
// Blacklist <script> targets here for now to prevent unpleasantries. This
// also disallows the perfectly "valid" animation of 'className' on said
// element. If SVGScriptElement.href is transitioned off of SVGAnimatedHref,
// this can be removed.
if (isSVGScriptElement(*targetElement())) {
m_type = AnimatedUnknown;
m_cssPropertyId = CSSPropertyInvalid;
}
DCHECK(m_type != AnimatedPoint && m_type != AnimatedStringList &&
m_type != AnimatedTransform && m_type != AnimatedTransformList);
}
......
......@@ -22,6 +22,7 @@
#include "bindings/core/v8/ScriptEventListener.h"
#include "core/HTMLNames.h"
#include "core/XLinkNames.h"
#include "core/dom/Attribute.h"
#include "core/dom/ScriptLoader.h"
#include "core/dom/ScriptRunner.h"
......@@ -146,9 +147,9 @@ void SVGScriptElement::dispatchLoadEvent() {
#if DCHECK_IS_ON()
bool SVGScriptElement::isAnimatableAttribute(const QualifiedName& name) const {
if (name == SVGNames::typeAttr)
if (name == SVGNames::typeAttr || name == SVGNames::hrefAttr ||
name == XLinkNames::hrefAttr)
return false;
return SVGElement::isAnimatableAttribute(name);
}
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment