mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
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:
parent
c59d9181cb
commit
749233d55b
@ -348,7 +348,8 @@ void SVGAnimatedOrient::SetBaseType(SVGEnumValue aValue,
|
|||||||
if (mBaseType == aValue) {
|
if (mBaseType == aValue) {
|
||||||
return;
|
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);
|
AutoChangeOrientNotifier notifier(this, aSVGElement);
|
||||||
|
|
||||||
mBaseVal = .0f;
|
mBaseVal = .0f;
|
||||||
@ -422,14 +423,6 @@ SVGAnimatedOrient::DOMAnimatedEnum::~DOMAnimatedEnum() {
|
|||||||
sSVGAnimatedEnumTearoffTable.RemoveTearoff(mVal);
|
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) {
|
UniquePtr<SMILAttr> SVGAnimatedOrient::ToSMILAttr(SVGElement* aSVGElement) {
|
||||||
if (aSVGElement->NodeInfo()->Equals(nsGkAtoms::marker, kNameSpaceID_SVG)) {
|
if (aSVGElement->NodeInfo()->Equals(nsGkAtoms::marker, kNameSpaceID_SVG)) {
|
||||||
return MakeUnique<SMILOrient>(this, aSVGElement);
|
return MakeUnique<SMILOrient>(this, aSVGElement);
|
||||||
|
@ -111,7 +111,7 @@ class SVGAnimatedOrient {
|
|||||||
SVGAnimatedOrient* mVal; // kept alive because it belongs to content
|
SVGAnimatedOrient* mVal; // kept alive because it belongs to content
|
||||||
|
|
||||||
using dom::DOMSVGAnimatedEnumeration::SetBaseVal;
|
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 {
|
void SetBaseVal(uint16_t aBaseVal, ErrorResult& aRv) override {
|
||||||
mVal->SetBaseType(aBaseVal, mSVGElement, aRv);
|
mVal->SetBaseType(aBaseVal, mSVGElement, aRv);
|
||||||
}
|
}
|
||||||
@ -120,11 +120,8 @@ class SVGAnimatedOrient {
|
|||||||
// getters need to flush any resample requests to reflect these
|
// getters need to flush any resample requests to reflect these
|
||||||
// modifications.
|
// modifications.
|
||||||
mSVGElement->FlushAnimations();
|
mSVGElement->FlushAnimations();
|
||||||
return Sanitize(mVal->mAnimType);
|
return mVal->mAnimType;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
uint16_t Sanitize(uint16_t aValue);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMILOrient final : public SMILAttr {
|
struct SMILOrient final : public SMILAttr {
|
||||||
|
@ -30,9 +30,6 @@ namespace dom {
|
|||||||
class DOMSVGAnimatedAngle;
|
class DOMSVGAnimatedAngle;
|
||||||
class DOMSVGAnimatedEnumeration;
|
class DOMSVGAnimatedEnumeration;
|
||||||
|
|
||||||
// Non-Exposed Marker Orientation Types
|
|
||||||
static const uint16_t SVG_MARKER_ORIENT_AUTO_START_REVERSE = 3;
|
|
||||||
|
|
||||||
using SVGMarkerElementBase = SVGElement;
|
using SVGMarkerElementBase = SVGElement;
|
||||||
|
|
||||||
class SVGMarkerElement : public SVGMarkerElementBase {
|
class SVGMarkerElement : public SVGMarkerElementBase {
|
||||||
|
@ -22,12 +22,6 @@
|
|||||||
* If 'orientType.animVal' is SVG_MARKER_ORIENT_ANGLE, then
|
* If 'orientType.animVal' is SVG_MARKER_ORIENT_ANGLE, then
|
||||||
* 'orientAngle.animVal' contains the angle that is being used. The lacuna
|
* 'orientAngle.animVal' contains the angle that is being used. The lacuna
|
||||||
* value is 0.
|
* 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 {
|
namespace mozilla {
|
||||||
|
@ -194,8 +194,8 @@ function runTests() {
|
|||||||
|
|
||||||
marker.setAttribute("orient", "auto-start-reverse");
|
marker.setAttribute("orient", "auto-start-reverse");
|
||||||
is(marker.getAttribute("orient"), "auto-start-reverse", "checking 'auto-start-reverse' string preserved");
|
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.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_AUTO_START_REVERSE, "type baseVal");
|
||||||
is(marker.orientType.animVal, SVGMarkerElement.SVG_MARKER_ORIENT_UNKNOWN, "type animVal");
|
is(marker.orientType.animVal, SVGMarkerElement.SVG_MARKER_ORIENT_AUTO_START_REVERSE, "type animVal");
|
||||||
|
|
||||||
marker.setAttribute("orient", "");
|
marker.setAttribute("orient", "");
|
||||||
ok(marker.getAttribute("orient") === "", "empty angle attribute");
|
ok(marker.getAttribute("orient") === "", "empty angle attribute");
|
||||||
|
@ -22,9 +22,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=892372
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testAutoStartReverseIsSet(marker) {
|
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");
|
"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");
|
"orientType animVal for auto-start-reverse");
|
||||||
is(marker.orientAngle.baseVal.value, 0,
|
is(marker.orientAngle.baseVal.value, 0,
|
||||||
"orientAngle baseVal for auto-start-reverse");
|
"orientAngle baseVal for auto-start-reverse");
|
||||||
|
@ -22,6 +22,7 @@ interface SVGMarkerElement : SVGElement {
|
|||||||
const unsigned short SVG_MARKER_ORIENT_UNKNOWN = 0;
|
const unsigned short SVG_MARKER_ORIENT_UNKNOWN = 0;
|
||||||
const unsigned short SVG_MARKER_ORIENT_AUTO = 1;
|
const unsigned short SVG_MARKER_ORIENT_AUTO = 1;
|
||||||
const unsigned short SVG_MARKER_ORIENT_ANGLE = 2;
|
const unsigned short SVG_MARKER_ORIENT_ANGLE = 2;
|
||||||
|
const unsigned short SVG_MARKER_ORIENT_AUTO_START_REVERSE = 3;
|
||||||
|
|
||||||
[Constant]
|
[Constant]
|
||||||
readonly attribute SVGAnimatedLength refX;
|
readonly attribute SVGAnimatedLength refX;
|
||||||
|
@ -76,7 +76,7 @@ function sample3() {
|
|||||||
assert_approx_equals(marker.orientAngle.animVal.value, 0, epsilon);
|
assert_approx_equals(marker.orientAngle.animVal.value, 0, epsilon);
|
||||||
assert_equals(marker.orientAngle.baseVal.value, 0);
|
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);
|
assert_equals(marker.orientType.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_ANGLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,4 +94,4 @@ smil_async_test((t) => {
|
|||||||
runAnimationTest(t, expectedValues);
|
runAnimationTest(t, expectedValues);
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -90,8 +90,17 @@ test(function() {
|
|||||||
|
|
||||||
markerElement.setAttribute('orient', '10deg');
|
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.
|
// 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.orientType.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_ANGLE);
|
||||||
assert_equals(markerElement.getAttribute('orient'), "10deg");
|
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.orientType.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_AUTO);
|
||||||
assert_equals(markerElement.getAttribute('orient'), "auto");
|
assert_equals(markerElement.getAttribute('orient'), "auto");
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user