<!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>[201421] 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/201421">201421</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2016-05-26 10:08:17 -0700 (Thu, 26 May 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Font Loading] Allow empty strings in FontFace constructor
https://bugs.webkit.org/show_bug.cgi?id=158112

Reviewed by Darin Adler.

Source/WebCore:

Other browsers accept empty strings and parse them as if they are omitted.
We should do the same. However, this is only true for the constructor. Setting
an attribute to an empty string should still throw an exception.

Test: fast/text/font-face-empty-string.html

* css/FontFace.cpp:
(WebCore::FontFace::create):
(WebCore::FontFace::setFamily):
(WebCore::FontFace::setStyle):
(WebCore::FontFace::setWeight):
(WebCore::FontFace::setUnicodeRange):
(WebCore::FontFace::setVariant):
(WebCore::FontFace::setFeatureSettings):

LayoutTests:

* fast/text/font-face-empty-string-expected.txt: Added.
* fast/text/font-face-empty-string.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="#trunkSourceWebCorecssFontFacecpp">trunk/Source/WebCore/css/FontFace.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasttextfontfaceemptystringexpectedtxt">trunk/LayoutTests/fast/text/font-face-empty-string-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasttextfontfaceemptystringhtml">trunk/LayoutTests/fast/text/font-face-empty-string.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (201420 => 201421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-05-26 16:24:42 UTC (rev 201420)
+++ trunk/LayoutTests/ChangeLog        2016-05-26 17:08:17 UTC (rev 201421)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-05-26  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        [Font Loading] Allow empty strings in FontFace constructor
+        https://bugs.webkit.org/show_bug.cgi?id=158112
+
+        Reviewed by Darin Adler.
+
+        * fast/text/font-face-empty-string-expected.txt: Added.
+        * fast/text/font-face-empty-string.html: Added.
+
</ins><span class="cx"> 2016-05-26  Adam Bergkvist  &lt;adam.bergkvist@ericsson.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebRTC: RTCSessionDescription: Make attributes readonly (and remove custom binding)
</span></span></pre></div>
<a id="trunkLayoutTestsfasttextfontfaceemptystringexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/font-face-empty-string-expected.txt (0 => 201421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/font-face-empty-string-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/text/font-face-empty-string-expected.txt        2016-05-26 17:08:17 UTC (rev 201421)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+This test makes sure that constructing a FontFace with empty strings is the same as omitting those strings.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS fontface = new FontFace('WebFont', 'url(\'asdf\')', {style: ''}) did not throw exception.
+PASS fontface.style is &quot;normal&quot;
+PASS fontface.style = '' threw exception Error: SyntaxError: DOM Exception 12.
+PASS fontface = new FontFace('WebFont', 'url(\'asdf\')', {weight: ''}) did not throw exception.
+PASS fontface.weight is &quot;normal&quot;
+PASS fontface.weight = '' threw exception Error: SyntaxError: DOM Exception 12.
+PASS fontface = new FontFace('WebFont', 'url(\'asdf\')', {unicodeRange: ''}) did not throw exception.
+PASS fontface.unicodeRange is &quot;U+0-10ffff&quot;
+PASS fontface.unicodeRange = '' threw exception Error: SyntaxError: DOM Exception 12.
+PASS fontface = new FontFace('WebFont', 'url(\'asdf\')', {variant: ''}) did not throw exception.
+PASS fontface.variant is &quot;normal&quot;
+PASS fontface.variant = '' threw exception Error: SyntaxError: DOM Exception 12.
+PASS fontface = new FontFace('WebFont', 'url(\'asdf\')', {featureSettings: ''}) did not throw exception.
+PASS fontface.featureSettings is &quot;normal&quot;
+PASS fontface.featureSettings = '' threw exception Error: SyntaxError: DOM Exception 12.
+PASS fontface.family = '' threw exception Error: SyntaxError: DOM Exception 12.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/text/font-face-empty-string-expected.txt
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkLayoutTestsfasttextfontfaceemptystringhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/font-face-empty-string.html (0 => 201421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/font-face-empty-string.html                                (rev 0)
+++ trunk/LayoutTests/fast/text/font-face-empty-string.html        2016-05-26 17:08:17 UTC (rev 201421)
</span><span class="lines">@@ -0,0 +1,31 @@
</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;script&gt;
+description(&quot;This test makes sure that constructing a FontFace with empty strings is the same as omitting those strings.&quot;);
+
+var fontface;
+shouldNotThrow(&quot;fontface = new FontFace('WebFont', 'url(\\\'asdf\\\')', {style: ''})&quot;);
+shouldBeEqualToString(&quot;fontface.style&quot;, &quot;normal&quot;);
+shouldThrow(&quot;fontface.style = ''&quot;);
+shouldNotThrow(&quot;fontface = new FontFace('WebFont', 'url(\\\'asdf\\\')', {weight: ''})&quot;);
+shouldBeEqualToString(&quot;fontface.weight&quot;, &quot;normal&quot;);
+shouldThrow(&quot;fontface.weight = ''&quot;);
+shouldNotThrow(&quot;fontface = new FontFace('WebFont', 'url(\\\'asdf\\\')', {unicodeRange: ''})&quot;);
+shouldBeEqualToString(&quot;fontface.unicodeRange&quot;, &quot;U+0-10ffff&quot;);
+shouldThrow(&quot;fontface.unicodeRange = ''&quot;);
+shouldNotThrow(&quot;fontface = new FontFace('WebFont', 'url(\\\'asdf\\\')', {variant: ''})&quot;);
+shouldBeEqualToString(&quot;fontface.variant&quot;, &quot;normal&quot;);
+shouldThrow(&quot;fontface.variant = ''&quot;);
+shouldNotThrow(&quot;fontface = new FontFace('WebFont', 'url(\\\'asdf\\\')', {featureSettings: ''})&quot;);
+shouldBeEqualToString(&quot;fontface.featureSettings&quot;, &quot;normal&quot;);
+shouldThrow(&quot;fontface.featureSettings = ''&quot;);
+
+shouldThrow(&quot;fontface.family = ''&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 (201420 => 201421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-05-26 16:24:42 UTC (rev 201420)
+++ trunk/Source/WebCore/ChangeLog        2016-05-26 17:08:17 UTC (rev 201421)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2016-05-26  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        [Font Loading] Allow empty strings in FontFace constructor
+        https://bugs.webkit.org/show_bug.cgi?id=158112
+
+        Reviewed by Darin Adler.
+
+        Other browsers accept empty strings and parse them as if they are omitted.
+        We should do the same. However, this is only true for the constructor. Setting
+        an attribute to an empty string should still throw an exception.
+
+        Test: fast/text/font-face-empty-string.html
+
+        * css/FontFace.cpp:
+        (WebCore::FontFace::create):
+        (WebCore::FontFace::setFamily):
+        (WebCore::FontFace::setStyle):
+        (WebCore::FontFace::setWeight):
+        (WebCore::FontFace::setUnicodeRange):
+        (WebCore::FontFace::setVariant):
+        (WebCore::FontFace::setFeatureSettings):
+
</ins><span class="cx"> 2016-05-26  Adam Bergkvist  &lt;adam.bergkvist@ericsson.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebRTC: RTCSessionDescription: Make attributes readonly (and remove custom binding)
</span></span></pre></div>
<a id="trunkSourceWebCorecssFontFacecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/FontFace.cpp (201420 => 201421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/FontFace.cpp        2016-05-26 16:24:42 UTC (rev 201420)
+++ trunk/Source/WebCore/css/FontFace.cpp        2016-05-26 17:08:17 UTC (rev 201421)
</span><span class="lines">@@ -70,22 +70,23 @@
</span><span class="cx">         dataRequiresAsynchronousLoading = populateFontFaceWithArrayBuffer(result-&gt;backing(), arrayBufferView.releaseNonNull());
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    result-&gt;setStyle(descriptors.style, ec);
</del><ins>+    // These ternaries match the default strings inside the FontFaceDescriptors dictionary inside FontFace.idl.
+    result-&gt;setStyle(descriptors.style.isEmpty() ? ASCIILiteral(&quot;normal&quot;) : descriptors.style, ec);
</ins><span class="cx">     if (ec)
</span><span class="cx">         return nullptr;
</span><del>-    result-&gt;setWeight(descriptors.weight, ec);
</del><ins>+    result-&gt;setWeight(descriptors.weight.isEmpty() ? ASCIILiteral(&quot;normal&quot;) : descriptors.weight, ec);
</ins><span class="cx">     if (ec)
</span><span class="cx">         return nullptr;
</span><del>-    result-&gt;setStretch(descriptors.stretch, ec);
</del><ins>+    result-&gt;setStretch(descriptors.stretch.isEmpty() ? ASCIILiteral(&quot;normal&quot;) : descriptors.stretch, ec);
</ins><span class="cx">     if (ec)
</span><span class="cx">         return nullptr;
</span><del>-    result-&gt;setUnicodeRange(descriptors.unicodeRange, ec);
</del><ins>+    result-&gt;setUnicodeRange(descriptors.unicodeRange.isEmpty() ? ASCIILiteral(&quot;U+0-10FFFF&quot;) : descriptors.unicodeRange, ec);
</ins><span class="cx">     if (ec)
</span><span class="cx">         return nullptr;
</span><del>-    result-&gt;setVariant(descriptors.variant, ec);
</del><ins>+    result-&gt;setVariant(descriptors.variant.isEmpty() ? ASCIILiteral(&quot;normal&quot;) : descriptors.variant, ec);
</ins><span class="cx">     if (ec)
</span><span class="cx">         return nullptr;
</span><del>-    result-&gt;setFeatureSettings(descriptors.featureSettings, ec);
</del><ins>+    result-&gt;setFeatureSettings(descriptors.featureSettings.isEmpty() ? ASCIILiteral(&quot;normal&quot;) : descriptors.featureSettings, ec);
</ins><span class="cx">     if (ec)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><span class="lines">@@ -136,6 +137,11 @@
</span><span class="cx"> 
</span><span class="cx"> void FontFace::setFamily(const String&amp; family, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><ins>+    if (family.isEmpty()) {
+        ec = SYNTAX_ERR;
+        return;
+    }
+
</ins><span class="cx">     bool success = false;
</span><span class="cx">     if (auto value = parseString(family, CSSPropertyFontFamily))
</span><span class="cx">         success = m_backing-&gt;setFamilies(*value);
</span><span class="lines">@@ -145,6 +151,11 @@
</span><span class="cx"> 
</span><span class="cx"> void FontFace::setStyle(const String&amp; style, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><ins>+    if (style.isEmpty()) {
+        ec = SYNTAX_ERR;
+        return;
+    }
+
</ins><span class="cx">     bool success = false;
</span><span class="cx">     if (auto value = parseString(style, CSSPropertyFontStyle))
</span><span class="cx">         success = m_backing-&gt;setStyle(*value);
</span><span class="lines">@@ -154,6 +165,11 @@
</span><span class="cx"> 
</span><span class="cx"> void FontFace::setWeight(const String&amp; weight, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><ins>+    if (weight.isEmpty()) {
+        ec = SYNTAX_ERR;
+        return;
+    }
+
</ins><span class="cx">     bool success = false;
</span><span class="cx">     if (auto value = parseString(weight, CSSPropertyFontWeight))
</span><span class="cx">         success = m_backing-&gt;setWeight(*value);
</span><span class="lines">@@ -168,6 +184,11 @@
</span><span class="cx"> 
</span><span class="cx"> void FontFace::setUnicodeRange(const String&amp; unicodeRange, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><ins>+    if (unicodeRange.isEmpty()) {
+        ec = SYNTAX_ERR;
+        return;
+    }
+
</ins><span class="cx">     bool success = false;
</span><span class="cx">     if (auto value = parseString(unicodeRange, CSSPropertyUnicodeRange))
</span><span class="cx">         success = m_backing-&gt;setUnicodeRange(*value);
</span><span class="lines">@@ -177,6 +198,11 @@
</span><span class="cx"> 
</span><span class="cx"> void FontFace::setVariant(const String&amp; variant, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><ins>+    if (variant.isEmpty()) {
+        ec = SYNTAX_ERR;
+        return;
+    }
+
</ins><span class="cx">     auto style = MutableStyleProperties::create();
</span><span class="cx">     auto result = CSSParser::parseValue(style, CSSPropertyFontVariant, variant, true, CSSStrictMode, nullptr);
</span><span class="cx">     if (result == CSSParser::ParseResult::Error) {
</span><span class="lines">@@ -229,6 +255,11 @@
</span><span class="cx"> 
</span><span class="cx"> void FontFace::setFeatureSettings(const String&amp; featureSettings, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><ins>+    if (featureSettings.isEmpty()) {
+        ec = SYNTAX_ERR;
+        return;
+    }
+
</ins><span class="cx">     auto value = parseString(featureSettings, CSSPropertyFontFeatureSettings);
</span><span class="cx">     if (!value) {
</span><span class="cx">         ec = SYNTAX_ERR;
</span></span></pre>
</div>
</div>

</body>
</html>