Bug 1687195 - Invalid enums should return the initial value, not the unknown value r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D102131
This commit is contained in:
longsonr 2021-01-18 11:10:56 +00:00
Родитель b6fbbfced5
Коммит 3beb46b1eb
4 изменённых файлов: 5 добавлений и 19 удалений

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

@ -64,8 +64,8 @@ bool SVGAnimatedEnumeration::SetBaseValueAtom(const nsAtom* aValue,
while (mapping && mapping->mKey) {
if (aValue == mapping->mKey) {
mIsBaseSet = true;
if (mBaseVal != mapping->mVal) {
if (!mIsBaseSet || mBaseVal != mapping->mVal) {
mIsBaseSet = true;
// We don't need to call DidChange* here - we're only called by
// SVGElement::ParseAttribute under Element::SetAttr,
// which takes care of notifying.
@ -104,8 +104,8 @@ void SVGAnimatedEnumeration::SetBaseValue(uint16_t aValue,
while (mapping && mapping->mKey) {
if (mapping->mVal == aValue) {
mIsBaseSet = true;
if (mBaseVal != uint8_t(aValue)) {
if (!mIsBaseSet || mBaseVal != uint8_t(aValue)) {
mIsBaseSet = true;
AutoChangeEnumNotifier notifier(this, aSVGElement);
mBaseVal = uint8_t(aValue);

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

@ -29,7 +29,6 @@
#include "mozilla/SVGContentUtils.h"
#include "mozilla/Unused.h"
#include "DOMSVGAnimatedEnumeration.h"
#include "mozAutoDocUpdate.h"
#include "nsAttrValueOrString.h"
#include "nsCSSProps.h"
@ -521,7 +520,7 @@ bool SVGElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
// Exact error value does not matter; we just need to mark the
// parse as failed.
rv = NS_ERROR_FAILURE;
enumInfo.SetUnknownValue(i);
enumInfo.Reset(i);
} else {
aResult.SetTo(valAtom);
didSetResult = true;
@ -1967,11 +1966,6 @@ void SVGElement::EnumAttributesInfo::Reset(uint8_t aAttrEnum) {
mEnums[aAttrEnum].Init(aAttrEnum, mEnumInfo[aAttrEnum].mDefaultValue);
}
void SVGElement::EnumAttributesInfo::SetUnknownValue(uint8_t aAttrEnum) {
// Fortunately in SVG every enum's unknown value is 0
mEnums[aAttrEnum].Init(aAttrEnum, 0);
}
void SVGElement::DidChangeEnum(uint8_t aAttrEnum) {
EnumAttributesInfo info = GetEnumInfo();

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

@ -522,7 +522,6 @@ class SVGElement : public SVGElementBase // nsIContent
: mEnums(aEnums), mEnumInfo(aEnumInfo), mEnumCount(aEnumCount) {}
void Reset(uint8_t aAttrEnum);
void SetUnknownValue(uint8_t aAttrEnum);
};
struct NumberListInfo {

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

@ -1,7 +0,0 @@
[svgfeblendelement-mode-001.html]
[SVGFEBlendElement.prototype.mode, getter, invalid value]
expected: FAIL
[SVGFEBlendElement.prototype.mode, setter, numeric value for "normal"]
expected: FAIL