diff --git a/dom/svg/SVGAnimatedOrient.cpp b/dom/svg/SVGAnimatedOrient.cpp index 24b9c23eb5b8..170377ac3fbc 100644 --- a/dom/svg/SVGAnimatedOrient.cpp +++ b/dom/svg/SVGAnimatedOrient.cpp @@ -348,7 +348,8 @@ void SVGAnimatedOrient::SetBaseType(SVGEnumValue aValue, if (mBaseType == aValue) { return; } - if (aValue == SVG_MARKER_ORIENT_AUTO || aValue == SVG_MARKER_ORIENT_ANGLE) { + if (aValue >= SVG_MARKER_ORIENT_AUTO && + aValue <= SVG_MARKER_ORIENT_AUTO_START_REVERSE) { AutoChangeOrientNotifier notifier(this, aSVGElement); mBaseVal = .0f; @@ -422,14 +423,6 @@ SVGAnimatedOrient::DOMAnimatedEnum::~DOMAnimatedEnum() { sSVGAnimatedEnumTearoffTable.RemoveTearoff(mVal); } -// we want to avoid exposing SVG_MARKER_ORIENT_AUTO_START_REVERSE to -// Web content -uint16_t SVGAnimatedOrient::DOMAnimatedEnum::Sanitize(uint16_t aValue) { - return aValue == dom::SVG_MARKER_ORIENT_AUTO_START_REVERSE - ? dom::SVGMarkerElement_Binding::SVG_MARKER_ORIENT_UNKNOWN - : aValue; -} - UniquePtr SVGAnimatedOrient::ToSMILAttr(SVGElement* aSVGElement) { if (aSVGElement->NodeInfo()->Equals(nsGkAtoms::marker, kNameSpaceID_SVG)) { return MakeUnique(this, aSVGElement); diff --git a/dom/svg/SVGAnimatedOrient.h b/dom/svg/SVGAnimatedOrient.h index 74b36214b962..3e20c960ba05 100644 --- a/dom/svg/SVGAnimatedOrient.h +++ b/dom/svg/SVGAnimatedOrient.h @@ -111,7 +111,7 @@ class SVGAnimatedOrient { SVGAnimatedOrient* mVal; // kept alive because it belongs to content using dom::DOMSVGAnimatedEnumeration::SetBaseVal; - uint16_t BaseVal() override { return Sanitize(mVal->mBaseType); } + uint16_t BaseVal() override { return mVal->mBaseType; } void SetBaseVal(uint16_t aBaseVal, ErrorResult& aRv) override { mVal->SetBaseType(aBaseVal, mSVGElement, aRv); } @@ -120,11 +120,8 @@ class SVGAnimatedOrient { // getters need to flush any resample requests to reflect these // modifications. mSVGElement->FlushAnimations(); - return Sanitize(mVal->mAnimType); + return mVal->mAnimType; } - - private: - uint16_t Sanitize(uint16_t aValue); }; struct SMILOrient final : public SMILAttr { diff --git a/dom/svg/SVGMarkerElement.h b/dom/svg/SVGMarkerElement.h index 6b4130f038df..6999703d1381 100644 --- a/dom/svg/SVGMarkerElement.h +++ b/dom/svg/SVGMarkerElement.h @@ -30,9 +30,6 @@ namespace dom { class DOMSVGAnimatedAngle; class DOMSVGAnimatedEnumeration; -// Non-Exposed Marker Orientation Types -static const uint16_t SVG_MARKER_ORIENT_AUTO_START_REVERSE = 3; - using SVGMarkerElementBase = SVGElement; class SVGMarkerElement : public SVGMarkerElementBase { diff --git a/dom/svg/SVGOrientSMILType.h b/dom/svg/SVGOrientSMILType.h index 5f09319f42da..49fc8d9b31fa 100644 --- a/dom/svg/SVGOrientSMILType.h +++ b/dom/svg/SVGOrientSMILType.h @@ -22,12 +22,6 @@ * If 'orientType.animVal' is SVG_MARKER_ORIENT_ANGLE, then * 'orientAngle.animVal' contains the angle that is being used. The lacuna * value is 0. - * - * The SVG 2 specification does not define a - * SVG_MARKER_ORIENT_AUTO_START_REVERSE constant value for orientType to use; - * instead, if the attribute is set to "auto-start-reverse", - * SVG_MARKER_ORIENT_UNKNOWN is used. Internally, however, we do use a - * constant with this name. */ namespace mozilla { diff --git a/dom/svg/test/test_dataTypes.html b/dom/svg/test/test_dataTypes.html index f18bffec33f0..a02a52e2a166 100644 --- a/dom/svg/test/test_dataTypes.html +++ b/dom/svg/test/test_dataTypes.html @@ -194,8 +194,8 @@ function runTests() { marker.setAttribute("orient", "auto-start-reverse"); is(marker.getAttribute("orient"), "auto-start-reverse", "checking 'auto-start-reverse' string preserved"); - is(marker.orientType.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_UNKNOWN, "type baseVal"); - is(marker.orientType.animVal, SVGMarkerElement.SVG_MARKER_ORIENT_UNKNOWN, "type animVal"); + is(marker.orientType.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_AUTO_START_REVERSE, "type baseVal"); + is(marker.orientType.animVal, SVGMarkerElement.SVG_MARKER_ORIENT_AUTO_START_REVERSE, "type animVal"); marker.setAttribute("orient", ""); ok(marker.getAttribute("orient") === "", "empty angle attribute"); diff --git a/dom/svg/test/test_markerOrient.xhtml b/dom/svg/test/test_markerOrient.xhtml index 756731e4bdde..1b91a9a62a11 100644 --- a/dom/svg/test/test_markerOrient.xhtml +++ b/dom/svg/test/test_markerOrient.xhtml @@ -22,9 +22,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=892372 } function testAutoStartReverseIsSet(marker) { - is(marker.orientType.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_UNKNOWN, + is(marker.orientType.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_AUTO_START_REVERSE, "orientType baseVal for auto-start-reverse"); - is(marker.orientType.animVal, SVGMarkerElement.SVG_MARKER_ORIENT_UNKNOWN, + is(marker.orientType.animVal, SVGMarkerElement.SVG_MARKER_ORIENT_AUTO_START_REVERSE, "orientType animVal for auto-start-reverse"); is(marker.orientAngle.baseVal.value, 0, "orientAngle baseVal for auto-start-reverse"); diff --git a/dom/webidl/SVGMarkerElement.webidl b/dom/webidl/SVGMarkerElement.webidl index a72116c02e04..4c5aef38a9a5 100644 --- a/dom/webidl/SVGMarkerElement.webidl +++ b/dom/webidl/SVGMarkerElement.webidl @@ -22,6 +22,7 @@ interface SVGMarkerElement : SVGElement { const unsigned short SVG_MARKER_ORIENT_UNKNOWN = 0; const unsigned short SVG_MARKER_ORIENT_AUTO = 1; const unsigned short SVG_MARKER_ORIENT_ANGLE = 2; + const unsigned short SVG_MARKER_ORIENT_AUTO_START_REVERSE = 3; [Constant] readonly attribute SVGAnimatedLength refX; diff --git a/testing/web-platform/tests/svg/animations/animate-marker-orient-from-auto-to-auto-start-reverse.html b/testing/web-platform/tests/svg/animations/animate-marker-orient-from-auto-to-auto-start-reverse.html index fedfe4a8c281..b7a4e68562da 100644 --- a/testing/web-platform/tests/svg/animations/animate-marker-orient-from-auto-to-auto-start-reverse.html +++ b/testing/web-platform/tests/svg/animations/animate-marker-orient-from-auto-to-auto-start-reverse.html @@ -76,7 +76,7 @@ function sample3() { assert_approx_equals(marker.orientAngle.animVal.value, 0, epsilon); assert_equals(marker.orientAngle.baseVal.value, 0); - assert_equals(marker.orientType.animVal, SVGMarkerElement.SVG_MARKER_ORIENT_UNKNOWN); + assert_equals(marker.orientType.animVal, SVGMarkerElement.SVG_MARKER_ORIENT_AUTO_START_REVERSE); assert_equals(marker.orientType.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_ANGLE); } @@ -94,4 +94,4 @@ smil_async_test((t) => { runAnimationTest(t, expectedValues); }); - \ No newline at end of file + diff --git a/testing/web-platform/tests/svg/types/scripted/SVGAnimatedEnumeration-SVGMarkerElement.html b/testing/web-platform/tests/svg/types/scripted/SVGAnimatedEnumeration-SVGMarkerElement.html index 7ac884ae3e50..dfc9dd248007 100644 --- a/testing/web-platform/tests/svg/types/scripted/SVGAnimatedEnumeration-SVGMarkerElement.html +++ b/testing/web-platform/tests/svg/types/scripted/SVGAnimatedEnumeration-SVGMarkerElement.html @@ -90,8 +90,17 @@ test(function() { markerElement.setAttribute('orient', '10deg'); + // Switch to 'auto-start-reverse' value - by modifying orientType. + markerElement.orientType.baseVal = SVGMarkerElement.SVG_MARKER_ORIENT_AUTO_START_REVERSE; + assert_equals(markerElement.orientAngle.baseVal.value, 0); + assert_equals(markerElement.orientAngle.baseVal.unitType, SVGAngle.SVG_ANGLETYPE_UNSPECIFIED); + assert_equals(markerElement.orientType.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_AUTO_START_REVERSE); + assert_equals(markerElement.getAttribute('orient'), "auto-start-reverse"); + + markerElement.setAttribute('orient', '10deg'); + // Try setting invalid values. - assert_throws_js(TypeError, function() { markerElement.orientType.baseVal = 3; }); + assert_throws_js(TypeError, function() { markerElement.orientType.baseVal = 4; }); assert_equals(markerElement.orientType.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_ANGLE); assert_equals(markerElement.getAttribute('orient'), "10deg"); @@ -110,4 +119,4 @@ test(function() { assert_equals(markerElement.orientType.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_AUTO); assert_equals(markerElement.getAttribute('orient'), "auto"); }); - \ No newline at end of file +