Skip to content

Commit 9c10ca3

Browse files
Fredrik Söderquistchromium-wpt-export-bot
Fredrik Söderquist
authored andcommitted
Funnel angle value updates in SVGAngle through NewValueSpecifiedUnits
Refactor/structure the code so that all cases[*] that set the `value_in_specified_units_` field does so using NewValueSpecifiedUnits. This makes it easier to guarantee that the value the orient type enum is only updated in one place, and that updating it isn't forgotten. Factor out the conversion from one angle unit to another into a helper, to facilitate this. This fixes an issue where the 'valueInSpecifiedUnits' setter didn't update the orient type. Export the test svg/dom/SVGMarkerElement-orientType-synchronization.html to WPT and add an additional case that tests the above. [*] Code-paths that reset said field when the orient type changes still (re)set the value themselves. Fixed: 378120437 Change-Id: I59845590f60d1edbf022a71103d3c6fb3a21aec1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6023025 Reviewed-by: Philip Rogers <[email protected]> Auto-Submit: Fredrik Söderquist <[email protected]> Commit-Queue: Philip Rogers <[email protected]> Cr-Commit-Position: refs/heads/main@{#1384659}
1 parent 90ae0db commit 9c10ca3

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<title>SVGMarkerElement.orientType synchronization</title>
3+
<link rel="help" href="https://svgwg.org/svg2-draft/painting.html#InterfaceSVGMarkerElement">
4+
<link rel="help" href="https://svgwg.org/svg2-draft/types.html#InterfaceSVGAngle">
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<script>
8+
test(function() {
9+
const marker = document.createElementNS('http://www.w3.org/2000/svg', 'marker');
10+
assert_equals(marker.orientType.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_ANGLE, 'initial');
11+
12+
marker.orientType.baseVal = SVGMarkerElement.SVG_MARKER_ORIENT_AUTO;
13+
assert_equals(marker.getAttribute('orient'), 'auto');
14+
assert_equals(marker.orientType.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_AUTO, `to 'auto'`);
15+
}, `${document.title}, setting orientType to 'auto'`);
16+
17+
test(function() {
18+
const marker = document.createElementNS('http://www.w3.org/2000/svg', 'marker');
19+
assert_false(marker.hasAttribute('orient'));
20+
21+
marker.setOrientToAuto();
22+
assert_equals(marker.getAttribute('orient'), 'auto');
23+
24+
marker.orientAngle.baseVal.valueInSpecifiedUnits = 1;
25+
assert_true(marker.hasAttribute('orient'));
26+
assert_equals(marker.getAttribute('orient'), '1');
27+
assert_equals(marker.orientType.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_ANGLE);
28+
}, `${document.title}, setting orientAngle using valueInSpecifiedUnits`);
29+
</script>

0 commit comments

Comments
 (0)