diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2017-02-04 09:41:13 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2017-02-04 09:41:13 +0000 |
commit | e7366bf41f68cfe07e9ea03fc4a398baecbae651 (patch) | |
tree | 5bb9c3cbe7eab7e70ff1ebd65d9de59a694762df /libcss_style_sharing.mdwn | |
download | netsurf-wiki-e7366bf41f68cfe07e9ea03fc4a398baecbae651.tar.gz netsurf-wiki-e7366bf41f68cfe07e9ea03fc4a398baecbae651.tar.bz2 |
Initial conversion from MediaWiki, 20170204
Diffstat (limited to 'libcss_style_sharing.mdwn')
-rw-r--r-- | libcss_style_sharing.mdwn | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/libcss_style_sharing.mdwn b/libcss_style_sharing.mdwn new file mode 100644 index 0000000..1c8a635 --- /dev/null +++ b/libcss_style_sharing.mdwn @@ -0,0 +1,48 @@ +[[!meta title="LibCSS Style Sharing"]] +[[!meta author="Tlsa"]] +[[!meta date="2014-01-03T15:21:20Z"]] + + +[[!toc]] At the moment NetSurf does +not share computed styles. Every element on every page has its own +unique computed style allocated. Computed styles are quite large. +Consider the following page: + +- <http://git.netsurf-browser.org/netsurf.git/tree/render/layout.c> + +It has over twenty thousand element nodes each with its own computed +style. But there are less than 40 unique computed styles on the page. +This is a massive waste of memory. + +Computed Style Sharing +---------------------- + +If different elements can reference the same computed styles, we can +save a lot of memory. + +- Computed styles will become reference counted. +- There are two ways to go about sharing computed styles: + 1. Memoising calls to css\_get\_style() + - We'll use selection calbacks to find if node has previous + sibling with same element name, classes, etc. If so the + style for node can be an extra reference to the computed + style of the previous sibling. + - Presentational hint gathering for nodes needs to change such + that presentational hints for two nodes can be compared. + - Only shares styles between siblings. Could be extended to + share between cousins, etc. + - As well as saving memory, this will make selection faster. + - It will be a big saving in cases where styles can be + shared, by bypassing the need to iterate over the + applicable selector chains. + - In cases where the styles can't be shared, it will have + a relatively small cost. + + 2. Interning computed styles + - Will have a performance cost. + - Much greater scope for sharing computed styles than the + above. + - Can even share computed styles between different pages. + (NetSurf will be unique in doing that.) + - Fully compatible with the above, so we can do both. + |