Hi,
With my CSS parser being mostly complete, the next part to replacing
NetSurf’s LibCSS in Servo is selector matching.
Part of that is doing it in a way that can meet our performance
requirements. I’ve been going through Gecko’s nsCSSRuleProcessor.cpp
source code and the Fast and Parallel Webpage Layout paper.
http://www.eecs.berkeley.edu/~lmeyerov/projects/pbrowser/pubfiles/playout.pdf
What I got so far:
* Different rules can use the same selector. Map unique selectors each
to a list of rules, so that identical selectors do not need to be
matched more than once.
* Map ID values to selectors that requires their subjects to have it.
Then same with class names, element names, etc. Each time with remaining
selectors from the previous step. Have a list of the remaining selectors.
* For each element in the document, possibly in parallel, find matching
selectors. The maps defined above allow rejecting quickly most selectors.
* There is a bloom filter for descendant combinators. I don’t understand
exactly how this works yet, but more code reading should fix that.
Did I miss something important?
Servo does not seem to have namespaces right now. I suppose it shouldn’t
be a problem to add later.
Perhaps more tricky is dynamic changes (in stylesheets, in DOM tree,
etc.) Should we consider as soon as now how to make them fast in
selector matching?
Would it help to have a video / whiteboard discussion of all this?
Cheers,
--
Simon Sapin
_______________________________________________
dev-servo mailing list
dev-servo@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-servo