<!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>[172619] 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/172619">172619</a></dd>
<dt>Author</dt> <dd>benjamin@webkit.org</dd>
<dt>Date</dt> <dd>2014-08-14 21:06:27 -0700 (Thu, 14 Aug 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>CSS JIT: compile the :empty pseudo class
https://bugs.webkit.org/show_bug.cgi?id=135958
Reviewed by Andreas Kling.
Source/WebCore:
Compile :empty, nothing fancy.
Tests: fast/selectors/empty-basics.html
fast/selectors/empty-long-adjacent-backtracking.html
fast/selectors/empty-adjacent-style-update.html
fast/selectors/empty-style-update.html
* cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::addPseudoClassType):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementMatching):
(WebCore::SelectorCompiler::jumpIfElementIsNotEmpty):
(WebCore::SelectorCompiler::setElementStyleIsAffectedByEmpty):
(WebCore::SelectorCompiler::setElementStyleFromContextIsAffectedByEmptyAndUpdateRenderStyleIfNecessary):
(WebCore::SelectorCompiler::setElementStyleIsAffectedByEmptyAndUpdateRenderStyleIfNecessary):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsEmpty):
* dom/CharacterData.h:
(WebCore::CharacterData::dataMemoryOffset):
* dom/ContainerNode.h:
(WebCore::ContainerNode::firstChildMemoryOffset):
* dom/Node.h:
(WebCore::Node::flagIsText):
Source/WTF:
* wtf/text/StringImpl.h:
(WTF::StringImpl::lengthMemoryOffset):
LayoutTests:
Add some test coverage, :empty had very little testing.
The test empty-adjacent-style-update expose some problems with style update,
I will look into them separately.
* fast/selectors/empty-adjacent-style-update-expected.txt: Added.
* fast/selectors/empty-adjacent-style-update.html: Added.
* fast/selectors/empty-basics-expected.txt: Added.
* fast/selectors/empty-basics.html: Added.
* fast/selectors/empty-long-adjacent-backtracking-expected.txt: Added.
* fast/selectors/empty-long-adjacent-backtracking.html: Added.
* fast/selectors/empty-style-update-expected.txt: Added.
* fast/selectors/empty-style-update.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtftextStringImplh">trunk/Source/WTF/wtf/text/StringImpl.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssjitSelectorCompilercpp">trunk/Source/WebCore/cssjit/SelectorCompiler.cpp</a></li>
<li><a href="#trunkSourceWebCoredomCharacterDatah">trunk/Source/WebCore/dom/CharacterData.h</a></li>
<li><a href="#trunkSourceWebCoredomContainerNodeh">trunk/Source/WebCore/dom/ContainerNode.h</a></li>
<li><a href="#trunkSourceWebCoredomNodeh">trunk/Source/WebCore/dom/Node.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastselectorsemptyadjacentstyleupdateexpectedtxt">trunk/LayoutTests/fast/selectors/empty-adjacent-style-update-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsemptyadjacentstyleupdatehtml">trunk/LayoutTests/fast/selectors/empty-adjacent-style-update.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorsemptybasicsexpectedtxt">trunk/LayoutTests/fast/selectors/empty-basics-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsemptybasicshtml">trunk/LayoutTests/fast/selectors/empty-basics.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorsemptylongadjacentbacktrackingexpectedtxt">trunk/LayoutTests/fast/selectors/empty-long-adjacent-backtracking-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsemptylongadjacentbacktrackinghtml">trunk/LayoutTests/fast/selectors/empty-long-adjacent-backtracking.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorsemptystyleupdateexpectedtxt">trunk/LayoutTests/fast/selectors/empty-style-update-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorsemptystyleupdatehtml">trunk/LayoutTests/fast/selectors/empty-style-update.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (172618 => 172619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-08-15 03:22:01 UTC (rev 172618)
+++ trunk/LayoutTests/ChangeLog        2014-08-15 04:06:27 UTC (rev 172619)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2014-08-14 Benjamin Poulain <benjamin@webkit.org>
+
+ CSS JIT: compile the :empty pseudo class
+ https://bugs.webkit.org/show_bug.cgi?id=135958
+
+ Reviewed by Andreas Kling.
+
+ Add some test coverage, :empty had very little testing.
+
+ The test empty-adjacent-style-update expose some problems with style update,
+ I will look into them separately.
+
+ * fast/selectors/empty-adjacent-style-update-expected.txt: Added.
+ * fast/selectors/empty-adjacent-style-update.html: Added.
+ * fast/selectors/empty-basics-expected.txt: Added.
+ * fast/selectors/empty-basics.html: Added.
+ * fast/selectors/empty-long-adjacent-backtracking-expected.txt: Added.
+ * fast/selectors/empty-long-adjacent-backtracking.html: Added.
+ * fast/selectors/empty-style-update-expected.txt: Added.
+ * fast/selectors/empty-style-update.html: Added.
+
</ins><span class="cx"> 2014-08-14 Martin Hock <mhock@apple.com>
</span><span class="cx">
</span><span class="cx"> IndexedDB should respect SchemeRegistry's database access setting.
</span></span></pre></div>
<a id="trunkLayoutTestsfastselectorsemptyadjacentstyleupdateexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/empty-adjacent-style-update-expected.txt (0 => 172619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/empty-adjacent-style-update-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/selectors/empty-adjacent-style-update-expected.txt        2014-08-15 04:06:27 UTC (rev 172619)
</span><span class="lines">@@ -0,0 +1,30 @@
</span><ins>+Test the style with a :empty pseudo class used for a sibling of the styled element.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Initial state is emtpy.
+PASS getComputedStyle(document.getElementById("target-with-renderer")).backgroundColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.getElementById("target-without-renderer")).backgroundColor is "rgb(1, 2, 3)"
+Adding a comment does not change the :empty state.
+PASS getComputedStyle(document.getElementById("target-with-renderer")).backgroundColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.getElementById("target-without-renderer")).backgroundColor is "rgb(1, 2, 3)"
+Add an element as child make updates :empty.
+FAIL getComputedStyle(document.getElementById("target-with-renderer")).backgroundColor should be rgb(255, 255, 255). Was rgb(1, 2, 3).
+FAIL getComputedStyle(document.getElementById("target-without-renderer")).backgroundColor should be rgb(255, 255, 255). Was rgb(1, 2, 3).
+Adding an empty text node, this is still not empty because of the element.
+FAIL getComputedStyle(document.getElementById("target-with-renderer")).backgroundColor should be rgb(255, 255, 255). Was rgb(1, 2, 3).
+FAIL getComputedStyle(document.getElementById("target-without-renderer")).backgroundColor should be rgb(255, 255, 255). Was rgb(1, 2, 3).
+Removing the elements previously added should restore the :empty state.
+PASS getComputedStyle(document.getElementById("target-with-renderer")).backgroundColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.getElementById("target-without-renderer")).backgroundColor is "rgb(1, 2, 3)"
+Adding a non empty text node makes the state non empty.
+FAIL getComputedStyle(document.getElementById("target-with-renderer")).backgroundColor should be rgb(255, 255, 255). Was rgb(1, 2, 3).
+FAIL getComputedStyle(document.getElementById("target-without-renderer")).backgroundColor should be rgb(255, 255, 255). Was rgb(1, 2, 3).
+Removing the last text child, back to being empty.
+PASS getComputedStyle(document.getElementById("target-with-renderer")).backgroundColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.getElementById("target-without-renderer")).backgroundColor is "rgb(1, 2, 3)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsemptyadjacentstyleupdatehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/empty-adjacent-style-update.html (0 => 172619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/empty-adjacent-style-update.html         (rev 0)
+++ trunk/LayoutTests/fast/selectors/empty-adjacent-style-update.html        2014-08-15 04:06:27 UTC (rev 172619)
</span><span class="lines">@@ -0,0 +1,73 @@
</span><ins>+<!doctype html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<style>
+target {
+ background-color: white;
+}
+testcase:empty+target {
+ background-color: rgb(1, 2, 3);
+}
+</style>
+</head>
+<body>
+ <div>
+ <testcase id="with-renderer"></testcase>
+ <target id="target-with-renderer"></target>
+ </div>
+ <div style="display:none;">
+ <testcase id="without-renderer"></testcase>
+ <target id="target-without-renderer"></target>
+ </div>
+</body>
+<script>
+description('Test the style with a :empty pseudo class used for a sibling of the styled element.');
+
+var testCaseWithRender = document.getElementById("with-renderer");
+var testCaseWithoutRenderer = document.getElementById("without-renderer");
+
+debug("Initial state is emtpy.");
+shouldBeEqualToString('getComputedStyle(document.getElementById("target-with-renderer")).backgroundColor', 'rgb(1, 2, 3)');
+shouldBeEqualToString('getComputedStyle(document.getElementById("target-without-renderer")).backgroundColor', 'rgb(1, 2, 3)');
+
+debug("Adding a comment does not change the :empty state.");
+testCaseWithRender.appendChild(document.createComment("WebKit!"));
+testCaseWithoutRenderer.appendChild(document.createComment("WebKit!"));
+shouldBeEqualToString('getComputedStyle(document.getElementById("target-with-renderer")).backgroundColor', 'rgb(1, 2, 3)');
+shouldBeEqualToString('getComputedStyle(document.getElementById("target-without-renderer")).backgroundColor', 'rgb(1, 2, 3)');
+
+debug("Add an element as child make updates :empty.");
+var elementForCaseWithRenderer = document.createElement('div');
+var elementForCaseWithoutRenderer = document.createElement('div');
+testCaseWithRender.appendChild(elementForCaseWithRenderer);
+testCaseWithoutRenderer.appendChild(elementForCaseWithoutRenderer);
+shouldBeEqualToString('getComputedStyle(document.getElementById("target-with-renderer")).backgroundColor', 'rgb(255, 255, 255)');
+shouldBeEqualToString('getComputedStyle(document.getElementById("target-without-renderer")).backgroundColor', 'rgb(255, 255, 255)');
+
+debug("Adding an empty text node, this is still not empty because of the element.");
+testCaseWithRender.appendChild(document.createTextNode(''));
+testCaseWithoutRenderer.appendChild(document.createTextNode(''));
+shouldBeEqualToString('getComputedStyle(document.getElementById("target-with-renderer")).backgroundColor', 'rgb(255, 255, 255)');
+shouldBeEqualToString('getComputedStyle(document.getElementById("target-without-renderer")).backgroundColor', 'rgb(255, 255, 255)');
+
+debug("Removing the elements previously added should restore the :empty state.");
+testCaseWithRender.removeChild(elementForCaseWithRenderer);
+testCaseWithoutRenderer.removeChild(elementForCaseWithoutRenderer);
+shouldBeEqualToString('getComputedStyle(document.getElementById("target-with-renderer")).backgroundColor', 'rgb(1, 2, 3)');
+shouldBeEqualToString('getComputedStyle(document.getElementById("target-without-renderer")).backgroundColor', 'rgb(1, 2, 3)');
+
+debug("Adding a non empty text node makes the state non empty.");
+testCaseWithRender.appendChild(document.createTextNode('WebKit!'));
+testCaseWithoutRenderer.appendChild(document.createTextNode('WebKit!'));
+shouldBeEqualToString('getComputedStyle(document.getElementById("target-with-renderer")).backgroundColor', 'rgb(255, 255, 255)');
+shouldBeEqualToString('getComputedStyle(document.getElementById("target-without-renderer")).backgroundColor', 'rgb(255, 255, 255)');
+
+debug("Removing the last text child, back to being empty.");
+testCaseWithRender.removeChild(testCaseWithRender.lastChild);
+testCaseWithoutRenderer.removeChild(testCaseWithoutRenderer.lastChild);
+shouldBeEqualToString('getComputedStyle(document.getElementById("target-with-renderer")).backgroundColor', 'rgb(1, 2, 3)');
+shouldBeEqualToString('getComputedStyle(document.getElementById("target-without-renderer")).backgroundColor', 'rgb(1, 2, 3)');
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsemptybasicsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/empty-basics-expected.txt (0 => 172619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/empty-basics-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/selectors/empty-basics-expected.txt        2014-08-15 04:06:27 UTC (rev 172619)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+Check the basic features of the ":empty" pseudo class.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.querySelectorAll("testcase:empty").length is 4
+PASS document.querySelectorAll("testcase:empty")[0] is document.getElementById("no-content")
+PASS document.querySelectorAll("testcase:empty")[1] is document.getElementById("comment")
+PASS document.querySelectorAll("testcase:empty")[2] is document.getElementById("empty-textnodes")
+PASS document.querySelectorAll("testcase:empty")[3] is document.getElementById("comments-and-empty-textnodes")
+PASS getComputedStyle(document.getElementById("no-content")).backgroundColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.getElementById("comment")).backgroundColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.getElementById("empty-textnodes")).backgroundColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.getElementById("comments-and-empty-textnodes")).backgroundColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.getElementById("space-character")).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.getElementById("element")).backgroundColor is "rgb(255, 255, 255)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsemptybasicshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/empty-basics.html (0 => 172619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/empty-basics.html         (rev 0)
+++ trunk/LayoutTests/fast/selectors/empty-basics.html        2014-08-15 04:06:27 UTC (rev 172619)
</span><span class="lines">@@ -0,0 +1,63 @@
</span><ins>+<!doctype html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<style>
+testcase {
+ background-color: white;
+}
+testcase:empty {
+ background-color: rgb(1, 2, 3);
+}
+</style>
+</head>
+<body>
+ <div style="display:none">
+ <!-- Success: No content -->
+ <testcase id="no-content"></testcase>
+
+ <!-- Success: Comments are not elment -->
+ <testcase id="comment"><!-- empty --></testcase>
+
+ <!-- Success: Empty text node are okay. -->
+ <testcase id="empty-textnodes"></testcase>
+
+ <!-- Success: The two above. -->
+ <testcase id="comments-and-empty-textnodes"></testcase>
+
+ <!-- Failure: Non empty text node, there is a space character. -->
+ <testcase id="space-character"> </testcase>
+
+ <!-- Failure: the <span> element inside makes the node non-empty. -->
+ <testcase id="element"><span></span></testcase>
+ </div>
+</body>
+<script>
+description('Check the basic features of the ":empty" pseudo class.');
+
+var emptyTextnodes = document.getElementById("empty-textnodes");
+for (var i = 0; i < 10; ++i)
+ emptyTextnodes.appendChild(document.createTextNode(""));
+
+var commentsAndEmptyTextnodes = document.getElementById("comments-and-empty-textnodes");
+for (var i = 0; i < 10; ++i) {
+ commentsAndEmptyTextnodes.appendChild(document.createTextNode(""));
+ commentsAndEmptyTextnodes.appendChild(document.createComment("WebKit!"));
+}
+
+shouldBe('document.querySelectorAll("testcase:empty").length', '4');
+shouldBe('document.querySelectorAll("testcase:empty")[0]', 'document.getElementById("no-content")');
+shouldBe('document.querySelectorAll("testcase:empty")[1]', 'document.getElementById("comment")');
+shouldBe('document.querySelectorAll("testcase:empty")[2]', 'document.getElementById("empty-textnodes")');
+shouldBe('document.querySelectorAll("testcase:empty")[3]', 'document.getElementById("comments-and-empty-textnodes")');
+
+shouldBeEqualToString('getComputedStyle(document.getElementById("no-content")).backgroundColor', 'rgb(1, 2, 3)');
+shouldBeEqualToString('getComputedStyle(document.getElementById("comment")).backgroundColor', 'rgb(1, 2, 3)');
+shouldBeEqualToString('getComputedStyle(document.getElementById("empty-textnodes")).backgroundColor', 'rgb(1, 2, 3)');
+shouldBeEqualToString('getComputedStyle(document.getElementById("comments-and-empty-textnodes")).backgroundColor', 'rgb(1, 2, 3)');
+shouldBeEqualToString('getComputedStyle(document.getElementById("space-character")).backgroundColor', 'rgb(255, 255, 255)');
+shouldBeEqualToString('getComputedStyle(document.getElementById("element")).backgroundColor', 'rgb(255, 255, 255)');
+
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsemptylongadjacentbacktrackingexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/empty-long-adjacent-backtracking-expected.txt (0 => 172619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/empty-long-adjacent-backtracking-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/selectors/empty-long-adjacent-backtracking-expected.txt        2014-08-15 04:06:27 UTC (rev 172619)
</span><span class="lines">@@ -0,0 +1,77 @@
</span><ins>+Test backtracking of a long chain of :empty siblings to catch any issue with register allocation.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.querySelectorAll(":empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty~:not(:empty)").length is 3
+PASS document.querySelectorAll(":empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty~:not(:empty)")[0] is document.getElementById("target1")
+PASS document.querySelectorAll(":empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty~:not(:empty)")[1] is document.getElementById("target2")
+PASS document.querySelectorAll(":empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty~:not(:empty)")[2] is document.getElementById("target3")
+PASS document.querySelectorAll(":empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty~:not(:empty)>target-child").length is 1
+PASS document.querySelectorAll(":empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty~:not(:empty)>target-child")[0] is document.getElementById("target4")
+PASS document.querySelectorAll("testcase").length is 61
+PASS getComputedStyle(document.querySelectorAll("testcase")[0]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[1]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[2]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[3]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[4]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[5]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[6]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[7]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[8]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[9]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[10]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[11]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[12]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[13]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[14]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[15]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[16]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[17]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[18]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[19]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[20]).backgroundColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[21]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[22]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[23]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[24]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[25]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[26]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[27]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[28]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[29]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[30]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[31]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[32]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[33]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[34]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[35]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[36]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[37]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[38]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[39]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[40]).backgroundColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[41]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[42]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[43]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[44]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[45]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[46]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[47]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[48]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[49]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[50]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[51]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[52]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[53]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[54]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[55]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[56]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[57]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[58]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[59]).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.querySelectorAll("testcase")[60]).backgroundColor is "rgb(1, 2, 3)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsemptylongadjacentbacktrackinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/empty-long-adjacent-backtracking.html (0 => 172619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/empty-long-adjacent-backtracking.html         (rev 0)
+++ trunk/LayoutTests/fast/selectors/empty-long-adjacent-backtracking.html        2014-08-15 04:06:27 UTC (rev 172619)
</span><span class="lines">@@ -0,0 +1,109 @@
</span><ins>+<!doctype html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<style>
+testcase {
+ background-color: white;
+}
+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty~:not(:empty) {
+ background-color: rgb(1, 2, 3);
+}
+</style>
+</head>
+<body>
+ <div style="display:none">
+ <!-- 20 empty -->
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+
+ <testcase id=target1><foobar></foobar></testcase>
+
+ <!-- 19 empty -->
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+
+ <testcase id=target2>Not Empty!</testcase>
+
+ <!-- 19 empty -->
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+ <testcase class=empty></testcase>
+
+ <testcase id="target3">
+ <target-child id="target4"></target-child>
+ </testcase>
+ </div>
+</body>
+<script>
+description('Test backtracking of a long chain of :empty siblings to catch any issue with register allocation.');
+
+shouldBe('document.querySelectorAll(":empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty~:not(:empty)").length', '3');
+shouldBe('document.querySelectorAll(":empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty~:not(:empty)")[0]', 'document.getElementById("target1")');
+shouldBe('document.querySelectorAll(":empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty~:not(:empty)")[1]', 'document.getElementById("target2")');
+shouldBe('document.querySelectorAll(":empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty~:not(:empty)")[2]', 'document.getElementById("target3")');
+
+shouldBe('document.querySelectorAll(":empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty~:not(:empty)>target-child").length', '1');
+shouldBe('document.querySelectorAll(":empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty+:empty~:not(:empty)>target-child")[0]', 'document.getElementById("target4")');
+
+shouldBe('document.querySelectorAll("testcase").length', '61')
+
+var allTestCases = document.querySelectorAll("testcase");
+for (var i = 0; i < 61; ++i)
+ shouldBeEqualToString('getComputedStyle(document.querySelectorAll("testcase")[' + i + ']).backgroundColor', allTestCases[i].classList.contains('empty') ? 'rgb(255, 255, 255)' : 'rgb(1, 2, 3)');
+
+
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsemptystyleupdateexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/empty-style-update-expected.txt (0 => 172619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/empty-style-update-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/selectors/empty-style-update-expected.txt        2014-08-15 04:06:27 UTC (rev 172619)
</span><span class="lines">@@ -0,0 +1,30 @@
</span><ins>+Test the style update with the :empty pseudo class.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Initial state is emtpy.
+PASS getComputedStyle(document.getElementById("with-renderer")).backgroundColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.getElementById("without-renderer")).backgroundColor is "rgb(1, 2, 3)"
+Adding a comment does not change the :empty state.
+PASS getComputedStyle(document.getElementById("with-renderer")).backgroundColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.getElementById("without-renderer")).backgroundColor is "rgb(1, 2, 3)"
+Add an element as child make updates :empty.
+PASS getComputedStyle(document.getElementById("with-renderer")).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.getElementById("without-renderer")).backgroundColor is "rgb(255, 255, 255)"
+Adding an empty text node, this is still not empty because of the element.
+PASS getComputedStyle(document.getElementById("with-renderer")).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.getElementById("without-renderer")).backgroundColor is "rgb(255, 255, 255)"
+Removing the elements previously added should restore the :empty state.
+PASS getComputedStyle(document.getElementById("with-renderer")).backgroundColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.getElementById("without-renderer")).backgroundColor is "rgb(1, 2, 3)"
+Adding a non empty text node makes the state non empty.
+PASS getComputedStyle(document.getElementById("with-renderer")).backgroundColor is "rgb(255, 255, 255)"
+PASS getComputedStyle(document.getElementById("without-renderer")).backgroundColor is "rgb(255, 255, 255)"
+Removing the last text child, back to being empty.
+PASS getComputedStyle(document.getElementById("with-renderer")).backgroundColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.getElementById("without-renderer")).backgroundColor is "rgb(1, 2, 3)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorsemptystyleupdatehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/empty-style-update.html (0 => 172619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/empty-style-update.html         (rev 0)
+++ trunk/LayoutTests/fast/selectors/empty-style-update.html        2014-08-15 04:06:27 UTC (rev 172619)
</span><span class="lines">@@ -0,0 +1,71 @@
</span><ins>+<!doctype html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<style>
+testcase {
+ background-color: white;
+}
+testcase:empty {
+ background-color: rgb(1, 2, 3);
+}
+</style>
+</head>
+<body>
+ <div>
+ <testcase id="with-renderer"></testcase>
+ </div>
+ <div style="display:none;">
+ <testcase id="without-renderer"></testcase>
+ </div>
+</body>
+<script>
+description('Test the style update with the :empty pseudo class.');
+
+var testCaseWithRender = document.getElementById("with-renderer");
+var testCaseWithoutRenderer = document.getElementById("without-renderer");
+
+debug("Initial state is emtpy.");
+shouldBeEqualToString('getComputedStyle(document.getElementById("with-renderer")).backgroundColor', 'rgb(1, 2, 3)');
+shouldBeEqualToString('getComputedStyle(document.getElementById("without-renderer")).backgroundColor', 'rgb(1, 2, 3)');
+
+debug("Adding a comment does not change the :empty state.");
+testCaseWithRender.appendChild(document.createComment("WebKit!"));
+testCaseWithoutRenderer.appendChild(document.createComment("WebKit!"));
+shouldBeEqualToString('getComputedStyle(document.getElementById("with-renderer")).backgroundColor', 'rgb(1, 2, 3)');
+shouldBeEqualToString('getComputedStyle(document.getElementById("without-renderer")).backgroundColor', 'rgb(1, 2, 3)');
+
+debug("Add an element as child make updates :empty.");
+var elementForCaseWithRenderer = document.createElement('div');
+var elementForCaseWithoutRenderer = document.createElement('div');
+testCaseWithRender.appendChild(elementForCaseWithRenderer);
+testCaseWithoutRenderer.appendChild(elementForCaseWithoutRenderer);
+shouldBeEqualToString('getComputedStyle(document.getElementById("with-renderer")).backgroundColor', 'rgb(255, 255, 255)');
+shouldBeEqualToString('getComputedStyle(document.getElementById("without-renderer")).backgroundColor', 'rgb(255, 255, 255)');
+
+debug("Adding an empty text node, this is still not empty because of the element.");
+testCaseWithRender.appendChild(document.createTextNode(''));
+testCaseWithoutRenderer.appendChild(document.createTextNode(''));
+shouldBeEqualToString('getComputedStyle(document.getElementById("with-renderer")).backgroundColor', 'rgb(255, 255, 255)');
+shouldBeEqualToString('getComputedStyle(document.getElementById("without-renderer")).backgroundColor', 'rgb(255, 255, 255)');
+
+debug("Removing the elements previously added should restore the :empty state.");
+testCaseWithRender.removeChild(elementForCaseWithRenderer);
+testCaseWithoutRenderer.removeChild(elementForCaseWithoutRenderer);
+shouldBeEqualToString('getComputedStyle(document.getElementById("with-renderer")).backgroundColor', 'rgb(1, 2, 3)');
+shouldBeEqualToString('getComputedStyle(document.getElementById("without-renderer")).backgroundColor', 'rgb(1, 2, 3)');
+
+debug("Adding a non empty text node makes the state non empty.");
+testCaseWithRender.appendChild(document.createTextNode('WebKit!'));
+testCaseWithoutRenderer.appendChild(document.createTextNode('WebKit!'));
+shouldBeEqualToString('getComputedStyle(document.getElementById("with-renderer")).backgroundColor', 'rgb(255, 255, 255)');
+shouldBeEqualToString('getComputedStyle(document.getElementById("without-renderer")).backgroundColor', 'rgb(255, 255, 255)');
+
+debug("Removing the last text child, back to being empty.");
+testCaseWithRender.removeChild(testCaseWithRender.lastChild);
+testCaseWithoutRenderer.removeChild(testCaseWithoutRenderer.lastChild);
+shouldBeEqualToString('getComputedStyle(document.getElementById("with-renderer")).backgroundColor', 'rgb(1, 2, 3)');
+shouldBeEqualToString('getComputedStyle(document.getElementById("without-renderer")).backgroundColor', 'rgb(1, 2, 3)');
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (172618 => 172619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2014-08-15 03:22:01 UTC (rev 172618)
+++ trunk/Source/WTF/ChangeLog        2014-08-15 04:06:27 UTC (rev 172619)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2014-08-14 Benjamin Poulain <benjamin@webkit.org>
+
+ CSS JIT: compile the :empty pseudo class
+ https://bugs.webkit.org/show_bug.cgi?id=135958
+
+ Reviewed by Andreas Kling.
+
+ * wtf/text/StringImpl.h:
+ (WTF::StringImpl::lengthMemoryOffset):
+
</ins><span class="cx"> 2014-08-12 Myles C. Maxfield <mmaxfield@apple.com>
</span><span class="cx">
</span><span class="cx"> Elements whose contents start with an astral Unicode symbol disappear when CSS `::first-letter` is applied to them
</span></span></pre></div>
<a id="trunkSourceWTFwtftextStringImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/StringImpl.h (172618 => 172619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/StringImpl.h        2014-08-15 03:22:01 UTC (rev 172618)
+++ trunk/Source/WTF/wtf/text/StringImpl.h        2014-08-15 04:06:27 UTC (rev 172619)
</span><span class="lines">@@ -412,6 +412,7 @@
</span><span class="cx"> WTF_EXPORT_STRING_API static PassRef<StringImpl> adopt(StringBuffer<LChar>&);
</span><span class="cx">
</span><span class="cx"> unsigned length() const { return m_length; }
</span><ins>+ static ptrdiff_t lengthMemoryOffset() { return OBJECT_OFFSETOF(StringImpl, m_length); }
</ins><span class="cx"> bool is8Bit() const { return m_hashAndFlags & s_hashFlag8BitBuffer; }
</span><span class="cx">
</span><span class="cx"> ALWAYS_INLINE const LChar* characters8() const { ASSERT(is8Bit()); return m_data8; }
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (172618 => 172619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-08-15 03:22:01 UTC (rev 172618)
+++ trunk/Source/WebCore/ChangeLog        2014-08-15 04:06:27 UTC (rev 172619)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2014-08-14 Benjamin Poulain <benjamin@webkit.org>
+
+ CSS JIT: compile the :empty pseudo class
+ https://bugs.webkit.org/show_bug.cgi?id=135958
+
+ Reviewed by Andreas Kling.
+
+ Compile :empty, nothing fancy.
+
+ Tests: fast/selectors/empty-basics.html
+ fast/selectors/empty-long-adjacent-backtracking.html
+ fast/selectors/empty-adjacent-style-update.html
+ fast/selectors/empty-style-update.html
+
+ * cssjit/SelectorCompiler.cpp:
+ (WebCore::SelectorCompiler::addPseudoClassType):
+ (WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementMatching):
+ (WebCore::SelectorCompiler::jumpIfElementIsNotEmpty):
+ (WebCore::SelectorCompiler::setElementStyleIsAffectedByEmpty):
+ (WebCore::SelectorCompiler::setElementStyleFromContextIsAffectedByEmptyAndUpdateRenderStyleIfNecessary):
+ (WebCore::SelectorCompiler::setElementStyleIsAffectedByEmptyAndUpdateRenderStyleIfNecessary):
+ (WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsEmpty):
+ * dom/CharacterData.h:
+ (WebCore::CharacterData::dataMemoryOffset):
+ * dom/ContainerNode.h:
+ (WebCore::ContainerNode::firstChildMemoryOffset):
+ * dom/Node.h:
+ (WebCore::Node::flagIsText):
+
</ins><span class="cx"> 2014-08-14 Wenson Hsieh <wenson_hsieh@apple.com>
</span><span class="cx">
</span><span class="cx"> Implement scroll snapping animations on Mac
</span></span></pre></div>
<a id="trunkSourceWebCorecssjitSelectorCompilercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/cssjit/SelectorCompiler.cpp (172618 => 172619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/cssjit/SelectorCompiler.cpp        2014-08-15 03:22:01 UTC (rev 172618)
+++ trunk/Source/WebCore/cssjit/SelectorCompiler.cpp        2014-08-15 04:06:27 UTC (rev 172619)
</span><span class="lines">@@ -238,6 +238,7 @@
</span><span class="cx"> void generateElementFunctionCallTest(Assembler::JumpList& failureCases, JSC::FunctionPtr);
</span><span class="cx"> void generateContextFunctionCallTest(Assembler::JumpList& failureCases, JSC::FunctionPtr);
</span><span class="cx"> void generateElementIsActive(Assembler::JumpList& failureCases, const SelectorFragment&);
</span><ins>+ void generateElementIsEmpty(Assembler::JumpList& failureCases, const SelectorFragment&);
</ins><span class="cx"> void generateElementIsFirstChild(Assembler::JumpList& failureCases, const SelectorFragment&);
</span><span class="cx"> void generateElementIsHovered(Assembler::JumpList& failureCases, const SelectorFragment&);
</span><span class="cx"> void generateElementIsInLanguage(Assembler::JumpList& failureCases, const AtomicString&);
</span><span class="lines">@@ -497,7 +498,6 @@
</span><span class="cx"> return FunctionType::CannotMatchAnything;
</span><span class="cx">
</span><span class="cx"> // FIXME: Compile these pseudoclasses, too!
</span><del>- case CSSSelector::PseudoClassEmpty:
</del><span class="cx"> case CSSSelector::PseudoClassFirstOfType:
</span><span class="cx"> case CSSSelector::PseudoClassLastOfType:
</span><span class="cx"> case CSSSelector::PseudoClassOnlyOfType:
</span><span class="lines">@@ -529,6 +529,7 @@
</span><span class="cx"> return FunctionType::SelectorCheckerWithCheckingContext;
</span><span class="cx">
</span><span class="cx"> case CSSSelector::PseudoClassActive:
</span><ins>+ case CSSSelector::PseudoClassEmpty:
</ins><span class="cx"> case CSSSelector::PseudoClassFirstChild:
</span><span class="cx"> case CSSSelector::PseudoClassHover:
</span><span class="cx"> case CSSSelector::PseudoClassLastChild:
</span><span class="lines">@@ -1963,6 +1964,8 @@
</span><span class="cx">
</span><span class="cx"> if (fragment.pseudoClasses.contains(CSSSelector::PseudoClassActive))
</span><span class="cx"> generateElementIsActive(matchingPostTagNameFailureCases, fragment);
</span><ins>+ if (fragment.pseudoClasses.contains(CSSSelector::PseudoClassEmpty))
+ generateElementIsEmpty(matchingPostTagNameFailureCases, fragment);
</ins><span class="cx"> if (fragment.pseudoClasses.contains(CSSSelector::PseudoClassHover))
</span><span class="cx"> generateElementIsHovered(matchingPostTagNameFailureCases, fragment);
</span><span class="cx"> if (fragment.pseudoClasses.contains(CSSSelector::PseudoClassOnlyChild))
</span><span class="lines">@@ -2459,6 +2462,97 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static void jumpIfElementIsNotEmpty(Assembler& assembler, RegisterAllocator& registerAllocator, Assembler::JumpList& notEmptyCases, Assembler::RegisterID element)
+{
+ LocalRegister currentChild(registerAllocator);
+ assembler.loadPtr(Assembler::Address(element, ContainerNode::firstChildMemoryOffset()), currentChild);
+
+ Assembler::Label loopStart(assembler.label());
+ Assembler::Jump noMoreChildren = assembler.branchTestPtr(Assembler::Zero, currentChild);
+
+ notEmptyCases.append(testIsElementFlagOnNode(Assembler::NonZero, assembler, currentChild));
+
+ {
+ Assembler::Jump skipTextNodeCheck = assembler.branchTest32(Assembler::Zero, Assembler::Address(currentChild, Node::nodeFlagsMemoryOffset()), Assembler::TrustedImm32(Node::flagIsText()));
+
+ LocalRegister textStringImpl(registerAllocator);
+ assembler.loadPtr(Assembler::Address(currentChild, CharacterData::dataMemoryOffset()), textStringImpl);
+ notEmptyCases.append(assembler.branchTest32(Assembler::NonZero, Assembler::Address(textStringImpl, StringImpl::lengthMemoryOffset())));
+
+ skipTextNodeCheck.link(&assembler);
+ }
+
+ assembler.loadPtr(Assembler::Address(currentChild, Node::nextSiblingMemoryOffset()), currentChild);
+ assembler.jump().linkTo(loopStart, &assembler);
+
+ noMoreChildren.link(&assembler);
+}
+
+static void setElementStyleIsAffectedByEmpty(Element* element)
+{
+ element->setStyleAffectedByEmpty();
+}
+
+static void setElementStyleFromContextIsAffectedByEmptyAndUpdateRenderStyleIfNecessary(CheckingContext* context, bool isEmpty)
+{
+ ASSERT(context->elementStyle);
+ context->elementStyle->setEmptyState(isEmpty);
+}
+
+static void setElementStyleIsAffectedByEmptyAndUpdateRenderStyleIfNecessary(Element* element, bool isEmpty)
+{
+ element->setStyleAffectedByEmpty();
+
+ if (element->renderStyle() && (element->document().styleSheetCollection().usesSiblingRules() || element->renderStyle()->unique()))
+ element->renderStyle()->setEmptyState(isEmpty);
+}
+
+void SelectorCodeGenerator::generateElementIsEmpty(Assembler::JumpList& failureCases, const SelectorFragment& fragment)
+{
+ if (m_selectorContext == SelectorContext::QuerySelector) {
+ jumpIfElementIsNotEmpty(m_assembler, m_registerAllocator, failureCases, elementAddressRegister);
+ return;
+ }
+
+ LocalRegisterWithPreference isEmptyResults(m_registerAllocator, JSC::GPRInfo::argumentGPR1);
+ m_assembler.move(Assembler::TrustedImm32(0), isEmptyResults);
+
+ Assembler::JumpList notEmpty;
+ jumpIfElementIsNotEmpty(m_assembler, m_registerAllocator, notEmpty, elementAddressRegister);
+ m_assembler.move(Assembler::TrustedImm32(1), isEmptyResults);
+ notEmpty.link(&m_assembler);
+
+ Assembler::Jump skipMarking;
+ if (shouldUseRenderStyleFromCheckingContext(m_selectorContext, fragment)) {
+ {
+ LocalRegister checkingContext(m_registerAllocator);
+ skipMarking = jumpIfNotResolvingStyle(checkingContext);
+
+ FunctionCall functionCall(m_assembler, m_registerAllocator, m_stackAllocator, m_functionCalls);
+ functionCall.setFunctionAddress(setElementStyleFromContextIsAffectedByEmptyAndUpdateRenderStyleIfNecessary);
+ functionCall.setTwoArguments(checkingContext, isEmptyResults);
+ functionCall.call();
+ }
+
+ FunctionCall functionCall(m_assembler, m_registerAllocator, m_stackAllocator, m_functionCalls);
+ functionCall.setFunctionAddress(setElementStyleIsAffectedByEmpty);
+ functionCall.setOneArgument(elementAddressRegister);
+ functionCall.call();
+ } else {
+ {
+ LocalRegister checkingContext(m_registerAllocator);
+ skipMarking = jumpIfNotResolvingStyle(checkingContext);
+ }
+ FunctionCall functionCall(m_assembler, m_registerAllocator, m_stackAllocator, m_functionCalls);
+ functionCall.setFunctionAddress(setElementStyleIsAffectedByEmptyAndUpdateRenderStyleIfNecessary);
+ functionCall.setTwoArguments(elementAddressRegister, isEmptyResults);
+ functionCall.call();
+ }
+ skipMarking.link(&m_assembler);
+
+ failureCases.append(m_assembler.branchTest32(Assembler::Zero, isEmptyResults));
+}
+
</ins><span class="cx"> void SelectorCodeGenerator::generateElementIsFirstChild(Assembler::JumpList& failureCases, const SelectorFragment& fragment)
</span><span class="cx"> {
</span><span class="cx"> if (m_selectorContext == SelectorContext::QuerySelector) {
</span></span></pre></div>
<a id="trunkSourceWebCoredomCharacterDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/CharacterData.h (172618 => 172619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/CharacterData.h        2014-08-15 03:22:01 UTC (rev 172618)
+++ trunk/Source/WebCore/dom/CharacterData.h        2014-08-15 04:06:27 UTC (rev 172619)
</span><span class="lines">@@ -31,6 +31,8 @@
</span><span class="cx"> class CharacterData : public Node {
</span><span class="cx"> public:
</span><span class="cx"> String data() const { return m_data; }
</span><ins>+ static ptrdiff_t dataMemoryOffset() { return OBJECT_OFFSETOF(CharacterData, m_data); }
+
</ins><span class="cx"> void setData(const String&, ExceptionCode&);
</span><span class="cx"> unsigned length() const { return m_data.length(); }
</span><span class="cx"> String substringData(unsigned offset, unsigned count, ExceptionCode&);
</span></span></pre></div>
<a id="trunkSourceWebCoredomContainerNodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ContainerNode.h (172618 => 172619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ContainerNode.h        2014-08-15 03:22:01 UTC (rev 172618)
+++ trunk/Source/WebCore/dom/ContainerNode.h        2014-08-15 04:06:27 UTC (rev 172619)
</span><span class="lines">@@ -84,6 +84,7 @@
</span><span class="cx"> virtual ~ContainerNode();
</span><span class="cx">
</span><span class="cx"> Node* firstChild() const { return m_firstChild; }
</span><ins>+ static ptrdiff_t firstChildMemoryOffset() { return OBJECT_OFFSETOF(ContainerNode, m_firstChild); }
</ins><span class="cx"> Node* lastChild() const { return m_lastChild; }
</span><span class="cx"> bool hasChildNodes() const { return m_firstChild; }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoredomNodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Node.h (172618 => 172619)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Node.h        2014-08-15 03:22:01 UTC (rev 172618)
+++ trunk/Source/WebCore/dom/Node.h        2014-08-15 04:06:27 UTC (rev 172619)
</span><span class="lines">@@ -572,6 +572,7 @@
</span><span class="cx"> #if ENABLE(CSS_SELECTOR_JIT)
</span><span class="cx"> static ptrdiff_t nodeFlagsMemoryOffset() { return OBJECT_OFFSETOF(Node, m_nodeFlags); }
</span><span class="cx"> static ptrdiff_t rareDataMemoryOffset() { return OBJECT_OFFSETOF(Node, m_data.m_rareData); }
</span><ins>+ static int32_t flagIsText() { return IsTextFlag; }
</ins><span class="cx"> static int32_t flagIsElement() { return IsElementFlag; }
</span><span class="cx"> static int32_t flagIsHTML() { return IsHTMLFlag; }
</span><span class="cx"> static int32_t flagIsLink() { return IsLinkFlag; }
</span></span></pre>
</div>
</div>
</body>
</html>