Diff
Modified: trunk/LayoutTests/ChangeLog (192731 => 192732)
--- trunk/LayoutTests/ChangeLog 2015-11-22 10:48:48 UTC (rev 192731)
+++ trunk/LayoutTests/ChangeLog 2015-11-22 17:06:35 UTC (rev 192732)
@@ -1 +1,11 @@
+2015-11-22 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ Font selection should not consult font-variant property
+ https://bugs.webkit.org/show_bug.cgi?id=151537
+
+ Reviewed by Simon Fraser.
+
+ * fast/text/font-selection-font-variant-expected.html: Added.
+ * fast/text/font-selection-font-variant.html: Added.
+
== Rolled over to ChangeLog-2015-11-21 ==
Added: trunk/LayoutTests/fast/text/font-selection-font-variant-expected.html (0 => 192732)
--- trunk/LayoutTests/fast/text/font-selection-font-variant-expected.html (rev 0)
+++ trunk/LayoutTests/fast/text/font-selection-font-variant-expected.html 2015-11-22 17:06:35 UTC (rev 192732)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+ font-family: "Test1";
+ src: url("../writing-mode/resources/MakibaFont13.ttf") format("truetype");
+}
+@font-face {
+ font-family: "Test2";
+ src: url("../../resources/Ahem.ttf") format("truetype");
+}
+.test {
+ display: inline-block;
+ font-size: 40px;
+}
+</style>
+</head>
+<body>
+<p>This test makes sure that font-variant is not consulted when performing font selection.</p>
+<div class="test" style="font-family: Test2;">Hello</div>
+<div class="test" style="font-family: Test2;">Hello</div>
+<div class="test" style="font-family: Test2; font-variant: small-caps;">Hello</div>
+<div class="test" style="font-family: Test2; font-variant: small-caps;">Hello</div>
+<div class="test" style="font-family: Test2;">Hello</div>
+<div class="test" style="font-family: Test2;">Hello</div>
+<div class="test" style="font-family: Test2; font-variant: small-caps;">Hello</div>
+<div class="test" style="font-family: Test2; font-variant: small-caps;">Hello</div>
+<div class="test" style="font-family: Test1;">Hello</div>
+<div class="test" style="font-family: Test1;">Hello</div>
+<div class="test" style="font-family: Test1; font-variant: small-caps;">Hello</div>
+<div class="test" style="font-family: Test1; font-variant: small-caps;">Hello</div>
+<div class="test" style="font-family: Times;">Hello</div>
+<div class="test" style="font-family: Times; font-variant: small-caps;">Hello</div>
+</body>
+</html>
\ No newline at end of file
Added: trunk/LayoutTests/fast/text/font-selection-font-variant.html (0 => 192732)
--- trunk/LayoutTests/fast/text/font-selection-font-variant.html (rev 0)
+++ trunk/LayoutTests/fast/text/font-selection-font-variant.html 2015-11-22 17:06:35 UTC (rev 192732)
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+ font-family: "Test1";
+ src: url("../writing-mode/resources/MakibaFont13.ttf") format("truetype");
+}
+@font-face {
+ font-family: "Test1";
+ src: url("../../resources/Ahem.ttf") format("truetype");
+ font-variant: small-caps;
+}
+@font-face {
+ font-family: "Test2";
+ src: url("../writing-mode/resources/MakibaFont13.ttf") format("truetype");
+ font-variant: small-caps;
+}
+@font-face {
+ font-family: "Test2";
+ src: url("../../resources/Ahem.ttf") format("truetype");
+}
+@font-face {
+ font-family: "Test3";
+ src: url("../writing-mode/resources/MakibaFont13.ttf") format("truetype");
+}
+@font-face {
+ font-family: "Test3SmallCaps";
+ src: url("../writing-mode/resources/MakibaFont13.ttf") format("truetype");
+ font-variant: small-caps;
+}
+.test {
+ display: inline-block;
+ font-size: 40px;
+}
+</style>
+</head>
+<body>
+<p>This test makes sure that font-variant is not consulted when performing font selection.</p>
+<div class="test" style="font-family: Test1;">Hello</div>
+<div class="test" style="font-family: Test1;">Hello</div>
+<div class="test" style="font-family: Test1; font-variant: small-caps;">Hello</div>
+<div class="test" style="font-family: Test1; font-variant: small-caps;">Hello</div>
+<div class="test" style="font-family: Test2;">Hello</div>
+<div class="test" style="font-family: Test2;">Hello</div>
+<div class="test" style="font-family: Test2; font-variant: small-caps;">Hello</div>
+<div class="test" style="font-family: Test2; font-variant: small-caps;">Hello</div>
+<div class="test" style="font-family: Test3;">Hello</div>
+<div class="test" style="font-family: Test3SmallCaps;">Hello</div>
+<div class="test" style="font-family: Test3; font-variant: small-caps;">Hello</div>
+<div class="test" style="font-family: Test3SmallCaps; font-variant: small-caps;">Hello</div>
+<div class="test" style="font-family: Times;">Hello</div>
+<div class="test" style="font-family: Times; font-variant: small-caps;">Hello</div>
+</body>
+</html>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (192731 => 192732)
--- trunk/Source/WebCore/ChangeLog 2015-11-22 10:48:48 UTC (rev 192731)
+++ trunk/Source/WebCore/ChangeLog 2015-11-22 17:06:35 UTC (rev 192732)
@@ -1,3 +1,43 @@
+2015-11-22 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ Font selection should not consult font-variant property
+ https://bugs.webkit.org/show_bug.cgi?id=151537
+
+ Reviewed by Simon Fraser.
+
+ In section 4.7 of the CSS Fonts Level 3 spec, it says "[The font-variant and
+ font-feature-settings] do not affect font selection."
+
+ All the other browsers (Chrome, Firefox, and Edge) all obey the spec here. We
+ are the only one who misbehaves. This patch aligns our behavior with the other
+ browsers.
+
+ Test: fast/text/font-selection-font-variant.html
+
+ * css/CSSFontSelector.cpp:
+ (WebCore::computeTraitsMask): Deleted.
+ (WebCore::compareFontFaces): Deleted.
+ (WebCore::CSSFontSelector::getFontFace): Deleted.
+ * css/CSSParser.cpp:
+ (WebCore::isValidKeywordPropertyAndValue):
+ (WebCore::isKeywordPropertyID):
+ (WebCore::CSSParser::createFontFaceRule):
+ (WebCore::CSSParser::CSSParser): Deleted.
+ (WebCore::CSSParser::parseValue): Deleted.
+ (WebCore::CSSParser::parseDeclaration): Deleted.
+ (WebCore::CSSParser::clearProperties): Deleted.
+ (WebCore::CSSParser::parseFontVariant): Deleted.
+ (WebCore::CSSParser::createStyleRule): Deleted.
+ (WebCore::CSSParser::deleteFontFaceOnlyValues): Deleted.
+ * css/CSSParser.h:
+ * platform/graphics/FontDescription.cpp:
+ (WebCore::FontDescription::traitsMask): Deleted.
+ * platform/graphics/win/FontCacheWin.cpp:
+ (WebCore::traitsInFamilyEnumProc):
+ * platform/graphics/cocoa/FontCacheCoreText.cpp:
+ (WebCore::toTraitsMask):
+ * platform/text/TextFlags.h:
+
2015-11-22 Carlos Garcia Campos <cgar...@igalia.com>
Unreviewed, rolling out r192727.
Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (192731 => 192732)
--- trunk/Source/WebCore/css/CSSFontSelector.cpp 2015-11-22 10:48:48 UTC (rev 192731)
+++ trunk/Source/WebCore/css/CSSFontSelector.cpp 2015-11-22 17:06:35 UTC (rev 192732)
@@ -149,35 +149,6 @@
} else
traitsMask |= FontWeight400Mask;
- if (RefPtr<CSSValue> fontVariant = style.getPropertyCSSValue(CSSPropertyFontVariant)) {
- // font-variant descriptor can be a value list.
- if (fontVariant->isPrimitiveValue()) {
- RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
- list->append(fontVariant.releaseNonNull());
- fontVariant = list.releaseNonNull();
- } else if (!is<CSSValueList>(*fontVariant))
- return Nullopt;
-
- CSSValueList& variantList = downcast<CSSValueList>(*fontVariant);
- unsigned numVariants = variantList.length();
- if (!numVariants)
- return Nullopt;
-
- for (unsigned i = 0; i < numVariants; ++i) {
- switch (downcast<CSSPrimitiveValue>(variantList.itemWithoutBoundsCheck(i))->getValueID()) {
- case CSSValueNormal:
- traitsMask |= FontVariantNormalMask;
- break;
- case CSSValueSmallCaps:
- traitsMask |= FontVariantSmallCapsMask;
- break;
- default:
- break;
- }
- }
- } else
- traitsMask |= FontVariantMask;
-
return static_cast<FontTraitsMask>(traitsMask);
}
@@ -427,22 +398,6 @@
FontTraitsMask firstTraitsMask = first.traitsMask();
FontTraitsMask secondTraitsMask = second.traitsMask();
- bool firstHasDesiredVariant = firstTraitsMask & desiredTraitsMaskForComparison & FontVariantMask;
- bool secondHasDesiredVariant = secondTraitsMask & desiredTraitsMaskForComparison & FontVariantMask;
-
- if (firstHasDesiredVariant != secondHasDesiredVariant)
- return firstHasDesiredVariant;
-
- // We need to check font-variant css property for CSS2.1 compatibility.
- if ((desiredTraitsMaskForComparison & FontVariantSmallCapsMask) && !first.isLocalFallback() && !second.isLocalFallback()) {
- // Prefer a font that has indicated that it can only support small-caps to a font that claims to support
- // all variants. The specialized font is more likely to be true small-caps and not require synthesis.
- bool firstRequiresSmallCaps = (firstTraitsMask & FontVariantSmallCapsMask) && !(firstTraitsMask & FontVariantNormalMask);
- bool secondRequiresSmallCaps = (secondTraitsMask & FontVariantSmallCapsMask) && !(secondTraitsMask & FontVariantNormalMask);
- if (firstRequiresSmallCaps != secondRequiresSmallCaps)
- return firstRequiresSmallCaps;
- }
-
bool firstHasDesiredStyle = firstTraitsMask & desiredTraitsMaskForComparison & FontStyleMask;
bool secondHasDesiredStyle = secondTraitsMask & desiredTraitsMaskForComparison & FontStyleMask;
@@ -539,14 +494,6 @@
unsigned candidateTraitsMask = candidate.traitsMask();
if ((traitsMask & FontStyleNormalMask) && !(candidateTraitsMask & FontStyleNormalMask))
continue;
- if ((traitsMask & FontVariantNormalMask) && !(candidateTraitsMask & FontVariantNormalMask))
- continue;
-#if ENABLE(SVG_FONTS)
- // For SVG Fonts that specify that they only support the "normal" variant, we will assume they are incapable
- // of small-caps synthesis and just ignore the font face as a candidate.
- if (candidate.hasSVGFontFaceSource() && (traitsMask & FontVariantSmallCapsMask) && !(candidateTraitsMask & FontVariantSmallCapsMask))
- continue;
-#endif
candidateFontFaces.append(candidate);
}
@@ -556,8 +503,6 @@
unsigned candidateTraitsMask = candidate->traitsMask();
if ((traitsMask & FontStyleNormalMask) && !(candidateTraitsMask & FontStyleNormalMask))
continue;
- if ((traitsMask & FontVariantNormalMask) && !(candidateTraitsMask & FontVariantNormalMask))
- continue;
candidateFontFaces.append(candidate);
}
}
Modified: trunk/Source/WebCore/css/CSSParser.cpp (192731 => 192732)
--- trunk/Source/WebCore/css/CSSParser.cpp 2015-11-22 10:48:48 UTC (rev 192731)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2015-11-22 17:06:35 UTC (rev 192732)
@@ -323,7 +323,6 @@
, m_inParseShorthand(0)
, m_currentShorthand(CSSPropertyInvalid)
, m_implicitShorthand(false)
- , m_hasFontFaceOnlyValues(false)
, m_hadSyntacticallyValidCSSRule(false)
, m_logErrors(false)
, m_ignoreErrorsInDeclaration(false)
@@ -1064,6 +1063,10 @@
if (valueID == CSSValueNormal || valueID == CSSValueHistoricalForms)
return true;
break;
+ case CSSPropertyFontVariant: // normal | small-caps
+ if (valueID == CSSValueNormal || valueID == CSSValueSmallCaps)
+ return true;
+ break;
default:
ASSERT_NOT_REACHED();
return false;
@@ -1196,6 +1199,7 @@
case CSSPropertyFontVariantPosition:
case CSSPropertyFontVariantCaps:
case CSSPropertyFontVariantAlternates:
+ case CSSPropertyFontVariant:
return true;
default:
return false;
@@ -1400,8 +1404,6 @@
m_rule = nullptr;
ParseResult result = ParseResult::Error;
- if (m_hasFontFaceOnlyValues)
- deleteFontFaceOnlyValues();
if (!m_parsedProperties.isEmpty()) {
result = declaration->addParsedProperties(m_parsedProperties) ? ParseResult::Changed : ParseResult::Unchanged;
@@ -1494,9 +1496,6 @@
cssyyparse(this);
m_rule = nullptr;
- if (m_hasFontFaceOnlyValues)
- deleteFontFaceOnlyValues();
-
Ref<ImmutableStyleProperties> style = createStyleProperties();
clearProperties();
return style;
@@ -1521,8 +1520,6 @@
m_rule = nullptr;
bool ok = false;
- if (m_hasFontFaceOnlyValues)
- deleteFontFaceOnlyValues();
if (!m_parsedProperties.isEmpty()) {
ok = true;
declaration->addParsedProperties(m_parsedProperties);
@@ -1699,7 +1696,6 @@
{
m_parsedProperties.clear();
m_numParsedPropertiesBeforeMarginBox = INVALID_NUM_PARSED_PROPERTIES;
- m_hasFontFaceOnlyValues = false;
}
URL CSSParser::completeURL(const CSSParserContext& context, const String& url)
@@ -2371,9 +2367,6 @@
case CSSPropertyFontSize:
return parseFontSize(important);
- case CSSPropertyFontVariant: // normal | small-caps | inherit
- return parseFontVariant(important);
-
case CSSPropertyVerticalAlign:
// baseline | sub | super | top | text-top | middle | bottom | text-bottom |
// <percentage> | <length> | inherit
@@ -7034,53 +7027,6 @@
return validPrimitive;
}
-bool CSSParser::parseFontVariant(bool important)
-{
- RefPtr<CSSValueList> values;
- if (m_valueList->size() > 1)
- values = CSSValueList::createCommaSeparated();
- CSSParserValue* val;
- bool expectComma = false;
- while ((val = m_valueList->current())) {
- RefPtr<CSSPrimitiveValue> parsedValue;
- if (!expectComma) {
- expectComma = true;
- if (val->id == CSSValueNormal || val->id == CSSValueSmallCaps)
- parsedValue = CSSValuePool::singleton().createIdentifierValue(val->id);
- else if (val->id == CSSValueAll && !values) {
- // 'all' is only allowed in @font-face and with no other values. Make a value list to
- // indicate that we are in the @font-face case.
- values = CSSValueList::createCommaSeparated();
- parsedValue = CSSValuePool::singleton().createIdentifierValue(val->id);
- }
- } else if (val->unit == CSSParserValue::Operator && val->iValue == ',') {
- expectComma = false;
- m_valueList->next();
- continue;
- }
-
- if (!parsedValue)
- return false;
-
- m_valueList->next();
-
- if (values)
- values->append(parsedValue.releaseNonNull());
- else {
- addProperty(CSSPropertyFontVariant, parsedValue.release(), important);
- return true;
- }
- }
-
- if (values && values->length()) {
- m_hasFontFaceOnlyValues = true;
- addProperty(CSSPropertyFontVariant, values.release(), important);
- return true;
- }
-
- return false;
-}
-
static CSSValueID createFontWeightValueKeyword(int weight)
{
ASSERT(!(weight % 100) && weight >= 100 && weight <= 900);
@@ -12642,8 +12588,6 @@
if (selectors) {
m_allowImportRules = false;
m_allowNamespaceDeclarations = false;
- if (m_hasFontFaceOnlyValues)
- deleteFontFaceOnlyValues();
rule = StyleRule::create(m_lastSelectorLineNumber, createStyleProperties());
rule->parserAdoptSelectorVector(*selectors);
processAndAddNewRuleToSourceTreeIfNeeded();
@@ -12658,9 +12602,7 @@
m_allowImportRules = m_allowNamespaceDeclarations = false;
for (unsigned i = 0; i < m_parsedProperties.size(); ++i) {
CSSProperty& property = m_parsedProperties[i];
- if (property.id() == CSSPropertyFontVariant && property.value()->isPrimitiveValue())
- property.wrapValueInCommaSeparatedList();
- else if (property.id() == CSSPropertyFontFamily && (!is<CSSValueList>(*property.value()) || downcast<CSSValueList>(*property.value()).length() != 1)) {
+ if (property.id() == CSSPropertyFontFamily && (!is<CSSValueList>(*property.value()) || downcast<CSSValueList>(*property.value()).length() != 1)) {
// Unlike font-family property, font-family descriptor in @font-face rule
// has to be a value list with exactly one family name. It cannot have a
// have 'initial' value and cannot 'inherit' from parent.
@@ -12818,14 +12760,6 @@
m_numParsedPropertiesBeforeMarginBox = INVALID_NUM_PARSED_PROPERTIES;
}
-void CSSParser::deleteFontFaceOnlyValues()
-{
- ASSERT(m_hasFontFaceOnlyValues);
- m_parsedProperties.removeAllMatching([] (const CSSProperty& property) {
- return property.id() == CSSPropertyFontVariant && property.value()->isValueList();
- });
-}
-
RefPtr<StyleKeyframe> CSSParser::createKeyframe(CSSParserValueList& keys)
{
// Create a key string from the passed keys
Modified: trunk/Source/WebCore/css/CSSParser.h (192731 => 192732)
--- trunk/Source/WebCore/css/CSSParser.h 2015-11-22 10:48:48 UTC (rev 192731)
+++ trunk/Source/WebCore/css/CSSParser.h 2015-11-22 17:06:35 UTC (rev 192732)
@@ -265,7 +265,6 @@
bool parseLineHeight(bool important);
bool parseFontSize(bool important);
- bool parseFontVariant(bool important);
bool parseFontWeight(bool important);
bool parseFontSynthesis(bool important);
bool parseFontFaceSrc();
@@ -417,7 +416,6 @@
CSSPropertyID m_currentShorthand;
bool m_implicitShorthand;
- bool m_hasFontFaceOnlyValues;
bool m_hadSyntacticallyValidCSSRule;
bool m_logErrors;
bool m_ignoreErrorsInDeclaration;
@@ -565,8 +563,6 @@
bool isValidSize(ValueWithCalculation&);
- void deleteFontFaceOnlyValues();
-
bool isGeneratedImageValue(CSSParserValue&) const;
bool parseGeneratedImage(CSSParserValueList&, RefPtr<CSSValue>&);
Modified: trunk/Source/WebCore/platform/graphics/FontDescription.cpp (192731 => 192732)
--- trunk/Source/WebCore/platform/graphics/FontDescription.cpp 2015-11-22 10:48:48 UTC (rev 192731)
+++ trunk/Source/WebCore/platform/graphics/FontDescription.cpp 2015-11-22 17:06:35 UTC (rev 192732)
@@ -79,7 +79,6 @@
FontTraitsMask FontDescription::traitsMask() const
{
return static_cast<FontTraitsMask>((m_italic ? FontStyleItalicMask : FontStyleNormalMask)
- | (m_smallCaps ? FontVariantSmallCapsMask : FontVariantNormalMask)
| (FontWeight100Mask << (m_weight - FontWeight100)));
}
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (192731 => 192732)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2015-11-22 10:48:48 UTC (rev 192731)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2015-11-22 17:06:35 UTC (rev 192732)
@@ -476,8 +476,7 @@
weightMask = FontWeight900Mask;
break;
}
- return static_cast<FontTraitsMask>(((ctFontTraits & kCTFontTraitItalic) ? FontStyleItalicMask : FontStyleNormalMask)
- | FontVariantNormalMask | weightMask);
+ return static_cast<FontTraitsMask>(((ctFontTraits & kCTFontTraitItalic) ? FontStyleItalicMask : FontStyleNormalMask) | weightMask);
}
bool isFontWeightBold(FontWeight fontWeight)
Modified: trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp (192731 => 192732)
--- trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp 2015-11-22 10:48:48 UTC (rev 192731)
+++ trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp 2015-11-22 17:06:35 UTC (rev 192732)
@@ -528,7 +528,6 @@
unsigned traitsMask = 0;
traitsMask |= logFont->lfItalic ? FontStyleItalicMask : FontStyleNormalMask;
- traitsMask |= FontVariantNormalMask;
LONG weight = adjustedGDIFontWeight(logFont->lfWeight, procData->m_familyName);
traitsMask |= weight == FW_THIN ? FontWeight100Mask :
weight == FW_EXTRALIGHT ? FontWeight200Mask :
Modified: trunk/Source/WebCore/platform/text/TextFlags.h (192731 => 192732)
--- trunk/Source/WebCore/platform/text/TextFlags.h 2015-11-22 10:48:48 UTC (rev 192731)
+++ trunk/Source/WebCore/platform/text/TextFlags.h 2015-11-22 17:06:35 UTC (rev 192732)
@@ -277,8 +277,6 @@
enum {
FontStyleNormalBit = 0,
FontStyleItalicBit,
- FontVariantNormalBit,
- FontVariantSmallCapsBit,
FontWeight100Bit,
FontWeight200Bit,
FontWeight300Bit,
@@ -296,10 +294,6 @@
FontStyleItalicMask = 1 << FontStyleItalicBit,
FontStyleMask = FontStyleNormalMask | FontStyleItalicMask,
- FontVariantNormalMask = 1 << FontVariantNormalBit,
- FontVariantSmallCapsMask = 1 << FontVariantSmallCapsBit,
- FontVariantMask = FontVariantNormalMask | FontVariantSmallCapsMask,
-
FontWeight100Mask = 1 << FontWeight100Bit,
FontWeight200Mask = 1 << FontWeight200Bit,
FontWeight300Mask = 1 << FontWeight300Bit,