Changeset 219215 in webkit


Ignore:
Timestamp:
Jul 6, 2017 2:07:19 PM (7 years ago)
Author:
mmaxfield@apple.com
Message:

Unify FontCascadeFonts::glyphDataForVariant() and FontCascadeFonts::glyphDataForNormalVariant()
https://bugs.webkit.org/show_bug.cgi?id=174213

Reviewed by Zalan Bujtas.

They have almost identical code. This is in preparation for https://bugs.webkit.org/show_bug.cgi?id=173962

No new tests because there is no behavior change.

  • platform/graphics/FontCascadeFonts.cpp:

(WebCore::FontCascadeFonts::glyphDataForVariant):
(WebCore::FontCascadeFonts::glyphDataForCharacter):
(WebCore::FontCascadeFonts::glyphDataForNormalVariant): Deleted.

  • platform/graphics/FontCascadeFonts.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r219213 r219215  
     12017-07-06  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Unify FontCascadeFonts::glyphDataForVariant() and FontCascadeFonts::glyphDataForNormalVariant()
     4        https://bugs.webkit.org/show_bug.cgi?id=174213
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        They have almost identical code. This is in preparation for https://bugs.webkit.org/show_bug.cgi?id=173962
     9
     10        No new tests because there is no behavior change.
     11
     12        * platform/graphics/FontCascadeFonts.cpp:
     13        (WebCore::FontCascadeFonts::glyphDataForVariant):
     14        (WebCore::FontCascadeFonts::glyphDataForCharacter):
     15        (WebCore::FontCascadeFonts::glyphDataForNormalVariant): Deleted.
     16        * platform/graphics/FontCascadeFonts.h:
     17
    1182017-07-06  Don Olmstead  <don.olmstead@sony.com>
    219
  • trunk/Source/WebCore/platform/graphics/FontCascadeFonts.cpp

    r218372 r219215  
    357357}
    358358
    359 GlyphData FontCascadeFonts::glyphDataForVariant(UChar32 c, const FontCascadeDescription& description, FontVariant variant, unsigned fallbackIndex)
     359GlyphData FontCascadeFonts::glyphDataForVariant(UChar32 character, const FontCascadeDescription& description, FontVariant variant, unsigned fallbackIndex)
    360360{
    361361    ExternalResourceDownloadPolicy policy = ExternalResourceDownloadPolicy::Allow;
    362362    GlyphData loadingResult;
    363     while (true) {
    364         auto& fontRanges = realizeFallbackRangesAt(description, fallbackIndex++);
     363    for (; ; ++fallbackIndex) {
     364        auto& fontRanges = realizeFallbackRangesAt(description, fallbackIndex);
    365365        if (fontRanges.isNull())
    366366            break;
    367         GlyphData data = fontRanges.glyphDataForCharacter(c, policy);
     367
     368        GlyphData data = fontRanges.glyphDataForCharacter(character, policy);
    368369        if (!data.font)
    369370            continue;
     371
    370372        if (data.font->isInterstitial()) {
    371373            policy = ExternalResourceDownloadPolicy::Forbid;
     
    374376            continue;
    375377        }
    376         // The variantFont function should not normally return 0.
    377         // But if it does, we will just render the capital letter big.
    378         if (const Font* variantFont = data.font->variantFont(description, variant))
    379             return variantFont->glyphDataForCharacter(c);
     378
     379        if (variant == NormalVariant) {
     380            if (data.font->platformData().orientation() == Vertical && !data.font->isTextOrientationFallback()) {
     381                if (!FontCascade::isCJKIdeographOrSymbol(character))
     382                    return glyphDataForNonCJKCharacterWithGlyphOrientation(character, description.nonCJKGlyphOrientation(), data);
     383
     384                if (!data.font->hasVerticalGlyphs()) {
     385                    // Use the broken ideograph font data. The broken ideograph font will use the horizontal width of glyphs
     386                    // to make sure you get a square (even for broken glyphs like symbols used for punctuation).
     387                    return glyphDataForVariant(character, description, BrokenIdeographVariant, fallbackIndex);
     388                }
     389            }
     390        } else {
     391            // The variantFont function should not normally return 0.
     392            // But if it does, we will just render the capital letter big.
     393            if (const Font* variantFont = data.font->variantFont(description, variant))
     394                return variantFont->glyphDataForCharacter(character);
     395        }
     396
    380397        return data;
    381398    }
     
    383400    if (loadingResult.font)
    384401        return loadingResult;
    385     return glyphDataForSystemFallback(c, description, variant);
    386 }
    387 
    388 GlyphData FontCascadeFonts::glyphDataForNormalVariant(UChar32 c, const FontCascadeDescription& description)
    389 {
    390     ExternalResourceDownloadPolicy policy = ExternalResourceDownloadPolicy::Allow;
    391     GlyphData loadingResult;
    392     for (unsigned fallbackIndex = 0; ; ++fallbackIndex) {
    393         auto& fontRanges = realizeFallbackRangesAt(description, fallbackIndex);
    394         if (fontRanges.isNull())
    395             break;
    396         GlyphData data = fontRanges.glyphDataForCharacter(c, policy);
    397         if (!data.font)
    398             continue;
    399         if (data.font->isInterstitial()) {
    400             policy = ExternalResourceDownloadPolicy::Forbid;
    401             if (!loadingResult.font)
    402                 loadingResult = data;
    403             continue;
    404         }
    405         if (data.font->platformData().orientation() == Vertical && !data.font->isTextOrientationFallback()) {
    406             if (!FontCascade::isCJKIdeographOrSymbol(c))
    407                 return glyphDataForNonCJKCharacterWithGlyphOrientation(c, description.nonCJKGlyphOrientation(), data);
    408 
    409             if (!data.font->hasVerticalGlyphs()) {
    410                 // Use the broken ideograph font data. The broken ideograph font will use the horizontal width of glyphs
    411                 // to make sure you get a square (even for broken glyphs like symbols used for punctuation).
    412                 return glyphDataForVariant(c, description, BrokenIdeographVariant, fallbackIndex);
    413             }
    414         }
    415         return data;
    416     }
    417 
    418     if (loadingResult.font)
    419         return loadingResult;
    420     return glyphDataForSystemFallback(c, description, NormalVariant);
     402    return glyphDataForSystemFallback(character, description, variant);
    421403}
    422404
     
    453435
    454436    if (variant != NormalVariant)
    455         return glyphDataForVariant(c, description, variant, 0);
     437        return glyphDataForVariant(c, description, variant);
    456438
    457439    const unsigned pageNumber = GlyphPage::pageNumberForCodePoint(c);
     
    466448    if (!glyphData.glyph) {
    467449        // No glyph, resolve per-character.
    468         glyphData = glyphDataForNormalVariant(c, description);
     450        ASSERT(variant == NormalVariant);
     451        glyphData = glyphDataForVariant(c, description, variant);
    469452        // Cache the results.
    470453        cacheEntry.setGlyphDataForCharacter(c, glyphData);
  • trunk/Source/WebCore/platform/graphics/FontCascadeFonts.h

    r194496 r219215  
    7878
    7979    GlyphData glyphDataForSystemFallback(UChar32, const FontCascadeDescription&, FontVariant);
    80     GlyphData glyphDataForNormalVariant(UChar32, const FontCascadeDescription&);
    81     GlyphData glyphDataForVariant(UChar32, const FontCascadeDescription&, FontVariant, unsigned fallbackIndex);
     80    GlyphData glyphDataForVariant(UChar32, const FontCascadeDescription&, FontVariant, unsigned fallbackIndex = 0);
    8281
    8382    Vector<FontRanges, 1> m_realizedFallbackRanges;
Note: See TracChangeset for help on using the changeset viewer.