-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inefficiency in applying stylesheet #529
Comments
When you open a document and there is no cache, the XML is parsed and the DOM built. While the DOM is built, there is an optimisation: we apply styles as we create the nodes (as CSS styles depends only on parents and previous siblings, and not on the not-yet-met children or next siblings). Later, when you rerender the document (change font size, style tweaks...), the DOM is there and is reused. But the nodes styles may no longer be valid, and need to be recomputed. So, styles are always computed only once in each of these 2 operations.
And possibly some more other calls if selectors have parent/siblings rules. We must be sure they will work for them too, so we can't just cache stuff for the currently stylesheet.apply(current_node), or we need to have 2 paths for when stuff is cached for the current node and for when stuff is not for parent nodes.
Not sure I understand what you have in mind in that italic part.
Also not sure how you see that.
So, not a solution if we want to support 32bits arm like our Kobo & co.
Dunno if that's what you had in mind, but when I read that earlier, I thought about |
If an epub's stylesheets contain a lot of class selectors (which is not rare) then current code can be terribly slow. Basically if there are m class selectors and n nodes, more than mn calls to
LVCssSelectorRule::check()
are made. Some optimization ideas:class
attr, we can skip most class selectors. Can be constructed duringLVStyleSheet.push()
?getAttributeValue()
results inLVStyleSheet::apply()
, so we don't repeatedly call that on the same node against different rules.ldomNode
trades speed for space. On x64 there are 4 bytes padding that can be utilized, such as storing node ID. May be irrelevant if previous 2 items are implemented.I test epubs with
LoadDocument()
andRender()
. I've noticed that styles are applied in both calls. Why so?The text was updated successfully, but these errors were encountered: