-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serialization format for path strings #321
Comments
There was an additional suggestion from Brian Birtles
All H and V commands would be normalized to L in the serialization format, |
The reason that the path syntaxes (with and without That said: I like the idea of being able to access normalized path data for As you say, using normalized paths for computed styles would increase the flexibility of path interpolation considerably. It wouldn't be that much of a stretch to go one step farther and allow interpolation to/from the other shape functions, by converting them to equivalent paths. There is an existing standard for what a "normalized" path string looks like: the The big limitation of that standard is that the normalized path notation doesn't include true arcs, and instead recommends they get converted into straight lines! I'd definitely not want to see that re-created in any new spec. (If you have to normalize arcs to another segment type, at least use cubic beziers!) |
When we are animating, we have to choose a format. It is reasonable for the format to be specified by the standard. The normalizedPathSegList normalization
gives a precedent for normalizing to absolute instead of relative coordinates. I agree with Amelia's preference against normalising arcs to straight lines. A new normalization proposal is required, perhaps the following:-
Thus H, V and Q can appear in getComputedStyle results, but animation from H to V would result in L, and animation from V to C would result in C. |
Do we need a promotion to Q, given that we are normalising to 'M', 'L', 'C' and 'Z'? So all that's needed is the following, correct? H x -> L x cy Also, there is probably a need to briefly address the handling of the new 'B' (bearing) command also, isn't there? I.e. that it affects the following commands, but drops from the normalisation. Regarding Arcs. If they are going to be normalised to cubic beziers for animation, then I believe some additional info is going to need to be added to the centre<->endpoint parameterization section. There is current;y no advice supplied on how to position the bezier curves. |
Rather, we can't parse path data with the CSS parser; it's written in a way that is wholly incompatible with the CSS tokenizer, and would require heroic efforts to reverse the obtained tokens back into reasonable path commands. (If it's even possible at all; without a thorough review, I'm not willing to say that some cases aren't impossible to recover.) Thus you have to pass it thru the CSS parser as a string, and then do special-case parsing at the impl level. This doesn't mean it's a "string" in a semantic sense; it doesn't contain arbitrary opaque data. It's very much transparent, and contains meaningful structured data! As such, the computed value of a
While not strictly necessary, doing so means that animating an
You can't convert an arc to a cubic bezier in general. (You can get very close, but it's impossible to get a correct perfect equivalence.) Maybe it's worthwhile to try, tho? If people can animate between arcs and lines (yes), and they can animate between lines and curves (yes), I presume they'd want to be able to animate between arcs and curves. Doing so, tho, would mean we've have to downgrade the arc into one or more curves, which then becomes tricky to animate (subdivide the curve it's animating against into the same number of subcurves? where do place the cuts?). It's a difficult problem with some tradeoffs.
That's not necessarily obvious. Animating a
|
We add animation tests for 4 of the 5 longhand properties defined by CSS Motion Path https://drafts.fxtf.org/motion-1/ offset-path is skipped for now, while CSS path interpolation semantics and serialization format are still being discussed. w3c/svgwg#321 BUG=722757 Change-Id: I4b31215c77a66316be849156bf63b6f1d45b374c Reviewed-on: https://chromium-review.googlesource.com/612000 Commit-Queue: Eric Willigers <[email protected]> WPT-Export-Revision: d717234ceedb68fd24118550be579a2e3c3d70c8
We add animation tests for 4 of the 5 longhand properties defined by CSS Motion Path https://drafts.fxtf.org/motion-1/ offset-path is skipped for now, while CSS path interpolation semantics and serialization format are still being discussed. w3c/svgwg#321 BUG=722757 Change-Id: I4b31215c77a66316be849156bf63b6f1d45b374c Reviewed-on: https://chromium-review.googlesource.com/612000 Commit-Queue: Eric Willigers <[email protected]> WPT-Export-Revision: d717234ceedb68fd24118550be579a2e3c3d70c8
We add animation tests for 4 of the 5 longhand properties defined by CSS Motion Path https://drafts.fxtf.org/motion-1/ offset-path is skipped for now, while CSS path interpolation semantics and serialization format are still being discussed. w3c/svgwg#321 BUG=722757 Change-Id: I4b31215c77a66316be849156bf63b6f1d45b374c Reviewed-on: https://chromium-review.googlesource.com/612000 Reviewed-by: Darren Shen <[email protected]> Commit-Queue: Eric Willigers <[email protected]> Cr-Commit-Position: refs/heads/master@{#493942}
The graphic at https://pomax.github.io/bezierinfo/#circles_cubic illustrates that a single cubic Bezier is a reasonable approximation for small arcs, but terrible for large arcs (e.g. 300 degrees). So any animation between an arc and a spline would have a large jump in the first frame, defeating the usual purposes of animation. One way to avoid that would be to represent large arcs by a sequence of splines, but in that case we should allow animation between paths that contain different numbers of commands. This would be useful, but it is also a large departure from SMIL path interpolation. |
Right, I think in general you shouldn't approximate more than 90deg of arc with a cubic bezier. This is a hard problem, as you note, due to it opening up general multi-segment interpolation. |
I would prefer if "normalization" only included lossless changes: making coordinates absolute, converting smooth connections into explicit control points, upgrading H/V to L, and maybe Q to C. Leave arcs as arcs. They're still not great for interpolation, but at least you'd be re-creating the SMIL behavior. |
We add animation tests for 4 of the 5 longhand properties defined by CSS Motion Path https://drafts.fxtf.org/motion-1/ offset-path is skipped for now, while CSS path interpolation semantics and serialization format are still being discussed. w3c/svgwg#321 BUG=722757 Change-Id: I4b31215c77a66316be849156bf63b6f1d45b374c Reviewed-on: https://chromium-review.googlesource.com/612000 Commit-Queue: Eric Willigers <[email protected]> WPT-Export-Revision: d717234ceedb68fd24118550be579a2e3c3d70c8
Not blocking updated 2.0 CR publication - assigning 2.1 WD milestone |
@ewilligers We're implementing this in Gecko now and apparently Blink currently does normalization at animation time, not computed value time. That is, in the absence of animation the result from It seems like always returning absolute commands would make life easier for authors since they only need to parse the absolute commands. If that's right, is someone able to update Blink to normalize at computed value time? |
By the way, about this issue:
Gecko uses double quotes because CSS object model [1] says to use double-quotes. [1] https://drafts.csswg.org/cssom/#serialize-a-string cc @emilio |
Yeah, CSS things all use double quotes; we should consistently be doing this. |
Yes, getComputedStyle should be returning absolute commands. I can also change Blink to double quotes. |
Cool. Thanks, Eric. I will change Gecko to normalize the path string at computed time (Bug 1489392). |
The canonical serialization format for path strings uses absolute commands only. Discussed in w3c/svgwg#321 Previously, Blink only normalized path string to absolute commands when they were animated. BUG=696395 Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel Change-Id: I773ceb40f22fc5ce1e5f7ea0b4eca6cc612e763e
Actually, I suspect we will normalize earlier, specified value will also show absolute commands. I'm not sure Blink's CSS implementation of paths will be able to easily distinguish the two. Proposed Blink CL |
The canonical serialization format for path strings uses absolute commands only. Discussed in w3c/svgwg#321 Previously, Blink only normalized path string to absolute commands when they were animated. BUG=696395 Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel Change-Id: I773ceb40f22fc5ce1e5f7ea0b4eca6cc612e763e
The canonical serialization format for path strings uses absolute commands only. Discussed in w3c/svgwg#321 Previously, Blink only normalized path string to absolute commands when they were animated. BUG=696395 Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel Change-Id: I773ceb40f22fc5ce1e5f7ea0b4eca6cc612e763e
The canonical serialization format for path strings uses absolute commands only. Discussed in w3c/svgwg#321 Previously, Blink only normalized path string to absolute commands when they were animated. BUG=696395 Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel Change-Id: I773ceb40f22fc5ce1e5f7ea0b4eca6cc612e763e
I think that's acceptable, it saves us having to have two different representations for the path... |
The canonical serialization format for path strings uses absolute commands only. Discussed in w3c/svgwg#321 Previously, Blink only normalized path string to absolute commands when they were animated. BUG=696395 Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel Change-Id: I773ceb40f22fc5ce1e5f7ea0b4eca6cc612e763e
It seems the recent update of Chrome keeps the original path segment data, and normalize it for animations or calling [1] https://chromium-review.googlesource.com/c/chromium/src/+/1215150 |
I'm not really keen on 3. There is currently no concept of "when needed" and it introduces a lot of complexity. For example, is normalization needed when you have a timing function of In order to implement any answer to the above we will need to add special case code that feels to me like a layering violation (e.g. passing flags around to say, "Are we in an animation path in a particular animation state where we need to return a normalized value"). Furthermore, from an authoring point of view having My experience is that adding complexity to interpolation code almost always creates more work over time (particularly as the set or permutations continues to grow) and should be done at computed value time if possible. This is particularly so as we try to extend this behavior through additive CSS, additive animations, collapsing forwards-filling animations etc. |
Yes, I'm fine with spec'ing the Chrome 69 behavior.
I don't see how this different is from any other data format that converts values to support transitions. E.g., transitioning from
Well, that much may be true… A final option is just stick with the SVG 1 path animation rules (for now, anyway), and don't change any segment types to facilitate animations. |
Correct.
SMIL implementations allowed animation between absolute and relative commands. |
Well, that's interesting. That's not how I read the SVG 1.1 spec:
But I tested, and it works in Safari, Chrome and Firefox. Other devs must have had more generous interpretations of "exactly the same" than I did. PS, The current spec text isn't much clearer on that point, so whatever gets resolved here, it should be clarified. |
The Similarly for For properties that actually do return For example, if you try this pen: https://codepen.io/birtles/pen/BObNXd In Firefox you'll get results like:
In Chrome you'll get false everywhere (i.e. (2) from above, which I'm pretty sure is wrong per-spec). I'm concerned about saying "do whatever you do in those cases" since even if we take that to mean "do whatever you do for background-position" it's different between engines (and inconsistent even within the one engine). Furthermore, I'm not even sure what behavior we would want to specify for each of the different cases. |
If it seems like I'm being pedantic here, part of the background is that implementations will have the computed values as derived from With approach (3) that kind of optimization will be observable so we need to spec when it is allowed/required. With approach (1) or (2) we don't need to. |
This issue has become slightly complicated in terms of spec interactions, compared to when the issue was opened. It now affects the slimmed-down SVG 2 Paths chapter, and also requires changes to parts of the split-out Paths module (or perhaps backporting the normalize operation from paths module to Paths chapter, if anyone implements that), and also affects the animation part of MotionPath. |
As an author, I would trade the ability to interpolate between paths with different-but-similar path segments in exchange for consistency when inspecting the value in devtools, script in the console, etc. The convenience of passing in a looser range of values (that are probably coming from a tool, at least for me) doesn't seem to outweigh the potential debugging headaches. I personally would like to see the path data absolutized at the 1 or 2 points in @emilio's choices — it seems more consistent with having my authored values normalized for other data types (which may be wrong, but that's my impression from living in devtools and having stuff like color values normalized). |
…olute commands, a=testonly Automatic update from web-platform-testsCSS: path string computed style uses absolute commands The canonical computed style format for path strings uses absolute commands only. Discussed in w3c/svgwg#321 Previously, Blink only normalized path string to absolute commands when they were animated. BUG=696395 Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel Change-Id: I773ceb40f22fc5ce1e5f7ea0b4eca6cc612e763e Reviewed-on: https://chromium-review.googlesource.com/1215150 Commit-Queue: Eric Willigers <ericwilligerschromium.org> Reviewed-by: Fredrik Söderquist <fsopera.com> Cr-Commit-Position: refs/heads/master{#591996} -- wpt-commits: 9b900a584259526b6927565fa010d4036c1224af wpt-pr: 12906 UltraBlame original commit: cea1dbbb46c0cd590ff12f201402a916b7108273
…olute commands, a=testonly Automatic update from web-platform-testsCSS: path string computed style uses absolute commands The canonical computed style format for path strings uses absolute commands only. Discussed in w3c/svgwg#321 Previously, Blink only normalized path string to absolute commands when they were animated. BUG=696395 Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel Change-Id: I773ceb40f22fc5ce1e5f7ea0b4eca6cc612e763e Reviewed-on: https://chromium-review.googlesource.com/1215150 Commit-Queue: Eric Willigers <ericwilligerschromium.org> Reviewed-by: Fredrik Söderquist <fsopera.com> Cr-Commit-Position: refs/heads/master{#591996} -- wpt-commits: 9b900a584259526b6927565fa010d4036c1224af wpt-pr: 12906 UltraBlame original commit: cea1dbbb46c0cd590ff12f201402a916b7108273
…olute commands, a=testonly Automatic update from web-platform-testsCSS: path string computed style uses absolute commands The canonical computed style format for path strings uses absolute commands only. Discussed in w3c/svgwg#321 Previously, Blink only normalized path string to absolute commands when they were animated. BUG=696395 Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel Change-Id: I773ceb40f22fc5ce1e5f7ea0b4eca6cc612e763e Reviewed-on: https://chromium-review.googlesource.com/1215150 Commit-Queue: Eric Willigers <ericwilligerschromium.org> Reviewed-by: Fredrik Söderquist <fsopera.com> Cr-Commit-Position: refs/heads/master{#591996} -- wpt-commits: 9b900a584259526b6927565fa010d4036c1224af wpt-pr: 12906 UltraBlame original commit: cea1dbbb46c0cd590ff12f201402a916b7108273
It seems like there is no conclusion for now, so I update the WPT to accept both normalized path string and non-normalized path string at computed time, in https://bugzilla.mozilla.org/show_bug.cgi?id=1489392. |
…ime. There is still no conclusion in w3c/svgwg#321, so we follow the option 3 in [1] for now: Don't absolutize anywhere except when needed for animations. [1] w3c/svgwg#321 (comment) Note: 1. Drop "offset-path-serialization.html" because we are doing the simliar thing in offset-path-computed.html and offset-path-parsing-valid.html. 2. `z` is serialized as `Z` because `Z` and `z` commands take no parameters, they have an identical effect. (https://www.w3.org/TR/SVG2/paths.html#PathDataClosePathCommand) Differential Revision: https://phabricator.services.mozilla.com/D172071 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1489392 gecko-commit: 4ee091c23aa2976da9922f3bf9c8e62a5b9462f5 gecko-reviewers: emilio
… at computed time. r=emilio There is still no conclusion in w3c/svgwg#321, so we follow the option 3 in [1] for now: Don't absolutize anywhere except when needed for animations. [1] w3c/svgwg#321 (comment) Note: 1. Drop "offset-path-serialization.html" because we are doing the simliar thing in offset-path-computed.html and offset-path-parsing-valid.html. 2. `z` is serialized as `Z` because `Z` and `z` commands take no parameters, they have an identical effect. (https://www.w3.org/TR/SVG2/paths.html#PathDataClosePathCommand) Differential Revision: https://phabricator.services.mozilla.com/D172071
…ime. There is still no conclusion in w3c/svgwg#321, so we follow the option 3 in [1] for now: Don't absolutize anywhere except when needed for animations. [1] w3c/svgwg#321 (comment) Note: 1. Drop "offset-path-serialization.html" because we are doing the simliar thing in offset-path-computed.html and offset-path-parsing-valid.html. 2. `z` is serialized as `Z` because `Z` and `z` commands take no parameters, they have an identical effect. (https://www.w3.org/TR/SVG2/paths.html#PathDataClosePathCommand) Differential Revision: https://phabricator.services.mozilla.com/D172071 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1489392 gecko-commit: 4ee091c23aa2976da9922f3bf9c8e62a5b9462f5 gecko-reviewers: emilio
…ime. There is still no conclusion in w3c/svgwg#321, so we follow the option 3 in [1] for now: Don't absolutize anywhere except when needed for animations. [1] w3c/svgwg#321 (comment) Note: 1. Drop "offset-path-serialization.html" because we are doing the simliar thing in offset-path-computed.html and offset-path-parsing-valid.html. 2. `z` is serialized as `Z` because `Z` and `z` commands take no parameters, they have an identical effect. (https://www.w3.org/TR/SVG2/paths.html#PathDataClosePathCommand) Differential Revision: https://phabricator.services.mozilla.com/D172071 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1489392 gecko-commit: 4ee091c23aa2976da9922f3bf9c8e62a5b9462f5 gecko-reviewers: emilio
…ime. There is still no conclusion in w3c/svgwg#321, so we follow the option 3 in [1] for now: Don't absolutize anywhere except when needed for animations. [1] w3c/svgwg#321 (comment) Note: 1. Drop "offset-path-serialization.html" because we are doing the simliar thing in offset-path-computed.html and offset-path-parsing-valid.html. 2. `z` is serialized as `Z` because `Z` and `z` commands take no parameters, they have an identical effect. (https://www.w3.org/TR/SVG2/paths.html#PathDataClosePathCommand) Differential Revision: https://phabricator.services.mozilla.com/D172071 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1489392 gecko-commit: 4ee091c23aa2976da9922f3bf9c8e62a5b9462f5 gecko-reviewers: emilio
…ime. There is still no conclusion in w3c/svgwg#321, so we follow the option 3 in [1] for now: Don't absolutize anywhere except when needed for animations. [1] w3c/svgwg#321 (comment) Note: 1. Drop "offset-path-serialization.html" because we are doing the simliar thing in offset-path-computed.html and offset-path-parsing-valid.html. 2. `z` is serialized as `Z` because `Z` and `z` commands take no parameters, they have an identical effect. (https://www.w3.org/TR/SVG2/paths.html#PathDataClosePathCommand) Differential Revision: https://phabricator.services.mozilla.com/D172071 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1489392 gecko-commit: 4ee091c23aa2976da9922f3bf9c8e62a5b9462f5 gecko-reviewers: emilio
…ime. There is still no conclusion in w3c/svgwg#321, so we follow the option 3 in [1] for now: Don't absolutize anywhere except when needed for animations. [1] w3c/svgwg#321 (comment) Note: 1. Drop "offset-path-serialization.html" because we are doing the simliar thing in offset-path-computed.html and offset-path-parsing-valid.html. 2. `z` is serialized as `Z` because `Z` and `z` commands take no parameters, they have an identical effect. (https://www.w3.org/TR/SVG2/paths.html#PathDataClosePathCommand) Differential Revision: https://phabricator.services.mozilla.com/D172071 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1489392 gecko-commit: 4ee091c23aa2976da9922f3bf9c8e62a5b9462f5 gecko-reviewers: emilio
… at computed time. r=emilio There is still no conclusion in w3c/svgwg#321, so we follow the option 3 in [1] for now: Don't absolutize anywhere except when needed for animations. [1] w3c/svgwg#321 (comment) Note: 1. Drop "offset-path-serialization.html" because we are doing the simliar thing in offset-path-computed.html and offset-path-parsing-valid.html. 2. `z` is serialized as `Z` because `Z` and `z` commands take no parameters, they have an identical effect. (https://www.w3.org/TR/SVG2/paths.html#PathDataClosePathCommand) Differential Revision: https://phabricator.services.mozilla.com/D172071
This issue came up in an Intent to Ship (offset-path animation) discussion on blink-dev.
https://groups.google.com/a/chromium.org/d/msg/blink-dev/_DPl-JG6bV8/y2_GUwFVDwAJ
'd' path strings can contain a mix of absolute and relative coordinates, and a mix of comma and
space separators. https://www.w3.org/TR/SVG2/paths.html#TheDProperty
It is also possible to animate between paths that differ in the use of separators and absolute and
relative coordinates, for example between 'M 200 400 H 500 v -100' and 'm100,200h400V300'.
Now that 'd' is exposed as a presentation attribute, page authors can use getComputedStyle to
inspect the path string.
For consistency between implementations, it would be helpful if the standard specified absolute
[or relative] coordinates in the serialization format, and space separators.
The above example path strings would become 'M 200 400 H 500 V 300' and 'M 100 200 H 500 V300'
when serialized.
Blink's currently shipping implementation uses space separators, and uses the 'to' format for
absolute/relative coordinates, except at animation progress 0, where the 'from' format is used:-
property from [path('M 200 400 H 500 v -100')] to [path('m100,200h400V300')]
at (0) is [path('M 200 400 H 500 v -100')]
at (0.5) is [path('m 150 300 h 350 V 300')]
at (1) is [path('m 100 200 h 400 V 300')]
If we specify absolute coordinates for the serialization format, these would become:
property from [path('M 200 400 H 500 v -100')] to [path('m100,200h400V300')]
at (0) is [path('M 200 400 H 500 V 300')]
at (0.5) is [path('M 150 300 H 500 V 300')]
at (1) is [path('M 100 200 H 500 V 300')]
If we specify relative coordinates for the serialization format, these would become:
property from [path('M 200 400 H 500 v -100')] to [path('m100,200h400V300')]
at (0) is [path('m 200 400 h 300 v -100')]
at (0.5) is [path('m 150 300 h 350 v 0')]
at (1) is [path('m 100 200 h 400 v 100')]
No backward compatibility issues are anticipated in moving to consistent absolute coordinates [or consistent relative coordinates].
If issue #320 is accepted, there is also the choice of quote character around the path string. Blink uses single quotes.
The text was updated successfully, but these errors were encountered: