Diff
Modified: trunk/Source/WebCore/ChangeLog (282862 => 282863)
--- trunk/Source/WebCore/ChangeLog 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/ChangeLog 2021-09-22 04:06:11 UTC (rev 282863)
@@ -1,3 +1,80 @@
+2021-09-21 Myles C. Maxfield <[email protected]>
+
+ 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:
+
2021-09-21 Simon Fraser <[email protected]>
Change from ENABLE(RUBBER_BANDING) to HAVE(RUBBER_BANDING)
Modified: trunk/Source/WebCore/Headers.cmake (282862 => 282863)
--- trunk/Source/WebCore/Headers.cmake 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/Headers.cmake 2021-09-22 04:06:11 UTC (rev 282863)
@@ -1256,6 +1256,7 @@
platform/graphics/FontCascade.h
platform/graphics/FontCascadeDescription.h
platform/graphics/FontCascadeFonts.h
+ platform/graphics/FontCreationContext.h
platform/graphics/FontDescription.h
platform/graphics/FontFamilySpecificationNull.h
platform/graphics/FontGenericFamilies.h
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (282862 => 282863)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-09-22 04:06:11 UTC (rev 282863)
@@ -651,6 +651,7 @@
1C21E57D183ED1FF001C289D /* IOSurfacePool.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C21E57B183ED1FF001C289D /* IOSurfacePool.h */; settings = {ATTRIBUTES = (Private, ); }; };
1C24EEA51C729CE40080F8FC /* FontFaceSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C24EEA31C729CE40080F8FC /* FontFaceSet.h */; };
1C24EEA91C72A7B40080F8FC /* JSFontFaceSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C24EEA71C72A7B40080F8FC /* JSFontFaceSet.h */; };
+ 1C26671B26FA932F00117073 /* FontCreationContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C26671926FA7F2E00117073 /* FontCreationContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
1C43DE6B22AB4B8A001527D9 /* LocalCurrentTraitCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C43DE6822AB4B8A001527D9 /* LocalCurrentTraitCollection.h */; settings = {ATTRIBUTES = (Private, ); }; };
1C4D0DD324D9F10D003D7498 /* GlyphBufferMembers.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C4D0DD124D9F0DB003D7498 /* GlyphBufferMembers.h */; settings = {ATTRIBUTES = (Private, ); }; };
1C5E1DA826F94B9000E07AF1 /* FontPaletteValues.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C5E1DA626F949B900E07AF1 /* FontPaletteValues.h */; };
@@ -7046,6 +7047,7 @@
1C24EEA61C72A7B40080F8FC /* JSFontFaceSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSFontFaceSet.cpp; path = DerivedSources/WebCore/JSFontFaceSet.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
1C24EEA71C72A7B40080F8FC /* JSFontFaceSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSFontFaceSet.h; path = DerivedSources/WebCore/JSFontFaceSet.h; sourceTree = BUILT_PRODUCTS_DIR; };
1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentLoaderMac.cpp; sourceTree = "<group>"; };
+ 1C26671926FA7F2E00117073 /* FontCreationContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontCreationContext.h; sourceTree = "<group>"; };
1C3249101C6D6A3B007EDB32 /* FontVariantBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontVariantBuilder.cpp; sourceTree = "<group>"; };
1C3969CF1B74211E002BCFA7 /* FontCacheCoreText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontCacheCoreText.cpp; sourceTree = "<group>"; };
1C43DE6822AB4B8A001527D9 /* LocalCurrentTraitCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalCurrentTraitCollection.h; sourceTree = "<group>"; };
@@ -27001,6 +27003,7 @@
E4E8B4F2216B8B6000B8834D /* FontCascadeDescription.h */,
B2C3DA560D006CD600EF6F26 /* FontCascadeFonts.cpp */,
B2C3DA570D006CD600EF6F26 /* FontCascadeFonts.h */,
+ 1C26671926FA7F2E00117073 /* FontCreationContext.h */,
37ACCE620DA2AA960089E602 /* FontDescription.cpp */,
B2C3DA550D006CD600EF6F26 /* FontDescription.h */,
C280B3FD1EF4608900D35135 /* FontFamilySpecificationNull.cpp */,
@@ -32501,6 +32504,7 @@
B2C3DA610D006CD600EF6F26 /* FontCascade.h in Headers */,
E4E8B4F5216B956500B8834D /* FontCascadeDescription.h in Headers */,
B2C3DA680D006CD600EF6F26 /* FontCascadeFonts.h in Headers */,
+ 1C26671B26FA932F00117073 /* FontCreationContext.h in Headers */,
B2AFFC7E0D00A5C10030074D /* FontCustomPlatformData.h in Headers */,
B2C3DA660D006CD600EF6F26 /* FontDescription.h in Headers */,
1C6626111C6E7CA600AB527C /* FontFace.h in Headers */,
Modified: trunk/Source/WebCore/css/CSSFontFace.cpp (282862 => 282863)
--- trunk/Source/WebCore/css/CSSFontFace.cpp 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/css/CSSFontFace.cpp 2021-09-22 04:06:11 UTC (rev 282863)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -679,10 +679,12 @@
Font::Visibility visibility = WebCore::visibility(status(), fontLoadTiming());
return Font::create(fontCache.lastResortFallbackFont(fontDescription)->platformData(), Font::Origin::Local, &fontCache, Font::Interstitial::Yes, visibility);
}
- case CSSFontFaceSource::Status::Success:
- if (auto result = source->font(fontDescription, syntheticBold, syntheticItalic, m_featureSettings, m_fontSelectionCapabilities))
+ case CSSFontFaceSource::Status::Success: {
+ FontCreationContext fontCreationContext { m_featureSettings, m_fontSelectionCapabilities };
+ if (auto result = source->font(fontDescription, syntheticBold, syntheticItalic, fontCreationContext))
return result;
break;
+ }
case CSSFontFaceSource::Status::Failure:
break;
}
Modified: trunk/Source/WebCore/css/CSSFontFaceSource.cpp (282862 => 282863)
--- trunk/Source/WebCore/css/CSSFontFaceSource.cpp 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/css/CSSFontFaceSource.cpp 2021-09-22 04:06:11 UTC (rev 282863)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008, 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -34,6 +34,7 @@
#include "Font.h"
#include "FontCache.h"
#include "FontCascadeDescription.h"
+#include "FontCreationContext.h"
#include "FontCustomPlatformData.h"
#include "FontDescription.h"
#include "ResourceLoadObserver.h"
@@ -185,7 +186,7 @@
fontDescription.setOneFamily(m_familyNameOrURI);
fontDescription.setComputedSize(1);
fontDescription.setShouldAllowUserInstalledFonts(m_face.allowUserInstalledFonts());
- success = FontCache::singleton().fontForFamily(fontDescription, m_familyNameOrURI, nullptr, FontSelectionSpecifiedCapabilities(), true);
+ success = FontCache::singleton().fontForFamily(fontDescription, m_familyNameOrURI, { }, true);
if (document && RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled())
ResourceLoadObserver::shared().logFontLoad(*document, m_familyNameOrURI.string(), success);
}
@@ -193,7 +194,7 @@
}
}
-RefPtr<Font> CSSFontFaceSource::font(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings& fontFaceFeatures, FontSelectionSpecifiedCapabilities fontFaceCapabilities)
+RefPtr<Font> CSSFontFaceSource::font(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, const FontCreationContext& fontCreationContext)
{
ASSERT(status() == Status::Success);
@@ -203,12 +204,12 @@
if (m_immediateSource) {
if (!m_immediateFontCustomPlatformData)
return nullptr;
- return Font::create(CachedFont::platformDataFromCustomData(*m_immediateFontCustomPlatformData, fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceCapabilities), Font::Origin::Remote);
+ return Font::create(CachedFont::platformDataFromCustomData(*m_immediateFontCustomPlatformData, fontDescription, syntheticBold, syntheticItalic, fontCreationContext), Font::Origin::Remote);
}
// We're local. Just return a Font from the normal cache.
// We don't want to check alternate font family names here, so pass true as the checkingAlternateName parameter.
- return FontCache::singleton().fontForFamily(fontDescription, m_familyNameOrURI, &fontFaceFeatures, fontFaceCapabilities, true);
+ return FontCache::singleton().fontForFamily(fontDescription, m_familyNameOrURI, fontCreationContext, true);
}
if (m_fontRequest) {
@@ -216,7 +217,7 @@
ASSERT_UNUSED(success, success);
ASSERT(status() == Status::Success);
- auto result = m_fontRequest->createFont(fontDescription, m_familyNameOrURI, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceCapabilities);
+ auto result = m_fontRequest->createFont(fontDescription, m_familyNameOrURI, syntheticBold, syntheticItalic, fontCreationContext);
ASSERT(result);
return result;
}
@@ -228,7 +229,7 @@
return nullptr;
if (!m_inDocumentCustomPlatformData)
return nullptr;
- return Font::create(m_inDocumentCustomPlatformData->fontPlatformData(fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceCapabilities), Font::Origin::Remote);
+ return Font::create(m_inDocumentCustomPlatformData->fontPlatformData(fontDescription, syntheticBold, syntheticItalic, fontCreationContext), Font::Origin::Remote);
}
bool CSSFontFaceSource::isSVGFontFaceSource() const
Modified: trunk/Source/WebCore/css/CSSFontFaceSource.h (282862 => 282863)
--- trunk/Source/WebCore/css/CSSFontFaceSource.h 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/css/CSSFontFaceSource.h 2021-09-22 04:06:11 UTC (rev 282863)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -36,6 +36,7 @@
class CSSFontSelector;
class Document;
class Font;
+struct FontCreationContext;
struct FontCustomPlatformData;
class FontDescription;
struct FontSelectionSpecifiedCapabilities;
@@ -73,7 +74,7 @@
void opportunisticallyStartFontDataURLLoading();
void load(Document* = nullptr);
- RefPtr<Font> font(const FontDescription&, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings&, FontSelectionSpecifiedCapabilities);
+ RefPtr<Font> font(const FontDescription&, bool syntheticBold, bool syntheticItalic, const FontCreationContext&);
FontLoadRequest* fontLoadRequest() const { return m_fontRequest.get(); }
bool requiresExternalResource() const { return m_fontRequest.get(); }
Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (282862 => 282863)
--- trunk/Source/WebCore/css/CSSFontSelector.cpp 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/css/CSSFontSelector.cpp 2021-09-22 04:06:11 UTC (rev 282863)
@@ -347,7 +347,7 @@
if (!resolveGenericFamilyFirst)
resolveAndAssignGenericFamily();
- auto font = m_fontCache->fontForFamily(*fontDescriptionForLookup, familyForLookup);
+ auto font = m_fontCache->fontForFamily(*fontDescriptionForLookup, familyForLookup, { });
if (document && RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled())
ResourceLoadObserver::shared().logFontLoad(*document, familyForLookup.string(), !!font);
return FontRanges { WTFMove(font) };
Modified: trunk/Source/WebCore/loader/FontLoadRequest.h (282862 => 282863)
--- trunk/Source/WebCore/loader/FontLoadRequest.h 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/loader/FontLoadRequest.h 2021-09-22 04:06:11 UTC (rev 282863)
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2021 Metrological Group B.V.
* Copyright (C) 2021 Igalia S.L.
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -31,6 +32,7 @@
namespace WebCore {
class Font;
+struct FontCreationContext;
class FontDescription;
class FontLoadRequest;
struct FontSelectionSpecifiedCapabilities;
@@ -51,7 +53,7 @@
virtual bool errorOccurred() const = 0;
virtual bool ensureCustomFontData(const AtomString& remoteURI) = 0;
- virtual RefPtr<Font> createFont(const FontDescription&, const AtomString& remoteURI, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings&, FontSelectionSpecifiedCapabilities) = 0;
+ virtual RefPtr<Font> createFont(const FontDescription&, const AtomString& remoteURI, bool syntheticBold, bool syntheticItalic, const FontCreationContext&) = 0;
virtual void setClient(FontLoadRequestClient*) = 0;
Modified: trunk/Source/WebCore/loader/cache/CachedFont.cpp (282862 => 282863)
--- trunk/Source/WebCore/loader/cache/CachedFont.cpp 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/loader/cache/CachedFont.cpp 2021-09-22 04:06:11 UTC (rev 282863)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2021 Apple Inc. All rights reserved.
* Copyright (C) 2009 Torch Mobile, Inc.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,6 +30,7 @@
#include "CachedFontClient.h"
#include "CachedResourceClientWalker.h"
#include "CachedResourceLoader.h"
+#include "FontCreationContext.h"
#include "FontCustomPlatformData.h"
#include "FontDescription.h"
#include "FontPlatformData.h"
@@ -109,20 +110,20 @@
return buffer ? createFontCustomPlatformData(*buffer, itemInCollection) : nullptr;
}
-RefPtr<Font> CachedFont::createFont(const FontDescription& fontDescription, const AtomString&, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings& fontFaceFeatures, FontSelectionSpecifiedCapabilities fontFaceCapabilities)
+RefPtr<Font> CachedFont::createFont(const FontDescription& fontDescription, const AtomString&, bool syntheticBold, bool syntheticItalic, const FontCreationContext& fontCreationContext)
{
- return Font::create(platformDataFromCustomData(fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceCapabilities), Font::Origin::Remote);
+ return Font::create(platformDataFromCustomData(fontDescription, syntheticBold, syntheticItalic, fontCreationContext), Font::Origin::Remote);
}
-FontPlatformData CachedFont::platformDataFromCustomData(const FontDescription& fontDescription, bool bold, bool italic, const FontFeatureSettings& fontFaceFeatures, FontSelectionSpecifiedCapabilities fontFaceCapabilities)
+FontPlatformData CachedFont::platformDataFromCustomData(const FontDescription& fontDescription, bool bold, bool italic, const FontCreationContext& fontCreationContext)
{
ASSERT(m_fontCustomPlatformData);
- return platformDataFromCustomData(*m_fontCustomPlatformData, fontDescription, bold, italic, fontFaceFeatures, fontFaceCapabilities);
+ return platformDataFromCustomData(*m_fontCustomPlatformData, fontDescription, bold, italic, fontCreationContext);
}
-FontPlatformData CachedFont::platformDataFromCustomData(FontCustomPlatformData& fontCustomPlatformData, const FontDescription& fontDescription, bool bold, bool italic, const FontFeatureSettings& fontFaceFeatures, FontSelectionSpecifiedCapabilities fontFaceCapabilities)
+FontPlatformData CachedFont::platformDataFromCustomData(FontCustomPlatformData& fontCustomPlatformData, const FontDescription& fontDescription, bool bold, bool italic, const FontCreationContext& fontCreationContext)
{
- return fontCustomPlatformData.fontPlatformData(fontDescription, bold, italic, fontFaceFeatures, fontFaceCapabilities);
+ return fontCustomPlatformData.fontPlatformData(fontDescription, bold, italic, fontCreationContext);
}
void CachedFont::allClientsRemoved()
Modified: trunk/Source/WebCore/loader/cache/CachedFont.h (282862 => 282863)
--- trunk/Source/WebCore/loader/cache/CachedFont.h 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/loader/cache/CachedFont.h 2021-09-22 04:06:11 UTC (rev 282863)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -34,6 +34,7 @@
namespace WebCore {
class CachedResourceLoader;
+struct FontCreationContext;
class FontDescription;
class FontPlatformData;
struct FontSelectionSpecifiedCapabilities;
@@ -54,12 +55,12 @@
virtual bool ensureCustomFontData(const AtomString& remoteURI);
static std::unique_ptr<FontCustomPlatformData> createCustomFontData(SharedBuffer&, const String& itemInCollection, bool& wrapping);
- static FontPlatformData platformDataFromCustomData(FontCustomPlatformData&, const FontDescription&, bool bold, bool italic, const FontFeatureSettings&, FontSelectionSpecifiedCapabilities);
+ static FontPlatformData platformDataFromCustomData(FontCustomPlatformData&, const FontDescription&, bool bold, bool italic, const FontCreationContext&);
- virtual RefPtr<Font> createFont(const FontDescription&, const AtomString& remoteURI, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings&, FontSelectionSpecifiedCapabilities);
+ virtual RefPtr<Font> createFont(const FontDescription&, const AtomString& remoteURI, bool syntheticBold, bool syntheticItalic, const FontCreationContext&);
protected:
- FontPlatformData platformDataFromCustomData(const FontDescription&, bool bold, bool italic, const FontFeatureSettings&, FontSelectionSpecifiedCapabilities);
+ FontPlatformData platformDataFromCustomData(const FontDescription&, bool bold, bool italic, const FontCreationContext&);
bool ensureCustomFontData(SharedBuffer* data);
Modified: trunk/Source/WebCore/loader/cache/CachedFontLoadRequest.h (282862 => 282863)
--- trunk/Source/WebCore/loader/cache/CachedFontLoadRequest.h 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/loader/cache/CachedFontLoadRequest.h 2021-09-22 04:06:11 UTC (rev 282863)
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2021 Metrological Group B.V.
* Copyright (C) 2021 Igalia S.L.
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -33,6 +34,8 @@
namespace WebCore {
+struct FontCreationContext;
+
class CachedFontLoadRequest final : public FontLoadRequest, public CachedFontClient {
WTF_MAKE_FAST_ALLOCATED;
public:
@@ -56,9 +59,9 @@
bool errorOccurred() const final { return m_font->errorOccurred(); }
bool ensureCustomFontData(const AtomString& remoteURI) final { return m_font->ensureCustomFontData(remoteURI); }
- RefPtr<Font> createFont(const FontDescription& description, const AtomString& remoteURI, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings& settings, FontSelectionSpecifiedCapabilities capabilities) final
+ RefPtr<Font> createFont(const FontDescription& description, const AtomString& remoteURI, bool syntheticBold, bool syntheticItalic, const FontCreationContext& fontCreationContext) final
{
- return m_font->createFont(description, remoteURI, syntheticBold, syntheticItalic, settings, capabilities);
+ return m_font->createFont(description, remoteURI, syntheticBold, syntheticItalic, fontCreationContext);
}
void setClient(FontLoadRequestClient* client) final
Modified: trunk/Source/WebCore/loader/cache/CachedSVGFont.cpp (282862 => 282863)
--- trunk/Source/WebCore/loader/cache/CachedSVGFont.cpp 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/loader/cache/CachedSVGFont.cpp 2021-09-22 04:06:11 UTC (rev 282863)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2021 Apple Inc. All rights reserved.
* Copyright (C) 2009 Torch Mobile, Inc.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,6 +27,7 @@
#include "config.h"
#include "CachedSVGFont.h"
+#include "FontCreationContext.h"
#include "FontDescription.h"
#include "FontPlatformData.h"
#include "SVGDocument.h"
@@ -53,17 +54,17 @@
{
}
-RefPtr<Font> CachedSVGFont::createFont(const FontDescription& fontDescription, const AtomString& remoteURI, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings& fontFaceFeatures, FontSelectionSpecifiedCapabilities fontFaceCapabilities)
+RefPtr<Font> CachedSVGFont::createFont(const FontDescription& fontDescription, const AtomString& remoteURI, bool syntheticBold, bool syntheticItalic, const FontCreationContext& fontCreationContext)
{
ASSERT(firstFontFace(remoteURI));
- return CachedFont::createFont(fontDescription, remoteURI, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceCapabilities);
+ return CachedFont::createFont(fontDescription, remoteURI, syntheticBold, syntheticItalic, fontCreationContext);
}
-FontPlatformData CachedSVGFont::platformDataFromCustomData(const FontDescription& fontDescription, bool bold, bool italic, const FontFeatureSettings& fontFaceFeatures, FontSelectionSpecifiedCapabilities fontFaceCapabilities)
+FontPlatformData CachedSVGFont::platformDataFromCustomData(const FontDescription& fontDescription, bool bold, bool italic, const FontCreationContext& fontCreationContext)
{
if (m_externalSVGDocument)
- return FontPlatformData(fontDescription.computedPixelSize(), bold, italic);
- return CachedFont::platformDataFromCustomData(fontDescription, bold, italic, fontFaceFeatures, fontFaceCapabilities);
+ return FontPlatformData(fontDescription.computedPixelSize(), bold, italic); // FIXME: This doesn't seem right.
+ return CachedFont::platformDataFromCustomData(fontDescription, bold, italic, fontCreationContext);
}
bool CachedSVGFont::ensureCustomFontData(const AtomString& remoteURI)
Modified: trunk/Source/WebCore/loader/cache/CachedSVGFont.h (282862 => 282863)
--- trunk/Source/WebCore/loader/cache/CachedSVGFont.h 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/loader/cache/CachedSVGFont.h 2021-09-22 04:06:11 UTC (rev 282863)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,6 +29,7 @@
namespace WebCore {
+struct FontCreationContext;
class SVGFontFaceElement;
class Settings;
@@ -39,10 +40,10 @@
bool ensureCustomFontData(const AtomString& remoteURI) override;
- RefPtr<Font> createFont(const FontDescription&, const AtomString& remoteURI, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings&, FontSelectionSpecifiedCapabilities) override;
+ RefPtr<Font> createFont(const FontDescription&, const AtomString& remoteURI, bool syntheticBold, bool syntheticItalic, const FontCreationContext&) override;
private:
- FontPlatformData platformDataFromCustomData(const FontDescription&, bool bold, bool italic, const FontFeatureSettings&, FontSelectionSpecifiedCapabilities);
+ FontPlatformData platformDataFromCustomData(const FontDescription&, bool bold, bool italic, const FontCreationContext&);
SVGFontElement* getSVGFontById(const String&) const;
Modified: trunk/Source/WebCore/platform/graphics/Font.cpp (282862 => 282863)
--- trunk/Source/WebCore/platform/graphics/Font.cpp 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/platform/graphics/Font.cpp 2021-09-22 04:06:11 UTC (rev 282863)
@@ -74,7 +74,9 @@
auto customFontData = CachedFont::createCustomFontData(fontFaceData.get(), { }, wrapping);
FontDescription description;
description.setComputedSize(fontSize);
- return Font::create(CachedFont::platformDataFromCustomData(*customFontData, description, syntheticBold, syntheticItalic, { }, { }), origin, fontCacheForVerticalData);
+ // FIXME: Why doesn't this pass in any meaningful data for the last few arguments?
+ auto platformData = CachedFont::platformDataFromCustomData(*customFontData, description, syntheticBold, syntheticItalic, { });
+ return Font::create(WTFMove(platformData), origin, fontCacheForVerticalData);
}
Font::Font(const FontPlatformData& platformData, Origin origin, Interstitial interstitial, Visibility visibility, OrientationFallback orientationFallback, std::optional<RenderingResourceIdentifier> renderingResourceIdentifier, FontCache* fontCacheForVerticalData)
Modified: trunk/Source/WebCore/platform/graphics/FontCache.cpp (282862 => 282863)
--- trunk/Source/WebCore/platform/graphics/FontCache.cpp 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/platform/graphics/FontCache.cpp 2021-09-22 04:06:11 UTC (rev 282863)
@@ -31,6 +31,7 @@
#include "FontCache.h"
#include "FontCascade.h"
+#include "FontCreationContext.h"
#include "FontPlatformData.h"
#include "FontSelector.h"
#include "Logging.h"
@@ -80,17 +81,18 @@
struct FontPlatformDataCacheKey {
FontDescriptionKey descriptionKey;
FontFamilyName family;
- FontFeatureSettings features;
- FontSelectionSpecifiedCapabilities capabilities;
+ FontCreationContext fontCreationContext;
};
static bool operator==(const FontPlatformDataCacheKey& a, const FontPlatformDataCacheKey& b)
{
- return a.descriptionKey == b.descriptionKey && a.family == b.family && a.features == b.features && a.capabilities == b.capabilities;
+ return a.descriptionKey == b.descriptionKey
+ && a.family == b.family
+ && a.fontCreationContext == b.fontCreationContext;
}
struct FontPlatformDataCacheKeyHash {
- static unsigned hash(const FontPlatformDataCacheKey& key) { return computeHash(key.descriptionKey, key.family, key.features, key.capabilities.tied()); }
+ static unsigned hash(const FontPlatformDataCacheKey& key) { return computeHash(key.descriptionKey, key.family, key.fontCreationContext); }
static bool equal(const FontPlatformDataCacheKey& a, const FontPlatformDataCacheKey& b) { return a == b; }
static constexpr bool safeToCompareToEmptyOrDeleted = true;
};
@@ -206,8 +208,7 @@
return std::nullopt;
}
-FontPlatformData* FontCache::cachedFontPlatformData(const FontDescription& fontDescription, const String& passedFamilyName,
- const FontFeatureSettings* features, FontSelectionSpecifiedCapabilities capabilities, bool checkingAlternateName)
+FontPlatformData* FontCache::cachedFontPlatformData(const FontDescription& fontDescription, const String& passedFamilyName, const FontCreationContext& fontCreationContext, bool checkingAlternateName)
{
#if PLATFORM(IOS_FAMILY)
Locker locker { m_fontLock };
@@ -227,17 +228,17 @@
platformInit();
});
- FontPlatformDataCacheKey key { fontDescription, { familyName }, features ? *features : FontFeatureSettings { }, capabilities };
+ FontPlatformDataCacheKey key { fontDescription, { familyName }, fontCreationContext };
auto addResult = m_fontDataCaches->platformData.add(key, nullptr);
FontPlatformDataCache::iterator it = addResult.iterator;
if (addResult.isNewEntry) {
- it->value = createFontPlatformData(fontDescription, familyName, features, capabilities);
+ it->value = createFontPlatformData(fontDescription, familyName, fontCreationContext);
if (!it->value && !checkingAlternateName) {
// We were unable to find a font. We have a small set of fonts that we alias to other names,
// e.g., Arial/Helvetica, Courier/Courier New, etc. Try looking up the font under the aliased name.
if (auto alternateName = alternateFamilyName(familyName)) {
- auto* alternateData = cachedFontPlatformData(fontDescription, *alternateName, features, capabilities, true);
+ auto* alternateData = cachedFontPlatformData(fontDescription, *alternateName, fontCreationContext, true);
// Look up the key in the hash table again as the previous iterator may have
// been invalidated by the recursive call to cachedFontPlatformData().
it = m_fontDataCaches->platformData.find(key);
@@ -262,12 +263,12 @@
const unsigned cMaxUnderMemoryPressureInactiveFontData = 50;
const unsigned cTargetUnderMemoryPressureInactiveFontData = 30;
-RefPtr<Font> FontCache::fontForFamily(const FontDescription& fontDescription, const String& family, const FontFeatureSettings* features, FontSelectionSpecifiedCapabilities capabilities, bool checkingAlternateName)
+RefPtr<Font> FontCache::fontForFamily(const FontDescription& fontDescription, const String& family, const FontCreationContext& fontCreationContext, bool checkingAlternateName)
{
if (!m_purgeTimer.isActive())
m_purgeTimer.startOneShot(0_s);
- if (auto* platformData = cachedFontPlatformData(fontDescription, family, features, capabilities, checkingAlternateName))
+ if (auto* platformData = cachedFontPlatformData(fontDescription, family, fontCreationContext, checkingAlternateName))
return fontForPlatformData(*platformData);
return nullptr;
Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (282862 => 282863)
--- trunk/Source/WebCore/platform/graphics/FontCache.h 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h 2021-09-22 04:06:11 UTC (rev 282863)
@@ -30,6 +30,7 @@
#pragma once
#include "FontCascadeFonts.h"
+#include "FontCreationContext.h"
#include "FontDescription.h"
#include "FontPlatformData.h"
#include "FontSelector.h"
@@ -301,7 +302,7 @@
// It comes into play when you create an @font-face which shares a family name as a preinstalled font.
Vector<FontSelectionCapabilities> getFontSelectionCapabilitiesInFamily(const AtomString&, AllowUserInstalledFonts);
- WEBCORE_EXPORT RefPtr<Font> fontForFamily(const FontDescription&, const String&, const FontFeatureSettings* fontFaceFeatures = nullptr, FontSelectionSpecifiedCapabilities fontFaceCapabilities = { }, bool checkingAlternateName = false);
+ WEBCORE_EXPORT RefPtr<Font> fontForFamily(const FontDescription&, const String&, const FontCreationContext& = { }, bool checkingAlternateName = false);
WEBCORE_EXPORT Ref<Font> lastResortFallbackFont(const FontDescription&);
WEBCORE_EXPORT Ref<Font> fontForPlatformData(const FontPlatformData&);
RefPtr<Font> similarFont(const FontDescription&, const String& family);
@@ -356,10 +357,10 @@
void pruneSystemFallbackFonts();
Ref<FontCascadeFonts> retrieveOrAddCachedFonts(const FontCascadeDescription&, RefPtr<FontSelector>&&);
- FontPlatformData* cachedFontPlatformData(const FontDescription&, const String& family, const FontFeatureSettings* = nullptr, FontSelectionSpecifiedCapabilities = { }, bool checkingAlternateName = false);
+ FontPlatformData* cachedFontPlatformData(const FontDescription&, const String& family, const FontCreationContext& = { }, bool checkingAlternateName = false);
// These functions are implemented by each platform (unclear which functions this comment applies to).
- WEBCORE_EXPORT std::unique_ptr<FontPlatformData> createFontPlatformData(const FontDescription&, const AtomString& family, const FontFeatureSettings*, FontSelectionSpecifiedCapabilities);
+ WEBCORE_EXPORT std::unique_ptr<FontPlatformData> createFontPlatformData(const FontDescription&, const AtomString& family, const FontCreationContext&);
static std::optional<ASCIILiteral> alternateFamilyName(const String&);
static std::optional<ASCIILiteral> platformAlternateFamilyName(const String&);
@@ -392,7 +393,7 @@
inline std::unique_ptr<FontPlatformData> FontCache::createFontPlatformDataForTesting(const FontDescription& fontDescription, const AtomString& family)
{
- return createFontPlatformData(fontDescription, family, nullptr, { });
+ return createFontPlatformData(fontDescription, family, { });
}
#if !PLATFORM(COCOA) && !USE(FREETYPE)
Added: trunk/Source/WebCore/platform/graphics/FontCreationContext.h (0 => 282863)
--- trunk/Source/WebCore/platform/graphics/FontCreationContext.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/FontCreationContext.h 2021-09-22 04:06:11 UTC (rev 282863)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "FontSelectionAlgorithm.h"
+#include "FontTaggedSettings.h"
+
+namespace WebCore {
+
+struct FontCreationContext {
+ bool operator==(const FontCreationContext& other) const
+ {
+ return fontFaceFeatures == other.fontFaceFeatures
+ && fontFaceCapabilities == other.fontFaceCapabilities;
+ }
+
+ bool operator!=(const FontCreationContext& other) const
+ {
+ return !(*this == other);
+ }
+
+ FontFeatureSettings fontFaceFeatures;
+ FontSelectionSpecifiedCapabilities fontFaceCapabilities;
+ // FIXME: Add support for font-palette-values and font-feature-values.
+};
+
+inline void add(Hasher& hasher, const FontCreationContext& fontCreationContext)
+{
+ add(hasher, fontCreationContext.fontFaceFeatures);
+ add(hasher, fontCreationContext.fontFaceCapabilities.tied());
+}
+
+}
Property changes on: trunk/Source/WebCore/platform/graphics/FontCreationContext.h
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Author Date Id Rev URL
\ No newline at end of property
Modified: trunk/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h (282862 => 282863)
--- trunk/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h 2021-09-22 04:06:11 UTC (rev 282863)
@@ -31,6 +31,7 @@
namespace WebCore {
+struct FontCreationContext;
class FontDescription;
class FontPlatformData;
class SharedBuffer;
@@ -46,7 +47,7 @@
public:
FontCustomPlatformData(FT_Face, SharedBuffer&);
~FontCustomPlatformData() = default;
- FontPlatformData fontPlatformData(const FontDescription&, bool bold, bool italic, const FontFeatureSettings&, FontSelectionSpecifiedCapabilities);
+ FontPlatformData fontPlatformData(const FontDescription&, bool bold, bool italic, const FontCreationContext&);
static bool supportsFormat(const String&);
private:
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (282862 => 282863)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2021-09-22 04:06:11 UTC (rev 282863)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,8 +26,10 @@
#include "config.h"
#include "FontCache.h"
+#include "Color.h"
#include "Font.h"
#include "FontCascadeDescription.h"
+#include "FontCreationContext.h"
#include "FontFamilySpecificationCoreText.h"
#include "RenderThemeCocoa.h"
#include "SystemFontDatabaseCoreText.h"
@@ -440,7 +442,7 @@
bool aatShaping { false };
};
-RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, const FontDescription& fontDescription, const FontFeatureSettings* fontFaceFeatures, FontSelectionSpecifiedCapabilities fontFaceCapabilities, bool applyWeightWidthSlopeVariations)
+RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, const FontDescription& fontDescription, const FontCreationContext& fontCreationContext, bool applyWeightWidthSlopeVariations)
{
if (!originalFont)
return originalFont;
@@ -469,7 +471,7 @@
bool textRenderingModeIsAuto = textRenderingMode == TextRenderingMode::AutoTextRendering;
bool variantSettingsIsNormal = variantSettings.isAllNormal();
bool dontNeedToApplyOpticalSizing = fontOpticalSizing == FontOpticalSizing::Enabled && !forceOpticalSizingOn;
- bool fontFaceDoesntSpecifyFeatures = !fontFaceFeatures || fontFaceFeatures->isEmpty();
+ bool fontFaceDoesntSpecifyFeatures = fontCreationContext.fontFaceFeatures.isEmpty();
if (noFontFeatureSettings && noFontVariationSettings && textRenderingModeIsAuto && variantSettingsIsNormal && dontNeedToApplyOpticalSizing && fontFaceDoesntSpecifyFeatures && !shouldDisableLigaturesForSpacing) {
#if HAVE(CTFONTCREATEFORCHARACTERSWITHLANGUAGEANDOPTION)
return originalFont;
@@ -515,11 +517,11 @@
float weight = fontSelectionRequest.weight;
float width = fontSelectionRequest.width;
float slope = fontSelectionRequest.slope.value_or(normalItalicValue());
- if (auto weightValue = fontFaceCapabilities.weight)
+ if (auto weightValue = fontCreationContext.fontFaceCapabilities.weight)
weight = std::max(std::min(weight, static_cast<float>(weightValue->maximum)), static_cast<float>(weightValue->minimum));
- if (auto widthValue = fontFaceCapabilities.width)
+ if (auto widthValue = fontCreationContext.fontFaceCapabilities.width)
width = std::max(std::min(width, static_cast<float>(widthValue->maximum)), static_cast<float>(widthValue->minimum));
- if (auto slopeValue = fontFaceCapabilities.weight)
+ if (auto slopeValue = fontCreationContext.fontFaceCapabilities.weight)
slope = std::max(std::min(slope, static_cast<float>(slopeValue->maximum)), static_cast<float>(slopeValue->minimum));
if (needsConversion) {
weight = denormalizeWeight(weight);
@@ -539,8 +541,8 @@
// FIXME: Implement Step 6: the font-variation-settings descriptor inside @font-face
// Step 7: Consult with font-feature-settings inside @font-face
- if (fontFaceFeatures) {
- for (auto& fontFaceFeature : *fontFaceFeatures)
+ if (!fontCreationContext.fontFaceFeatures.isEmpty()) {
+ for (auto& fontFaceFeature : fontCreationContext.fontFaceFeatures)
applyFeature(fontFaceFeature.tag(), fontFaceFeature.value());
}
@@ -574,7 +576,7 @@
for (auto& newVariation : variations)
applyVariation(newVariation.tag(), newVariation.value());
- auto attributes = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+ auto attributes = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
if (!featuresToBeApplied.isEmpty()) {
auto featureArray = adoptCF(CFArrayCreateMutable(kCFAllocatorDefault, features.size(), &kCFTypeArrayCallBacks));
for (auto& p : featuresToBeApplied) {
@@ -1242,7 +1244,7 @@
return nullptr;
}
-static RetainPtr<CTFontRef> fontWithFamily(const AtomString& family, const FontDescription& fontDescription, const FontFeatureSettings* fontFaceFeatures, FontSelectionSpecifiedCapabilities fontFaceCapabilities, float size)
+static RetainPtr<CTFontRef> fontWithFamily(const AtomString& family, const FontDescription& fontDescription, const FontCreationContext& fontCreationContext, float size)
{
if (family.isEmpty())
return nullptr;
@@ -1251,7 +1253,7 @@
fontLookup.result = fontWithFamilySpecialCase(family, fontDescription, size, fontDescription.shouldAllowUserInstalledFonts());
if (!fontLookup.result)
fontLookup = platformFontLookupWithFamily(family, fontDescription.fontSelectionRequest(), size, fontDescription.shouldAllowUserInstalledFonts());
- return preparePlatformFont(fontLookup.result.get(), fontDescription, fontFaceFeatures, fontFaceCapabilities, !fontLookup.createdFromPostScriptName);
+ return preparePlatformFont(fontLookup.result.get(), fontDescription, fontCreationContext, !fontLookup.createdFromPostScriptName);
}
#if PLATFORM(MAC)
@@ -1285,11 +1287,11 @@
}
#endif
-std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomString& family, const FontFeatureSettings* fontFaceFeatures, FontSelectionSpecifiedCapabilities fontFaceCapabilities)
+std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomString& family, const FontCreationContext& fontCreationContext)
{
float size = fontDescription.computedPixelSize();
- auto font = fontWithFamily(family, fontDescription, fontFaceFeatures, fontFaceCapabilities, size);
+ auto font = fontWithFamily(family, fontDescription, fontCreationContext, size);
#if PLATFORM(MAC)
if (!font) {
@@ -1300,7 +1302,7 @@
// Ignore the result because we want to use our own algorithm to actually find the font.
autoActivateFont(family.string(), size);
- font = fontWithFamily(family, fontDescription, fontFaceFeatures, fontFaceCapabilities, size);
+ font = fontWithFamily(family, fontDescription, fontCreationContext, size);
}
#endif
@@ -1412,7 +1414,7 @@
m_fontNamesRequiringSystemFallbackForPrewarming.add(fullName);
auto result = lookupFallbackFont(platformData.font(), description.weight(), description.computedLocale(), description.shouldAllowUserInstalledFonts(), characters, length);
- result = preparePlatformFont(result.get(), description, nullptr, { });
+ result = preparePlatformFont(result.get(), description, { });
if (!result)
return lastResortFallbackFont(description);
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h (282862 => 282863)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h 2021-09-22 04:06:11 UTC (rev 282863)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -34,6 +34,8 @@
namespace WebCore {
+struct FontCreationContext;
+
struct SynthesisPair {
explicit SynthesisPair(bool needsSyntheticBold, bool needsSyntheticOblique)
: needsSyntheticBold(needsSyntheticBold)
@@ -59,7 +61,7 @@
typedef HashMap<FontTag, VariationDefaults, FourCharacterTagHash, FourCharacterTagHashTraits> VariationDefaultsMap;
-RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, const FontDescription&, const FontFeatureSettings* fontFaceFeatures, FontSelectionSpecifiedCapabilities fontFaceCapabilities, bool applyWeightWidthSlopeVariations = true);
+RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, const FontDescription&, const FontCreationContext&, bool applyWeightWidthSlopeVariations = true);
enum class ShouldComputePhysicalTraits : bool { No, Yes };
SynthesisPair computeNecessarySynthesis(CTFontRef, const FontDescription&, ShouldComputePhysicalTraits = ShouldComputePhysicalTraits::No, bool isPlatformFont = false);
RetainPtr<CTFontRef> platformFontWithFamily(const AtomString& family, FontSelectionRequest, TextRenderingMode, float size);
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp (282862 => 282863)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp 2021-09-22 04:06:11 UTC (rev 282863)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -97,7 +97,7 @@
auto font = adoptCF(CTFontCreateWithFontDescriptor(m_fontDescriptor.get(), size, nullptr));
- font = preparePlatformFont(font.get(), fontDescription, nullptr, { });
+ font = preparePlatformFont(font.get(), fontDescription, { });
auto [syntheticBold, syntheticOblique] = computeNecessarySynthesis(font.get(), fontDescription, ShouldComputePhysicalTraits::Yes).boldObliquePair();
Modified: trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp (282862 => 282863)
--- trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp 2021-09-22 04:06:11 UTC (rev 282863)
@@ -498,7 +498,7 @@
|| equalLettersIgnoringASCIICase(familyNameString, "cursive");
}
-std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomString& family, const FontFeatureSettings* fontFaceFeatures, FontSelectionSpecifiedCapabilities)
+std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomString& family, const FontCreationContext& fontCreationContext)
{
// The CSS font matching algorithm (http://www.w3.org/TR/css3-fonts/#font-matching-algorithm)
// says that we must find an exact match for font family, slant (italic or oblique can be used)
@@ -573,8 +573,8 @@
bool fixedWidth, syntheticBold, syntheticOblique;
getFontPropertiesFromPattern(resultPattern.get(), fontDescription, fixedWidth, syntheticBold, syntheticOblique);
- if (fontFaceFeatures) {
- for (auto& fontFaceFeature : *fontFaceFeatures) {
+ if (!fontCreationContext.fontFaceFeatures.isEmpty()) {
+ for (auto& fontFaceFeature : fontCreationContext.fontFaceFeatures) {
if (fontFaceFeature.enabled()) {
const auto& tag = fontFaceFeature.tag();
const char buffer[] = { tag[0], tag[1], tag[2], tag[3], '\0' };
Modified: trunk/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp (282862 => 282863)
--- trunk/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp 2021-09-22 04:06:11 UTC (rev 282863)
@@ -24,6 +24,7 @@
#include "CairoUtilities.h"
#include "FontCacheFreeType.h"
+#include "FontCreationContext.h"
#include "FontDescription.h"
#include "FontPlatformData.h"
#include "SharedBuffer.h"
@@ -73,7 +74,7 @@
return adoptRef(FcPatternDuplicate(pattern));
}
-FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& description, bool bold, bool italic, const FontFeatureSettings& fontFaceFeatures, FontSelectionSpecifiedCapabilities)
+FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& description, bool bold, bool italic, const FontCreationContext& fontCreationContext)
{
auto* freeTypeFace = static_cast<FT_Face>(cairo_font_face_get_user_data(m_fontFace.get(), &freeTypeFaceKey));
ASSERT(freeTypeFace);
@@ -80,7 +81,7 @@
RefPtr<FcPattern> pattern = defaultFontconfigOptions();
FcPatternAddString(pattern.get(), FC_FAMILY, reinterpret_cast<const FcChar8*>(freeTypeFace->family_name));
- for (auto& fontFaceFeature : fontFaceFeatures) {
+ for (auto& fontFaceFeature : fontCreationContext.fontFaceFeatures) {
if (fontFaceFeature.enabled()) {
const auto& tag = fontFaceFeature.tag();
const char buffer[] = { tag[0], tag[1], tag[2], tag[3], '\0' };
Modified: trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp (282862 => 282863)
--- trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp 2021-09-22 04:06:11 UTC (rev 282863)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2021 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -23,6 +23,7 @@
#include "FontCache.h"
#include "FontCacheCoreText.h"
+#include "FontCreationContext.h"
#include "FontDescription.h"
#include "FontPlatformData.h"
#include "SharedBuffer.h"
@@ -35,7 +36,7 @@
FontCustomPlatformData::~FontCustomPlatformData() = default;
-FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& fontDescription, bool bold, bool italic, const FontFeatureSettings& fontFaceFeatures, FontSelectionSpecifiedCapabilities fontFaceCapabilities)
+FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& fontDescription, bool bold, bool italic, const FontCreationContext& fontCreationContext)
{
auto attributes = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
addAttributesForWebFonts(attributes.get(), fontDescription.shouldAllowUserInstalledFonts());
@@ -46,7 +47,7 @@
FontOrientation orientation = fontDescription.orientation();
FontWidthVariant widthVariant = fontDescription.widthVariant();
auto font = adoptCF(CTFontCreateWithFontDescriptor(modifiedFontDescriptor.get(), size, nullptr));
- font = preparePlatformFont(font.get(), fontDescription, &fontFaceFeatures, fontFaceCapabilities);
+ font = preparePlatformFont(font.get(), fontDescription, fontCreationContext);
ASSERT(font);
return FontPlatformData(font.get(), size, bold, italic, orientation, widthVariant, fontDescription.textRenderingMode(), &creationData);
}
Modified: trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h (282862 => 282863)
--- trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h 2021-09-22 04:06:11 UTC (rev 282863)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007 Apple Inc.
+ * Copyright (C) 2007-2021 Apple Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -33,6 +33,7 @@
namespace WebCore {
+struct FontCreationContext;
class FontDescription;
struct FontSelectionSpecifiedCapabilities;
class SharedBuffer;
@@ -51,7 +52,7 @@
WEBCORE_EXPORT ~FontCustomPlatformData();
- FontPlatformData fontPlatformData(const FontDescription&, bool bold, bool italic, const FontFeatureSettings& fontFaceFeatures, FontSelectionSpecifiedCapabilities fontFaceCapabilities);
+ FontPlatformData fontPlatformData(const FontDescription&, bool bold, bool italic, const FontCreationContext&);
static bool supportsFormat(const String&);
Modified: trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp (282862 => 282863)
--- trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp 2021-09-22 04:06:11 UTC (rev 282863)
@@ -649,7 +649,7 @@
return result;
}
-std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomString& family, const FontFeatureSettings*, FontSelectionSpecifiedCapabilities)
+std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomString& family, const FontCreationContext&)
{
bool isLucidaGrande = equalLettersIgnoringASCIICase(family, "lucida grande");
Modified: trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp (282862 => 282863)
--- trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp 2021-09-22 04:06:11 UTC (rev 282863)
@@ -21,6 +21,7 @@
#include "config.h"
#include "FontCustomPlatformData.h"
+#include "FontCreationContext.h"
#include "FontDescription.h"
#include "FontMemoryResource.h"
#include "FontPlatformData.h"
@@ -49,7 +50,7 @@
FontCustomPlatformData::~FontCustomPlatformData() = default;
-FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& fontDescription, bool bold, bool italic, const FontFeatureSettings&, FontSelectionSpecifiedCapabilities)
+FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& fontDescription, bool bold, bool italic, const FontCreationContext&)
{
int size = fontDescription.computedPixelSize();
FontRenderingMode renderingMode = fontDescription.renderingMode();
Modified: trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h (282862 => 282863)
--- trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h 2021-09-22 04:06:11 UTC (rev 282863)
@@ -36,6 +36,7 @@
namespace WebCore {
+struct FontCreationContext;
class FontDescription;
class FontMemoryResource;
class SharedBuffer;
@@ -52,7 +53,7 @@
FontCustomPlatformData(const String& name, FontPlatformData::CreationData&&);
~FontCustomPlatformData();
- FontPlatformData fontPlatformData(const FontDescription&, bool bold, bool italic, const FontFeatureSettings&, FontSelectionSpecifiedCapabilities);
+ FontPlatformData fontPlatformData(const FontDescription&, bool bold, bool italic, const FontCreationContext&);
static bool supportsFormat(const String&);
Modified: trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp (282862 => 282863)
--- trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp 2021-09-22 04:06:11 UTC (rev 282863)
@@ -21,6 +21,7 @@
#include "config.h"
#include "FontCustomPlatformData.h"
+#include "FontCreationContext.h"
#include "FontDescription.h"
#include "FontMemoryResource.h"
#include "FontPlatformData.h"
@@ -41,7 +42,7 @@
FontCustomPlatformData::~FontCustomPlatformData() = default;
-FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& fontDescription, bool bold, bool italic, const FontFeatureSettings&, FontSelectionSpecifiedCapabilities)
+FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& fontDescription, bool bold, bool italic, const FontCreationContext&)
{
int size = fontDescription.computedPixelSize();
FontRenderingMode renderingMode = fontDescription.renderingMode();
Modified: trunk/Source/WebCore/workers/WorkerFontLoadRequest.cpp (282862 => 282863)
--- trunk/Source/WebCore/workers/WorkerFontLoadRequest.cpp 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/workers/WorkerFontLoadRequest.cpp 2021-09-22 04:06:11 UTC (rev 282863)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2021 Apple Inc. All rights reserved.
* Copyright (C) 2009 Torch Mobile, Inc.
* Copyright (C) 2021 Metrological Group B.V.
* Copyright (C) 2021 Igalia S.L.
@@ -29,6 +29,7 @@
#include "WorkerFontLoadRequest.h"
#include "Font.h"
+#include "FontCreationContext.h"
#include "FontCustomPlatformData.h"
#include "FontSelectionAlgorithm.h"
#include "ResourceLoaderOptions.h"
@@ -88,11 +89,11 @@
return m_fontCustomPlatformData.get();
}
-RefPtr<Font> WorkerFontLoadRequest::createFont(const FontDescription& fontDescription, const AtomString&, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings& fontFaceFeatures, FontSelectionSpecifiedCapabilities fontFaceCapabilities)
+RefPtr<Font> WorkerFontLoadRequest::createFont(const FontDescription& fontDescription, const AtomString&, bool syntheticBold, bool syntheticItalic, const FontCreationContext& fontCreationContext)
{
ASSERT(m_fontCustomPlatformData);
ASSERT(m_context);
- return Font::create(m_fontCustomPlatformData->fontPlatformData(fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceCapabilities), Font::Origin::Remote, &m_context->fontCache());
+ return Font::create(m_fontCustomPlatformData->fontPlatformData(fontDescription, syntheticBold, syntheticItalic, fontCreationContext), Font::Origin::Remote, &m_context->fontCache());
}
void WorkerFontLoadRequest::setClient(FontLoadRequestClient* client)
Modified: trunk/Source/WebCore/workers/WorkerFontLoadRequest.h (282862 => 282863)
--- trunk/Source/WebCore/workers/WorkerFontLoadRequest.h 2021-09-22 03:40:29 UTC (rev 282862)
+++ trunk/Source/WebCore/workers/WorkerFontLoadRequest.h 2021-09-22 04:06:11 UTC (rev 282863)
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2021 Metrological Group B.V.
* Copyright (C) 2021 Igalia S.L.
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -33,6 +34,7 @@
namespace WebCore {
+struct FontCreationContext;
class ScriptExecutionContext;
class SharedBuffer;
class WorkerGlobalScope;
@@ -54,7 +56,7 @@
bool errorOccurred() const final { return m_errorOccurred; }
bool ensureCustomFontData(const AtomString& remoteURI) final;
- RefPtr<Font> createFont(const FontDescription&, const AtomString& remoteURI, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings&, FontSelectionSpecifiedCapabilities) final;
+ RefPtr<Font> createFont(const FontDescription&, const AtomString& remoteURI, bool syntheticBold, bool syntheticItalic, const FontCreationContext&) final;
void setClient(FontLoadRequestClient*) final;