mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 12:44:11 -10:00
blitz-dom's serializer (svg_css_paint) now writes each SVG element's computed paint properties into its style attribute: fill, stroke and their opacities, fill-rule, stroke-width, -linecap, -linejoin, -miterlimit, -dasharray and -dashoffset where they differ from the parent's computed value (they inherit, so a rule on the <svg> stays on the <svg>), and vector-effect where it isn't none. currentcolor is written as the element's color, as presentation attributes already were. The style attribute beats presentation attributes in usvg as in CSS, so a rule's fill wins over a fill="" attribute, as Chrome has it. vendor/stylo now has vector-effect for Servo too (it was Gecko-only), so a stylesheet's non-scaling-stroke reaches the source and isn't reported as not applied. bench/svg-css-paint/check.sh draws five squares: a and b from a stylesheet rule on the path (a with vector-effect), c with attributes, d with a fill attribute under a rule on the <svg> (the attribute wins, as it's on the path), and e with a rule on the path over a fill attribute (the rule wins). Chrome 148 draws a, b and c as green outlines, d orange and e green. The raea before this drew a and b as black squares and e orange, and noted vector-effect as not applied; the raea with it passes. WPT css-transforms, an 11-07 build vs this tree (won/lost lists; the newer build has #39 and other lanes' changes too): 18 svg-document-styles, svg-external-styles and svg-inline-styles tests now pass (their transforms' boxes are drawn with CSS fill). Three tests that passed because the test and its reference were drawn equally wrong now fail on their real gaps: svgbox-stroke-box-003/004 (with non-scaling-stroke, Chrome uses stroke-box as fill-box) and css-masking's clip-path-animation-neutral-keyframe-svg-smil (raea doesn't run SMIL <animate>, so the CSS fill shows where Chrome animates it). fps, the same 120-frame page back to back, three runs each: 3.7, 3.9, 3.5 ms a frame before, 2.4, 3.3, 3.4 after (about 280 fps both). Upstream candidate: blitz-dom serialize.rs's svg_css_paint (Blitz), stylo's vector-effect for Servo.
23 lines
1.6 KiB
HTML
23 lines
1.6 KiB
HTML
<!doctype html>
|
|
<!-- #45: an inline SVG's fill and stroke from a stylesheet, as Chrome draws them. a and b set them on the path from a
|
|
stylesheet rule (a with vector-effect too), c as attributes; all three are a green outline on white, empty inside
|
|
(raea drew a and b as black squares: the rule wasn't in the serialized SVG usvg reads). d sets a stylesheet fill
|
|
on the svg and an attribute fill on the path, which wins over what it inherits (orange); e's rule on the path
|
|
beats its attribute (green). bench/svg-css-paint/check.sh -->
|
|
<html><head><style>
|
|
#a path { fill: none; stroke: #13502B; stroke-width: 6; vector-effect: non-scaling-stroke }
|
|
#b path { fill: none; stroke: #13502B; stroke-width: 6 }
|
|
#d { fill: #13502B }
|
|
#e path { fill: #13502B }
|
|
svg { width: 100px; height: 100px; position: absolute; top: 20px }
|
|
</style></head>
|
|
<body style="margin:0;background:#fff">
|
|
<div data-composition-id="main" data-start="0" data-duration="1" data-width="600" data-height="140" style="position:relative;width:600px;height:140px">
|
|
<svg id="a" style="left:0" viewBox="0 0 100 100"><path d="M20 20 H80 V80 H20 Z"/></svg>
|
|
<svg id="b" style="left:120px" viewBox="0 0 100 100"><path d="M20 20 H80 V80 H20 Z"/></svg>
|
|
<svg id="c" style="left:240px" viewBox="0 0 100 100"><path d="M20 20 H80 V80 H20 Z" fill="none" stroke="#13502B" stroke-width="6" vector-effect="non-scaling-stroke"/></svg>
|
|
<svg id="d" style="left:360px" viewBox="0 0 100 100"><path d="M20 20 H80 V80 H20 Z" fill="#f08000"/></svg>
|
|
<svg id="e" style="left:480px" viewBox="0 0 100 100"><path d="M20 20 H80 V80 H20 Z" fill="#f08000"/></svg>
|
|
</div>
|
|
</body></html>
|