Bug 1685543 - Expose auto-start-reverse enum value r=emilio

Per https://github.com/w3c/svgwg/issues/424 we should expose the new value in webidl

Differential Revision: https://phabricator.services.mozilla.com/D101089
This commit is contained in:
longsonr 2021-01-08 00:05:11 +00:00
parent c59d9181cb
commit 749233d55b
9 changed files with 22 additions and 31 deletions

View File

@ -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<SMILAttr> SVGAnimatedOrient::ToSMILAttr(SVGElement* aSVGElement) {
if (aSVGElement->NodeInfo()->Equals(nsGkAtoms::marker, kNameSpaceID_SVG)) {
return MakeUnique<SMILOrient>(this, aSVGElement);

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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");

View File

@ -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");

View File

@ -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;

View File

@ -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);
});
</script>
</script>

View File

@ -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");
});
</script>
</script>