View Single Post
Old 06-20-2009, 10:39 PM   #35
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,498
Karma: 28548962
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You certainly need to store the entire XML tag structure in memory to support CSS 2.1, you don't need to store the text nodes and that will reduce memory consumption for files that have a low tag/text ratio. However, you still have to read and parse the entire tag tree. Whether you do it in a streamed fashion or not. The reason you have to read and parse the entire tree is to support CSS selectors. I suggest you read the following to understand just why it is neccessary http://www.w3.org/TR/CSS2/selector.h...dant-selectors

It's certainly true that you don't have to store all the text content in memory and that means the size limit of 300KB can probably be increased. But frankly, the increased programming complexity and consequent rendering fragility is not worth it. I think 300KB is a perfectly reasonable limit. EPUB creators simply have to keep it in mind.

As for pre-parsing and storing rendered versions of the file, I think that is an extremely inelegant solution and imposes an absolute restriction on allowing display modification by the user. Say good bye to allowing free font resizing, line space and margin adjustments.
kovidgoyal is offline   Reply With Quote