<!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>[204952] 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/204952">204952</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-08-24 19:40:55 -0700 (Wed, 24 Aug 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Implement `CSS.escape` as per CSSOM
https://bugs.webkit.org/show_bug.cgi?id=126337

Patch by Joseph Pecoraro &lt;pecoraro@apple.com&gt; on 2016-08-24
Reviewed by Dean Jackson.

Source/WebCore:

Test: css3/escape-dom-api.html

* css/CSSOMUtils.cpp:
(WebCore::serializeIdentifier):
Update serialization to match the latest version of the spec:
&lt;https://drafts.csswg.org/cssom/#serialize-an-identifier&gt;
New handling for 0x0, 0x7f, just &quot;-&quot;, and &quot;--&quot; is now allowed.

* css/DOMCSSNamespace.cpp:
(WebCore::DOMCSSNamespace::escape):
* css/DOMCSSNamespace.h:
* css/DOMCSSNamespace.idl:
New CSS.escape method.

LayoutTests:

CSS.escape is part of the CSSOM Spec:
https://drafts.csswg.org/cssom/#the-css.escape%28%29-method

Tests:
https://github.com/mathiasbynens/CSS.escape/blob/master/tests/tests.js

Change is based on the Blink change (patch by &lt;rob.buis@samsung.com&gt;) and follow-ups:
&lt;https://chromium.googlesource.com/chromium/blink/+/c1a5ffdc924b089e70cd33ad2726b58cc8312abe&gt;

* css3/escape-dom-api-expected.txt: Added.
* css3/escape-dom-api.html: Added.
New tests, taken from the polyfill.

* fast/css/parsing-css-nonascii-expected.txt:
* fast/css/parsing-css-nonascii.html:
* fast/css/selector-text-escape.html:
Update existing tests now that 0x7f is escaped.

* js/dom/function-removed-after-parsing-expected.txt:
* js/dom/function-removed-after-parsing.html:
Rename use of `CSS.escape` here now that `CSS.escape` exists.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastcssparsingcssnonasciiexpectedtxt">trunk/LayoutTests/fast/css/parsing-css-nonascii-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcssparsingcssnonasciihtml">trunk/LayoutTests/fast/css/parsing-css-nonascii.html</a></li>
<li><a href="#trunkLayoutTestsfastcssselectortextescapehtml">trunk/LayoutTests/fast/css/selector-text-escape.html</a></li>
<li><a href="#trunkLayoutTestsjsdomfunctionremovedafterparsingexpectedtxt">trunk/LayoutTests/js/dom/function-removed-after-parsing-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsdomfunctionremovedafterparsinghtml">trunk/LayoutTests/js/dom/function-removed-after-parsing.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssCSSOMUtilscpp">trunk/Source/WebCore/css/CSSOMUtils.cpp</a></li>
<li><a href="#trunkSourceWebCorecssDOMCSSNamespacecpp">trunk/Source/WebCore/css/DOMCSSNamespace.cpp</a></li>
<li><a href="#trunkSourceWebCorecssDOMCSSNamespaceh">trunk/Source/WebCore/css/DOMCSSNamespace.h</a></li>
<li><a href="#trunkSourceWebCorecssDOMCSSNamespaceidl">trunk/Source/WebCore/css/DOMCSSNamespace.idl</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscss3escapedomapiexpectedtxt">trunk/LayoutTests/css3/escape-dom-api-expected.txt</a></li>
<li><a href="#trunkLayoutTestscss3escapedomapihtml">trunk/LayoutTests/css3/escape-dom-api.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (204951 => 204952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-08-25 01:55:04 UTC (rev 204951)
+++ trunk/LayoutTests/ChangeLog        2016-08-25 02:40:55 UTC (rev 204952)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2016-08-24  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Implement `CSS.escape` as per CSSOM
+        https://bugs.webkit.org/show_bug.cgi?id=126337
+
+        Reviewed by Dean Jackson.
+
+        CSS.escape is part of the CSSOM Spec:
+        https://drafts.csswg.org/cssom/#the-css.escape%28%29-method
+
+        Tests:
+        https://github.com/mathiasbynens/CSS.escape/blob/master/tests/tests.js
+
+        Change is based on the Blink change (patch by &lt;rob.buis@samsung.com&gt;) and follow-ups:
+        &lt;https://chromium.googlesource.com/chromium/blink/+/c1a5ffdc924b089e70cd33ad2726b58cc8312abe&gt;
+
+        * css3/escape-dom-api-expected.txt: Added.
+        * css3/escape-dom-api.html: Added.
+        New tests, taken from the polyfill.
+
+        * fast/css/parsing-css-nonascii-expected.txt:
+        * fast/css/parsing-css-nonascii.html:
+        * fast/css/selector-text-escape.html:
+        Update existing tests now that 0x7f is escaped.
+
+        * js/dom/function-removed-after-parsing-expected.txt:
+        * js/dom/function-removed-after-parsing.html:
+        Rename use of `CSS.escape` here now that `CSS.escape` exists.
+
</ins><span class="cx"> 2016-08-24  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         ASSERTION FAILED: contentSize &gt;= 0 in WebCore::RenderFlexibleBox::adjustChildSizeForMinAndMax
</span></span></pre></div>
<a id="trunkLayoutTestscss3escapedomapiexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/css3/escape-dom-api-expected.txt (0 => 204952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/css3/escape-dom-api-expected.txt                                (rev 0)
+++ trunk/LayoutTests/css3/escape-dom-api-expected.txt        2016-08-25 02:40:55 UTC (rev 204952)
</span><span class="lines">@@ -0,0 +1,69 @@
</span><ins>+Test window.CSS.escape()
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS CSS.escape.length is 1
+PASS CSS.escape('\0') is &quot;�&quot;
+PASS CSS.escape('a\0') is &quot;a�&quot;
+PASS CSS.escape('\0b') is &quot;�b&quot;
+PASS CSS.escape('a\0b') is &quot;a�b&quot;
+PASS CSS.escape('�') is &quot;�&quot;
+PASS CSS.escape('a�') is &quot;a�&quot;
+PASS CSS.escape('�b') is &quot;�b&quot;
+PASS CSS.escape('a�b') is &quot;a�b&quot;
+PASS CSS.escape() threw exception TypeError: Not enough arguments.
+PASS CSS.escape(undefined) is &quot;undefined&quot;
+PASS CSS.escape(true) is &quot;true&quot;
+PASS CSS.escape(false) is &quot;false&quot;
+PASS CSS.escape(null) is &quot;null&quot;
+PASS CSS.escape('') is &quot;&quot;
+PASS CSS.escape('') is &quot;\\1 \\2 \\1e \\1f &quot;
+PASS CSS.escape('0a') is &quot;\\30 a&quot;
+PASS CSS.escape('1a') is &quot;\\31 a&quot;
+PASS CSS.escape('2a') is &quot;\\32 a&quot;
+PASS CSS.escape('3a') is &quot;\\33 a&quot;
+PASS CSS.escape('4a') is &quot;\\34 a&quot;
+PASS CSS.escape('5a') is &quot;\\35 a&quot;
+PASS CSS.escape('6a') is &quot;\\36 a&quot;
+PASS CSS.escape('7a') is &quot;\\37 a&quot;
+PASS CSS.escape('8a') is &quot;\\38 a&quot;
+PASS CSS.escape('9a') is &quot;\\39 a&quot;
+PASS CSS.escape('a0b') is &quot;a0b&quot;
+PASS CSS.escape('a1b') is &quot;a1b&quot;
+PASS CSS.escape('a2b') is &quot;a2b&quot;
+PASS CSS.escape('a3b') is &quot;a3b&quot;
+PASS CSS.escape('a4b') is &quot;a4b&quot;
+PASS CSS.escape('a5b') is &quot;a5b&quot;
+PASS CSS.escape('a6b') is &quot;a6b&quot;
+PASS CSS.escape('a7b') is &quot;a7b&quot;
+PASS CSS.escape('a8b') is &quot;a8b&quot;
+PASS CSS.escape('a9b') is &quot;a9b&quot;
+PASS CSS.escape('-0a') is &quot;-\\30 a&quot;
+PASS CSS.escape('-1a') is &quot;-\\31 a&quot;
+PASS CSS.escape('-2a') is &quot;-\\32 a&quot;
+PASS CSS.escape('-3a') is &quot;-\\33 a&quot;
+PASS CSS.escape('-4a') is &quot;-\\34 a&quot;
+PASS CSS.escape('-5a') is &quot;-\\35 a&quot;
+PASS CSS.escape('-6a') is &quot;-\\36 a&quot;
+PASS CSS.escape('-7a') is &quot;-\\37 a&quot;
+PASS CSS.escape('-8a') is &quot;-\\38 a&quot;
+PASS CSS.escape('-9a') is &quot;-\\39 a&quot;
+PASS CSS.escape('-') is &quot;\\-&quot;
+PASS CSS.escape('-a') is &quot;-a&quot;
+PASS CSS.escape('--') is &quot;--&quot;
+PASS CSS.escape('--a') is &quot;--a&quot;
+PASS CSS.escape('€-_©') is &quot;€-_©&quot;
+PASS CSS.escape('€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ') is &quot;\\7f Â€ÂÂ‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ&quot;
+PASS CSS.escape(' ¡¢') is &quot; ¡¢&quot;
+PASS CSS.escape('a0123456789b') is &quot;a0123456789b&quot;
+PASS CSS.escape('abcdefghijklmnopqrstuvwxyz') is &quot;abcdefghijklmnopqrstuvwxyz&quot;
+PASS CSS.escape('ABCDEFGHIJKLMNOPQRSTUVWXYZ') is &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;
+PASS CSS.escape(' !xy') is &quot;\\ \\!xy&quot;
+PASS CSS.escape('𝌆') is &quot;𝌆&quot;
+PASS CSS.escape('í¼†') is &quot;í¼†&quot;
+PASS CSS.escape('í ´') is &quot;í ´&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscss3escapedomapihtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/css3/escape-dom-api.html (0 => 204952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/css3/escape-dom-api.html                                (rev 0)
+++ trunk/LayoutTests/css3/escape-dom-api.html        2016-08-25 02:40:55 UTC (rev 204952)
</span><span class="lines">@@ -0,0 +1,86 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../resources/js-test.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script&gt;
+    // Test from https://github.com/mathiasbynens/CSS.escape
+    description(&quot;Test window.CSS.escape()&quot;);
+
+    shouldBe(&quot;CSS.escape.length&quot;, &quot;1&quot;);
+
+    shouldBeEqualToString(&quot;CSS.escape('\0')&quot;, &quot;\ufffd&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('a\0')&quot;, &quot;a\ufffd&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('\0b')&quot;, &quot;\ufffdb&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('a\0b')&quot;, &quot;a\ufffdb&quot;);
+
+    shouldBeEqualToString(&quot;CSS.escape('\ufffd')&quot;, &quot;\ufffd&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('a\ufffd')&quot;, &quot;a\ufffd&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('\ufffdb')&quot;, &quot;\ufffdb&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('a\ufffdb')&quot;, &quot;a\ufffdb&quot;);
+
+    shouldThrow(&quot;CSS.escape()&quot;);
+    shouldBeEqualToString(&quot;CSS.escape(undefined)&quot;, &quot;undefined&quot;);
+    shouldBeEqualToString(&quot;CSS.escape(true)&quot;, &quot;true&quot;);
+    shouldBeEqualToString(&quot;CSS.escape(false)&quot;, &quot;false&quot;);
+    shouldBeEqualToString(&quot;CSS.escape(null)&quot;, &quot;null&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('')&quot;, &quot;&quot;);
+
+    shouldBeEqualToString(&quot;CSS.escape('\x01\x02\x1E\x1F')&quot;, &quot;\\1 \\2 \\1e \\1f &quot;);
+
+    shouldBeEqualToString(&quot;CSS.escape('0a')&quot;, &quot;\\30 a&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('1a')&quot;, &quot;\\31 a&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('2a')&quot;, &quot;\\32 a&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('3a')&quot;, &quot;\\33 a&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('4a')&quot;, &quot;\\34 a&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('5a')&quot;, &quot;\\35 a&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('6a')&quot;, &quot;\\36 a&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('7a')&quot;, &quot;\\37 a&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('8a')&quot;, &quot;\\38 a&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('9a')&quot;, &quot;\\39 a&quot;);
+
+    shouldBeEqualToString(&quot;CSS.escape('a0b')&quot;, &quot;a0b&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('a1b')&quot;, &quot;a1b&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('a2b')&quot;, &quot;a2b&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('a3b')&quot;, &quot;a3b&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('a4b')&quot;, &quot;a4b&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('a5b')&quot;, &quot;a5b&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('a6b')&quot;, &quot;a6b&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('a7b')&quot;, &quot;a7b&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('a8b')&quot;, &quot;a8b&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('a9b')&quot;, &quot;a9b&quot;);
+
+    shouldBeEqualToString(&quot;CSS.escape('-0a')&quot;, &quot;-\\30 a&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('-1a')&quot;, &quot;-\\31 a&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('-2a')&quot;, &quot;-\\32 a&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('-3a')&quot;, &quot;-\\33 a&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('-4a')&quot;, &quot;-\\34 a&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('-5a')&quot;, &quot;-\\35 a&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('-6a')&quot;, &quot;-\\36 a&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('-7a')&quot;, &quot;-\\37 a&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('-8a')&quot;, &quot;-\\38 a&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('-9a')&quot;, &quot;-\\39 a&quot;);
+
+    shouldBeEqualToString(&quot;CSS.escape('-')&quot;, &quot;\\-&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('-a')&quot;, &quot;-a&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('--')&quot;, &quot;--&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('--a')&quot;, &quot;--a&quot;);
+
+    shouldBeEqualToString(&quot;CSS.escape('\x80\x2D\x5F\xA9')&quot;, &quot;\x80\x2D\x5F\xA9&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F')&quot;, &quot;\\7f \x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('\xA0\xA1\xA2')&quot;, &quot;\xA0\xA1\xA2&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('a0123456789b')&quot;, &quot;a0123456789b&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('abcdefghijklmnopqrstuvwxyz')&quot;, &quot;abcdefghijklmnopqrstuvwxyz&quot;);
+    shouldBeEqualToString(&quot;CSS.escape('ABCDEFGHIJKLMNOPQRSTUVWXYZ')&quot;, &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;);
+
+    shouldBeEqualToString(&quot;CSS.escape('\x20\x21\x78\x79')&quot;, &quot;\\ \\!xy&quot;);
+
+    // astral symbol (U+1D306 TETRAGRAM FOR CENTRE)
+    shouldBeEqualToString(&quot;CSS.escape('\uD834\uDF06')&quot;, &quot;\uD834\uDF06&quot;);
+    // lone surrogates
+    shouldBeEqualToString(&quot;CSS.escape('\uDF06')&quot;, '\uDF06');
+    shouldBeEqualToString(&quot;CSS.escape('\uD834')&quot;, '\uD834');
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcssparsingcssnonasciiexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/css/parsing-css-nonascii-expected.txt (204951 => 204952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/parsing-css-nonascii-expected.txt        2016-08-25 01:55:04 UTC (rev 204951)
+++ trunk/LayoutTests/fast/css/parsing-css-nonascii-expected.txt        2016-08-25 02:40:55 UTC (rev 204952)
</span><span class="lines">@@ -4,7 +4,7 @@
</span><span class="cx"> 
</span><span class="cx"> Rules from the stylesheet:
</span><span class="cx"> 
</span><del>-#a127_\ { color: red; }
</del><ins>+#a127_\7f  { color: red; }
</ins><span class="cx"> #a128_€ { color: red; }
</span><span class="cx"> #b128_€ { color: green; }
</span><span class="cx"> #a159_Ÿ { color: red; }
</span><span class="lines">@@ -15,7 +15,7 @@
</span><span class="cx"> #b384_ƀ { color: green; }
</span><span class="cx"> Expected result:
</span><span class="cx"> 
</span><del>-#a127_\ { color: red; }
</del><ins>+#a127_\7f  { color: red; }
</ins><span class="cx"> #a128_€ { color: red; }
</span><span class="cx"> #b128_€ { color: green; }
</span><span class="cx"> #a159_Ÿ { color: red; }
</span></span></pre></div>
<a id="trunkLayoutTestsfastcssparsingcssnonasciihtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/css/parsing-css-nonascii.html (204951 => 204952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/parsing-css-nonascii.html        2016-08-25 01:55:04 UTC (rev 204951)
+++ trunk/LayoutTests/fast/css/parsing-css-nonascii.html        2016-08-25 02:40:55 UTC (rev 204952)
</span><span class="lines">@@ -5,7 +5,7 @@
</span><span class="cx"> /*
</span><span class="cx">   === Warning ===
</span><span class="cx"> 
</span><del>-  This file intentionally contains scpecial characters which
</del><ins>+  This file intentionally contains special characters which
</ins><span class="cx">   cannot be displayed by some text editors. Please
</span><span class="cx">   carefully edit the file.
</span><span class="cx"> */
</span><span class="lines">@@ -64,7 +64,7 @@
</span><span class="cx"> 
</span><span class="cx"> &lt;p&gt;Expected result:&lt;/p&gt;
</span><span class="cx"> 
</span><del>-&lt;pre id=&quot;expected&quot;&gt;#a127_\ { color: red; }
</del><ins>+&lt;pre id=&quot;expected&quot;&gt;#a127_\7f  { color: red; }
</ins><span class="cx"> #a128_€ { color: red; }
</span><span class="cx"> #b128_€ { color: green; }
</span><span class="cx"> #a159_Ÿ { color: red; }
</span></span></pre></div>
<a id="trunkLayoutTestsfastcssselectortextescapehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/css/selector-text-escape.html (204951 => 204952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/selector-text-escape.html        2016-08-25 01:55:04 UTC (rev 204951)
+++ trunk/LayoutTests/fast/css/selector-text-escape.html        2016-08-25 02:40:55 UTC (rev 204952)
</span><span class="lines">@@ -93,7 +93,7 @@
</span><span class="cx">     &quot;.\\39 _class&quot;,
</span><span class="cx">     &quot;.-\\30 _class&quot;,
</span><span class="cx">     &quot;.-\\39 _class&quot;,
</span><del>-    &quot;.-\\-_class&quot;,
</del><ins>+    &quot;.--_class&quot;,
</ins><span class="cx">     &quot;.\x81_class&quot;,
</span><span class="cx">     &quot;.日本語_class&quot;,
</span><span class="cx">     &quot;.𐐀_class&quot;,
</span></span></pre></div>
<a id="trunkLayoutTestsjsdomfunctionremovedafterparsingexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/dom/function-removed-after-parsing-expected.txt (204951 => 204952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/function-removed-after-parsing-expected.txt        2016-08-25 01:55:04 UTC (rev 204951)
+++ trunk/LayoutTests/js/dom/function-removed-after-parsing-expected.txt        2016-08-25 02:40:55 UTC (rev 204952)
</span><span class="lines">@@ -1,2 +1,2 @@
</span><del>-window.CSS.escape still here
</del><ins>+window.CSS.layoutTestEscape still here
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsjsdomfunctionremovedafterparsinghtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/dom/function-removed-after-parsing.html (204951 => 204952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/function-removed-after-parsing.html        2016-08-25 01:55:04 UTC (rev 204951)
+++ trunk/LayoutTests/js/dom/function-removed-after-parsing.html        2016-08-25 02:40:55 UTC (rev 204952)
</span><span class="lines">@@ -2,6 +2,9 @@
</span><span class="cx"> &lt;!--
</span><span class="cx"> NOTE: This intentionally does not use description() and does not include js-test-post because
</span><span class="cx"> doing either of those things made the bug go away.
</span><ins>+
+NOTE: This intentionally does not use the name `CSS.escape` because that function exists now but
+did not when this test was added. The name was changed to `CSS.layoutTestEscape` for this test.
</ins><span class="cx"> --&gt;
</span><span class="cx">   &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">   &lt;script type='text/javascript'&gt;
</span><span class="lines">@@ -20,9 +23,9 @@
</span><span class="cx">         InvalidCharacterError.prototype = new Error;
</span><span class="cx">         InvalidCharacterError.prototype.name = 'InvalidCharacterError';
</span><span class="cx"> 
</span><del>-        if (!CSS.escape) {
</del><ins>+        if (!CSS.layoutTestEscape) {
</ins><span class="cx">                 // https://drafts.csswg.org/cssom/#serialize-an-identifier
</span><del>-                CSS.escape = function(value) {
</del><ins>+                CSS.layoutTestEscape = function(value) {
</ins><span class="cx">                         var string = String(value);
</span><span class="cx">                         var length = string.length;
</span><span class="cx">                         var index = -1;
</span><span class="lines">@@ -107,14 +110,14 @@
</span><span class="cx">       testRunner.dumpAsText(window.enablePixelTesting);
</span><span class="cx">       testRunner.waitUntilDone();
</span><span class="cx">     } catch (e) { }
</span><del>-    if (!window.CSS.escape) {
-      debug('window.CSS.escape not loaded');
</del><ins>+    if (!window.CSS.layoutTestEscape) {
+      debug('window.CSS.layoutTestEscape not loaded');
</ins><span class="cx">     }
</span><span class="cx">     setTimeout(function() {
</span><del>-      if (window.CSS.escape)
-        debug(&quot;window.CSS.escape still here&quot;);
</del><ins>+      if (window.CSS.layoutTestEscape)
+        debug(&quot;window.CSS.layoutTestEscape still here&quot;);
</ins><span class="cx">       else
</span><del>-        debug('window.CSS.escape missing in event');
</del><ins>+        debug('window.CSS.layoutTestEscape missing in event');
</ins><span class="cx">       try {
</span><span class="cx">         testRunner.notifyDone();
</span><span class="cx">       } catch (e) { }
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (204951 => 204952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-08-25 01:55:04 UTC (rev 204951)
+++ trunk/Source/WebCore/ChangeLog        2016-08-25 02:40:55 UTC (rev 204952)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2016-08-24  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Implement `CSS.escape` as per CSSOM
+        https://bugs.webkit.org/show_bug.cgi?id=126337
+
+        Reviewed by Dean Jackson.
+
+        Test: css3/escape-dom-api.html
+
+        * css/CSSOMUtils.cpp:
+        (WebCore::serializeIdentifier):
+        Update serialization to match the latest version of the spec:
+        &lt;https://drafts.csswg.org/cssom/#serialize-an-identifier&gt;
+        New handling for 0x0, 0x7f, just &quot;-&quot;, and &quot;--&quot; is now allowed.
+
+        * css/DOMCSSNamespace.cpp:
+        (WebCore::DOMCSSNamespace::escape):
+        * css/DOMCSSNamespace.h:
+        * css/DOMCSSNamespace.idl:
+        New CSS.escape method.
+
</ins><span class="cx"> 2016-08-24  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         ASSERTION FAILED: contentSize &gt;= 0 in WebCore::RenderFlexibleBox::adjustChildSizeForMinAndMax
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSOMUtilscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSOMUtils.cpp (204951 => 204952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSOMUtils.cpp        2016-08-25 01:55:04 UTC (rev 204951)
+++ trunk/Source/WebCore/css/CSSOMUtils.cpp        2016-08-25 02:40:55 UTC (rev 204952)
</span><span class="lines">@@ -57,11 +57,18 @@
</span><span class="cx">     unsigned index = 0;
</span><span class="cx">     while (index &lt; identifier.length()) {
</span><span class="cx">         UChar32 c = identifier.characterStartingAt(index);
</span><ins>+        if (!c) {
+            // Check for lone surrogate which characterStartingAt does not return.
+            c = identifier[index];
+        }
+
</ins><span class="cx">         index += U16_LENGTH(c);
</span><span class="cx"> 
</span><del>-        if (c &lt;= 0x1f || (0x30 &lt;= c &amp;&amp; c &lt;= 0x39 &amp;&amp; (isFirst || (isSecond &amp;&amp; isFirstCharHyphen))))
</del><ins>+        if (!c)
+            appendTo.append(0xfffd);
+        else if (c &lt;= 0x1f || c == 0x7f || (0x30 &lt;= c &amp;&amp; c &lt;= 0x39 &amp;&amp; (isFirst || (isSecond &amp;&amp; isFirstCharHyphen))))
</ins><span class="cx">             serializeCharacterAsCodePoint(c, appendTo);
</span><del>-        else if (c == 0x2d &amp;&amp; isSecond &amp;&amp; isFirstCharHyphen)
</del><ins>+        else if (c == 0x2d &amp;&amp; isFirst &amp;&amp; index == identifier.length())
</ins><span class="cx">             serializeCharacter(c, appendTo);
</span><span class="cx">         else if (0x80 &lt;= c || c == 0x2d || c == 0x5f || (0x30 &lt;= c &amp;&amp; c &lt;= 0x39) || (0x41 &lt;= c &amp;&amp; c &lt;= 0x5a) || (0x61 &lt;= c &amp;&amp; c &lt;= 0x7a))
</span><span class="cx">             appendTo.append(c);
</span><span class="lines">@@ -72,9 +79,8 @@
</span><span class="cx">             isFirst = false;
</span><span class="cx">             isSecond = true;
</span><span class="cx">             isFirstCharHyphen = (c == 0x2d);
</span><del>-        } else if (isSecond) {
</del><ins>+        } else if (isSecond)
</ins><span class="cx">             isSecond = false;
</span><del>-        }
</del><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorecssDOMCSSNamespacecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/DOMCSSNamespace.cpp (204951 => 204952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/DOMCSSNamespace.cpp        2016-08-25 01:55:04 UTC (rev 204951)
+++ trunk/Source/WebCore/css/DOMCSSNamespace.cpp        2016-08-25 02:40:55 UTC (rev 204952)
</span><span class="lines">@@ -30,8 +30,10 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;DOMCSSNamespace.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;CSSOMUtils.h&quot;
</ins><span class="cx"> #include &quot;CSSParser.h&quot;
</span><span class="cx"> #include &quot;StyleProperties.h&quot;
</span><ins>+#include &lt;wtf/text/StringBuilder.h&gt;
</ins><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -77,4 +79,11 @@
</span><span class="cx">     return parser.parseSupportsCondition(conditionText);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+String DOMCSSNamespace::escape(const String&amp; ident)
+{
+    StringBuilder builder;
+    serializeIdentifier(ident, builder);
+    return builder.toString();
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCorecssDOMCSSNamespaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/DOMCSSNamespace.h (204951 => 204952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/DOMCSSNamespace.h        2016-08-25 01:55:04 UTC (rev 204951)
+++ trunk/Source/WebCore/css/DOMCSSNamespace.h        2016-08-25 02:40:55 UTC (rev 204952)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx"> public:
</span><span class="cx">     static bool supports(const String&amp; property, const String&amp; value);
</span><span class="cx">     static bool supports(const String&amp; conditionText);
</span><ins>+    static String escape(const String&amp; ident);
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorecssDOMCSSNamespaceidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/DOMCSSNamespace.idl (204951 => 204952)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/DOMCSSNamespace.idl        2016-08-25 01:55:04 UTC (rev 204951)
+++ trunk/Source/WebCore/css/DOMCSSNamespace.idl        2016-08-25 02:40:55 UTC (rev 204952)
</span><span class="lines">@@ -33,4 +33,5 @@
</span><span class="cx"> ] interface DOMCSSNamespace {
</span><span class="cx">     static boolean supports(DOMString property, DOMString value);
</span><span class="cx">     static boolean supports(DOMString conditionText);
</span><ins>+    static DOMString escape(DOMString ident);
</ins><span class="cx"> };
</span></span></pre>
</div>
</div>

</body>
</html>