<!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>[177745] 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/177745">177745</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-12-25 23:34:39 -0800 (Thu, 25 Dec 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Source/WebCore:
Allow strings as argument to :lang()
https://bugs.webkit.org/show_bug.cgi?id=139678

Patch by Dhi Aurrahman &lt;diorahman@rockybars.com&gt; on 2014-12-25
Reviewed by Benjamin Poulain.

Allow strings as argument to :lang()[1]. The selector with empty string argument (e.g. :lang(&quot;&quot;))
is handled as never matching.

[1] http://www.w3.org/blog/CSS/2014/12/11/minutes-telecon-231/

Test: fast/css/css-lang-selector-with-string-arguments-text.html
      fast/selectors/lang-extended-filtering-with-string-arguments.html

* css/CSSGrammar.y.in:
* css/SelectorCheckerTestFunctions.h:
(WebCore::matchesLangPseudoClass):

LayoutTests:
Extend :lang() with string arguments
https://bugs.webkit.org/show_bug.cgi?id=139678

Patch by Dhi Aurrahman &lt;diorahman@rockybars.com&gt; on 2014-12-25
Reviewed by Benjamin Poulain.

* fast/css/css-lang-selector-with-string-arguments-text-expected.txt: Added.
* fast/css/css-lang-selector-with-string-arguments-text.html: Added.
* fast/selectors/lang-extended-filtering-with-string-arguments-expected.txt: Added.
* fast/selectors/lang-extended-filtering-with-string-arguments.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="#trunkSourceWebCorecssCSSGrammaryin">trunk/Source/WebCore/css/CSSGrammar.y.in</a></li>
<li><a href="#trunkSourceWebCorecssSelectorCheckerTestFunctionsh">trunk/Source/WebCore/css/SelectorCheckerTestFunctions.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastcsscsslangselectorwithstringargumentstextexpectedtxt">trunk/LayoutTests/fast/css/css-lang-selector-with-string-arguments-text-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcsscsslangselectorwithstringargumentstexthtml">trunk/LayoutTests/fast/css/css-lang-selector-with-string-arguments-text.html</a></li>
<li><a href="#trunkLayoutTestsfastselectorslangextendedfilteringwithstringargumentsexpectedtxt">trunk/LayoutTests/fast/selectors/lang-extended-filtering-with-string-arguments-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastselectorslangextendedfilteringwithstringargumentshtml">trunk/LayoutTests/fast/selectors/lang-extended-filtering-with-string-arguments.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (177744 => 177745)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-12-26 04:23:28 UTC (rev 177744)
+++ trunk/LayoutTests/ChangeLog        2014-12-26 07:34:39 UTC (rev 177745)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-12-25  Dhi Aurrahman  &lt;diorahman@rockybars.com&gt;
+
+        Extend :lang() with string arguments
+        https://bugs.webkit.org/show_bug.cgi?id=139678
+
+        Reviewed by Benjamin Poulain.
+
+        * fast/css/css-lang-selector-with-string-arguments-text-expected.txt: Added.
+        * fast/css/css-lang-selector-with-string-arguments-text.html: Added.
+        * fast/selectors/lang-extended-filtering-with-string-arguments-expected.txt: Added.
+        * fast/selectors/lang-extended-filtering-with-string-arguments.html: Added.
+
</ins><span class="cx"> 2014-12-24  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Import the tests for :valid/:invalid on form/fieldset from blink
</span></span></pre></div>
<a id="trunkLayoutTestsfastcsscsslangselectorwithstringargumentstextexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/css-lang-selector-with-string-arguments-text-expected.txt (0 => 177745)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/css-lang-selector-with-string-arguments-text-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/css/css-lang-selector-with-string-arguments-text-expected.txt        2014-12-26 07:34:39 UTC (rev 177745)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+This tests parsing and re-serialization of :lang CSS selector with string arguments
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS parseThenSerializeRule(':lang(&quot;a&quot;) { }') is ':lang(a) { }'
+PASS parseThenSerializeRule(':lang(&quot;bb&quot;, cc) { }') is ':lang(bb, cc) { }'
+PASS parseThenSerializeRule(':lang(&quot;ddd&quot;, eee) { }') is ':lang(ddd, eee) { }'
+PASS parseThenSerializeRule(':lang(&quot;*-1997&quot;) { }') is ':lang(*-1997) { }'
+PASS parseThenSerializeRule(':lang(&quot;*-1997&quot;, &quot;*-1998&quot;) { }') is ':lang(*-1997, *-1998) { }'
+PASS parseThenSerializeRule(':lang(&quot;&quot;) { }') is ':lang() { }'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcsscsslangselectorwithstringargumentstexthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/css-lang-selector-with-string-arguments-text.html (0 => 177745)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/css-lang-selector-with-string-arguments-text.html                                (rev 0)
+++ trunk/LayoutTests/fast/css/css-lang-selector-with-string-arguments-text.html        2014-12-26 07:34:39 UTC (rev 177745)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+&lt;html&gt;
+&lt;head id=&quot;head&quot;&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script&gt;
+
+description(&quot;This tests parsing and re-serialization of :lang CSS selector with string arguments&quot;);
+
+function parseThenSerializeRule(rule)
+{
+    var styleElement = document.getElementById(&quot;style&quot;);
+    var head = document.getElementById(&quot;head&quot;);
+    if (styleElement)
+        head.removeChild(styleElement);
+
+    styleElement = document.createElement(&quot;style&quot;);
+    styleElement.id = &quot;style&quot;;
+    var head = document.getElementById(&quot;head&quot;);
+    head.appendChild(styleElement);
+    
+    styleElement.appendChild(document.createTextNode(rule));
+    return styleElement.sheet.cssRules[0].cssText;
+}
+
+function testSelectorRoundTrip(selector)
+{
+    var expected = selector.split('&quot;').join('');
+    shouldBe(&quot;parseThenSerializeRule('&quot; + selector + &quot; { }')&quot;, &quot;'&quot; + expected + &quot; { }'&quot;);
+}
+
+testSelectorRoundTrip(':lang(&quot;a&quot;)');
+testSelectorRoundTrip(':lang(&quot;bb&quot;, cc)');
+testSelectorRoundTrip(':lang(&quot;ddd&quot;, eee)');
+testSelectorRoundTrip(':lang(&quot;*-1997&quot;)');
+testSelectorRoundTrip(':lang(&quot;*-1997&quot;, &quot;*-1998&quot;)');
+testSelectorRoundTrip(':lang(&quot;&quot;)');
+
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorslangextendedfilteringwithstringargumentsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/lang-extended-filtering-with-string-arguments-expected.txt (0 => 177745)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/lang-extended-filtering-with-string-arguments-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/lang-extended-filtering-with-string-arguments-expected.txt        2014-12-26 07:34:39 UTC (rev 177745)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+Verify selector specifying extended filtering of :lang() pseudo class with string arguments
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS document.querySelectorAll(':lang(&quot;en&quot;)').length is 1
+PASS document.querySelectorAll(':lang(&quot;de-1997&quot;)').length is 1
+PASS document.querySelectorAll(':lang(&quot;*-1997&quot;)').length is 1
+PASS document.querySelectorAll(&quot;:lang('')&quot;).length is 0
+PASS document.querySelectorAll(':lang(&quot;&quot;)').length is 0
+PASS document.querySelectorAll(':lang(&quot;en&quot;, &quot;*-1997&quot;)').length is 2
+PASS document.querySelectorAll(':lang(&quot;&quot;, &quot;*-1997&quot;)').length is 1
+PASS document.querySelectorAll(':lang(&quot;&quot;&quot;&quot;)') threw exception Error: SyntaxError: DOM Exception 12.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastselectorslangextendedfilteringwithstringargumentshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/selectors/lang-extended-filtering-with-string-arguments.html (0 => 177745)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/selectors/lang-extended-filtering-with-string-arguments.html                                (rev 0)
+++ trunk/LayoutTests/fast/selectors/lang-extended-filtering-with-string-arguments.html        2014-12-26 07:34:39 UTC (rev 177745)
</span><span class="lines">@@ -0,0 +1,25 @@
</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 lang=&quot;en&quot;&gt;&lt;/div&gt;
+    &lt;div lang=&quot;&quot;&gt;&lt;/div&gt;
+    &lt;div lang=&quot;\&quot;\&quot;&quot;&gt;&lt;/div&gt;
+    &lt;div lang=&quot;de-1997-Latn&quot;&gt;&lt;/div&gt;
+    &lt;script&gt;
+    description('Verify selector specifying extended filtering of :lang() pseudo class with string arguments');
+    shouldBe('document.querySelectorAll(\':lang(&quot;en&quot;)\').length', '1');
+    shouldBe('document.querySelectorAll(\':lang(&quot;de-1997&quot;)\').length', '1');
+    shouldBe('document.querySelectorAll(\':lang(&quot;*-1997&quot;)\').length', '1');
+    shouldBe('document.querySelectorAll(&quot;:lang(\'\')&quot;).length', &quot;0&quot;);
+    shouldBe('document.querySelectorAll(\':lang(&quot;&quot;)\').length', '0');
+    shouldBe('document.querySelectorAll(\':lang(&quot;en&quot;, &quot;*-1997&quot;)\').length', '2');
+    shouldBe('document.querySelectorAll(\':lang(&quot;&quot;, &quot;*-1997&quot;)\').length', '1');
+
+    shouldThrow('document.querySelectorAll(\':lang(&quot;&quot;&quot;&quot;)\')');
+    &lt;/script&gt;
+    &lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (177744 => 177745)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-12-26 04:23:28 UTC (rev 177744)
+++ trunk/Source/WebCore/ChangeLog        2014-12-26 07:34:39 UTC (rev 177745)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2014-12-25  Dhi Aurrahman  &lt;diorahman@rockybars.com&gt;
+
+        Allow strings as argument to :lang()
+        https://bugs.webkit.org/show_bug.cgi?id=139678
+
+        Reviewed by Benjamin Poulain.
+
+        Allow strings as argument to :lang()[1]. The selector with empty string argument (e.g. :lang(&quot;&quot;))
+        is handled as never matching.
+
+        [1] http://www.w3.org/blog/CSS/2014/12/11/minutes-telecon-231/
+
+        Test: fast/css/css-lang-selector-with-string-arguments-text.html
+              fast/selectors/lang-extended-filtering-with-string-arguments.html
+
+        * css/CSSGrammar.y.in:
+        * css/SelectorCheckerTestFunctions.h:
+        (WebCore::matchesLangPseudoClass):
+
</ins><span class="cx"> 2014-12-25  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         DOM exception creator functions should return Ref.
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSGrammaryin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSGrammar.y.in (177744 => 177745)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSGrammar.y.in        2014-12-26 04:23:28 UTC (rev 177744)
+++ trunk/Source/WebCore/css/CSSGrammar.y.in        2014-12-26 07:34:39 UTC (rev 177745)
</span><span class="lines">@@ -1104,7 +1104,7 @@
</span><span class="cx">     ;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE_CSS_SELECTORS_LEVEL4
</span><del>-lang_range: LANGRANGE | IDENT 
</del><ins>+lang_range: LANGRANGE | IDENT | STRING
</ins><span class="cx"> 
</span><span class="cx"> comma_separated_lang_ranges:
</span><span class="cx">     lang_range %prec UNIMPORTANT_TOK {
</span></span></pre></div>
<a id="trunkSourceWebCorecssSelectorCheckerTestFunctionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/SelectorCheckerTestFunctions.h (177744 => 177745)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/SelectorCheckerTestFunctions.h        2014-12-26 04:23:28 UTC (rev 177744)
+++ trunk/Source/WebCore/css/SelectorCheckerTestFunctions.h        2014-12-26 07:34:39 UTC (rev 177745)
</span><span class="lines">@@ -158,7 +158,7 @@
</span><span class="cx"> #endif
</span><span class="cx">         language = element-&gt;computeInheritedLanguage();
</span><span class="cx"> 
</span><del>-    if (language.isNull())
</del><ins>+    if (language.isNull() || language.isEmpty())
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     // Implement basic and extended filterings of given language tags 
</span><span class="lines">@@ -169,6 +169,9 @@
</span><span class="cx">     language.string().split('-', true, languageSubtags);
</span><span class="cx"> 
</span><span class="cx">     for (const AtomicString&amp; range : ranges) {
</span><ins>+        if (range.isEmpty())
+            continue;
+
</ins><span class="cx">         if (range == &quot;*&quot;)
</span><span class="cx">             return true;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>