Commit 885faa47 authored by jbroman@chromium.org's avatar jbroman@chromium.org

Explicitly compare FontVariant to enumerators.

It's a little opaque to say "if (fontDescription.variant())".

Review URL: https://codereview.chromium.org/343813002

git-svn-id: svn://svn.chromium.org/blink/trunk@176472 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent d70d30ba
......@@ -713,7 +713,7 @@ ALWAYS_INLINE float RenderText::widthFromCache(const Font& f, int start, int len
return combineText->combinedTextWidth(f);
}
if (f.isFixedPitch() && !f.fontDescription().variant() && m_isAllASCII && (!glyphOverflow || !glyphOverflow->computeBounds)) {
if (f.isFixedPitch() && f.fontDescription().variant() == FontVariantNormal && m_isAllASCII && (!glyphOverflow || !glyphOverflow->computeBounds)) {
float monospaceCharacterWidth = f.spaceWidth();
float w = 0;
bool isSpace;
......
......@@ -396,7 +396,7 @@ std::pair<GlyphData, GlyphPage*> Font::glyphDataAndPageForCharacter(UChar32 c, b
ASSERT(isMainThread());
if (variant == AutoVariant) {
if (m_fontDescription.variant() && !primaryFont()->isSVGFont()) {
if (m_fontDescription.variant() == FontVariantSmallCaps && !primaryFont()->isSVGFont()) {
UChar32 upperC = toUpper(c);
if (upperC != c) {
c = upperC;
......
......@@ -184,9 +184,10 @@ inline unsigned WidthIterator::advanceInternal(TextIterator& textIterator, Glyph
if (m_fallbackFonts && fontData != primaryFont) {
// FIXME: This does a little extra work that could be avoided if
// glyphDataForCharacter() returned whether it chose to use a small caps font.
if (!m_font->fontDescription().variant() || character == toUpper(character))
if (m_font->fontDescription().variant() == FontVariantNormal || character == toUpper(character))
m_fallbackFonts->add(fontData);
else {
ASSERT(m_font->fontDescription().variant() == FontVariantSmallCaps);
const GlyphData& uppercaseGlyphData = m_font->glyphDataForCharacter(toUpper(character), rtl);
if (uppercaseGlyphData.fontData != primaryFont)
m_fallbackFonts->add(uppercaseGlyphData.fontData);
......
......@@ -841,7 +841,7 @@ bool HarfBuzzShaper::shapeHarfBuzzRuns()
static const uint16_t preContext = ' ';
hb_buffer_add_utf16(harfBuzzBuffer.get(), &preContext, 1, 1, 0);
if (fontDescription.variant() && u_islower(m_normalizedBuffer[currentRun->startIndex()])) {
if (fontDescription.variant() == FontVariantSmallCaps && u_islower(m_normalizedBuffer[currentRun->startIndex()])) {
String upperText = String(m_normalizedBuffer.get() + currentRun->startIndex(), currentRun->numCharacters()).upper();
ASSERT(!upperText.is8Bit()); // m_normalizedBuffer is 16 bit, therefore upperText is 16 bit, even after we call makeUpper().
hb_buffer_add_utf16(harfBuzzBuffer.get(), toUint16(upperText.characters16()), currentRun->numCharacters(), 0, currentRun->numCharacters());
......
......@@ -244,7 +244,7 @@ void ComplexTextController::collectComplexTextRuns()
} else
cp = m_run.characters16();
if (m_font.fontDescription().variant())
if (m_font.fontDescription().variant() == FontVariantSmallCaps)
m_smallCapsBuffer.resize(m_end);
unsigned indexOfFontTransition = 0;
......@@ -265,7 +265,7 @@ void ComplexTextController::collectComplexTextRuns()
UChar uppercaseCharacter = 0;
bool isSmallCaps;
bool nextIsSmallCaps = m_font.fontDescription().variant() && !(U_GET_GC_MASK(baseCharacter) & U_GC_M_MASK) && (uppercaseCharacter = u_toupper(baseCharacter)) != baseCharacter;
bool nextIsSmallCaps = m_font.fontDescription().variant() == FontVariantSmallCaps && !(U_GET_GC_MASK(baseCharacter) & U_GC_M_MASK) && (uppercaseCharacter = u_toupper(baseCharacter)) != baseCharacter;
if (nextIsSmallCaps) {
m_smallCapsBuffer[sequenceStart - cp] = uppercaseCharacter;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment