Changeset 150716 in webkit


Ignore:
Timestamp:
May 26, 2013 7:50:51 AM (11 years ago)
Author:
Antti Koivisto
Message:

Use Vector instead of custom linked list for font families
https://bugs.webkit.org/show_bug.cgi?id=116783

Reviewed by Andreas Kling.

Get rid of FontFamily and SharedFontFamily.

  • accessibility/AccessibilityRenderObject.cpp:

(WebCore::AccessibilityRenderObject::hasSameFont):

  • accessibility/atk/WebKitAccessibleInterfaceText.cpp:

(getAttributeSetForAccessibilityObject):

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::fontFamilyFromStyle):

  • css/DeprecatedStyleBuilder.cpp:

(WebCore::ApplyPropertyFontFamily::applyInheritValue):
(WebCore::ApplyPropertyFontFamily::applyInitialValue):
(WebCore::ApplyPropertyFontFamily::applyValue):

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::styleForDocument):
(WebCore::StyleResolver::initializeFontStyle):

  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore::CanvasRenderingContext2D::font):
(WebCore::CanvasRenderingContext2D::setFont):

  • page/PrintContext.cpp:

(WebCore::PrintContext::pageProperty):

  • platform/efl/RenderThemeEfl.cpp:

(WebCore::RenderThemeEfl::systemFont):

  • platform/graphics/Font.h:

(WebCore::Font::firstFamily):
(WebCore::Font::familyCount):
(WebCore::Font::familyAt):

  • platform/graphics/FontCache.cpp:

(WebCore::FontCache::getFontData):

  • platform/graphics/FontDescription.cpp:

(SameSizeAsFontDescription):

  • platform/graphics/FontDescription.h:

(WebCore::FontDescription::FontDescription):
(WebCore::FontDescription::familyCount):
(WebCore::FontDescription::firstFamily):
(WebCore::FontDescription::familyAt):
(WebCore::FontDescription::families):
(WebCore::FontDescription::useFixedDefaultSize):
(WebCore::FontDescription::setOneFamily):
(WebCore::FontDescription::setFamilies):
(WebCore::FontDescription::adoptFamilies):
(WebCore::FontDescription::operator==):

  • platform/graphics/FontFamily.cpp:
  • platform/graphics/FontFamily.h:
  • platform/graphics/ca/win/PlatformCALayerWinInternal.cpp:

(PlatformCALayerWinInternal::displayCallback):

  • platform/graphics/mac/FontCacheMac.mm:

(WebCore::FontCache::getSimilarFontPlatformData):

  • platform/graphics/qt/FontCacheQt.cpp:

(WebCore::FontCache::getLastResortFallbackFont):

  • platform/gtk/RenderThemeGtk.cpp:

(WebCore::RenderThemeGtk::systemFont):

  • platform/mac/ThemeMac.mm:

(WebCore::ThemeMac::controlFont):

  • platform/qt/RenderThemeQStyle.cpp:

(WebCore::RenderThemeQStyle::adjustButtonStyle):

  • platform/text/transcoder/FontTranscoder.cpp:

(WebCore::FontTranscoder::converterType):

  • platform/win/DragImageWin.cpp:

(WebCore::dragLabelFont):

  • rendering/RenderText.cpp:

(WebCore::RenderText::styleDidChange):

  • rendering/RenderTextControl.cpp:

(WebCore::RenderTextControl::computeIntrinsicLogicalWidths):

  • rendering/RenderTextControlSingleLine.cpp:

(WebCore::RenderTextControlSingleLine::preferredContentLogicalWidth):

  • rendering/RenderThemeMac.mm:

(WebCore::RenderThemeMac::systemFont):
(WebCore::RenderThemeMac::setFontFromControlSize):

  • rendering/RenderThemeSafari.cpp:

(WebCore::RenderThemeSafari::systemFont):
(WebCore::RenderThemeSafari::setFontFromControlSize):

  • rendering/RenderThemeWin.cpp:

(WebCore::fillFontDescription):

Location:
trunk/Source/WebCore
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r150715 r150716  
     12013-05-26  Antti Koivisto  <antti@apple.com>
     2
     3        Use Vector instead of custom linked list for font families
     4        https://bugs.webkit.org/show_bug.cgi?id=116783
     5
     6        Reviewed by Andreas Kling.
     7
     8        Get rid of FontFamily and SharedFontFamily.
     9
     10        * accessibility/AccessibilityRenderObject.cpp:
     11        (WebCore::AccessibilityRenderObject::hasSameFont):
     12        * accessibility/atk/WebKitAccessibleInterfaceText.cpp:
     13        (getAttributeSetForAccessibilityObject):
     14        * css/CSSComputedStyleDeclaration.cpp:
     15        (WebCore::fontFamilyFromStyle):
     16        * css/DeprecatedStyleBuilder.cpp:
     17        (WebCore::ApplyPropertyFontFamily::applyInheritValue):
     18        (WebCore::ApplyPropertyFontFamily::applyInitialValue):
     19        (WebCore::ApplyPropertyFontFamily::applyValue):
     20        * css/StyleResolver.cpp:
     21        (WebCore::StyleResolver::styleForDocument):
     22        (WebCore::StyleResolver::initializeFontStyle):
     23        * html/canvas/CanvasRenderingContext2D.cpp:
     24        (WebCore::CanvasRenderingContext2D::font):
     25        (WebCore::CanvasRenderingContext2D::setFont):
     26        * page/PrintContext.cpp:
     27        (WebCore::PrintContext::pageProperty):
     28        * platform/efl/RenderThemeEfl.cpp:
     29        (WebCore::RenderThemeEfl::systemFont):
     30        * platform/graphics/Font.h:
     31        (WebCore::Font::firstFamily):
     32        (WebCore::Font::familyCount):
     33        (WebCore::Font::familyAt):
     34        * platform/graphics/FontCache.cpp:
     35        (WebCore::FontCache::getFontData):
     36        * platform/graphics/FontDescription.cpp:
     37        (SameSizeAsFontDescription):
     38        * platform/graphics/FontDescription.h:
     39        (WebCore::FontDescription::FontDescription):
     40        (WebCore::FontDescription::familyCount):
     41        (WebCore::FontDescription::firstFamily):
     42        (WebCore::FontDescription::familyAt):
     43        (WebCore::FontDescription::families):
     44        (WebCore::FontDescription::useFixedDefaultSize):
     45        (WebCore::FontDescription::setOneFamily):
     46        (WebCore::FontDescription::setFamilies):
     47        (WebCore::FontDescription::adoptFamilies):
     48        (WebCore::FontDescription::operator==):
     49        * platform/graphics/FontFamily.cpp:
     50        * platform/graphics/FontFamily.h:
     51        * platform/graphics/ca/win/PlatformCALayerWinInternal.cpp:
     52        (PlatformCALayerWinInternal::displayCallback):
     53        * platform/graphics/mac/FontCacheMac.mm:
     54        (WebCore::FontCache::getSimilarFontPlatformData):
     55        * platform/graphics/qt/FontCacheQt.cpp:
     56        (WebCore::FontCache::getLastResortFallbackFont):
     57        * platform/gtk/RenderThemeGtk.cpp:
     58        (WebCore::RenderThemeGtk::systemFont):
     59        * platform/mac/ThemeMac.mm:
     60        (WebCore::ThemeMac::controlFont):
     61        * platform/qt/RenderThemeQStyle.cpp:
     62        (WebCore::RenderThemeQStyle::adjustButtonStyle):
     63        * platform/text/transcoder/FontTranscoder.cpp:
     64        (WebCore::FontTranscoder::converterType):
     65        * platform/win/DragImageWin.cpp:
     66        (WebCore::dragLabelFont):
     67        * rendering/RenderText.cpp:
     68        (WebCore::RenderText::styleDidChange):
     69        * rendering/RenderTextControl.cpp:
     70        (WebCore::RenderTextControl::computeIntrinsicLogicalWidths):
     71        * rendering/RenderTextControlSingleLine.cpp:
     72        (WebCore::RenderTextControlSingleLine::preferredContentLogicalWidth):
     73        * rendering/RenderThemeMac.mm:
     74        (WebCore::RenderThemeMac::systemFont):
     75        (WebCore::RenderThemeMac::setFontFromControlSize):
     76        * rendering/RenderThemeSafari.cpp:
     77        (WebCore::RenderThemeSafari::systemFont):
     78        (WebCore::RenderThemeSafari::setFontFromControlSize):
     79        * rendering/RenderThemeWin.cpp:
     80        (WebCore::fillFontDescription):
     81
    1822013-05-26  Andreas Kling  <akling@apple.com>
    283
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r150525 r150716  
    32433243        return false;
    32443244   
    3245     return m_renderer->style()->fontDescription().family() == renderer->style()->fontDescription().family();
     3245    return m_renderer->style()->fontDescription().families() == renderer->style()->fontDescription().families();
    32463246}
    32473247
  • trunk/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp

    r150525 r150716  
    254254    }
    255255
    256     String fontFamilyName = style->font().family().family().string();
     256    String fontFamilyName = style->font().firstFamily();
    257257    if (fontFamilyName.left(8) == "-webkit-")
    258258        fontFamilyName = fontFamilyName.substring(8);
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r150554 r150716  
    14511451
    14521452static PassRefPtr<CSSValueList> fontFamilyFromStyle(RenderStyle* style)
    1453 {
    1454     const FontFamily& firstFamily = style->fontDescription().family();
     1453    {
    14551454    RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
    1456     for (const FontFamily* family = &firstFamily; family; family = family->next())
    1457         list->append(valueForFamily(family->family()));
     1455    for (unsigned i = 0; i < style->font().familyCount(); ++i)
     1456        list->append(valueForFamily(style->font().familyAt(i)));
    14581457    return list.release();
    14591458}
  • trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp

    r150525 r150716  
    11/*
    22 * Copyright (C) 2011 Google Inc. All rights reserved.
     3 * Copyright (C) 2013 Apple Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    665666       
    666667        fontDescription.setGenericFamily(parentFontDescription.genericFamily());
    667         fontDescription.setFamily(parentFontDescription.firstFamily());
     668        fontDescription.setFamilies(parentFontDescription.families());
    668669        fontDescription.setIsSpecifiedFont(parentFontDescription.isSpecifiedFont());
    669670        styleResolver->setFontDescription(fontDescription);
     
    680681            styleResolver->setFontSize(fontDescription, styleResolver->fontSizeForKeyword(styleResolver->document(), CSSValueXxSmall + fontDescription.keywordSize() - 1, false));
    681682        fontDescription.setGenericFamily(initialDesc.genericFamily());
    682         if (!initialDesc.firstFamily().familyIsEmpty())
    683             fontDescription.setFamily(initialDesc.firstFamily());
     683        if (!initialDesc.firstFamily().isEmpty())
     684            fontDescription.setFamilies(initialDesc.families());
    684685
    685686        styleResolver->setFontDescription(fontDescription);
     
    693694
    694695        FontDescription fontDescription = styleResolver->style()->fontDescription();
    695         FontFamily& firstFamily = fontDescription.firstFamily();
    696         FontFamily* currFamily = 0;
    697 
    698696        // Before mapping in a new font-family property, we should reset the generic family.
    699697        bool oldFamilyUsedFixedDefaultSize = fontDescription.useFixedDefaultSize();
    700698        fontDescription.setGenericFamily(FontDescription::NoFamily);
    701699
     700        Vector<AtomicString, 1> families;
    702701        for (CSSValueListIterator i = value; i.hasMore(); i.advance()) {
    703702            CSSValue* item = i.value();
     
    706705            CSSPrimitiveValue* contentValue = static_cast<CSSPrimitiveValue*>(item);
    707706            AtomicString face;
    708             Settings* settings = styleResolver->document()->settings();
    709707            if (contentValue->isString())
    710708                face = contentValue->getStringValue();
    711             else if (settings) {
     709            else if (Settings* settings = styleResolver->document()->settings()) {
    712710                switch (contentValue->getIdent()) {
    713711                case CSSValueWebkitBody:
     
    741739            }
    742740
    743             if (!face.isEmpty()) {
    744                 if (!currFamily) {
    745                     // Filling in the first family.
    746                     firstFamily.setFamily(face);
    747                     firstFamily.appendFamily(0); // Remove any inherited family-fallback list.
    748                     currFamily = &firstFamily;
    749                     fontDescription.setIsSpecifiedFont(fontDescription.genericFamily() == FontDescription::NoFamily);
    750                 } else {
    751                     RefPtr<SharedFontFamily> newFamily = SharedFontFamily::create();
    752                     newFamily->setFamily(face);
    753                     currFamily->appendFamily(newFamily);
    754                     currFamily = newFamily.get();
    755                 }
    756             }
    757         }
    758 
    759         // We can't call useFixedDefaultSize() until all new font families have been added
    760         // If currFamily is non-zero then we set at least one family on this description.
    761         if (currFamily) {
    762             if (fontDescription.keywordSize() && fontDescription.useFixedDefaultSize() != oldFamilyUsedFixedDefaultSize)
    763                 styleResolver->setFontSize(fontDescription, styleResolver->fontSizeForKeyword(styleResolver->document(), CSSValueXxSmall + fontDescription.keywordSize() - 1, !oldFamilyUsedFixedDefaultSize));
    764 
    765             styleResolver->setFontDescription(fontDescription);
    766         }
    767         return;
     741            if (face.isEmpty())
     742                continue;
     743            if (families.isEmpty())
     744                fontDescription.setIsSpecifiedFont(fontDescription.genericFamily() == FontDescription::NoFamily);
     745            families.append(face);
     746        }
     747
     748        if (families.isEmpty())
     749            return;
     750        fontDescription.adoptFamilies(families);
     751
     752        if (fontDescription.keywordSize() && fontDescription.useFixedDefaultSize() != oldFamilyUsedFixedDefaultSize)
     753            styleResolver->setFontSize(fontDescription, styleResolver->fontSizeForKeyword(styleResolver->document(), CSSValueXxSmall + fontDescription.keywordSize() - 1, !oldFamilyUsedFixedDefaultSize));
     754
     755        styleResolver->setFontDescription(fontDescription);
    768756    }
    769757
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r150387 r150716  
    921921        if (!standardFont.isEmpty()) {
    922922            fontDescription.setGenericFamily(FontDescription::StandardFamily);
    923             fontDescription.firstFamily().setFamily(standardFont);
    924             fontDescription.firstFamily().appendFamily(0);
     923            fontDescription.setOneFamily(standardFont);
    925924        }
    926925        fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1);
     
    32723271    fontDescription.setUsePrinterFont(document()->printing() || !settings->screenFontSubstitutionEnabled());
    32733272    const AtomicString& standardFontFamily = documentSettings()->standardFontFamily();
    3274     if (!standardFontFamily.isEmpty()) {
    3275         fontDescription.firstFamily().setFamily(standardFontFamily);
    3276         fontDescription.firstFamily().appendFamily(0);
    3277     }
     3273    if (!standardFontFamily.isEmpty())
     3274        fontDescription.setOneFamily(standardFontFamily);
    32783275    fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1);
    32793276    setFontSize(fontDescription, fontSizeForKeyword(document(), CSSValueMedium, false));
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r150137 r150716  
    19811981    serializedFont.appendLiteral("px");
    19821982
    1983     const FontFamily& firstFontFamily = fontDescription.family();
    1984     for (const FontFamily* fontFamily = &firstFontFamily; fontFamily; fontFamily = fontFamily->next()) {
    1985         if (fontFamily != &firstFontFamily)
     1983    for (unsigned i = 0; i < state().m_font.familyCount(); ++i) {
     1984        if (i)
    19861985            serializedFont.append(',');
    1987 
    19881986        // FIXME: We should append family directly to serializedFont rather than building a temporary string.
    1989         String family = fontFamily->family();
     1987        String family = state().m_font.familyAt(i);
    19901988        if (family.startsWith("-webkit-"))
    19911989            family = family.substring(8);
     
    20282026        newStyle->setFontDescription(computedStyle->fontDescription());
    20292027    else {
    2030         FontFamily fontFamily;
    2031         fontFamily.setFamily(defaultFontFamily);
    2032 
    20332028        FontDescription defaultFontDescription;
    2034         defaultFontDescription.setFamily(fontFamily);
     2029        defaultFontDescription.setOneFamily(defaultFontFamily);
    20352030        defaultFontDescription.setSpecifiedSize(defaultFontSize);
    20362031        defaultFontDescription.setComputedSize(defaultFontSize);
  • trunk/Source/WebCore/page/PrintContext.cpp

    r133813 r150716  
    280280        return String::number(style->fontDescription().computedPixelSize());
    281281    if (!strcmp(propertyName, "font-family"))
    282         return style->fontDescription().family().family().string();
     282        return style->fontDescription().firstFamily();
    283283    if (!strcmp(propertyName, "size"))
    284284        return String::number(style->pageSize().width().value()) + ' ' + String::number(style->pageSize().height().value());
  • trunk/Source/WebCore/platform/efl/RenderThemeEfl.cpp

    r147911 r150716  
    10191019    float fontSize = defaultFontSize;
    10201020
    1021     fontDescription.firstFamily().setFamily(fontFace);
     1021    fontDescription.setOneFamily(fontFace);
    10221022    fontDescription.setSpecifiedSize(fontSize);
    10231023    fontDescription.setIsAbsoluteSize(true);
  • trunk/Source/WebCore/platform/graphics/Font.h

    r147888 r150716  
    131131    TypesettingFeatures typesettingFeatures() const { return m_typesettingFeatures; }
    132132
    133     FontFamily& firstFamily() { return m_fontDescription.firstFamily(); }
    134     const FontFamily& family() const { return m_fontDescription.family(); }
     133    const AtomicString& firstFamily() const { return m_fontDescription.firstFamily(); }
     134    unsigned familyCount() const { return m_fontDescription.familyCount(); }
     135    const AtomicString& familyAt(unsigned i) const { return m_fontDescription.familyAt(i); }
    135136
    136137    FontItalic italic() const { return m_fontDescription.italic(); }
  • trunk/Source/WebCore/platform/graphics/FontCache.cpp

    r147889 r150716  
    11/*
    2  * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006, 2008, 2013 Apple Inc. All rights reserved.
    33 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
    44 *
     
    480480PassRefPtr<FontData> FontCache::getFontData(const Font& font, int& familyIndex, FontSelector* fontSelector)
    481481{
     482    ASSERT(familyIndex != cAllFamiliesScanned);
    482483    RefPtr<FontData> result;
    483484
    484     int startIndex = familyIndex;
    485     const FontFamily* startFamily = &font.fontDescription().family();
    486     for (int i = 0; startFamily && i < startIndex; i++)
    487         startFamily = startFamily->next();
    488     const FontFamily* currFamily = startFamily;
    489     while (currFamily && !result) {
    490         familyIndex++;
    491         if (currFamily->family().length()) {
    492             if (fontSelector)
    493                 result = fontSelector->getFontData(font.fontDescription(), currFamily->family());
    494 
    495             if (!result)
    496                 result = getCachedFontData(font.fontDescription(), currFamily->family());
    497         }
    498         currFamily = currFamily->next();
    499     }
    500 
    501     if (!currFamily)
     485    bool isFirst = !familyIndex;
     486    int familyCount = font.familyCount();
     487    for (;familyIndex < familyCount && !result; ++familyIndex) {
     488        const AtomicString& family = font.familyAt(familyIndex);
     489        if (family.isEmpty())
     490            continue;
     491        if (fontSelector)
     492            result = fontSelector->getFontData(font.fontDescription(), family);
     493        if (!result)
     494            result = getCachedFontData(font.fontDescription(), family);
     495    }
     496    if (familyIndex == familyCount)
    502497        familyIndex = cAllFamiliesScanned;
    503498
    504     if (!result)
     499    if (!result) {
    505500        // We didn't find a font. Try to find a similar font using our own specific knowledge about our platform.
    506501        // For example on OS X, we know to map any families containing the words Arabic, Pashto, or Urdu to the
    507502        // Geeza Pro font.
    508503        result = getSimilarFontPlatformData(font);
    509 
    510     if (!result && startIndex == 0) {
     504    }
     505
     506    if (!result && isFirst) {
    511507        // If it's the primary font that we couldn't find, we try the following. In all other cases, we will
    512508        // just use per-character system fallback.
    513 
    514509        if (fontSelector) {
    515510            // Try the user's preferred standard font.
     
    517512                return data.release();
    518513        }
    519 
    520514        // Still no result.  Hand back our last resort fallback font.
    521515        result = getLastResortFallbackFont(font.fontDescription());
  • trunk/Source/WebCore/platform/graphics/FontDescription.cpp

    r117868 r150716  
    11/*
    22 * Copyright (C) 2007 Nicholas Shanks <contact@nickshanks.com>
    3  * Copyright (C) 2008 Apple Inc. All rights reserved.
     3 * Copyright (C) 2008, 2013 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    3434
    3535struct SameSizeAsFontDescription {
    36     FontFamily familyList;
     36    Vector<AtomicString, 1> families;
    3737    RefPtr<FontFeatureSettings> m_featureSettings;
    3838    float sizes[2];
  • trunk/Source/WebCore/platform/graphics/FontDescription.h

    r147888 r150716  
    33 *           (C) 2000 Antti Koivisto (koivisto@kde.org)
    44 *           (C) 2000 Dirk Mueller (mueller@kde.org)
    5  * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
     5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2013 Apple Inc. All rights reserved.
    66 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
    77 *
     
    7878
    7979    FontDescription()
    80         : m_specifiedSize(0)
     80        : m_families(1)
     81        , m_specifiedSize(0)
    8182        , m_computedSize(0)
    8283        , m_orientation(Horizontal)
     
    104105    bool operator==(const FontDescription&) const;
    105106    bool operator!=(const FontDescription& other) const { return !(*this == other); }
    106    
    107     const FontFamily& family() const { return m_familyList; }
    108     FontFamily& firstFamily() { return m_familyList; }
     107
     108    unsigned familyCount() const { return m_families.size(); }
     109    const AtomicString& firstFamily() const { return familyAt(0); }
     110    const AtomicString& familyAt(unsigned i) const { return m_families[i]; }
     111    const Vector<AtomicString, 1>& families() const { return m_families; }
     112
    109113    float specifiedSize() const { return m_specifiedSize; }
    110114    float computedSize() const { return m_computedSize; }
     
    119123    bool usePrinterFont() const { return m_usePrinterFont; }
    120124    // only use fixed default size when there is only one font family, and that family is "monospace"
    121     bool useFixedDefaultSize() const { return genericFamily() == MonospaceFamily && !family().next() && family().family() == monospaceFamily; }
     125    bool useFixedDefaultSize() const { return genericFamily() == MonospaceFamily && familyCount() == 1 && firstFamily() == monospaceFamily; }
    122126    FontRenderingMode renderingMode() const { return static_cast<FontRenderingMode>(m_renderingMode); }
    123127    Kerning kerning() const { return static_cast<Kerning>(m_kerning); }
     
    138142    FontDescription makeNormalFeatureSettings() const;
    139143
    140     void setFamily(const FontFamily& family) { m_familyList = family; }
     144    void setOneFamily(const AtomicString& family) { ASSERT(m_families.size() == 1); m_families[0] = family; }
     145    void setFamilies(const Vector<AtomicString, 1>& families) { m_families = families; }
     146    void adoptFamilies(Vector<AtomicString, 1>& families) { m_families.swap(families); }
    141147    void setComputedSize(float s) { m_computedSize = clampToFloat(s); }
    142148    void setSpecifiedSize(float s) { m_specifiedSize = clampToFloat(s); }
     
    165171
    166172private:
    167     FontFamily m_familyList; // The list of font families to be used.
     173    Vector<AtomicString, 1> m_families;
    168174    RefPtr<FontFeatureSettings> m_featureSettings;
    169175
     
    204210inline bool FontDescription::operator==(const FontDescription& other) const
    205211{
    206     return m_familyList == other.m_familyList
     212    return m_families == other.m_families
    207213        && m_specifiedSize == other.m_specifiedSize
    208214        && m_computedSize == other.m_computedSize
  • trunk/Source/WebCore/platform/graphics/FontFamily.cpp

    r118177 r150716  
    1 /*
    2  * Copyright (C) 2004, 2008 Apple Inc. All rights reserved.
    3  *
    4  * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions
    6  * are met:
    7  * 1. Redistributions of source code must retain the above copyright
    8  *    notice, this list of conditions and the following disclaimer.
    9  * 2. Redistributions in binary form must reproduce the above copyright
    10  *    notice, this list of conditions and the following disclaimer in the
    11  *    documentation and/or other materials provided with the distribution.
    12  *
    13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
    14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
    17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
    21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    24  */
    25 
    26 #include "config.h"
    27 #include "FontFamily.h"
    28 
    29 namespace WebCore {
    30 
    31 bool operator==(const FontFamily& a, const FontFamily& b)
    32 {
    33     if (a.family() != b.family())
    34         return false;
    35     const FontFamily* ap;
    36     const FontFamily* bp;
    37     for (ap = a.next(), bp = b.next(); ap != bp; ap = ap->next(), bp = bp->next()) {
    38         if (!ap || !bp)
    39             return false;
    40         if (ap->family() != bp->family())
    41             return false;
    42     }
    43     return true;
    44 }
    45 
    46 }
     1// Remove me.
  • trunk/Source/WebCore/platform/graphics/FontFamily.h

    r149523 r150716  
    1 /*
    2  * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
    3  *
    4  * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions
    6  * are met:
    7  * 1. Redistributions of source code must retain the above copyright
    8  *    notice, this list of conditions and the following disclaimer.
    9  * 2. Redistributions in binary form must reproduce the above copyright
    10  *    notice, this list of conditions and the following disclaimer in the
    11  *    documentation and/or other materials provided with the distribution.
    12  *
    13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
    14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
    17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
    21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    24  */
    25 
    26 #ifndef FontFamily_h
    27 #define FontFamily_h
    28 
    29 #include <wtf/RefCounted.h>
    30 #include <wtf/RefPtr.h>
    31 #include <wtf/text/AtomicString.h>
    32 
    33 namespace WebCore {
    34 
    35 class SharedFontFamily;
    36 
    37 class FontFamily {
    38 public:
    39     FontFamily() { }
    40     ~FontFamily();
    41 
    42     void setFamily(const AtomicString& family) { m_family = family; }
    43     const AtomicString& family() const { return m_family; }
    44     bool familyIsEmpty() const { return m_family.isEmpty(); }
    45 
    46     const FontFamily* next() const;
    47 
    48     void appendFamily(PassRefPtr<SharedFontFamily>);
    49     PassRefPtr<SharedFontFamily> releaseNext();
    50 
    51 private:
    52     AtomicString m_family;
    53     RefPtr<SharedFontFamily> m_next;
    54 };
    55 
    56 class SharedFontFamily : public FontFamily, public RefCounted<SharedFontFamily> {
    57 public:
    58     static PassRefPtr<SharedFontFamily> create()
    59     {
    60         return adoptRef(new SharedFontFamily);
    61     }
    62 
    63 private:
    64     SharedFontFamily() { }
    65 };
    66 
    67 bool operator==(const FontFamily&, const FontFamily&);
    68 inline bool operator!=(const FontFamily& a, const FontFamily& b) { return !(a == b); }
    69 
    70 inline FontFamily::~FontFamily()
    71 {
    72     // This code came from removed ListRefPtr to avoid possible overflowing the stack.
    73     // FIXME: Do we really need it?
    74     RefPtr<SharedFontFamily> reaper = m_next.release();
    75     while (reaper && reaper->hasOneRef())
    76         reaper = reaper->releaseNext(); // implicitly protects reaper->next, then derefs reaper
    77 }
    78 
    79 inline const FontFamily* FontFamily::next() const
    80 {
    81     return m_next.get();
    82 }
    83 
    84 inline void FontFamily::appendFamily(PassRefPtr<SharedFontFamily> family)
    85 {
    86     m_next = family;
    87 }
    88 
    89 inline PassRefPtr<SharedFontFamily> FontFamily::releaseNext()
    90 {
    91     return m_next.release();
    92 }
    93 
    94 }
    95 
    96 #endif
     1// Remove me.
  • trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp

    r149716 r150716  
    125125        metrics.cbSize = sizeof(metrics);
    126126        SystemParametersInfo(SPI_GETNONCLIENTMETRICS, metrics.cbSize, &metrics, 0);
    127         FontFamily family;
    128         family.setFamily(metrics.lfSmCaptionFont.lfFaceName);
    129         desc.setFamily(family);
     127        desc.setOneFamily(metrics.lfSmCaptionFont.lfFaceName);
    130128
    131129        desc.setComputedSize(18);
  • trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm

    r147863 r150716  
    160160    // match any name that contains "Arabic" to Geeza Pro.
    161161    RefPtr<SimpleFontData> simpleFontData;
    162     const FontFamily* currFamily = &font.fontDescription().family();
    163     while (currFamily && !simpleFontData) {
    164         if (currFamily->family().length()) {
    165             static String* matchWords[3] = { new String("Arabic"), new String("Pashto"), new String("Urdu") };
    166             DEFINE_STATIC_LOCAL(AtomicString, geezaStr, ("Geeza Pro", AtomicString::ConstructFromLiteral));
    167             for (int j = 0; j < 3 && !simpleFontData; ++j)
    168                 if (currFamily->family().contains(*matchWords[j], false))
    169                     simpleFontData = getCachedFontData(font.fontDescription(), geezaStr);
    170         }
    171         currFamily = currFamily->next();
    172     }
    173 
     162    for (unsigned i = 0; i < font.familyCount(); ++i) {
     163        const AtomicString& family = font.familyAt(i);
     164        if (family.isEmpty())
     165            continue;
     166        static String* matchWords[3] = { new String("Arabic"), new String("Pashto"), new String("Urdu") };
     167        DEFINE_STATIC_LOCAL(AtomicString, geezaStr, ("Geeza Pro", AtomicString::ConstructFromLiteral));
     168        for (int j = 0; j < 3 && !simpleFontData; ++j)
     169            if (family.contains(*matchWords[j], false))
     170                simpleFontData = getCachedFontData(font.fontDescription(), geezaStr);
     171    }
    174172    return simpleFontData.release();
    175173}
  • trunk/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp

    r147639 r150716  
    8181PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
    8282{
    83     const AtomicString fallbackFamily = QFont(fontDescription.family().family()).lastResortFamily();
     83    const AtomicString fallbackFamily = QFont(fontDescription.firstFamily()).lastResortFamily();
    8484    return getCachedFontData(new FontPlatformData(fontDescription, fallbackFamily), shouldRetain);
    8585}
  • trunk/Source/WebCore/platform/gtk/RenderThemeGtk.cpp

    r149539 r150716  
    452452        return;
    453453
    454     fontDescription.firstFamily().setFamily(pango_font_description_get_family(pangoDescription));
     454    fontDescription.setOneFamily(pango_font_description_get_family(pangoDescription));
    455455
    456456    int size = pango_font_description_get_size(pangoDescription) / PANGO_SCALE;
  • trunk/Source/WebCore/platform/mac/ThemeMac.mm

    r150530 r150716  
    608608
    609609            NSFont* nsFont = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:controlSizeForFont(font)]];
    610             fontDescription.firstFamily().setFamily([nsFont webCoreFamilyName]);
     610            fontDescription.setOneFamily([nsFont webCoreFamilyName]);
    611611            fontDescription.setComputedSize([nsFont pointSize] * zoomFactor);
    612612            fontDescription.setSpecifiedSize([nsFont pointSize] * zoomFactor);
  • trunk/Source/WebCore/platform/qt/RenderThemeQStyle.cpp

    r150214 r150716  
    251251#endif
    252252
    253     FontFamily fontFamily;
    254     fontFamily.setFamily(m_buttonFontFamily);
    255     fontDescription.setFamily(fontFamily);
     253    fontDescription.setOneFamily(m_buttonFontFamily);
    256254    style->setFontDescription(fontDescription);
    257255    style->font().update(styleResolver->fontSelector());
  • trunk/Source/WebCore/platform/text/transcoder/FontTranscoder.cpp

    r130612 r150716  
    6363FontTranscoder::ConverterType FontTranscoder::converterType(const FontDescription& fontDescription, const TextEncoding* encoding) const
    6464{
    65     const AtomicString& fontFamily = fontDescription.family().family().string();
     65    const AtomicString& fontFamily = fontDescription.firstFamily();
    6666    if (!fontFamily.isNull()) {
    6767        HashMap<AtomicString, ConverterType>::const_iterator found = m_converterTypes.find(fontFamily);
  • trunk/Source/WebCore/platform/win/DragImageWin.cpp

    r147974 r150716  
    111111    FontDescription description;
    112112    description.setWeight(bold ? FontWeightBold : FontWeightNormal);
    113 
    114     FontFamily family;
    115     family.setFamily(metrics.lfSmCaptionFont.lfFaceName);
    116     description.setFamily(family);
     113    description.setOneFamily(metrics.lfSmCaptionFont.lfFaceName);
    117114    description.setSpecifiedSize((float)size);
    118115    description.setComputedSize((float)size);
  • trunk/Source/WebCore/rendering/RenderText.cpp

    r150259 r150716  
    209209        updateNeedsTranscoding();
    210210        needsResetText = m_needsTranscoding;
    211     } else if (oldStyle->font().needsTranscoding() != newStyle->font().needsTranscoding() || (newStyle->font().needsTranscoding() && oldStyle->font().family().family() != newStyle->font().family().family())) {
     211    } else if (oldStyle->font().needsTranscoding() != newStyle->font().needsTranscoding() || (newStyle->font().needsTranscoding() && oldStyle->font().firstFamily() != newStyle->font().firstFamily())) {
    212212        updateNeedsTranscoding();
    213213        needsResetText = true;
  • trunk/Source/WebCore/rendering/RenderTextControl.cpp

    r149880 r150716  
    263263{
    264264    // Use average character width. Matches IE.
    265     AtomicString family = style()->font().family().family();
     265    const AtomicString& family = style()->font().firstFamily();
    266266    maxLogicalWidth = preferredContentLogicalWidth(const_cast<RenderTextControl*>(this)->getAvgCharWidth(family));
    267267    if (RenderBox* innerTextRenderBox = innerTextElement()->renderBox())
  • trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp

    r148536 r150716  
    324324
    325325    float maxCharWidth = 0.f;
    326     AtomicString family = style()->font().family().family();
     326    const AtomicString& family = style()->font().firstFamily();
    327327    // Since Lucida Grande is the default font, we want this to match the width
    328328    // of MS Shell Dlg, the default font for textareas in Firefox, Safari Win and
  • trunk/Source/WebCore/rendering/RenderThemeMac.mm

    r150715 r150716  
    652652        cachedDesc->setIsAbsoluteSize(true);
    653653        cachedDesc->setGenericFamily(FontDescription::NoFamily);
    654         cachedDesc->firstFamily().setFamily([font webCoreFamilyName]);
     654        cachedDesc->setOneFamily([font webCoreFamilyName]);
    655655        cachedDesc->setSpecifiedSize([font pointSize]);
    656656        cachedDesc->setWeight(toFontWeight([fontManager weightOfFont:font]));
     
    10591059
    10601060    NSFont* font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:controlSize]];
    1061     fontDescription.firstFamily().setFamily([font webCoreFamilyName]);
     1061    fontDescription.setOneFamily([font webCoreFamilyName]);
    10621062    fontDescription.setComputedSize([font pointSize] * style->effectiveZoom());
    10631063    fontDescription.setSpecifiedSize([font pointSize] * style->effectiveZoom());
  • trunk/Source/WebCore/rendering/RenderThemeSafari.cpp

    r149716 r150716  
    240240        cachedDesc->setIsAbsoluteSize(true);
    241241        cachedDesc->setGenericFamily(FontDescription::NoFamily);
    242         cachedDesc->firstFamily().setFamily("Lucida Grande");
     242        cachedDesc->setOneFamily("Lucida Grande");
    243243        cachedDesc->setSpecifiedSize(fontSize);
    244244        cachedDesc->setWeight(FontWeightNormal);
     
    391391
    392392    float fontSize = systemFontSizeForControlSize(controlSize);
    393     fontDescription.firstFamily().setFamily("Lucida Grande");
     393    fontDescription.setOneFamily("Lucida Grande");
    394394    fontDescription.setComputedSize(fontSize);
    395395    fontDescription.setSpecifiedSize(fontSize);
  • trunk/Source/WebCore/rendering/RenderThemeWin.cpp

    r149284 r150716  
    286286    fontDescription.setIsAbsoluteSize(true);
    287287    fontDescription.setGenericFamily(FontDescription::NoFamily);
    288     fontDescription.firstFamily().setFamily(String(logFont.lfFaceName));
     288    fontDescription.setOneFamily(String(logFont.lfFaceName));
    289289    fontDescription.setSpecifiedSize(fontSize);
    290290    fontDescription.setWeight(logFont.lfWeight >= 700 ? FontWeightBold : FontWeightNormal); // FIXME: Use real weight.
Note: See TracChangeset for help on using the changeset viewer.