Diff
Modified: trunk/LayoutTests/ChangeLog (220724 => 220725)
--- trunk/LayoutTests/ChangeLog 2017-08-14 23:37:06 UTC (rev 220724)
+++ trunk/LayoutTests/ChangeLog 2017-08-15 00:03:56 UTC (rev 220725)
@@ -1,3 +1,13 @@
+2017-08-14 Myles C. Maxfield <[email protected]>
+
+ Parse font-display
+ https://bugs.webkit.org/show_bug.cgi?id=175382
+
+ Reviewed by Simon Fraser.
+
+ * fast/text/font-display/parse-expected.txt: Added.
+ * fast/text/font-display/parse.html: Added.
+
2017-08-14 Andy Estes <[email protected]>
[Apple Pay] Add support for phonetic contact names
Added: trunk/LayoutTests/fast/text/font-display/parse-expected.txt (0 => 220725)
--- trunk/LayoutTests/fast/text/font-display/parse-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/text/font-display/parse-expected.txt 2017-08-15 00:03:56 UTC (rev 220725)
@@ -0,0 +1,19 @@
+This test makes sure that the font-display descriptor in @font-face is appropriately parsed.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS sheet.rules[0].style.getPropertyValue('font-display') is ""
+PASS sheet.rules[1].style.getPropertyValue('font-display') is ""
+PASS sheet.rules[2].style.getPropertyValue('font-display') is ""
+PASS sheet.rules[3].style.getPropertyValue('font-display') is "auto"
+PASS sheet.rules[4].style.getPropertyValue('font-display') is "block"
+PASS sheet.rules[5].style.getPropertyValue('font-display') is "swap"
+PASS sheet.rules[6].style.getPropertyValue('font-display') is "fallback"
+PASS sheet.rules[7].style.getPropertyValue('font-display') is "optional"
+PASS sheet.rules[8].style.getPropertyValue('font-display') is ""
+PASS window.getComputedStyle(document.getElementById('test9')).getPropertyValue('font-display') is ""
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/text/font-display/parse.html (0 => 220725)
--- trunk/LayoutTests/fast/text/font-display/parse.html (rev 0)
+++ trunk/LayoutTests/fast/text/font-display/parse.html 2017-08-15 00:03:56 UTC (rev 220725)
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<style id="style">
+@font-face {
+ font-family: "Test0";
+ src: local("Times");
+ font-display: garbage;
+}
+@font-face {
+ font-family: "Test1";
+ src: local("Times");
+}
+@font-face {
+ font-family: "Test2";
+ src: local("Times");
+ font-display: block swap;
+}
+@font-face {
+ font-family: "Test3";
+ src: local("Times");
+ font-display: auto;
+}
+@font-face {
+ font-family: "Test4";
+ src: local("Times");
+ font-display: block;
+}
+@font-face {
+ font-family: "Test5";
+ src: local("Times");
+ font-display: swap;
+}
+@font-face {
+ font-family: "Test6";
+ src: local("Times");
+ font-display: fallback;
+}
+@font-face {
+ font-family: "Test7";
+ src: local("Times");
+ font-display: optional;
+}
+@font-face {
+ font-family: "Test8";
+ src: local("Times");
+ font-display: ;
+}
+</style>
+</head>
+<body>
+<div id="test9" style="font-display: block"></div>
+<script>
+description("This test makes sure that the font-display descriptor in @font-face is appropriately parsed.");
+
+var sheet = document.getElementById("style").sheet;
+shouldBeEqualToString("sheet.rules[0].style.getPropertyValue('font-display')", "");
+shouldBeEqualToString("sheet.rules[1].style.getPropertyValue('font-display')", "");
+shouldBeEqualToString("sheet.rules[2].style.getPropertyValue('font-display')", "");
+shouldBeEqualToString("sheet.rules[3].style.getPropertyValue('font-display')", "auto");
+shouldBeEqualToString("sheet.rules[4].style.getPropertyValue('font-display')", "block");
+shouldBeEqualToString("sheet.rules[5].style.getPropertyValue('font-display')", "swap");
+shouldBeEqualToString("sheet.rules[6].style.getPropertyValue('font-display')", "fallback");
+shouldBeEqualToString("sheet.rules[7].style.getPropertyValue('font-display')", "optional");
+shouldBeEqualToString("sheet.rules[8].style.getPropertyValue('font-display')", "");
+shouldBeEqualToString("window.getComputedStyle(document.getElementById('test9')).getPropertyValue('font-display')", "");
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (220724 => 220725)
--- trunk/Source/WebCore/ChangeLog 2017-08-14 23:37:06 UTC (rev 220724)
+++ trunk/Source/WebCore/ChangeLog 2017-08-15 00:03:56 UTC (rev 220725)
@@ -1,3 +1,34 @@
+2017-08-14 Myles C. Maxfield <[email protected]>
+
+ Parse font-display
+ https://bugs.webkit.org/show_bug.cgi?id=175382
+
+ Reviewed by Simon Fraser.
+
+ The syntax is very simple: font-display: auto | block | swap | fallback | optional.
+ So, parsing support is quite straightfoward.
+
+ Test: fast/text/font-display/parse.html
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::ComputedStyleExtractor::propertyValue):
+ * css/CSSFontFace.cpp:
+ (WebCore::CSSFontFace::setLoadingBehavior):
+ * css/CSSFontFace.h:
+ * css/CSSFontSelector.cpp:
+ (WebCore::CSSFontSelector::addFontFaceRule):
+ * css/CSSPrimitiveValueMappings.h:
+ (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+ (WebCore::CSSPrimitiveValue::operator FontLoadingBehavior const):
+ * css/CSSProperties.json:
+ * css/CSSProperty.cpp:
+ (WebCore::CSSProperty::isDescriptorOnly):
+ * css/CSSValueKeywords.in:
+ * css/parser/CSSPropertyParser.cpp:
+ (WebCore::consumeFontFaceFontDisplay):
+ (WebCore::CSSPropertyParser::parseFontFaceDescriptor):
+ * rendering/style/RenderStyleConstants.h:
+
2017-08-14 Jer Noble <[email protected]>
Obj-C exception crash in AVStreamSession when using EME in Private Browsing mode
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (220724 => 220725)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2017-08-14 23:37:06 UTC (rev 220724)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2017-08-15 00:03:56 UTC (rev 220725)
@@ -4018,6 +4018,7 @@
/* Unimplemented @font-face properties */
case CSSPropertySrc:
case CSSPropertyUnicodeRange:
+ case CSSPropertyFontDisplay:
break;
/* Other unimplemented properties */
Modified: trunk/Source/WebCore/css/CSSFontFace.cpp (220724 => 220725)
--- trunk/Source/WebCore/css/CSSFontFace.cpp 2017-08-14 23:37:06 UTC (rev 220724)
+++ trunk/Source/WebCore/css/CSSFontFace.cpp 2017-08-15 00:03:56 UTC (rev 220725)
@@ -149,6 +149,9 @@
void CSSFontFace::setWeight(CSSValue& weight)
{
auto range = calculateWeightRange(weight);
+ if (m_fontSelectionCapabilities.weight == range)
+ return;
+
setWeight(range);
if (m_cssConnection)
@@ -184,6 +187,9 @@
void CSSFontFace::setStretch(CSSValue& style)
{
auto range = calculateStretchRange(style);
+ if (m_fontSelectionCapabilities.width == range)
+ return;
+
setStretch(range);
if (m_cssConnection)
@@ -229,6 +235,9 @@
void CSSFontFace::setStyle(CSSValue& style)
{
auto range = calculateItalicRange(style);
+ if (m_fontSelectionCapabilities.slope == range)
+ return;
+
setStyle(range);
if (m_cssConnection)
@@ -244,13 +253,27 @@
if (!is<CSSValueList>(unicodeRange))
return false;
- m_ranges.clear();
+ Vector<UnicodeRange> ranges;
auto& list = downcast<CSSValueList>(unicodeRange);
for (auto& rangeValue : list) {
auto& range = downcast<CSSUnicodeRangeValue>(rangeValue.get());
- m_ranges.append({ range.from(), range.to() });
+ ranges.append({ range.from(), range.to() });
}
+ if (ranges.size() == m_ranges.size()) {
+ bool same = true;
+ for (size_t i = 0; i < ranges.size(); ++i) {
+ if (ranges[i] != m_ranges[i]) {
+ same = false;
+ break;
+ }
+ }
+ if (same)
+ return true;
+ }
+
+ m_ranges = WTFMove(ranges);
+
if (m_cssConnection)
m_cssConnection->mutableProperties().setProperty(CSSPropertyUnicodeRange, &unicodeRange);
@@ -265,6 +288,12 @@
{
auto ligatures = extractFontVariantLigatures(variantLigatures);
+ if (m_variantSettings.commonLigatures == ligatures.commonLigatures
+ && m_variantSettings.discretionaryLigatures == ligatures.discretionaryLigatures
+ && m_variantSettings.historicalLigatures == ligatures.historicalLigatures
+ && m_variantSettings.contextualAlternates == ligatures.contextualAlternates)
+ return true;
+
m_variantSettings.commonLigatures = ligatures.commonLigatures;
m_variantSettings.discretionaryLigatures = ligatures.discretionaryLigatures;
m_variantSettings.historicalLigatures = ligatures.historicalLigatures;
@@ -285,8 +314,13 @@
if (!is<CSSPrimitiveValue>(variantPosition))
return false;
- m_variantSettings.position = downcast<CSSPrimitiveValue>(variantPosition);
+ FontVariantPosition position = downcast<CSSPrimitiveValue>(variantPosition);
+ if (m_variantSettings.position == position)
+ return true;
+
+ m_variantSettings.position = position;
+
if (m_cssConnection)
m_cssConnection->mutableProperties().setProperty(CSSPropertyFontVariantPosition, &variantPosition);
@@ -302,8 +336,13 @@
if (!is<CSSPrimitiveValue>(variantCaps))
return false;
- m_variantSettings.caps = downcast<CSSPrimitiveValue>(variantCaps);
+ FontVariantCaps caps = downcast<CSSPrimitiveValue>(variantCaps);
+ if (m_variantSettings.caps == caps)
+ return true;
+
+ m_variantSettings.caps = caps;
+
if (m_cssConnection)
m_cssConnection->mutableProperties().setProperty(CSSPropertyFontVariantCaps, &variantCaps);
@@ -318,6 +357,13 @@
{
auto numeric = extractFontVariantNumeric(variantNumeric);
+ if (m_variantSettings.numericFigure == numeric.figure
+ && m_variantSettings.numericSpacing == numeric.spacing
+ && m_variantSettings.numericFraction == numeric.fraction
+ && m_variantSettings.numericOrdinal == numeric.ordinal
+ && m_variantSettings.numericSlashedZero == numeric.slashedZero)
+ return true;
+
m_variantSettings.numericFigure = numeric.figure;
m_variantSettings.numericSpacing = numeric.spacing;
m_variantSettings.numericFraction = numeric.fraction;
@@ -339,8 +385,13 @@
if (!is<CSSPrimitiveValue>(variantAlternates))
return false;
- m_variantSettings.alternates = downcast<CSSPrimitiveValue>(variantAlternates);
+ FontVariantAlternates alternates = downcast<CSSPrimitiveValue>(variantAlternates);
+ if (m_variantSettings.alternates == alternates)
+ return true;
+
+ m_variantSettings.alternates = alternates;
+
if (m_cssConnection)
m_cssConnection->mutableProperties().setProperty(CSSPropertyFontVariantAlternates, &variantAlternates);
@@ -355,6 +406,11 @@
{
auto eastAsian = extractFontVariantEastAsian(variantEastAsian);
+ if (m_variantSettings.eastAsianVariant == eastAsian.variant
+ && m_variantSettings.eastAsianWidth == eastAsian.width
+ && m_variantSettings.eastAsianRuby == eastAsian.ruby)
+ return true;
+
m_variantSettings.eastAsianVariant = eastAsian.variant;
m_variantSettings.eastAsianWidth = eastAsian.width;
m_variantSettings.eastAsianRuby = eastAsian.ruby;
@@ -397,6 +453,23 @@
});
}
+void CSSFontFace::setLoadingBehavior(CSSValue& loadingBehaviorValue)
+{
+ auto loadingBehavior = static_cast<FontLoadingBehavior>(downcast<CSSPrimitiveValue>(loadingBehaviorValue).valueID());
+
+ if (m_loadingBehavior == loadingBehavior)
+ return;
+
+ m_loadingBehavior = loadingBehavior;
+
+ if (m_cssConnection)
+ m_cssConnection->mutableProperties().setProperty(CSSPropertyFontDisplay, &loadingBehaviorValue);
+
+ iterateClients(m_clients, [&](Client& client) {
+ client.fontPropertyChanged(*this);
+ });
+}
+
bool CSSFontFace::rangesMatchCodePoint(UChar32 character) const
{
if (m_ranges.isEmpty())
Modified: trunk/Source/WebCore/css/CSSFontFace.h (220724 => 220725)
--- trunk/Source/WebCore/css/CSSFontFace.h 2017-08-14 23:37:06 UTC (rev 220724)
+++ trunk/Source/WebCore/css/CSSFontFace.h 2017-08-15 00:03:56 UTC (rev 220725)
@@ -76,6 +76,7 @@
bool setVariantAlternates(CSSValue&);
bool setVariantEastAsian(CSSValue&);
void setFeatureSettings(CSSValue&);
+ void setLoadingBehavior(CSSValue&);
enum class Status;
struct UnicodeRange;
@@ -137,6 +138,8 @@
struct UnicodeRange {
UChar32 from;
UChar32 to;
+ bool operator==(const UnicodeRange& other) const { return from == other.from && to == other.to; }
+ bool operator!=(const UnicodeRange& other) const { return !(*this == other); }
};
bool rangesMatchCodePoint(UChar32) const;
@@ -179,6 +182,7 @@
HashSet<Client*> m_clients;
WeakPtr<FontFace> m_wrapper;
FontSelectionSpecifiedCapabilities m_fontSelectionCapabilities;
+ FontLoadingBehavior m_loadingBehavior { FontLoadingBehavior::Auto };
Status m_status { Status::Pending };
bool m_isLocalFallback { false };
bool m_sourcesPopulated { false };
Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (220724 => 220725)
--- trunk/Source/WebCore/css/CSSFontSelector.cpp 2017-08-14 23:37:06 UTC (rev 220724)
+++ trunk/Source/WebCore/css/CSSFontSelector.cpp 2017-08-15 00:03:56 UTC (rev 220725)
@@ -157,6 +157,7 @@
RefPtr<CSSValue> variantNumeric = style.getPropertyCSSValue(CSSPropertyFontVariantNumeric);
RefPtr<CSSValue> variantAlternates = style.getPropertyCSSValue(CSSPropertyFontVariantAlternates);
RefPtr<CSSValue> variantEastAsian = style.getPropertyCSSValue(CSSPropertyFontVariantEastAsian);
+ RefPtr<CSSValue> loadingBehavior = style.getPropertyCSSValue(CSSPropertyFontDisplay);
if (!is<CSSValueList>(fontFamily.get()) || !is<CSSValueList>(src.get()) || (unicodeRange && !is<CSSValueList>(*unicodeRange)))
return;
@@ -197,6 +198,8 @@
return;
if (featureSettings)
fontFace->setFeatureSettings(*featureSettings);
+ if (loadingBehavior)
+ fontFace->setLoadingBehavior(*loadingBehavior);
CSSFontFace::appendSources(fontFace, srcList, m_document, isInitiatingElementInUserAgentShadowTree);
if (fontFace->allSourcesFailed())
Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (220724 => 220725)
--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h 2017-08-14 23:37:06 UTC (rev 220724)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h 2017-08-15 00:03:56 UTC (rev 220725)
@@ -5697,4 +5697,57 @@
return FontOpticalSizing::Enabled;
}
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontLoadingBehavior behavior)
+ : CSSValue(PrimitiveClass)
+{
+ m_primitiveUnitType = CSS_VALUE_ID;
+ switch (behavior) {
+ case FontLoadingBehavior::Auto:
+ m_value.valueID = CSSValueAuto;
+ break;
+ case FontLoadingBehavior::Block:
+ m_value.valueID = CSSValueBlock;
+ break;
+ case FontLoadingBehavior::Swap:
+ m_value.valueID = CSSValueSwap;
+ break;
+ case FontLoadingBehavior::Fallback:
+ m_value.valueID = CSSValueFallback;
+ break;
+ case FontLoadingBehavior::Optional:
+ m_value.valueID = CSSValueOptional;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
}
+
+template<> inline CSSPrimitiveValue::operator FontLoadingBehavior() const
+{
+ ASSERT(isValueID());
+ switch (m_value.valueID) {
+ case CSSValueAuto:
+ return FontLoadingBehavior::Auto;
+ case CSSValueBlock:
+ return FontLoadingBehavior::Block;
+ case CSSValueSwap:
+ return FontLoadingBehavior::Swap;
+ case CSSValueFallback:
+ return FontLoadingBehavior::Fallback;
+ case CSSValueOptional:
+ return FontLoadingBehavior::Optional;
+ default:
+ break;
+ }
+ ASSERT_NOT_REACHED();
+ return FontLoadingBehavior::Auto;
+}
+
+/*
+enum class FontLoadingBehavior {
+ Auto, Block, Swap, Fallback, Optional
+};
+*/
+
+}
Modified: trunk/Source/WebCore/css/CSSProperties.json (220724 => 220725)
--- trunk/Source/WebCore/css/CSSProperties.json 2017-08-14 23:37:06 UTC (rev 220724)
+++ trunk/Source/WebCore/css/CSSProperties.json 2017-08-15 00:03:56 UTC (rev 220725)
@@ -407,8 +407,8 @@
"enable-if": "ENABLE_VARIATION_FONTS"
},
"specification": {
- "category": "css-fonts",
- "url": "https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control-the-font-variation-settings-property"
+ "category": "css-fonts-4",
+ "url": "https://drafts.csswg.org/css-fonts-4/#font-variation-settings-def"
}
},
"-webkit-font-kerning": {
@@ -567,8 +567,8 @@
"enable-if": "ENABLE_VARIATION_FONTS"
},
"specification": {
- "category": "css-fonts",
- "url": "https://drafts.csswg.org/css-fonts-4/#optical-sizing-control-the-font-optical-sizing-property"
+ "category": "css-fonts-4",
+ "url": "https://drafts.csswg.org/css-fonts-4/#font-optical-sizing-def"
}
},
"font": {
@@ -3551,6 +3551,22 @@
"url": "https://www.w3.org/TR/css-fonts-3/#descdef-unicode-range"
}
},
+ "font-display": {
+ "codegen-properties": {
+ "skip-builder": true
+ },
+ "specification": {
+ "category": "css-fonts-4",
+ "url": "https://drafts.csswg.org/css-fonts-4/#font-display-desc"
+ },
+ "values": [
+ "auto",
+ "block",
+ "swap",
+ "fallback",
+ "optional"
+ ]
+ },
"vector-effect": {
"values": [
"none",
@@ -6752,6 +6768,11 @@
"longname": "CSS Fonts Module",
"url": "https://www.w3.org/TR/css-fonts-3/"
},
+ "css-fonts-4": {
+ "shortname": "CSS Fonts Level 4",
+ "longname": "CSS Fonts Module Level 4",
+ "url": "https://drafts.csswg.org/css-fonts-4"
+ },
"css-grid": {
"shortname": "CSS Grid Layout",
"longname": "CSS Grid Layout Module",
Modified: trunk/Source/WebCore/css/CSSProperty.cpp (220724 => 220725)
--- trunk/Source/WebCore/css/CSSProperty.cpp 2017-08-14 23:37:06 UTC (rev 220724)
+++ trunk/Source/WebCore/css/CSSProperty.cpp 2017-08-15 00:03:56 UTC (rev 220725)
@@ -164,6 +164,7 @@
#endif
case CSSPropertySrc:
case CSSPropertyUnicodeRange:
+ case CSSPropertyFontDisplay:
return true;
default:
return false;
Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (220724 => 220725)
--- trunk/Source/WebCore/css/CSSValueKeywords.in 2017-08-14 23:37:06 UTC (rev 220724)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in 2017-08-15 00:03:56 UTC (rev 220725)
@@ -1347,3 +1347,10 @@
// auto-repeat
auto-fill
auto-fit
+
+// font-display
+// auto
+// block
+swap
+fallback
+optional
Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (220724 => 220725)
--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp 2017-08-14 23:37:06 UTC (rev 220724)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp 2017-08-15 00:03:56 UTC (rev 220725)
@@ -4304,6 +4304,11 @@
return values;
}
+static RefPtr<CSSPrimitiveValue> consumeFontFaceFontDisplay(CSSParserTokenRange& range)
+{
+ return consumeIdent<CSSValueAuto, CSSValueBlock, CSSValueSwap, CSSValueFallback, CSSValueOptional>(range);
+}
+
static RefPtr<CSSValue> consumeFontFaceSrcURI(CSSParserTokenRange& range, const CSSParserContext& context)
{
String url = ""
@@ -4377,6 +4382,9 @@
case CSSPropertyUnicodeRange:
parsedValue = consumeFontFaceUnicodeRange(m_range);
break;
+ case CSSPropertyFontDisplay:
+ parsedValue = consumeFontFaceFontDisplay(m_range);
+ break;
case CSSPropertyFontWeight:
#if ENABLE(VARIATION_FONTS)
parsedValue = consumeFontWeightRange(m_range);
Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.h (220724 => 220725)
--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.h 2017-08-14 23:37:06 UTC (rev 220724)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.h 2017-08-15 00:03:56 UTC (rev 220725)
@@ -753,6 +753,10 @@
Markers
};
+enum class FontLoadingBehavior {
+ Auto, Block, Swap, Fallback, Optional
+};
+
extern const float defaultMiterLimit;
} // namespace WebCore