Ignore:
Timestamp:
Sep 21, 2021, 9:06:11 PM (4 years ago)
Author:
[email protected]
Message:

Add FontCreationContext
https://bugs.webkit.org/show_bug.cgi?id=230592

Reviewed by Alan Bujtas.

We have this pattern where we pass around "const FontFeatureSettings&, const FontSelectionSpecifiedCapabilities&"
through all the various font creation routines. When I add support for font palettes and font-feature-values,
this would need to grow to 4 arguments being passed around instead of 2. Rather than passing all these arguments
around, a better idea is to encapsulate these arguments in a "context" object. This is because most places that
take these arguments don't actually inspect them, but instead just forward them on to other routines.

No new tests because there is no behavior change.

  • Headers.cmake:
  • WebCore.xcodeproj/project.pbxproj:
  • css/CSSFontFace.cpp:

(WebCore::CSSFontFace::font):

  • css/CSSFontFaceSource.cpp:

(WebCore::CSSFontFaceSource::load):
(WebCore::CSSFontFaceSource::font):

  • css/CSSFontFaceSource.h:
  • css/CSSFontSelector.cpp:

(WebCore::CSSFontSelector::fontRangesForFamily):

  • loader/FontLoadRequest.h:
  • loader/cache/CachedFont.cpp:

(WebCore::CachedFont::createFont):
(WebCore::CachedFont::platformDataFromCustomData):

  • loader/cache/CachedFont.h:
  • loader/cache/CachedFontLoadRequest.h:
  • loader/cache/CachedSVGFont.cpp:

(WebCore::CachedSVGFont::createFont):
(WebCore::CachedSVGFont::platformDataFromCustomData):

  • loader/cache/CachedSVGFont.h:
  • platform/graphics/Font.cpp:

(WebCore::Font::create):

  • platform/graphics/FontCache.cpp:

(WebCore::operator==):
(WebCore::FontPlatformDataCacheKeyHash::hash):
(WebCore::FontCache::cachedFontPlatformData):
(WebCore::FontCache::fontForFamily):

  • platform/graphics/FontCache.h:

(WebCore::FontCache::fontForFamily):
(WebCore::FontCache::cachedFontPlatformData):
(WebCore::FontCache::createFontPlatformDataForTesting):

  • platform/graphics/FontCreationContext.h: Added.

(WebCore::FontCreationContext::operator== const):
(WebCore::FontCreationContext::operator!= const):
(WebCore::add):

  • platform/graphics/cairo/FontCustomPlatformData.h:
  • platform/graphics/cocoa/FontCacheCoreText.cpp:

(WebCore::preparePlatformFont):
(WebCore::fontWithFamily):
(WebCore::FontCache::createFontPlatformData):
(WebCore::FontCache::systemFallbackForCharacters):

  • platform/graphics/cocoa/FontCacheCoreText.h:
  • platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp:

(WebCore::FontFamilySpecificationCoreText::fontRanges const):

  • platform/graphics/freetype/FontCacheFreeType.cpp:

(WebCore::FontCache::createFontPlatformData):

  • platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp:

(WebCore::FontCustomPlatformData::fontPlatformData):

  • platform/graphics/mac/FontCustomPlatformData.cpp:

(WebCore::FontCustomPlatformData::fontPlatformData):

  • platform/graphics/mac/FontCustomPlatformData.h:
  • platform/graphics/win/FontCacheWin.cpp:

(WebCore::FontCache::createFontPlatformData):

  • platform/graphics/win/FontCustomPlatformData.cpp:

(WebCore::FontCustomPlatformData::fontPlatformData):

  • platform/graphics/win/FontCustomPlatformData.h:
  • platform/graphics/win/FontCustomPlatformDataCairo.cpp:

(WebCore::FontCustomPlatformData::fontPlatformData):

  • workers/WorkerFontLoadRequest.cpp:

(WebCore::WorkerFontLoadRequest::createFont):

  • workers/WorkerFontLoadRequest.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSFontFaceSource.cpp

    r276450 r282863  
    11/*
    2  * Copyright (C) 2007, 2008, 2010, 2011 Apple Inc. All rights reserved.
     2 * Copyright (C) 2007-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3535#include "FontCache.h"
    3636#include "FontCascadeDescription.h"
     37#include "FontCreationContext.h"
    3738#include "FontCustomPlatformData.h"
    3839#include "FontDescription.h"
     
    186187            fontDescription.setComputedSize(1);
    187188            fontDescription.setShouldAllowUserInstalledFonts(m_face.allowUserInstalledFonts());
    188             success = FontCache::singleton().fontForFamily(fontDescription, m_familyNameOrURI, nullptr, FontSelectionSpecifiedCapabilities(), true);
     189            success = FontCache::singleton().fontForFamily(fontDescription, m_familyNameOrURI, { }, true);
    189190            if (document && RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled())
    190191                ResourceLoadObserver::shared().logFontLoad(*document, m_familyNameOrURI.string(), success);
     
    194195}
    195196
    196 RefPtr<Font> CSSFontFaceSource::font(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings& fontFaceFeatures, FontSelectionSpecifiedCapabilities fontFaceCapabilities)
     197RefPtr<Font> CSSFontFaceSource::font(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, const FontCreationContext& fontCreationContext)
    197198{
    198199    ASSERT(status() == Status::Success);
     
    204205            if (!m_immediateFontCustomPlatformData)
    205206                return nullptr;
    206             return Font::create(CachedFont::platformDataFromCustomData(*m_immediateFontCustomPlatformData, fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceCapabilities), Font::Origin::Remote);
     207            return Font::create(CachedFont::platformDataFromCustomData(*m_immediateFontCustomPlatformData, fontDescription, syntheticBold, syntheticItalic, fontCreationContext), Font::Origin::Remote);
    207208        }
    208209
    209210        // We're local. Just return a Font from the normal cache.
    210211        // We don't want to check alternate font family names here, so pass true as the checkingAlternateName parameter.
    211         return FontCache::singleton().fontForFamily(fontDescription, m_familyNameOrURI, &fontFaceFeatures, fontFaceCapabilities, true);
     212        return FontCache::singleton().fontForFamily(fontDescription, m_familyNameOrURI, fontCreationContext, true);
    212213    }
    213214
     
    217218
    218219        ASSERT(status() == Status::Success);
    219         auto result = m_fontRequest->createFont(fontDescription, m_familyNameOrURI, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceCapabilities);
     220        auto result = m_fontRequest->createFont(fontDescription, m_familyNameOrURI, syntheticBold, syntheticItalic, fontCreationContext);
    220221        ASSERT(result);
    221222        return result;
     
    229230    if (!m_inDocumentCustomPlatformData)
    230231        return nullptr;
    231     return Font::create(m_inDocumentCustomPlatformData->fontPlatformData(fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceCapabilities), Font::Origin::Remote);
     232    return Font::create(m_inDocumentCustomPlatformData->fontPlatformData(fontDescription, syntheticBold, syntheticItalic, fontCreationContext), Font::Origin::Remote);
    232233}
    233234
Note: See TracChangeset for help on using the changeset viewer.