RESOLVED FIXED117388
Add special tree walking for the single tag or class CSS query selectors
https://bugs.webkit.org/show_bug.cgi?id=117388
Summary Add special tree walking for the single tag or class CSS query selectors
Benjamin Poulain
Reported 2013-06-09 18:50:40 PDT
Add special tree walking for the single tag or class CSS query selectors
Attachments
Patch (6.75 KB, patch)
2013-06-09 18:53 PDT, Benjamin Poulain
rniwa: review+
Benjamin Poulain
Comment 1 2013-06-09 18:53:52 PDT
Ryosuke Niwa
Comment 2 2013-06-09 20:11:35 PDT
Comment on attachment 204132 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=204132&action=review > Source/WebCore/dom/SelectorQuery.cpp:228 > const SelectorData& selectorData = m_selectors[0]; Maybe we should consider the case where we have multiple selectors as a special case instead? It might also make sense to apply these optimizations to each selector even when we have multiple selectors. e.g. #hello, #world shouldn't be doing a tree traversal if #hello and #world didn't have multiple matching elements.
Benjamin Poulain
Comment 3 2013-06-09 20:26:51 PDT
> Maybe we should consider the case where we have multiple selectors as a special case instead? > It might also make sense to apply these optimizations to each selector even when we have multiple selectors. > e.g. #hello, #world shouldn't be doing a tree traversal if #hello and #world didn't have multiple matching elements. Since we need to preserve the order, we cannot apply the optimizations on each selector in the case of multiselector. "#hello, #world", or "#hello a, #hello b" are interesting cases. We should look into that.
Ryosuke Niwa
Comment 4 2013-06-09 20:33:48 PDT
(In reply to comment #3) > > Maybe we should consider the case where we have multiple selectors as a special case instead? > > It might also make sense to apply these optimizations to each selector even when we have multiple selectors. > > e.g. #hello, #world shouldn't be doing a tree traversal if #hello and #world didn't have multiple matching elements. > > Since we need to preserve the order, we cannot apply the optimizations on each selector in the case of multiselector. > > "#hello, #world", or "#hello a, #hello b" are interesting cases. We should look into that. Suppose we have selectors #id_1, #id_2, #id_3, ... #id_n and each id_n resolves to exactly one element e_n, then we should be able to sort e_1, etc... e_n in O(k n log n) where k is the depth of the tree.
Benjamin Poulain
Comment 5 2013-06-10 01:04:19 PDT
Note You need to log in before you can comment on or make changes to this bug.