Bug 669865 - Calling clear() on list types should set mIsBaseSet to false so that we ignore the transform r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D192063
This commit is contained in:
Robert Longson 2023-10-27 11:52:05 +00:00
Родитель 02e26c5d93
Коммит 42f3b82240
5 изменённых файлов: 30 добавлений и 9 удалений

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

@ -129,7 +129,9 @@ void DOMSVGNumberList::Clear(ErrorResult& error) {
mAList->InternalBaseValListWillChangeTo(SVGNumberList());
mItems.Clear();
InternalList().Clear();
auto* alist = Element()->GetAnimatedNumberList(AttrEnum());
alist->mBaseVal.Clear();
alist->mIsBaseSet = false;
}
}

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

@ -130,7 +130,9 @@ void DOMSVGTransformList::Clear(ErrorResult& error) {
mAList->InternalBaseValListWillChangeLengthTo(0);
mItems.Clear();
InternalList().Clear();
auto* alist = Element()->GetAnimatedTransformList();
alist->mBaseVal.Clear();
alist->mIsBaseSet = false;
}
}

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

@ -60,7 +60,7 @@ nsresult SVGAnimatedTransformList::SetBaseValue(const SVGTransformList& aValue,
// back to the same length:
domWrapper->InternalBaseValListWillChangeLengthTo(mBaseVal.Length());
} else {
mIsAttrSet = true;
mIsBaseSet = true;
// We only need to treat this as a creation or removal of a transform if the
// frame already exists and it didn't have an existing one.
mCreatedOrRemovedOnLastChange =
@ -79,7 +79,7 @@ void SVGAnimatedTransformList::ClearBaseValue() {
domWrapper->InternalBaseValListWillChangeLengthTo(0);
}
mBaseVal.Clear();
mIsAttrSet = false;
mIsBaseSet = false;
// Caller notifies
}
@ -155,14 +155,14 @@ bool SVGAnimatedTransformList::IsExplicitlySet() const {
// been explicitly set.
//
// There are three ways an animated list can become set:
// 1) Markup -- we set mIsAttrSet to true on any successful call to
// 1) Markup -- we set mIsBaseSet to true on any successful call to
// SetBaseValueString and clear it on ClearBaseValue (as called by
// SVGElement::UnsetAttr or a failed SVGElement::ParseAttribute)
// 2) DOM call -- simply fetching the baseVal doesn't mean the transform value
// has been set. It is set if that baseVal has one or more transforms in
// the list.
// 3) Animation -- which will cause the mAnimVal member to be allocated
return mIsAttrSet || !mBaseVal.IsEmpty() || mAnimVal;
return mIsBaseSet || !mBaseVal.IsEmpty() || mAnimVal;
}
UniquePtr<SMILAttr> SVGAnimatedTransformList::ToSMILAttr(

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

@ -45,14 +45,14 @@ class SVGAnimatedTransformList {
public:
SVGAnimatedTransformList()
: mIsAttrSet(false), mCreatedOrRemovedOnLastChange(true) {}
: mIsBaseSet(false), mCreatedOrRemovedOnLastChange(true) {}
SVGAnimatedTransformList& operator=(const SVGAnimatedTransformList& aOther) {
mBaseVal = aOther.mBaseVal;
if (aOther.mAnimVal) {
mAnimVal = MakeUnique<SVGTransformList>(*aOther.mAnimVal);
}
mIsAttrSet = aOther.mIsAttrSet;
mIsBaseSet = aOther.mIsBaseSet;
mCreatedOrRemovedOnLastChange = aOther.mCreatedOrRemovedOnLastChange;
return *this;
}
@ -127,7 +127,7 @@ class SVGAnimatedTransformList {
SVGTransformList mBaseVal;
UniquePtr<SVGTransformList> mAnimVal;
bool mIsAttrSet;
bool mIsBaseSet;
// See documentation for accessor.
bool mCreatedOrRemovedOnLastChange;

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

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:h="http://www.w3.org/1999/xhtml">
<title>SVG Paint Servers: Clear should cause patternTransform to be ignored.</title>
<metadata>
<h:link rel="help" href="https://svgwg.org/svg2-draft/pservers.html#PatternElementPatternTransformAttribute"/>
<h:link rel="match" href="../reftests/reference/green-100x100.svg"/>
</metadata>
<pattern id="p1" patternTransform="scale(2)"/>
<pattern id="p" href="#p1" viewBox="0 0 50 50" patternTransform="scale(1)" width="100%" height="100%">
<rect fill="red" width="50" height="50"/>
<rect fill="green" width="25" height="25"/>
</pattern>
<rect fill="url(#p)" width="100" height="100"/>
<script><![CDATA[
document.getElementById("p").patternTransform.baseVal.clear();
]]></script>
</svg>

После

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