Diff
Modified: trunk/LayoutTests/ChangeLog (201420 => 201421)
--- trunk/LayoutTests/ChangeLog 2016-05-26 16:24:42 UTC (rev 201420)
+++ trunk/LayoutTests/ChangeLog 2016-05-26 17:08:17 UTC (rev 201421)
@@ -1,3 +1,13 @@
+2016-05-26 Myles C. Maxfield <[email protected]>
+
+ [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.
+
2016-05-26 Adam Bergkvist <[email protected]>
WebRTC: RTCSessionDescription: Make attributes readonly (and remove custom binding)
Added: trunk/LayoutTests/fast/text/font-face-empty-string-expected.txt (0 => 201421)
--- 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)
@@ -0,0 +1,25 @@
+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 "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS fontface = new FontFace('WebFont', 'url(\'asdf\')', {style: ''}) did not throw exception.
+PASS fontface.style is "normal"
+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 "normal"
+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 "U+0-10ffff"
+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 "normal"
+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 "normal"
+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
+
Property changes on: trunk/LayoutTests/fast/text/font-face-empty-string-expected.txt
___________________________________________________________________
Added: svn:keywords
Added: svn:eol-style
Added: trunk/LayoutTests/fast/text/font-face-empty-string.html (0 => 201421)
--- 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)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+description("This test makes sure that constructing a FontFace with empty strings is the same as omitting those strings.");
+
+var fontface;
+shouldNotThrow("fontface = new FontFace('WebFont', 'url(\\\'asdf\\\')', {style: ''})");
+shouldBeEqualToString("fontface.style", "normal");
+shouldThrow("fontface.style = ''");
+shouldNotThrow("fontface = new FontFace('WebFont', 'url(\\\'asdf\\\')', {weight: ''})");
+shouldBeEqualToString("fontface.weight", "normal");
+shouldThrow("fontface.weight = ''");
+shouldNotThrow("fontface = new FontFace('WebFont', 'url(\\\'asdf\\\')', {unicodeRange: ''})");
+shouldBeEqualToString("fontface.unicodeRange", "U+0-10ffff");
+shouldThrow("fontface.unicodeRange = ''");
+shouldNotThrow("fontface = new FontFace('WebFont', 'url(\\\'asdf\\\')', {variant: ''})");
+shouldBeEqualToString("fontface.variant", "normal");
+shouldThrow("fontface.variant = ''");
+shouldNotThrow("fontface = new FontFace('WebFont', 'url(\\\'asdf\\\')', {featureSettings: ''})");
+shouldBeEqualToString("fontface.featureSettings", "normal");
+shouldThrow("fontface.featureSettings = ''");
+
+shouldThrow("fontface.family = ''");
+</script>
+<script src=""
+</body>
+</html>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (201420 => 201421)
--- 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)
@@ -1,3 +1,25 @@
+2016-05-26 Myles C. Maxfield <[email protected]>
+
+ [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):
+
2016-05-26 Adam Bergkvist <[email protected]>
WebRTC: RTCSessionDescription: Make attributes readonly (and remove custom binding)
Modified: trunk/Source/WebCore/css/FontFace.cpp (201420 => 201421)
--- 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)
@@ -70,22 +70,23 @@
dataRequiresAsynchronousLoading = populateFontFaceWithArrayBuffer(result->backing(), arrayBufferView.releaseNonNull());
}
- result->setStyle(descriptors.style, ec);
+ // These ternaries match the default strings inside the FontFaceDescriptors dictionary inside FontFace.idl.
+ result->setStyle(descriptors.style.isEmpty() ? ASCIILiteral("normal") : descriptors.style, ec);
if (ec)
return nullptr;
- result->setWeight(descriptors.weight, ec);
+ result->setWeight(descriptors.weight.isEmpty() ? ASCIILiteral("normal") : descriptors.weight, ec);
if (ec)
return nullptr;
- result->setStretch(descriptors.stretch, ec);
+ result->setStretch(descriptors.stretch.isEmpty() ? ASCIILiteral("normal") : descriptors.stretch, ec);
if (ec)
return nullptr;
- result->setUnicodeRange(descriptors.unicodeRange, ec);
+ result->setUnicodeRange(descriptors.unicodeRange.isEmpty() ? ASCIILiteral("U+0-10FFFF") : descriptors.unicodeRange, ec);
if (ec)
return nullptr;
- result->setVariant(descriptors.variant, ec);
+ result->setVariant(descriptors.variant.isEmpty() ? ASCIILiteral("normal") : descriptors.variant, ec);
if (ec)
return nullptr;
- result->setFeatureSettings(descriptors.featureSettings, ec);
+ result->setFeatureSettings(descriptors.featureSettings.isEmpty() ? ASCIILiteral("normal") : descriptors.featureSettings, ec);
if (ec)
return nullptr;
@@ -136,6 +137,11 @@
void FontFace::setFamily(const String& family, ExceptionCode& ec)
{
+ if (family.isEmpty()) {
+ ec = SYNTAX_ERR;
+ return;
+ }
+
bool success = false;
if (auto value = parseString(family, CSSPropertyFontFamily))
success = m_backing->setFamilies(*value);
@@ -145,6 +151,11 @@
void FontFace::setStyle(const String& style, ExceptionCode& ec)
{
+ if (style.isEmpty()) {
+ ec = SYNTAX_ERR;
+ return;
+ }
+
bool success = false;
if (auto value = parseString(style, CSSPropertyFontStyle))
success = m_backing->setStyle(*value);
@@ -154,6 +165,11 @@
void FontFace::setWeight(const String& weight, ExceptionCode& ec)
{
+ if (weight.isEmpty()) {
+ ec = SYNTAX_ERR;
+ return;
+ }
+
bool success = false;
if (auto value = parseString(weight, CSSPropertyFontWeight))
success = m_backing->setWeight(*value);
@@ -168,6 +184,11 @@
void FontFace::setUnicodeRange(const String& unicodeRange, ExceptionCode& ec)
{
+ if (unicodeRange.isEmpty()) {
+ ec = SYNTAX_ERR;
+ return;
+ }
+
bool success = false;
if (auto value = parseString(unicodeRange, CSSPropertyUnicodeRange))
success = m_backing->setUnicodeRange(*value);
@@ -177,6 +198,11 @@
void FontFace::setVariant(const String& variant, ExceptionCode& ec)
{
+ if (variant.isEmpty()) {
+ ec = SYNTAX_ERR;
+ return;
+ }
+
auto style = MutableStyleProperties::create();
auto result = CSSParser::parseValue(style, CSSPropertyFontVariant, variant, true, CSSStrictMode, nullptr);
if (result == CSSParser::ParseResult::Error) {
@@ -229,6 +255,11 @@
void FontFace::setFeatureSettings(const String& featureSettings, ExceptionCode& ec)
{
+ if (featureSettings.isEmpty()) {
+ ec = SYNTAX_ERR;
+ return;
+ }
+
auto value = parseString(featureSettings, CSSPropertyFontFeatureSettings);
if (!value) {
ec = SYNTAX_ERR;