Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Issue 14581013: Optimized querySelector(All) when selector contains #id. (Closed)

Created:
7 years, 7 months ago by rune
Modified:
7 years, 7 months ago
CC:
blink-reviews, eae+blinkwatch, adamk+blink_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Visibility:
Public.

Description

Optimized querySelector(All) when selector contains #id. There existed an optimization that did an element lookup for an id if the leftmost part of the selector was an id selector. Without this change, these queries would do an id lookup: querySelector("#id"), querySelector("#id.class") while these wouldn't: querySelector(".class#id"), querySelector("[name=x]#id") This change modifies the element lookup to include the latter two. More importantly, it also extends the optimization for id selectors to limit traversal of the dom-tree to the sub-tree rooted at the element with an id matching the rightmost id selector in the whole selector. For id selectors appearing left of adjacent combinators, the traversal needs to be rooted at the parent of the element with the given id. Examples: querySelector("#id span") - traversal from the id element. querySelector("#id + div span") - traversal from the parent of the id element. This fix should make this: querySelector("#id span") as fast as: getElementById("id").querySelector("span") BUG=240188 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=150417

Patch Set 1 #

Total comments: 5

Patch Set 2 : Fixed review issues. #

Total comments: 2

Patch Set 3 : Fixed review issues in Patch Set 2 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+57 lines, -32 lines) Patch
A + PerformanceTests/Parser/query-selector-id-deep.html View 1 chunk +2 lines, -4 lines 0 comments Download
A + PerformanceTests/Parser/query-selector-id-last.html View 1 chunk +3 lines, -5 lines 0 comments Download
M Source/core/dom/SelectorQuery.h View 1 1 chunk +1 line, -1 line 0 comments Download
M Source/core/dom/SelectorQuery.cpp View 1 2 3 chunks +51 lines, -22 lines 0 comments Download

Messages

Total messages: 11 (0 generated)
haraken
The approach looks good to me, although I'm not sure of detailed implementation of findTraverseRoot(). ...
7 years, 7 months ago (2013-05-14 00:32:58 UTC) #1
Hajime Morrita
https://codereview.chromium.org/14581013/diff/1/Source/core/dom/SelectorQuery.cpp File Source/core/dom/SelectorQuery.cpp (right): https://codereview.chromium.org/14581013/diff/1/Source/core/dom/SelectorQuery.cpp#newcode107 Source/core/dom/SelectorQuery.cpp:107: bool SelectorDataList::findTraverseRoot(Node*& rootNode) const Using in-out parameter is almost ...
7 years, 7 months ago (2013-05-14 00:51:39 UTC) #2
tasak
I looked at the patch from the viewpoint of ::-webkit-distributed and custom pseudo. So, findTraverseRoot ...
7 years, 7 months ago (2013-05-14 04:30:14 UTC) #3
rune
On 2013/05/14 00:32:58, haraken wrote: > The approach looks good to me, although I'm not ...
7 years, 7 months ago (2013-05-14 08:51:04 UTC) #4
rune
On 2013/05/14 00:51:39, morrita1 wrote: > https://codereview.chromium.org/14581013/diff/1/Source/core/dom/SelectorQuery.cpp > File Source/core/dom/SelectorQuery.cpp (right): > > https://codereview.chromium.org/14581013/diff/1/Source/core/dom/SelectorQuery.cpp#newcode107 > ...
7 years, 7 months ago (2013-05-14 10:44:33 UTC) #5
rune
I think I've addressed the issues from patch set 1.
7 years, 7 months ago (2013-05-14 10:46:34 UTC) #6
haraken
LGTM, but please wait for review from tasak@. tasak: r? https://codereview.chromium.org/14581013/diff/8001/Source/core/dom/SelectorQuery.cpp File Source/core/dom/SelectorQuery.cpp (right): https://codereview.chromium.org/14581013/diff/8001/Source/core/dom/SelectorQuery.cpp#newcode107 ...
7 years, 7 months ago (2013-05-14 12:50:33 UTC) #7
rune
On 2013/05/14 12:50:33, haraken wrote: > LGTM, but please wait for review from tasak@. > ...
7 years, 7 months ago (2013-05-14 14:01:54 UTC) #8
tasak
lgtm
7 years, 7 months ago (2013-05-15 07:14:19 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/rune@opera.com/14581013/16001
7 years, 7 months ago (2013-05-15 07:15:48 UTC) #10
commit-bot: I haz the power
7 years, 7 months ago (2013-05-15 13:52:18 UTC) #11
Message was sent while issue was closed.
Change committed as 150417

Powered by Google App Engine
This is Rietveld 408576698