Source/core/css/resolver/FontBuilder.cpp
// FIXME: I am not convinced FontBuilder needs to know anything about CSSValues.
I am not convinced FontBuilder needs to know anything about CSSValues.
I am not convinced FontBuilder needs to know anything about CSSValues .
void FontBuilder::setFontFamilyValue(CSSValue* value)
{
    FontDescriptionChangeScope scope(this);
    if (!value->isValueList())
        return;
    FontFamily& firstFamily = scope.fontDescription().firstFamily();
    FontFamily* currFamily = 0;
    bool oldFamilyUsedFixedDefaultSize = scope.fontDescription().useFixedDefaultSize();
    scope.fontDescription().setGenericFamily(FontDescription::NoFamily);
    for (CSSValueListIterator i = value; i.hasMore(); i.advance()) {
        CSSValue* item = i.value();
        if (!item->isPrimitiveValue())
            continue;
        CSSPrimitiveValue* contentValue = toCSSPrimitiveValue(item);
        AtomicString face;
        Settings* settings = m_document->settings();
        if (contentValue->isString()) {
            face = AtomicString(contentValue->getStringValue());
        } else if (settings) {
            switch (contentValue->getValueID()) {
            case CSSValueWebkitBody:
                face = settings->genericFontFamilySettings().standard();
                break;
            case CSSValueSerif:
                face = FontFamilyNames::webkit_serif;
                scope.fontDescription().setGenericFamily(FontDescription::SerifFamily);
                break;
            case CSSValueSansSerif:
                face = FontFamilyNames::webkit_sans_serif;
                scope.fontDescription().setGenericFamily(FontDescription::SansSerifFamily);
                break;
            case CSSValueCursive:
                face = FontFamilyNames::webkit_cursive;
                scope.fontDescription().setGenericFamily(FontDescription::CursiveFamily);
                break;
            case CSSValueFantasy:
                face = FontFamilyNames::webkit_fantasy;
                scope.fontDescription().setGenericFamily(FontDescription::FantasyFamily);
                break;
            case CSSValueMonospace:
                face = FontFamilyNames::webkit_monospace;
                scope.fontDescription().setGenericFamily(FontDescription::MonospaceFamily);
                break;
            case CSSValueWebkitPictograph:
                face = FontFamilyNames::webkit_pictograph;
                scope.fontDescription().setGenericFamily(FontDescription::PictographFamily);
                break;
            default:
                break;
            }
        }
        if (!face.isEmpty()) {
            if (!currFamily) {
                firstFamily.setFamily(face);
                firstFamily.appendFamily(nullptr); 
                currFamily = &firstFamily;
            } else {
                RefPtr<SharedFontFamily> newFamily = SharedFontFamily::create();
                newFamily->setFamily(face);
                currFamily->appendFamily(newFamily);
                currFamily = newFamily.get();
            }
        }
    }
    if (!currFamily)
        return;
    if (scope.fontDescription().keywordSize() && scope.fontDescription().useFixedDefaultSize() != oldFamilyUsedFixedDefaultSize)
        scope.fontDescription().setSpecifiedSize(FontSize::fontSizeForKeyword(m_document, CSSValueXxSmall + scope.fontDescription().keywordSize() - 1, !oldFamilyUsedFixedDefaultSize));
}
void FontBuilder :: setFontFamilyValue ( CSSValue * value ) { FontDescriptionChangeScope scope ( this ) ; if ( ! value -> isValueList ( ) ) return ; FontFamily & firstFamily = scope . fontDescription ( ) . firstFamily ( ) ; FontFamily * currFamily = 0 ; bool oldFamilyUsedFixedDefaultSize = scope . fontDescription ( ) . useFixedDefaultSize ( ) ; scope . fontDescription ( ) . setGenericFamily ( FontDescription :: NoFamily ) ; for ( CSSValueListIterator i = value ; i . hasMore ( ) ; i . advance ( ) ) { CSSValue * item = i . value ( ) ; if ( ! item -> isPrimitiveValue ( ) ) continue ; CSSPrimitiveValue * contentValue = toCSSPrimitiveValue ( item ) ; AtomicString face ; Settings * settings = m_document -> settings ( ) ; if ( contentValue -> isString ( ) ) { face = AtomicString ( contentValue -> getStringValue ( ) ) ; } else if ( settings ) { switch ( contentValue -> getValueID ( ) ) { case CSSValueWebkitBody : face = settings -> genericFontFamilySettings ( ) . standard ( ) ; break ; case CSSValueSerif : face = FontFamilyNames :: webkit_serif ; scope . fontDescription ( ) . setGenericFamily ( FontDescription :: SerifFamily ) ; break ; case CSSValueSansSerif : face = FontFamilyNames :: webkit_sans_serif ; scope . fontDescription ( ) . setGenericFamily ( FontDescription :: SansSerifFamily ) ; break ; case CSSValueCursive : face = FontFamilyNames :: webkit_cursive ; scope . fontDescription ( ) . setGenericFamily ( FontDescription :: CursiveFamily ) ; break ; case CSSValueFantasy : face = FontFamilyNames :: webkit_fantasy ; scope . fontDescription ( ) . setGenericFamily ( FontDescription :: FantasyFamily ) ; break ; case CSSValueMonospace : face = FontFamilyNames :: webkit_monospace ; scope . fontDescription ( ) . setGenericFamily ( FontDescription :: MonospaceFamily ) ; break ; case CSSValueWebkitPictograph : face = FontFamilyNames :: webkit_pictograph ; scope . fontDescription ( ) . setGenericFamily ( FontDescription :: PictographFamily ) ; break ; default : break ; } } if ( ! face . isEmpty ( ) ) { if ( ! currFamily ) { firstFamily . setFamily ( face ) ; firstFamily . appendFamily ( nullptr ) ; currFamily = & firstFamily ; } else { RefPtr < SharedFontFamily > newFamily = SharedFontFamily :: create ( ) ; newFamily -> setFamily ( face ) ; currFamily -> appendFamily ( newFamily ) ; currFamily = newFamily . get ( ) ; } } } if ( ! currFamily ) return ; if ( scope . fontDescription ( ) . keywordSize ( ) && scope . fontDescription ( ) . useFixedDefaultSize ( ) != oldFamilyUsedFixedDefaultSize ) scope . fontDescription ( ) . setSpecifiedSize ( FontSize :: fontSizeForKeyword ( m_document , CSSValueXxSmall + scope . fontDescription ( ) . keywordSize ( ) - 1 , ! oldFamilyUsedFixedDefaultSize ) ) ; }
FIXME: I am not convinced FontBuilder needs to know anything about CSSValues.
FIXME : I am not convinced FontBuilder needs to know anything about CSSValues .
// Before mapping in a new font-family property, we should reset the generic family. // Filling in the first family. // Remove any inherited family-fallback list. // We can't call useFixedDefaultSize() until all new font families have been added // If currFamily is non-zero then we set at least one family on this description.