<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[161839] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/161839">161839</a></dd>
<dt>Author</dt> <dd>benjamin@webkit.org</dd>
<dt>Date</dt> <dd>2014-01-12 15:04:19 -0800 (Sun, 12 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use the Selector Code Generator for matching in SelectorQuery
https://bugs.webkit.org/show_bug.cgi?id=126185

Reviewed by Ryosuke Niwa.

Source/WebCore: 

Compile selectors on demand and use the generated binary to perform
element matching in SelectorQuery.

Tests: fast/selectors/querySelector-long-adjacent-backtracking.html
       fast/selectors/querySelector-long-child-backtracking.html
       fast/selectors/querySelector-mixed-child-adjacent-backtracking.html
       fast/selectors/querySelector-multiple-simple-child-backtracking.html
       fast/selectors/querySelector-simple-adjacent-backtracking.html
       fast/selectors/querySelector-simple-child-backtracking.html

* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::executeCompiledSimpleSelectorChecker):
(WebCore::SelectorDataList::executeCompiledSelectorCheckerWithContext):
(WebCore::SelectorDataList::execute):
* dom/SelectorQuery.h:

LayoutTests: 

Add some tests for longer backtracking cases typically not covered by the other tests.

* fast/selectors/querySelector-long-adjacent-backtracking-expected.txt: Added.
* fast/selectors/querySelector-long-adjacent-backtracking.html: Added.
* fast/selectors/querySelector-long-child-backtracking-expected.txt: Added.
* fast/selectors/querySelector-long-child-backtracking.html: Added.
* fast/selectors/querySelector-mixed-child-adjacent-backtracking-expected.txt: Added.
* fast/selectors/querySelector-mixed-child-adjacent-backtracking.html: Added.
* fast/selectors/querySelector-multiple-simple-child-backtracking-expected.txt: Added.
* fast/selectors/querySelector-multiple-simple-child-backtracking.html: Added.
* fast/selectors/querySelector-simple-adjacent-backtracking-expected.txt: Added.
* fast/selectors/querySelector-simple-adjacent-backtracking.html: Added.
* fast/selectors/querySelector-simple-child-backtracking-expected.txt: Added.
* fast/selectors/querySelector-simple-child-backtracking.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssjitSelectorCompilerh">trunk/Source/WebCore/cssjit/SelectorCompiler.h</a></li>
<li><a href="#trunkSourceWebCoredomSelectorQuerycpp">trunk/Source/WebCore/dom/SelectorQuery.cpp</a></li>
<li><a href="#trunkSourceWebCoredomSelectorQueryh">trunk/Source/WebCore/dom/SelectorQuery.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastselectorsquerySelectorlongadjacentbacktrackingexpectedtxt">trunk/LayoutTests/fast/selectors/querySelector-long-adjacent-backtracking-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsquerySelectorlongadjacentbacktrackinghtml">trunk/LayoutTests/fast/selectors/querySelector-long-adjacent-backtracking.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorsquerySelectorlongchildbacktrackingexpectedtxt">trunk/LayoutTests/fast/selectors/querySelector-long-child-backtracking-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsquerySelectorlongchildbacktrackinghtml">trunk/LayoutTests/fast/selectors/querySelector-long-child-backtracking.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorsquerySelectormixedchildadjacentbacktrackingexpectedtxt">trunk/LayoutTests/fast/selectors/querySelector-mixed-child-adjacent-backtracking-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsquerySelectormixedchildadjacentbacktrackinghtml">trunk/LayoutTests/fast/selectors/querySelector-mixed-child-adjacent-backtracking.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorsquerySelectormultiplesimplechildbacktrackingexpectedtxt">trunk/LayoutTests/fast/selectors/querySelector-multiple-simple-child-backtracking-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsquerySelectormultiplesimplechildbacktrackinghtml">trunk/LayoutTests/fast/selectors/querySelector-multiple-simple-child-backtracking.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorsquerySelectorsimpleadjacentbacktrackingexpectedtxt">trunk/LayoutTests/fast/selectors/querySelector-simple-adjacent-backtracking-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsquerySelectorsimpleadjacentbacktrackinghtml">trunk/LayoutTests/fast/selectors/querySelector-simple-adjacent-backtracking.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorsquerySelectorsimplechildbacktrackingexpectedtxt">trunk/LayoutTests/fast/selectors/querySelector-simple-child-backtracking-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsquerySelectorsimplechildbacktrackinghtml">trunk/LayoutTests/fast/selectors/querySelector-simple-child-backtracking.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (161838 => 161839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-01-12 22:07:44 UTC (rev 161838)
+++ trunk/LayoutTests/ChangeLog        2014-01-12 23:04:19 UTC (rev 161839)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2014-01-12  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
+
+        Use the Selector Code Generator for matching in SelectorQuery
+        https://bugs.webkit.org/show_bug.cgi?id=126185
+
+        Reviewed by Ryosuke Niwa.
+
+        Add some tests for longer backtracking cases typically not covered by the other tests.
+
+        * fast/selectors/querySelector-long-adjacent-backtracking-expected.txt: Added.
+        * fast/selectors/querySelector-long-adjacent-backtracking.html: Added.
+        * fast/selectors/querySelector-long-child-backtracking-expected.txt: Added.
+        * fast/selectors/querySelector-long-child-backtracking.html: Added.
+        * fast/selectors/querySelector-mixed-child-adjacent-backtracking-expected.txt: Added.
+        * fast/selectors/querySelector-mixed-child-adjacent-backtracking.html: Added.
+        * fast/selectors/querySelector-multiple-simple-child-backtracking-expected.txt: Added.
+        * fast/selectors/querySelector-multiple-simple-child-backtracking.html: Added.
+        * fast/selectors/querySelector-simple-adjacent-backtracking-expected.txt: Added.
+        * fast/selectors/querySelector-simple-adjacent-backtracking.html: Added.
+        * fast/selectors/querySelector-simple-child-backtracking-expected.txt: Added.
+        * fast/selectors/querySelector-simple-child-backtracking.html: Added.
+
</ins><span class="cx"> 2014-01-12  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION(r160806): line-height is not applied when only present in :link style.
</span></span></pre></div>
<a id="trunkLayoutTestsfastselectorsquerySelectorlongadjacentbacktrackingexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/querySelector-long-adjacent-backtracking-expected.txt (0 => 161839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/querySelector-long-adjacent-backtracking-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/querySelector-long-adjacent-backtracking-expected.txt        2014-01-12 23:04:19 UTC (rev 161839)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+Test backtracking with a long sequence of direct sibling relations.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS document.querySelectorAll(&quot;li+div+li+blockquote+li~span&quot;).length is 1
+PASS document.querySelectorAll(&quot;li+div+li+blockquote+li~span&quot;)[0].id is &quot;target&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsquerySelectorlongadjacentbacktrackinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/querySelector-long-adjacent-backtracking.html (0 => 161839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/querySelector-long-adjacent-backtracking.html                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/querySelector-long-adjacent-backtracking.html        2014-01-12 23:04:19 UTC (rev 161839)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div style=&quot;display:none&quot;&gt;
+  &lt;ul&gt;
+    &lt;!-- Correct sequence. --&gt;
+    &lt;li&gt;&lt;/li&gt;
+    &lt;div&gt;&lt;/div&gt;
+    &lt;li&gt;&lt;/li&gt;
+    &lt;blockquote&gt;&lt;/blockquote&gt;
+    &lt;li&gt;&lt;/li&gt;
+
+    &lt;!-- Lacks the ending &lt;li&gt;. --&gt;
+    &lt;li&gt;&lt;/li&gt;
+    &lt;div&gt;&lt;/div&gt;
+    &lt;li&gt;&lt;/li&gt;
+    &lt;blockquote&gt;&lt;/blockquote&gt;
+
+    &lt;!-- Lacks the &lt;blockquote&gt;. --&gt;
+    &lt;li&gt;&lt;/li&gt;
+    &lt;div&gt;&lt;/div&gt;
+    &lt;li&gt;&lt;/li&gt;
+    &lt;li&gt;&lt;/li&gt;
+
+    &lt;!-- Lacks the middle &lt;li&gt;. --&gt;
+    &lt;li&gt;&lt;/li&gt;
+    &lt;div&gt;&lt;/div&gt;
+    &lt;blockquote&gt;&lt;/blockquote&gt;
+    &lt;li&gt;&lt;/li&gt;
+
+    &lt;!-- Lacks the &lt;div&gt;. --&gt;
+    &lt;li&gt;&lt;/li&gt;
+    &lt;li&gt;&lt;/li&gt;
+    &lt;blockquote&gt;&lt;/blockquote&gt;
+    &lt;li&gt;&lt;/li&gt;
+
+    &lt;span id=target&gt;Target&lt;/span&gt;
+    &lt;div&gt;
+  &lt;/ul&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+description('Test backtracking with a long sequence of direct sibling relations.');
+
+shouldBe('document.querySelectorAll(&quot;li+div+li+blockquote+li~span&quot;).length', '1');
+shouldBeEqualToString('document.querySelectorAll(&quot;li+div+li+blockquote+li~span&quot;)[0].id', 'target');
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsquerySelectorlongchildbacktrackingexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/querySelector-long-child-backtracking-expected.txt (0 => 161839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/querySelector-long-child-backtracking-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/querySelector-long-child-backtracking-expected.txt        2014-01-12 23:04:19 UTC (rev 161839)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+Test backtracking with multiple child selector relations.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS document.querySelectorAll(&quot;ul&gt;li&gt;div&gt;pre span&quot;).length is 3
+PASS document.querySelectorAll(&quot;ul&gt;li&gt;div&gt;pre span&quot;)[0].id is &quot;target1&quot;
+PASS document.querySelectorAll(&quot;ul&gt;li&gt;div&gt;pre span&quot;)[1].id is &quot;target2&quot;
+PASS document.querySelectorAll(&quot;ul&gt;li&gt;div&gt;pre span&quot;)[2].id is &quot;target3&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsquerySelectorlongchildbacktrackinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/querySelector-long-child-backtracking.html (0 => 161839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/querySelector-long-child-backtracking.html                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/querySelector-long-child-backtracking.html        2014-01-12 23:04:19 UTC (rev 161839)
</span><span class="lines">@@ -0,0 +1,94 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div style=&quot;display:none&quot;&gt;
+&lt;!-- Fails on the &lt;li&gt; tag. --&gt;
+&lt;ul&gt;
+  &lt;li&gt;
+    &lt;div&gt;
+      &lt;div&gt;
+        &lt;pre&gt;
+          &lt;blockquote&gt;&lt;span&gt;Fail.&lt;/span&gt;&lt;/blockquote&gt;
+        &lt;/pre&gt;
+      &lt;/div&gt;
+    &lt;/div&gt;
+  &lt;/li&gt;
+&lt;/ul&gt;
+
+&lt;!-- Fails on the &lt;ul&gt; tag. --&gt;
+&lt;div&gt;
+  &lt;li&gt;
+    &lt;div&gt;
+      &lt;pre&gt;
+        &lt;blockquote&gt;&lt;span&gt;Fail.&lt;/span&gt;&lt;/blockquote&gt;
+      &lt;/pre&gt;
+    &lt;/div&gt;
+  &lt;/li&gt;
+&lt;/div&gt;
+
+&lt;!-- Simple matches. --&gt;
+&lt;ul&gt;
+  &lt;li&gt;
+    &lt;div&gt;
+      &lt;pre&gt;
+        &lt;blockquote&gt;&lt;span id=&quot;target1&quot;&gt;Target 1&lt;/span&gt;&lt;/blockquote&gt;
+      &lt;/pre&gt;
+    &lt;/div&gt;
+  &lt;/li&gt;
+&lt;/ul&gt;
+&lt;ul&gt;
+  &lt;li&gt;
+    &lt;div&gt;
+      &lt;pre&gt;
+        &lt;pre&gt;
+          &lt;blockquote&gt;&lt;span id=&quot;target2&quot;&gt;Target 2&lt;/span&gt;&lt;/blockquote&gt;
+        &lt;/pre&gt;
+      &lt;/pre&gt;
+    &lt;/div&gt;
+  &lt;/li&gt;
+&lt;/ul&gt;
+
+&lt;!-- Multiple failures before a match. --&gt;
+&lt;ul&gt;
+  &lt;li&gt;
+    &lt;div&gt;
+      &lt;pre&gt;
+
+        &lt;!-- This subtree lacks the ul. --&gt;
+        &lt;li&gt;
+          &lt;div&gt;
+            &lt;div&gt;
+
+              &lt;!-- This subtree lacks the li. --&gt;
+              &lt;div&gt;
+                &lt;div&gt;
+                  &lt;div&gt;
+                    &lt;blockquote&gt;&lt;span id=&quot;target3&quot;&gt;Target 3&lt;/span&gt;&lt;/blockquote&gt;
+                  &lt;/div&gt;
+                &lt;/div&gt;
+              &lt;/div&gt;
+
+            &lt;/div&gt;
+          &lt;/div&gt;
+        &lt;/li&gt;
+
+      &lt;/pre&gt;
+    &lt;/div&gt;
+  &lt;/li&gt;
+&lt;/ul&gt;
+
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+description('Test backtracking with multiple child selector relations.');
+
+shouldBe('document.querySelectorAll(&quot;ul&gt;li&gt;div&gt;pre span&quot;).length', '3');
+shouldBeEqualToString('document.querySelectorAll(&quot;ul&gt;li&gt;div&gt;pre span&quot;)[0].id', 'target1');
+shouldBeEqualToString('document.querySelectorAll(&quot;ul&gt;li&gt;div&gt;pre span&quot;)[1].id', 'target2');
+shouldBeEqualToString('document.querySelectorAll(&quot;ul&gt;li&gt;div&gt;pre span&quot;)[2].id', 'target3');
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsquerySelectormixedchildadjacentbacktrackingexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/querySelector-mixed-child-adjacent-backtracking-expected.txt (0 => 161839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/querySelector-mixed-child-adjacent-backtracking-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/querySelector-mixed-child-adjacent-backtracking-expected.txt        2014-01-12 23:04:19 UTC (rev 161839)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+Test backtracking of adjacent and child relation mixed together.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS document.querySelectorAll(&quot;html&gt;head+body div&gt;div~h1+blockquote&gt;p+div+blockquote~ul p&quot;).length is 8
+PASS document.querySelectorAll(&quot;html&gt;head+body div&gt;div~h1+blockquote&gt;p+div+blockquote~ul p&quot;)[0].id is &quot;target1&quot;
+PASS document.querySelectorAll(&quot;html&gt;head+body div&gt;div~h1+blockquote&gt;p+div+blockquote~ul p&quot;)[1].id is &quot;target2&quot;
+PASS document.querySelectorAll(&quot;html&gt;head+body div&gt;div~h1+blockquote&gt;p+div+blockquote~ul p&quot;)[2].id is &quot;target3&quot;
+PASS document.querySelectorAll(&quot;html&gt;head+body div&gt;div~h1+blockquote&gt;p+div+blockquote~ul p&quot;)[3].id is &quot;target4&quot;
+PASS document.querySelectorAll(&quot;html&gt;head+body div&gt;div~h1+blockquote&gt;p+div+blockquote~ul p&quot;)[4].id is &quot;target5&quot;
+PASS document.querySelectorAll(&quot;html&gt;head+body div&gt;div~h1+blockquote&gt;p+div+blockquote~ul p&quot;)[5].id is &quot;target6&quot;
+PASS document.querySelectorAll(&quot;html&gt;head+body div&gt;div~h1+blockquote&gt;p+div+blockquote~ul p&quot;)[6].id is &quot;target7&quot;
+PASS document.querySelectorAll(&quot;html&gt;head+body div&gt;div~h1+blockquote&gt;p+div+blockquote~ul p&quot;)[7].id is &quot;target8&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsquerySelectormixedchildadjacentbacktrackinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/querySelector-mixed-child-adjacent-backtracking.html (0 => 161839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/querySelector-mixed-child-adjacent-backtracking.html                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/querySelector-mixed-child-adjacent-backtracking.html        2014-01-12 23:04:19 UTC (rev 161839)
</span><span class="lines">@@ -0,0 +1,135 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div style=&quot;display:none&quot;&gt;
+
+  &lt;!-- Direct matching, no need to backtrack. --&gt;
+  &lt;div&gt;&lt;/div&gt;
+  &lt;table&gt;&lt;/table&gt;
+  &lt;h1&gt;&lt;/h1&gt;
+  &lt;blockquote&gt;
+    &lt;p&gt;&lt;/p&gt;
+    &lt;div&gt;&lt;/div&gt;
+    &lt;blockquote&gt;&lt;/blockquote&gt;
+    &lt;table&gt;&lt;/table&gt;
+    &lt;ul&gt;
+      &lt;li&gt;&lt;p id=&quot;target1&quot;&gt;Target 1&lt;/p&gt;&lt;/li&gt;
+    &lt;/ul&gt;
+  &lt;/blockquote&gt;
+
+  &lt;!-- A first block lacks the &lt;p&gt;. --&gt;
+  &lt;div&gt;&lt;/div&gt;
+  &lt;table&gt;&lt;/table&gt;
+  &lt;h1&gt;&lt;/h1&gt;
+  &lt;blockquote&gt;
+    &lt;p&gt;&lt;/p&gt;
+    &lt;div&gt;&lt;/div&gt;
+    &lt;blockquote&gt;&lt;/blockquote&gt;
+    &lt;table&gt;&lt;/table&gt;
+    &lt;div&gt;&lt;/div&gt;
+    &lt;blockquote&gt;&lt;/blockquote&gt;
+    &lt;table&gt;&lt;/table&gt;
+    &lt;ul&gt;
+      &lt;li&gt;&lt;p id=&quot;target2&quot;&gt;Target 2&lt;/p&gt;&lt;/li&gt;
+    &lt;/ul&gt;
+  &lt;/blockquote&gt;
+
+  &lt;!-- A second block lacks the &lt;h1&gt;. --&gt;
+  &lt;div&gt;&lt;/div&gt;
+  &lt;table&gt;&lt;/table&gt;
+  &lt;h1&gt;&lt;/h1&gt;
+  &lt;blockquote&gt;
+    &lt;p&gt;&lt;/p&gt;
+    &lt;div&gt;&lt;/div&gt;
+    &lt;blockquote&gt;&lt;/blockquote&gt;
+    &lt;table&gt;&lt;/table&gt;
+    &lt;ul&gt;
+      &lt;li&gt;
+
+        &lt;h2&gt;&lt;/h2&gt;
+        &lt;blockquote&gt;
+          &lt;p id=&quot;target3&quot;&gt;Target 3&lt;/p&gt;
+          &lt;div&gt;&lt;/div&gt;
+          &lt;blockquote&gt;&lt;/blockquote&gt;
+          &lt;table&gt;&lt;/table&gt;
+          &lt;ul&gt;
+            &lt;li&gt;&lt;p id=&quot;target4&quot;&gt;Target 4&lt;/p&gt;&lt;/li&gt;
+          &lt;/ul&gt;
+        &lt;/blockquote&gt;
+
+      &lt;/li&gt;
+    &lt;/ul&gt;
+  &lt;/blockquote&gt;
+
+  &lt;!-- A second block lacks the &lt;div&gt;. --&gt;
+  &lt;div&gt;&lt;/div&gt;
+  &lt;table&gt;&lt;/table&gt;
+  &lt;h1&gt;&lt;/h1&gt;
+  &lt;blockquote&gt;
+    &lt;p&gt;&lt;/p&gt;
+    &lt;div&gt;&lt;/div&gt;
+    &lt;blockquote&gt;&lt;/blockquote&gt;
+    &lt;table&gt;&lt;/table&gt;
+    &lt;ul&gt;
+      &lt;li&gt;
+
+        &lt;table&gt;&lt;/table&gt;
+        &lt;h1&gt;&lt;/h1&gt;
+        &lt;blockquote&gt;
+          &lt;p id=&quot;target5&quot;&gt;Target 5&lt;/p&gt;
+          &lt;div&gt;&lt;/div&gt;
+          &lt;blockquote&gt;&lt;/blockquote&gt;
+          &lt;table&gt;&lt;/table&gt;
+          &lt;ul&gt;
+            &lt;li&gt;&lt;p id=&quot;target6&quot;&gt;Target 6&lt;/p&gt;&lt;/li&gt;
+          &lt;/ul&gt;
+        &lt;/blockquote&gt;
+
+      &lt;/li&gt;
+    &lt;/ul&gt;
+  &lt;/blockquote&gt;
+
+  &lt;!-- A third block lacks the div. --&gt;
+  &lt;div&gt;&lt;/div&gt;
+  &lt;table&gt;&lt;/table&gt;
+  &lt;h1&gt;&lt;/h1&gt;
+  &lt;blockquote&gt;
+    &lt;p&gt;&lt;/p&gt;
+    &lt;div&gt;&lt;/div&gt;
+    &lt;blockquote&gt;&lt;/blockquote&gt;
+    &lt;table&gt;&lt;/table&gt;
+    &lt;ul&gt;
+      &lt;li&gt;
+
+        &lt;div&gt;&lt;/div&gt;
+        &lt;table&gt;&lt;/table&gt;
+        &lt;h1&gt;&lt;/h1&gt;
+        &lt;blockquote&gt;
+          &lt;p id=&quot;target7&quot;&gt;Target 7&lt;/p&gt;
+          &lt;div&gt;&lt;/div&gt;
+          &lt;blockquote&gt;&lt;/blockquote&gt;
+          &lt;table&gt;&lt;/table&gt;
+          &lt;ul&gt;
+            &lt;li&gt;&lt;p id=&quot;target8&quot;&gt;Target 8&lt;/p&gt;&lt;/li&gt;
+          &lt;/ul&gt;
+        &lt;/blockquote&gt;
+
+      &lt;/li&gt;
+    &lt;/ul&gt;
+  &lt;/blockquote&gt;
+
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+description('Test backtracking of adjacent and child relation mixed together.');
+
+shouldBe('document.querySelectorAll(&quot;html&gt;head+body div&gt;div~h1+blockquote&gt;p+div+blockquote~ul p&quot;).length', '8');
+for (var i = 0; i &lt; document.querySelectorAll(&quot;html&gt;head+body div&gt;div~h1+blockquote&gt;p+div+blockquote~ul p&quot;).length; ++i)
+  shouldBeEqualToString('document.querySelectorAll(&quot;html&gt;head+body div&gt;div~h1+blockquote&gt;p+div+blockquote~ul p&quot;)[' + i +'].id', 'target' + (i + 1));
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsquerySelectormultiplesimplechildbacktrackingexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/querySelector-multiple-simple-child-backtracking-expected.txt (0 => 161839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/querySelector-multiple-simple-child-backtracking-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/querySelector-multiple-simple-child-backtracking-expected.txt        2014-01-12 23:04:19 UTC (rev 161839)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+Test backtracking with multiple chains of child relations.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS document.querySelectorAll(&quot;div&gt;ul&gt;li&gt;div ul&gt;li ul&gt;li p&quot;).length is 1
+PASS document.querySelectorAll(&quot;div&gt;ul&gt;li&gt;div ul&gt;li ul&gt;li p&quot;)[0].id is &quot;target&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsquerySelectormultiplesimplechildbacktrackinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/querySelector-multiple-simple-child-backtracking.html (0 => 161839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/querySelector-multiple-simple-child-backtracking.html                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/querySelector-multiple-simple-child-backtracking.html        2014-01-12 23:04:19 UTC (rev 161839)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div style=&quot;display:none&quot;&gt;
+&lt;div&gt;
+  &lt;ul&gt;
+    &lt;li&gt;
+      &lt;div&gt;
+        &lt;ul&gt;
+          &lt;li&gt;
+            &lt;div&gt;
+              &lt;div&gt;
+                &lt;ul&gt;
+                  &lt;li&gt;
+                    &lt;p id=&quot;target&quot;&gt;&lt;span&gt;Target.&lt;/span&gt;&lt;/p&gt;
+                  &lt;/li&gt;
+                &lt;/ul&gt;
+              &lt;/div&gt;
+            &lt;div&gt;
+          &lt;/li&gt;
+        &lt;/ul&gt;
+      &lt;/div&gt;
+    &lt;/li&gt;
+  &lt;/ul&gt;
+&lt;/div&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+description('Test backtracking with multiple chains of child relations.');
+
+shouldBe('document.querySelectorAll(&quot;div&gt;ul&gt;li&gt;div ul&gt;li ul&gt;li p&quot;).length', '1');
+shouldBeEqualToString('document.querySelectorAll(&quot;div&gt;ul&gt;li&gt;div ul&gt;li ul&gt;li p&quot;)[0].id', 'target');
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsquerySelectorsimpleadjacentbacktrackingexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/querySelector-simple-adjacent-backtracking-expected.txt (0 => 161839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/querySelector-simple-adjacent-backtracking-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/querySelector-simple-adjacent-backtracking-expected.txt        2014-01-12 23:04:19 UTC (rev 161839)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test backtracking with a single direct adjacent relation.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS document.querySelectorAll(&quot;blockquote+li~li&quot;).length is 2
+PASS document.querySelectorAll(&quot;blockquote+li~li&quot;)[0].id is &quot;target1&quot;
+PASS document.querySelectorAll(&quot;blockquote+li~li&quot;)[1].id is &quot;target2&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsquerySelectorsimpleadjacentbacktrackinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/querySelector-simple-adjacent-backtracking.html (0 => 161839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/querySelector-simple-adjacent-backtracking.html                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/querySelector-simple-adjacent-backtracking.html        2014-01-12 23:04:19 UTC (rev 161839)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div style=&quot;display:none&quot;&gt;
+  &lt;ul&gt;
+    &lt;li&gt;&lt;/li&gt;
+    &lt;div&gt;&lt;/div&gt;
+    &lt;li&gt;&lt;/li&gt;
+    &lt;blockquote&gt;&lt;/blockquote&gt;
+    &lt;li&gt;&lt;/li&gt;
+    &lt;li id=target1&gt;Target 1&lt;/li&gt;
+    &lt;li id=target2&gt;Target 2&lt;/li&gt;
+  &lt;/ul&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+description('Test backtracking with a single direct adjacent relation.');
+
+shouldBe('document.querySelectorAll(&quot;blockquote+li~li&quot;).length', '2');
+shouldBeEqualToString('document.querySelectorAll(&quot;blockquote+li~li&quot;)[0].id', 'target1');
+shouldBeEqualToString('document.querySelectorAll(&quot;blockquote+li~li&quot;)[1].id', 'target2');
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsquerySelectorsimplechildbacktrackingexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/querySelector-simple-child-backtracking-expected.txt (0 => 161839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/querySelector-simple-child-backtracking-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/querySelector-simple-child-backtracking-expected.txt        2014-01-12 23:04:19 UTC (rev 161839)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test backtracking with a single child selector relation.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS document.querySelectorAll(&quot;ul&gt;li p&quot;).length is 2
+PASS document.querySelectorAll(&quot;ul&gt;li p&quot;)[0].id is &quot;target1&quot;
+PASS document.querySelectorAll(&quot;ul&gt;li p&quot;)[1].id is &quot;target2&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsquerySelectorsimplechildbacktrackinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/querySelector-simple-child-backtracking.html (0 => 161839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/querySelector-simple-child-backtracking.html                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/querySelector-simple-child-backtracking.html        2014-01-12 23:04:19 UTC (rev 161839)
</span><span class="lines">@@ -0,0 +1,36 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div style=&quot;display:none&quot;&gt;
+  &lt;ul&gt;
+    &lt;li&gt;&lt;/li&gt;
+    &lt;li&gt;
+      &lt;ol&gt;
+        &lt;li&gt;&lt;/li&gt;
+        &lt;li&gt;&lt;p id=&quot;target1&quot;&gt;Target 1&lt;/p&gt;&lt;/li&gt;
+        &lt;li&gt;&lt;/li&gt;
+      &lt;/ol&gt;
+    &lt;/li&gt;
+    &lt;li&gt;&lt;/li&gt;
+  &lt;/ul&gt;
+  &lt;ul&gt;
+    &lt;li&gt;
+      &lt;li&gt;
+        &lt;li&gt;&lt;p  id=&quot;target2&quot;&gt;Target 2&lt;/p&gt;&lt;/li&gt;
+      &lt;/li&gt;
+    &lt;/li&gt;
+  &lt;/ul&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+description('Test backtracking with a single child selector relation.');
+
+shouldBe('document.querySelectorAll(&quot;ul&gt;li p&quot;).length', '2');
+shouldBeEqualToString('document.querySelectorAll(&quot;ul&gt;li p&quot;)[0].id', 'target1');
+shouldBeEqualToString('document.querySelectorAll(&quot;ul&gt;li p&quot;)[1].id', 'target2');
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (161838 => 161839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-01-12 22:07:44 UTC (rev 161838)
+++ trunk/Source/WebCore/ChangeLog        2014-01-12 23:04:19 UTC (rev 161839)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2014-01-12  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
+
+        Use the Selector Code Generator for matching in SelectorQuery
+        https://bugs.webkit.org/show_bug.cgi?id=126185
+
+        Reviewed by Ryosuke Niwa.
+
+        Compile selectors on demand and use the generated binary to perform
+        element matching in SelectorQuery.
+
+        Tests: fast/selectors/querySelector-long-adjacent-backtracking.html
+               fast/selectors/querySelector-long-child-backtracking.html
+               fast/selectors/querySelector-mixed-child-adjacent-backtracking.html
+               fast/selectors/querySelector-multiple-simple-child-backtracking.html
+               fast/selectors/querySelector-simple-adjacent-backtracking.html
+               fast/selectors/querySelector-simple-child-backtracking.html
+
+        * dom/SelectorQuery.cpp:
+        (WebCore::SelectorDataList::executeCompiledSimpleSelectorChecker):
+        (WebCore::SelectorDataList::executeCompiledSelectorCheckerWithContext):
+        (WebCore::SelectorDataList::execute):
+        * dom/SelectorQuery.h:
+
</ins><span class="cx"> 2014-01-12  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Simplify creation of XMLHttpRequestStaticData
</span></span></pre></div>
<a id="trunkSourceWebCorecssjitSelectorCompilerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/cssjit/SelectorCompiler.h (161838 => 161839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/cssjit/SelectorCompiler.h        2014-01-12 22:07:44 UTC (rev 161838)
+++ trunk/Source/WebCore/cssjit/SelectorCompiler.h        2014-01-12 23:04:19 UTC (rev 161839)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if ENABLE(CSS_SELECTOR_JIT)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;SelectorChecker.h&quot;
</span><ins>+#include &lt;JavaScriptCore/MacroAssemblerCodeRef.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> class MacroAssemblerCodeRef;
</span></span></pre></div>
<a id="trunkSourceWebCoredomSelectorQuerycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/SelectorQuery.cpp (161838 => 161839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/SelectorQuery.cpp        2014-01-12 22:07:44 UTC (rev 161838)
+++ trunk/Source/WebCore/dom/SelectorQuery.cpp        2014-01-12 23:04:19 UTC (rev 161839)
</span><span class="lines">@@ -266,7 +266,33 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(CSS_SELECTOR_JIT)
</ins><span class="cx"> template &lt;typename SelectorQueryTrait&gt;
</span><ins>+ALWAYS_INLINE void SelectorDataList::executeCompiledSimpleSelectorChecker(const ContainerNode&amp; rootNode, SelectorCompiler::SimpleSelectorChecker selectorChecker, typename SelectorQueryTrait::OutputType&amp; output) const
+{
+    for (auto&amp; element : elementDescendants(const_cast&lt;ContainerNode&amp;&gt;(rootNode))) {
+        if (selectorChecker(&amp;element)) {
+            SelectorQueryTrait::appendOutputForElement(output, &amp;element);
+            if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
+                return;
+        }
+    }
+}
+
+template &lt;typename SelectorQueryTrait&gt;
+ALWAYS_INLINE void SelectorDataList::executeCompiledSelectorCheckerWithContext(const ContainerNode&amp; rootNode, SelectorCompiler::SelectorCheckerWithCheckingContext selectorChecker, const SelectorCompiler::CheckingContext&amp; context, typename SelectorQueryTrait::OutputType&amp; output) const
+{
+    for (auto&amp; element : elementDescendants(const_cast&lt;ContainerNode&amp;&gt;(rootNode))) {
+        if (selectorChecker(&amp;element, &amp;context)) {
+            SelectorQueryTrait::appendOutputForElement(output, &amp;element);
+            if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
+                return;
+        }
+    }
+}
+#endif // ENABLE(CSS_SELECTOR_JIT)
+
+template &lt;typename SelectorQueryTrait&gt;
</ins><span class="cx"> ALWAYS_INLINE void SelectorDataList::execute(ContainerNode&amp; rootNode, typename SelectorQueryTrait::OutputType&amp; output) const
</span><span class="cx"> {
</span><span class="cx">     if (m_selectors.size() == 1) {
</span><span class="lines">@@ -277,8 +303,33 @@
</span><span class="cx">             executeSingleTagNameSelectorData&lt;SelectorQueryTrait&gt;(rootNode, selectorData, output);
</span><span class="cx">         else if (isSingleClassNameSelector(*selectorData.selector))
</span><span class="cx">             executeSingleClassNameSelectorData&lt;SelectorQueryTrait&gt;(rootNode, selectorData, output);
</span><del>-        else
</del><ins>+        else {
+#if ENABLE(CSS_SELECTOR_JIT)
+            void* compiledSelectorChecker = selectorData.compiledSelectorCodeRef.code().executableAddress();
+            if (!compiledSelectorChecker &amp;&amp; selectorData.compilationStatus == SelectorCompilationStatus::NotCompiled) {
+                JSC::VM* vm = rootNode.document().scriptExecutionContext()-&gt;vm();
+                selectorData.compilationStatus = SelectorCompiler::compileSelector(selectorData.selector, vm, selectorData.compiledSelectorCodeRef);
+            }
+
+            if (compiledSelectorChecker) {
+                if (selectorData.compilationStatus == SelectorCompilationStatus::SimpleSelectorChecker) {
+                    SelectorCompiler::SimpleSelectorChecker selectorChecker = SelectorCompiler::simpleSelectorCheckerFunction(compiledSelectorChecker, selectorData.compilationStatus);
+                    executeCompiledSimpleSelectorChecker&lt;SelectorQueryTrait&gt;(rootNode, selectorChecker, output);
+                } else {
+                    ASSERT(selectorData.compilationStatus == SelectorCompilationStatus::SelectorCheckerWithCheckingContext);
+                    SelectorCompiler::SelectorCheckerWithCheckingContext selectorChecker = SelectorCompiler::selectorCheckerFunctionWithCheckingContext(compiledSelectorChecker, selectorData.compilationStatus);
+
+                    SelectorCompiler::CheckingContext context;
+                    context.elementStyle = nullptr;
+                    context.resolvingMode = SelectorChecker::QueryingRules;
+                    executeCompiledSelectorCheckerWithContext&lt;SelectorQueryTrait&gt;(rootNode, selectorChecker, context, output);
+                }
+                return;
+            }
+#endif // ENABLE(CSS_SELECTOR_JIT)
+
</ins><span class="cx">             executeSingleSelectorData&lt;SelectorQueryTrait&gt;(rootNode, selectorData, output);
</span><ins>+        }
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     executeSingleMultiSelectorData&lt;SelectorQueryTrait&gt;(rootNode, output);
</span></span></pre></div>
<a id="trunkSourceWebCoredomSelectorQueryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/SelectorQuery.h (161838 => 161839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/SelectorQuery.h        2014-01-12 22:07:44 UTC (rev 161838)
+++ trunk/Source/WebCore/dom/SelectorQuery.h        2014-01-12 23:04:19 UTC (rev 161839)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CSSSelectorList.h&quot;
</span><span class="cx"> #include &quot;NodeList.h&quot;
</span><ins>+#include &quot;SelectorCompiler.h&quot;
</ins><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> #include &lt;wtf/text/AtomicStringHash.h&gt;
</span><span class="lines">@@ -55,6 +56,11 @@
</span><span class="cx">         SelectorData(const CSSSelector* selector, bool isFastCheckable) : selector(selector), isFastCheckable(isFastCheckable) { }
</span><span class="cx">         const CSSSelector* selector;
</span><span class="cx">         bool isFastCheckable;
</span><ins>+
+#if ENABLE(CSS_SELECTOR_JIT)
+        mutable SelectorCompilationStatus compilationStatus;
+        mutable JSC::MacroAssemblerCodeRef compiledSelectorCodeRef;
+#endif // ENABLE(CSS_SELECTOR_JIT)
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     bool selectorMatches(const SelectorData&amp;, Element&amp;, const ContainerNode&amp; rootNode) const;
</span><span class="lines">@@ -65,6 +71,10 @@
</span><span class="cx">     template &lt;typename SelectorQueryTrait&gt; void executeSingleClassNameSelectorData(const ContainerNode&amp; rootNode, const SelectorData&amp;, typename SelectorQueryTrait::OutputType&amp;) const;
</span><span class="cx">     template &lt;typename SelectorQueryTrait&gt; void executeSingleSelectorData(const ContainerNode&amp; rootNode, const SelectorData&amp;, typename SelectorQueryTrait::OutputType&amp;) const;
</span><span class="cx">     template &lt;typename SelectorQueryTrait&gt; void executeSingleMultiSelectorData(const ContainerNode&amp; rootNode, typename SelectorQueryTrait::OutputType&amp;) const;
</span><ins>+#if ENABLE(CSS_SELECTOR_JIT)
+    template &lt;typename SelectorQueryTrait&gt; void executeCompiledSimpleSelectorChecker(const ContainerNode&amp; rootNode, SelectorCompiler::SimpleSelectorChecker, typename SelectorQueryTrait::OutputType&amp;) const;
+    template &lt;typename SelectorQueryTrait&gt; void executeCompiledSelectorCheckerWithContext(const ContainerNode&amp; rootNode, SelectorCompiler::SelectorCheckerWithCheckingContext, const SelectorCompiler::CheckingContext&amp;, typename SelectorQueryTrait::OutputType&amp;) const;
+#endif // ENABLE(CSS_SELECTOR_JIT)
</ins><span class="cx"> 
</span><span class="cx">     Vector&lt;SelectorData&gt; m_selectors;
</span><span class="cx"> };
</span></span></pre>
</div>
</div>

</body>
</html>