sprotty icon indicating copy to clipboard operation
sprotty copied to clipboard

SVG export of styles in Firefox is broken.

Open NiklasRentzCAU opened this issue 6 years ago • 1 comments

I am looking at a graph generated by the theia-xtext-sprotty-example project. Both in Chrome and in Firefox the graphs look good when viewed in Theia. After using the export feature (alt+E) on the diagram, only the Chrome-exported SVG works in most viewers, the Firefox-exported one does not work in most viewers, even Firefox itself cannot display the SVG anymore.

These are the SVGs exported by the different browsers: MrsGrantsSecretCompartment.zip The first file is the Chrome-generated, the one ending in '1' is generated by Firefox and the file ending with '1-modified' is the same file by Firefox with the topmost style attribute in the tag replaced with the style attribute of the Chrome-SVG. What can be seen there is that the exporter includes way too much CSS style properties of Theia not needed in the SVG, most notably the '--theia-icon-open-json' as an entire icon in base64.

This is the statemachine used to generate the diagrams:

statemachine MrsGrantsSecretCompartment

event doorClosed
event drawOpened
event lightOn
event panelClosed

state active
    lightOn => waitingForDraw
    drawOpened => waitingForLight

state idle
    doorClosed => active

state waitingForLight
    lightOn => idle

state waitingForDraw
    drawOpened => unlockedPanel

state unlockedPanel
    panelClosed => idle

NiklasRentzCAU avatar Nov 27 '19 13:11 NiklasRentzCAU

The same problem exists in VSCode extensions!

The following zip include a SVG generated with the states example extension in the sprotty-vscode Repo. The other two SVG are SVGs generated by a standalone view in Chrome and another VSCode extension: examples.zip

All examples use the latest Sprotty versions. Only the SVG generated in Chrome works. Both SVGs generated by VSCode extension contain unnecessary inline styles on the svg tag. Interestingly, their styles are quite different.

The problematic rule appears to be inline-size: 0px. Further, the sccharts-vscode.svg file also contains the rule block-size: 0px, which causes the svg to have a height of 0px. Removing both rules renders the SVGs.

christoph-fricke avatar May 21 '21 13:05 christoph-fricke