Open Bug 1309046 Opened 9 years ago Updated 3 years ago

SVG with external content via <use> does not print

Categories

(Core :: Printing: Output, defect, P3)

49 Branch
Unspecified
All
defect

Tracking

()

People

(Reporter: craigmcginley, Unassigned)

References

Details

(Whiteboard: DUPEME)

Attachments

(2 files, 1 obsolete file)

59 bytes, text/x-review-board-request
Details
1.75 KB, patch
Details | Diff | Splinter Review
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36 Steps to reproduce: My application uses an SVG icon sprite sheet, which is useful for caching. I am using svg4everybody for certain browsers but this shouldn't affect Firefox. I include icons in the page similar to this: <svg class="icon"> <use xlink:href="/img/icon-sprite.svg#icon-name"/> </svg> You can also reference here for an example, same method: https://css-tricks.com/examples/svg-for-everybody/ Actual results: As far as I can tell, all SVG's with external content via <use> do not print. Expected results: I would expect the SVG images to still print, as they do in all other browsers I tested (IE/safari/chrome).
I should add that the SVG's appear just fine on the webpage. This is only concerned with printing the webpage, where the SVG's then disappear.
OS: Unspecified → Mac OS X
Print Preview is affected too. Like older versions (FF29 e.g.), surely a duplicate.
Whiteboard: DUPEME
CJ, any idea on why?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(cku)
OS: Mac OS X → All
Priority: -- → P3
Update what I found so far: 1. While printing a web page, we will create a new document and use a nsSimplePageSequenceFrame as a root container. 2. Layout: there are several use elements in the test example, so I set a break pointer in SVGUseElement::CreateAnonymousContent[ to check whether we create anonymous content for reference target. We early return at [1] which means we do not create an anonymous use element tree. [1] https://searchfox.org/mozilla-central/source/dom/svg/SVGUseElement.cpp#221
Flags: needinfo?(cku)
Flags: needinfo?(cku)
nsDataDocumentContentPolicy::ShouldLoad(...) { .... if (doc->IsLoadedAsData()) { // ...but let static (print/print preview) documents to load fonts. if (!doc->IsStaticDocument() || aContentType != nsIContentPolicy::TYPE_FONT) { << reject here! *aDecision = nsIContentPolicy::REJECT_TYPE; return NS_OK; } } }
Attachment #8929981 - Attachment is obsolete: true
Assignee: nobody → cku
Flags: needinfo?(cku)
Attached patch Another WIP — — Splinter Review
Update what I had found now 1. When print, we create a static clone document from the original one for printing. This new cloned one is a. a data document [1] b. a static document.[2] 2. In the test cases, there are several <use> elements inside this document. Each of them will request a exteranl resource from an SVG file, e.g. <use href="foo.svg#svg_element_id">[3] 3. security checking for these request: since the cloned document is a data document(see #1), it basically can not load any content, except of nsIContentPolicy::TYPE_DTD and nsIContentPolicy::TYPE_FONT type [4]. [1] https://hg.mozilla.org/mozilla-central/file/b828f7a6c2bf/dom/base/nsDocument.cpp#l9813 [2] https://hg.mozilla.org/mozilla-central/file/905239391e05/layout/printing/nsPrintObject.cpp#l87 [3] https://hg.mozilla.org/mozilla-central/file/5ebe2e8980c6/dom/base/IDTracker.cpp#l104 [4] https://hg.mozilla.org/mozilla-central/file/952640eb7c56/dom/base/nsDataDocumentContentPolicy.cpp#l73
Assignee: cku → nobody
Currently, in the Nightly, pages that have a <use> element are just unable to be printed. Two error dialogs shows up, saying “Printer [or ‘Print Preview’] error” – “An unexpected problem occured when printing.” and in the browser console, this error shows up: In Printing:Print:Done handler, got unexpected rv PrintingChild.jsm:358 2147549183. print resource://gre/actors/PrintingChild.jsm:358:9 receiveMessage resource://gre/actors/PrintingChild.jsm:98:9 receiveMessage resource://gre/modules/ActorManagerChild.jsm:91:39 Is this the same issue, or is it a new one?
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: