Convert from SVG 1.1 SVGRect to SVG 2 DOMRect/DOMRectReadOnly
Categories
(Core :: SVG, enhancement, P3)
Tracking
()
People
(Reporter: longsonr, Assigned: longsonr)
References
Details
(Keywords: dev-doc-needed)
Attachments
(2 files)
29.34 KB,
patch
|
Details | Diff | Splinter Review | |
37.08 KB,
patch
|
Details | Diff | Splinter Review |
Assignee | ||
Comment 1•7 years ago
|
||
![]() |
||
Comment 3•7 years ago
|
||
Assignee | ||
Comment 4•7 years ago
|
||
Updated•7 years ago
|
Comment 5•7 years ago
|
||
Comment 6•7 years ago
|
||
Comment 7•7 years ago
|
||
![]() |
||
Comment 8•7 years ago
|
||
Assignee | ||
Comment 10•6 years ago
|
||
This is what I've got so far but....
- It doesn't work for AnimVal at all because you can't have an inherit readonly attribute
- It doesn't work for left, right, width, height (this one's fixable)
- It's going to be very fragile because if someone adds another property to DOMRect or DOMRectReadOnly it wont work in SVGAnimValRect or SVGBaseValRect without implementing it there too.
So in conclusion I'm rather thinking that
- we change methods that take an SVGRect/SVGPoint/SVGMatrix to take an DOMRectInit, DOMPointInit, DOMMatrixInit as that's compatible with either
- we won'tfix this and push back on the w3c to revert the spec at least for live attributes like viewBox.animVal and viewBox.baseVal.
Assignee | ||
Comment 12•6 years ago
|
||
Comment 13•6 years ago
|
||
Thanks a lot for looking into this, Robert. I looked at the github issue in comment 12. It looks like option 2 in comment 10 isn't getting much support yet. If I understand option 1 there correctly, is that really completely compatible with their current signature? For example, if a method void foo(SVGRect arg);
exists on a given interface, calling it with {}
would be emit a TypeError
, but with that option such a call would work successfully, no?
A bit about the performance concern that I had (apologies if I'm repeating something you already know), there specific case I'm worried about is JS code that for example deals with DOMRect
and SVGRect
objects, and calls DOMRect::SetX()
and SVGRect::SetX()
alternately. If the SetX()
function is virtual then the CPU's branch predictor logic will have a very hard time making correct predictions around which concrete implementation must be called, so each function call will have a lot of overhead because it will be a jump to a mispredicted code address. But perhaps such access patterns where JS code calls these virtual functions in alternating order or other patterns which are hard to predict are so uncommon that we should bite our tongue and live with this spec change? Hard for me to say as a non-domain-expert, but hopefully you'll have useful context to add here.
Assignee | ||
Comment 14•6 years ago
|
||
This isn't about foo(SVGRect arg), we've already changed all those to DOMRectInit, which is compatible with SVGRect and DOMRect. This is about DOMRect being live i.e. if element.viewBox.animVal is a DOMRect then element.viewBox.animVal.x should update the viewBox attribute like setAttribute does.
Comment 15•6 years ago
|
||
This is about DOMRect being live i.e. if element.viewBox.animVal is a DOMRect then element.viewBox.animVal.x should update the viewBox attribute like setAttribute does.
What about proposing to drop this liveness from SVG spec? It seems the trend now is to make SVG less special with respect to the rest of the web, animVal
and baseVal
stuff will become more and more irrelevant in the future, especially with more attributes becoming CSS property. animVal
already becomes an alias of baseVal
in spec, though no one has made this backward-incompatible change yet.
Assignee | ||
Comment 16•6 years ago
|
||
We'd be worried about breaking existing content. E.g. https://css-tricks.com/creating-a-panning-effect-for-svg/
Comment hidden (obsolete) |
Comment 18•6 years ago
|
||
My last comment is not correct. We are talking about calling from JS code with JIT, which is not able to inline native function in the first place IIRC. So the DOMPoint should already be significantly slower than a simple JS dictionary.
Just running a simple benchmark shows DOMPoint is incredibly slower than JS dictionary when being used in a for
loop, which makes it unusable as a mathematical utility.
Based on this, I doubt the extra overhead of a virtual
function really matters (it's already unusable if performance is a concern).
Comment 19•6 years ago
|
||
(In reply to Robert Longson [:longsonr] from comment #14)
This isn't about foo(SVGRect arg), we've already changed all those to DOMRectInit, which is compatible with SVGRect and DOMRect. This is about DOMRect being live i.e. if element.viewBox.animVal is a DOMRect then element.viewBox.animVal.x should update the viewBox attribute like setAttribute does.
Ah now I understand, sorry you had mentioned this before but it somehow didn't "click".
I think violet.bugreport is correct in comment 18 for this use case, so I take back my previous objection.
Updated•2 years ago
|
![]() |
||
Updated•3 months ago
|
Description
•