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

Unified Diff: third_party/WebKit/Source/core/dom/SelectorQueryTest.cpp

Issue 2820013002: Separate the id fast path in SelectorQuery. (Closed)
Patch Set: Update tests. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/SelectorQuery.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/SelectorQueryTest.cpp
diff --git a/third_party/WebKit/Source/core/dom/SelectorQueryTest.cpp b/third_party/WebKit/Source/core/dom/SelectorQueryTest.cpp
index d085bf4bb9384523916569cb26a5e80fa8f79b7e..1828396e9f15373efdc1a147cbe6001c5392e477 100644
--- a/third_party/WebKit/Source/core/dom/SelectorQueryTest.cpp
+++ b/third_party/WebKit/Source/core/dom/SelectorQueryTest.cpp
@@ -139,6 +139,8 @@ TEST(SelectorQueryTest, StandardsModeFastPaths) {
{"body #multiple", false, 1, {1, 1, 0, 0, 0, 0, 0}},
{"body span#multiple", false, 1, {2, 2, 0, 0, 0, 0, 0}},
{"body #multiple", true, 2, {2, 2, 0, 0, 0, 0, 0}},
+ {"[id=multiple]", true, 2, {2, 2, 0, 0, 0, 0, 0}},
+ {"body [id=multiple]", true, 2, {2, 2, 0, 0, 0, 0, 0}},
// Single selector tag fast path.
{"span", false, 1, {4, 0, 0, 4, 0, 0, 0}},
@@ -149,39 +151,36 @@ TEST(SelectorQueryTest, StandardsModeFastPaths) {
{".two", true, 4, {14, 0, 14, 0, 0, 0, 0}},
// Class in the right most selector fast path.
- {"body .two", false, 1, {6, 0, 0, 0, 6, 0, 0}},
- {"div .two", false, 1, {12, 0, 0, 0, 12, 0, 0}},
+ {"body .two", false, 1, {6, 0, 6, 0, 0, 0, 0}},
+ {"div .two", false, 1, {12, 0, 12, 0, 0, 0, 0}},
// Classes in the right most selector for querySelectorAll use a fast
// path.
{"body .two", true, 4, {14, 0, 14, 0, 0, 0, 0}},
{"div .two", true, 2, {14, 0, 14, 0, 0, 0, 0}},
- // TODO: querySelector disables the class fast path to favor the id, but
- // this means some selectors always end up doing fastScan.
- {"#second .two", false, 1, {2, 0, 0, 0, 2, 0, 0}},
-
- // TODO(esprehn): This should have used getElementById instead of doing
- // a fastClass scan. It could have looked at 4 elements instead.
- {"#second .two", true, 2, {14, 0, 14, 0, 0, 0, 0}},
+ // TODO: We could use the fast class path to find the elements inside
+ // the id scope instead of the fast scan.
+ {"#second .two", false, 1, {3, 1, 0, 0, 2, 0, 0}},
+ {"#second .two", true, 2, {5, 1, 0, 0, 4, 0, 0}},
// We combine the class fast path with the fast scan mode when possible.
- {".B span", false, 1, {11, 0, 0, 0, 11, 0, 0}},
+ {".B span", false, 1, {11, 0, 10, 0, 1, 0, 0}},
{".B span", true, 4, {14, 0, 10, 0, 4, 0, 0}},
// We expand the scope of id selectors when affected by an adjectent
// combinator.
- {"#c + :last-child", false, 1, {4, 0, 0, 0, 4, 0, 0}},
- {"#a ~ :last-child", false, 1, {4, 0, 0, 0, 4, 0, 0}},
- {"#c + div", true, 1, {4, 0, 0, 0, 4, 0, 0}},
- {"#a ~ span", true, 2, {4, 0, 0, 0, 4, 0, 0}},
+ {"#c + :last-child", false, 1, {5, 1, 0, 0, 4, 0, 0}},
+ {"#a ~ :last-child", false, 1, {5, 1, 0, 0, 4, 0, 0}},
+ {"#c + div", true, 1, {5, 1, 0, 0, 4, 0, 0}},
+ {"#a ~ span", true, 2, {5, 1, 0, 0, 4, 0, 0}},
// We only expand the scope for id selectors if they're directly affected
// the adjacent combinator.
- {"#first span + span", false, 1, {2, 0, 0, 0, 2, 0, 0}},
- {"#first span ~ span", false, 1, {2, 0, 0, 0, 2, 0, 0}},
- {"#second span + span", true, 3, {4, 0, 0, 0, 4, 0, 0}},
- {"#second span ~ span", true, 3, {4, 0, 0, 0, 4, 0, 0}},
+ {"#first span + span", false, 1, {3, 1, 0, 0, 2, 0, 0}},
+ {"#first span ~ span", false, 1, {3, 1, 0, 0, 2, 0, 0}},
+ {"#second span + span", true, 3, {5, 1, 0, 0, 4, 0, 0}},
+ {"#second span ~ span", true, 3, {5, 1, 0, 0, 4, 0, 0}},
// We disable the fast path for class selectors when affected by adjacent
// combinator.
@@ -268,7 +267,7 @@ TEST(SelectorQueryTest, FastPathScoped) {
{".root-class span:nth-child(2)", true, 1, {7, 0, 0, 0, 7, 0, 0}},
// If the id is an ancestor we scan all the descendants.
- {"#root-id span", true, 4, {7, 0, 0, 0, 7, 0, 0}},
+ {"#root-id span", true, 4, {8, 1, 0, 0, 7, 0, 0}},
};
{
@@ -304,6 +303,8 @@ TEST(SelectorQueryTest, QuirksModeSlowPath) {
{"#One", false, 1, {5, 0, 0, 0, 0, 5, 0}},
{"#ONE", false, 1, {5, 0, 0, 0, 0, 5, 0}},
{"#ONE", true, 2, {6, 0, 0, 0, 0, 6, 0}},
+ {"[id=One]", false, 1, {5, 0, 0, 0, 0, 5, 0}},
+ {"[id=One]", true, 1, {6, 0, 0, 0, 0, 6, 0}},
{"span", false, 1, {4, 0, 0, 0, 0, 4, 0}},
{"span", true, 3, {6, 0, 0, 0, 0, 6, 0}},
{".two", false, 1, {5, 0, 0, 0, 0, 5, 0}},
« no previous file with comments | « third_party/WebKit/Source/core/dom/SelectorQuery.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698