News for hackers. Stuff that matters.
Re:Introducing the layer based SVG engine by onion2k on Monday November 01, 2021 @01:13PM (#29069716)
SVG has no support for z-index in the spec. SVG renderers draw everything from the back to the front reading the elements as they appear in the doc tree - if you want put something on top of something else you have to move it down the document.

In my previous role I worked on a React app that was essentially just a big SVG editor for lawyers to make legal step diagrams (complex maps of legal structures that define how they change over time). Our solution to the z-index issue was to make extensive use of React portals to things lower down the doc tree when they were in focus. It worked really well, but I would have killed for proper z-index support. It would have greatly simplified my code.

I don't really care about the GPU acceleration; adding layers to SVGs is an amazing change on its own. Kudos to the team behind this. I hope it gets adopted everywhere.

Re:Introducing the layer based SVG engine by eyelidlessness on Monday November 01, 2021 @01:42PM (#29070148)
> Our solution to the z-index issue was to make extensive use of React portals to things lower down the doc tree when they were in focus.

I’m curious why you went with portals? Seems to me you could use the normal render cycle to control order (keyed if you intend to just reorder siblings).

> I don't really care about the GPU acceleration; adding layers to SVGs is an amazing change on its own.

I may be mistaken but in my reading of the article, my understanding is that SVG layers are only about acceleration, and don’t change the stacking semantics of SVG elements. But maybe I missed something.

Re:Introducing the layer based SVG engine by onion2k on Monday November 01, 2021 @02:50PM (#29071151)
I’m curious why you went with portals

We had to move things to the front of the SVG no matter where they were in the document. If it was just siblings it'd have been much easier.

Also, these are complex SVGs. On a large diagram there can be 50,000 elements in the SVG. Portals made it simpler.

Re:Introducing the layer based SVG engine by progers7 on Monday November 01, 2021 @04:22PM (#29072539)
This article is just about acceleration and stacking is not introduced. WebKit's architecture ties together the concepts of stacking and acceleration. A positive effect is that it will be quite easy to support stacking in SVG with this work.

A negative of joining the concepts of stacking and acceleration is that it is difficult to get acceleration without introducing paint order bugs where the accelerated content starts painting above non-accelerated content.

Re:Introducing the layer based SVG engine by btbuildem on Monday November 01, 2021 @02:36PM (#29070941)
The lack of z-index in SVG is such a drag. I'm working on a (relatively simple) project - think Figma in terms of interactions - and the hackery is inevitable and immediate when trying to deal with this. A hybrid approach of multiple SVG objects in a HTML tree seems to be working so far, but it's far from pretty.
Re:Introducing the layer based SVG engine by nzimmermann86 on Monday November 01, 2021 @04:08PM (#29072338)
It was in earlier SVG2 drafts, but was dropped due to the lack of implementation, see here: https://www.w3.org/TR/2015/WD-SVG2-20150915/render.html#ZInd...
Re:Introducing the layer based SVG engine by zestyping on Monday November 01, 2021 @02:42PM (#29071025)
This is a digression, but I'm really curious what you mean by a "legal step diagram". It sounds like a fascinating concept, but all I could find on Google were process flowcharts. Can you point me at more info on these? Thanks!
Re:Introducing the layer based SVG engine by onion2k on Monday November 01, 2021 @02:54PM (#29071227)
Step diagrams are what lawyers call flow charts, but with a design convention language that's a bit like UML, and with tons of meta data attached to each element. There's also a time dimension as you can step through to see each stage of a legal process.

I understand what they are as a dev but I'm not a lawyer so I can't point you to anything more unfortunately.

Re:Introducing the layer based SVG engine by theaussiestew on Monday November 01, 2021 @05:28PM (#29073375)
Was this company called Checkbox?
Re:Introducing the layer based SVG engine by LegitShady on Monday November 01, 2021 @11:57PM (#29076842)
It's a subset of process mapping specific to the legal area. Since there is no agreed upon convention for process maps everyone does their own thing and calls them slightly different things. I tend to just use the six sigma convention even for non six sigma things.
Re:Introducing the layer based SVG engine by tannhaeuser on Monday November 01, 2021 @01:52PM (#29070290)
AFAIK, SVG2 was supposed to bring that in line with HTML (or rather, CSS' z-index).
Re:Introducing the layer based SVG engine by ksec on Monday November 01, 2021 @03:34PM (#29071844)
Is SVG2 actually coming or is it in Limbo?
Re:Introducing the layer based SVG engine by nzimmermann86 on Monday November 01, 2021 @04:10PM (#29072362)
It totally depends on the implementors, if no one implements it, it won't come. If nobody does the first implementation, no other vendor will follow - it's as easy as this.

For WebKit/SVG, features as z-index are easy to implement in the layer based SVG engine - it's currently disabled, but only because it's lacking dedicated tests: I'd still need to write new reftests covering that.

Re:Introducing the layer based SVG engine by hutzlibu on Monday November 01, 2021 @08:13PM (#29075178)
I remember a article already quite some years ago, expressing much frustration with that. Basically the spec is complicated - and the vendors were unwilling to integrate more complexy. And that seemed to not have changed. Most parties are just interested in making things faster and more stable. (And then one bright day, implement a better, cleaner designed 2D vector standard)
Re:Introducing the layer based SVG engine by moron4hire on Monday November 01, 2021 @06:51PM (#29074302)
It's been a while since I've done any SVG, but it seems like you could just create a grouping element for each layer and not put any graphical elements in the doc root.