Bug 1717312 - clear mapped values if we're not animating any more r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D188712
This commit is contained in:
Robert Longson 2023-09-20 19:17:21 +00:00
Родитель 4c5476f29b
Коммит 905dbcc069
4 изменённых файлов: 36 добавлений и 7 удалений

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

@ -101,9 +101,7 @@ nsresult SMILCSSProperty::SetAnimValue(const SMILValue& aValue) {
}
void SMILCSSProperty::ClearAnimValue() {
// Put empty string in override style for our property
mElement->SMILOverrideStyle()->SetPropertyValue(mPropID, ""_ns, nullptr,
IgnoreErrors());
mElement->SMILOverrideStyle()->ClearSMILValue(mPropID);
}
// Based on http://www.w3.org/TR/SVG/propidx.html

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

@ -1507,8 +1507,13 @@ void SVGElement::DidAnimateLength(uint8_t aAttrEnum) {
// We don't map use element width/height currently. We can remove this
// test when we do.
if (propId != eCSSProperty_UNKNOWN) {
auto lengthInfo = GetLengthInfo();
if (lengthInfo.mValues[aAttrEnum].IsAnimated()) {
SMILOverrideStyle()->SetSMILValue(propId,
GetLengthInfo().mValues[aAttrEnum]);
lengthInfo.mValues[aAttrEnum]);
} else {
SMILOverrideStyle()->ClearSMILValue(propId);
}
}
}
@ -1711,8 +1716,13 @@ void SVGElement::DidAnimatePathSegList() {
// Notify style we have to update the d property because of SMIL animation.
if (name == nsGkAtoms::d) {
auto* animPathSegList = GetAnimPathSegList();
if (animPathSegList->IsAnimating()) {
SMILOverrideStyle()->SetSMILValue(nsCSSPropertyID::eCSSProperty_d,
*GetAnimPathSegList());
*animPathSegList);
} else {
SMILOverrideStyle()->ClearSMILValue(nsCSSPropertyID::eCSSProperty_d);
}
}
DidAnimateAttribute(kNameSpaceID_None, name);

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

@ -55,6 +55,10 @@ class nsDOMCSSAttributeDeclaration final : public nsDOMCSSDeclaration {
const SVGAnimatedLength& aLength);
nsresult SetSMILValue(const nsCSSPropertyID,
const mozilla::SVGAnimatedPathSegList& aPath);
void ClearSMILValue(const nsCSSPropertyID aPropID) {
// Put empty string in override style for our property
SetPropertyValue(aPropID, ""_ns, nullptr, mozilla::IgnoreErrors());
}
void SetPropertyValue(const nsCSSPropertyID aPropID, const nsACString& aValue,
nsIPrincipal* aSubjectPrincipal,

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

@ -0,0 +1,17 @@
<svg class="reftest-wait" onload="load()" xmlns="http://www.w3.org/2000/svg"
xmlns:html="http://www.w3.org/1999/xhtml">
<html:link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1717312"/>
<html:script src="/common/reftest-wait.js"/>
<html:script src="/common/rendering-utils.js"/>
<html:link rel="match" href="../../embedded/reference/green-rect-100x100.svg"/>
<rect id="r" width="100" height="50" fill="green">
<animate attributeName="height" values="0" dur="20ms"/>
</rect>
<script>
function load() {
document.documentElement.setCurrentTime(1);
document.getElementById("r").setAttribute("height", 100);
waitForAtLeastOneFrame().then(takeScreenshot);
}
</script>
</svg>

После

Ширина:  |  Высота:  |  Размер: 735 B