WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
159401
When copying embedded SVG, CSS is not retained.
https://bugs.webkit.org/show_bug.cgi?id=159401
Summary
When copying embedded SVG, CSS is not retained.
Samuel Williams
Reported
2016-07-04 00:56:57 PDT
Created
attachment 282693
[details]
A case which shows the issue. When copying either via the API or using Command-C, from the attached sample, and then pasting into Mail.app, the circular pie-chart shows black. There is possibly an additional bug where the sample also shows only one pie chart but on loading in Safari shows two. Not sure why. Perhaps it's evaluating the JavaScript code a second time?
Attachments
A case which shows the issue.
(17.28 KB, application/zip)
2016-07-04 00:56 PDT
,
Samuel Williams
no flags
Details
Example of copying into Mail.app from chartist-js website.
(264.00 KB, image/png)
2016-07-04 03:33 PDT
,
Samuel Williams
no flags
Details
Results of copying from Chrome.
(392.93 KB, image/png)
2016-07-04 03:36 PDT
,
Samuel Williams
no flags
Details
Example showing inline stylesheets working.
(394.50 KB, image/png)
2016-07-04 04:18 PDT
,
Samuel Williams
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Samuel Williams
Comment 1
2016-07-04 03:32:53 PDT
Another way to reproduce this is to go to
https://gionkunz.github.io/chartist-js/
and copy the charts and paste into Mail.app. It shows up as black shapes, i.e. without styles applied.
Samuel Williams
Comment 2
2016-07-04 03:33:28 PDT
Created
attachment 282701
[details]
Example of copying into Mail.app from chartist-js website.
Samuel Williams
Comment 3
2016-07-04 03:35:28 PDT
Tried copying from Chrome.. issue was still similar.
Samuel Williams
Comment 4
2016-07-04 03:36:02 PDT
Created
attachment 282702
[details]
Results of copying from Chrome.
Samuel Williams
Comment 5
2016-07-04 03:39:08 PDT
If the issue is similar from Chrome and Safari, i.e. the pasteboard content is similar but rendering is broken in both instances, is the problem related to how the pasteboard content is rendered? I assume webkit is responsible for rendering in Mail.app? Could it be a sandbox-related issue? I also noticed for the web archive, quick look was generating some odd previews. For example, when the preview was the thumbnail type, the shape was black. But when pressing spacebar to open quick look preview, it rendered correctly. Odd.
Samuel Williams
Comment 6
2016-07-04 04:18:27 PDT
Managed to work around the issue by traversing the SVG DOM and using getComputedStyle to apply fill and other related CSS properties as inline styles. Then, copying works. Here is a simple example of the code I used: function embedSVGStyle(element) { Array.prototype.forEach.call(element.children, function(child) { embedSVGStyle(child); }); var computedStyle = getComputedStyle(element); element.style.fill = computedStyle.fill; } Attached is a picture showing it working.
Samuel Williams
Comment 7
2016-07-04 04:18:54 PDT
Created
attachment 282705
[details]
Example showing inline stylesheets working.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug