Changeset 275420 in webkit
- Timestamp:
- Apr 2, 2021 7:06:16 AM (16 months ago)
- Location:
- trunk
- Files:
-
- 30 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/text/2d.text.font.parse.basic.worker-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/text/2d.text.font.parse.complex.worker-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/text/2d.text.font.parse.invalid.worker-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/text/2d.text.font.parse.tiny.worker-expected.txt (modified) (1 diff)
-
LayoutTests/platform/glib/TestExpectations (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/CSSFontSelector.cpp (modified) (7 diffs)
-
Source/WebCore/css/CSSFontSelector.h (modified) (4 diffs)
-
Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (modified) (3 diffs)
-
Source/WebCore/css/parser/CSSPropertyParserHelpers.h (modified) (2 diffs)
-
Source/WebCore/dom/Document.h (modified) (1 diff)
-
Source/WebCore/dom/ScriptExecutionContext.cpp (modified) (2 diffs)
-
Source/WebCore/dom/ScriptExecutionContext.h (modified) (2 diffs)
-
Source/WebCore/dom/make_names.pl (modified) (3 diffs)
-
Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp (modified) (1 diff)
-
Source/WebCore/html/canvas/OffscreenCanvasRenderingContext2D.cpp (modified) (3 diffs)
-
Source/WebCore/platform/graphics/FontCache.cpp (modified) (15 diffs)
-
Source/WebCore/platform/graphics/FontCache.h (modified) (6 diffs)
-
Source/WebCore/platform/graphics/FontCascade.cpp (modified) (2 diffs)
-
Source/WebCore/platform/graphics/FontCascadeFonts.cpp (modified) (4 diffs)
-
Source/WebCore/platform/graphics/FontSelector.h (modified) (2 diffs)
-
Source/WebCore/platform/graphics/cairo/FontCairoHarfbuzzNG.cpp (modified) (1 diff)
-
Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp (modified) (1 diff)
-
Source/WebCore/style/StyleBuilderCustom.h (modified) (1 diff)
-
Source/WebCore/style/StyleResolveForFontRaw.cpp (modified) (9 diffs)
-
Source/WebCore/style/StyleResolveForFontRaw.h (modified) (2 diffs)
-
Source/WebCore/workers/WorkerGlobalScope.cpp (modified) (3 diffs)
-
Source/WebCore/workers/WorkerGlobalScope.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r275417 r275420 1 2021-04-02 Chris Lord <clord@igalia.com> 2 3 Implement text rendering on OffscreenCanvas in a Worker 4 https://bugs.webkit.org/show_bug.cgi?id=202793 5 6 Reviewed by Darin Adler. 7 8 Adjust expectations for manual OffscreenCanvas worker text test. 9 10 * platform/glib/TestExpectations: 11 1 12 2021-04-02 Youenn Fablet <youenn@apple.com> 2 13 -
trunk/LayoutTests/imported/w3c/ChangeLog
r275416 r275420 1 2021-04-02 Chris Lord <clord@igalia.com> 2 3 Implement text rendering on OffscreenCanvas in a Worker 4 https://bugs.webkit.org/show_bug.cgi?id=202793 5 6 Reviewed by Darin Adler. 7 8 Adjust test expectations. 9 10 * web-platform-tests/html/canvas/offscreen/text/2d.text.font.parse.basic.worker-expected.txt: 11 * web-platform-tests/html/canvas/offscreen/text/2d.text.font.parse.complex.worker-expected.txt: 12 * web-platform-tests/html/canvas/offscreen/text/2d.text.font.parse.invalid.worker-expected.txt: 13 * web-platform-tests/html/canvas/offscreen/text/2d.text.font.parse.tiny.worker-expected.txt: 14 1 15 2021-04-02 Sergio Villar Senin <svillar@igalia.com> 2 16 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/text/2d.text.font.parse.basic.worker-expected.txt
r270102 r275420 1 1 2 FAIL 2d assert_equals: ctx.font === '20px serif' (got 10px sans-serif[string], expected 20px serif[string]) expected "20px serif" but got "10px sans-serif" 2 PASS 2d 3 3 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/text/2d.text.font.parse.complex.worker-expected.txt
r270102 r275420 1 1 2 FAIL 2d assert_equals: ctx.font === 'italic small-caps 12px "Unknown Font", sans-serif' (got 10px sans-serif[string], expected italic small-caps 12px "Unknown Font", sans-serif[string]) expected "italic small-caps 12px \"Unknown Font\", sans-serif" but got "10px sans-serif" 2 PASS 2d 3 3 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/text/2d.text.font.parse.invalid.worker-expected.txt
r270102 r275420 1 1 2 FAIL 2d assert_equals: ctx.font === '20px serif' (got 10px sans-serif[string], expected 20px serif[string]) expected "20px serif" but got "10px sans-serif" 2 PASS 2d 3 3 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/text/2d.text.font.parse.tiny.worker-expected.txt
r270102 r275420 1 1 2 FAIL 2d assert_equals: ctx.font === '1px sans-serif' (got 10px sans-serif[string], expected 1px sans-serif[string]) expected "1px sans-serif" but got "10px sans-serif" 2 PASS 2d 3 3 -
trunk/LayoutTests/platform/glib/TestExpectations
r275398 r275420 655 655 webkit.org/b/206055 imported/w3c/web-platform-tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.svg.worker.html [ Skip ] 656 656 webkit.org/b/206055 imported/w3c/web-platform-tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource.image.worker.html [ Skip ] 657 webkit.org/b/223671 imported/w3c/web-platform-tests/html/canvas/offscreen/manual/draw-generic-family/2d.text.draw.generic.family.w.html [ Failure ]658 657 659 658 # Console log lines may appear in a different order so we silence them. -
trunk/Source/WebCore/ChangeLog
r275417 r275420 1 2021-04-02 Chris Lord <clord@igalia.com> 2 3 Implement text rendering on OffscreenCanvas in a Worker 4 https://bugs.webkit.org/show_bug.cgi?id=202793 5 6 Reviewed by Darin Adler. 7 8 Add a CSSFontSelector and FontCache to WorkerGlobalScope and via 9 interface changes to ScriptExecutionContext and FontSelector, use them 10 as appropriate after enabling text functions on Worker threads with 11 OffscreenCanvas. 12 13 No new tests, rebaselined existing tests. 14 15 * css/CSSFontSelector.cpp: 16 (WebCore::CSSFontSelector::CSSFontSelector): 17 (WebCore::m_version): 18 (WebCore::CSSFontSelector::~CSSFontSelector): 19 (WebCore::CSSFontSelector::fontRangesForFamily): 20 (WebCore::CSSFontSelector::fallbackFontAt): 21 * css/CSSFontSelector.h: 22 * css/parser/CSSPropertyParserHelpers.cpp: 23 (WebCore::CSSPropertyParserHelpers::genericFontFamily): 24 (WebCore::CSSPropertyParserHelpers::genericFontFamilyIndex): 25 * css/parser/CSSPropertyParserHelpers.h: 26 * dom/Document.h: 27 * dom/ScriptExecutionContext.cpp: 28 (WebCore::ScriptExecutionContext::fontCache): 29 * dom/ScriptExecutionContext.h: 30 (WebCore::ScriptExecutionContext::cssFontSelector): 31 * dom/make_names.pl: 32 * html/canvas/CanvasRenderingContext2DBase.cpp: 33 (WebCore::CanvasRenderingContext2DBase::canDrawText): 34 * html/canvas/OffscreenCanvasRenderingContext2D.cpp: 35 (WebCore::OffscreenCanvasRenderingContext2D::setFont): 36 * platform/graphics/FontCache.cpp: 37 (WebCore::FontDataCacheKeyHash::hash): 38 (WebCore::FontDataCacheKeyHash::equal): 39 (WebCore::FontDataCacheKeyTraits::emptyValue): 40 (WebCore::FontDataCacheKeyTraits::constructDeletedValue): 41 (WebCore::FontDataCacheKeyTraits::isDeletedValue): 42 (WebCore::FontCache::create): 43 (WebCore::FontCache::singleton): 44 (WebCore::FontCache::FontCache): 45 (WebCore::FontCache::getCachedFontPlatformData): 46 (WebCore::FontCache::fontForPlatformData): 47 (WebCore::FontCache::purgeInactiveFontDataIfNeeded): 48 (WebCore::FontCache::purgeInactiveFontData): 49 (WebCore::FontCache::verticalData): 50 (WebCore::FontCache::fontCount): 51 (WebCore::FontCache::inactiveFontCount): 52 (WebCore::FontCache::invalidate): 53 * platform/graphics/FontCache.h: 54 (WebCore::FontCache::fontCacheFallbackToSingleton): 55 * platform/graphics/FontCascade.cpp: 56 (WebCore::FontCascade::isCurrent const): 57 (WebCore::FontCascade::update const): 58 * platform/graphics/FontCascadeFonts.cpp: 59 (WebCore::FontCascadeFonts::FontCascadeFonts): 60 (WebCore::realizeNextFallback): 61 (WebCore::FontCascadeFonts::realizeFallbackRangesAt): 62 * platform/graphics/FontSelector.h: 63 * platform/graphics/cairo/FontCairoHarfbuzzNG.cpp: 64 (WebCore::FontCascade::fontForCombiningCharacterSequence const): 65 * platform/graphics/freetype/FontCacheFreeType.cpp: 66 (WebCore::getFamilyNameStringFromFamily): 67 * style/StyleBuilderCustom.h: 68 (WebCore::Style::BuilderCustom::applyValueFontFamily): 69 * style/StyleResolveForFontRaw.cpp: 70 (WebCore::Style::useFixedDefaultSize): 71 (WebCore::Style::resolveForFontRaw): 72 * style/StyleResolveForFontRaw.h: 73 * workers/WorkerGlobalScope.cpp: 74 (WebCore::WorkerGlobalScope::~WorkerGlobalScope): 75 (WebCore::WorkerGlobalScope::cssFontSelector): 76 (WebCore::WorkerGlobalScope::fontCache): 77 * workers/WorkerGlobalScope.h: 78 1 79 2021-04-02 Youenn Fablet <youenn@apple.com> 2 80 -
trunk/Source/WebCore/css/CSSFontSelector.cpp
r274143 r275420 53 53 #include "StyleResolver.h" 54 54 #include "StyleRule.h" 55 #include "WebKitFontFamilyNames.h"56 55 #include <wtf/Ref.h> 57 56 #include <wtf/SetForScope.h> … … 67 66 : ActiveDOMObject(&context) 68 67 , m_context(makeWeakPtr(context)) 68 , m_fontCache(makeRef(context.fontCache())) 69 69 , m_cssFontFaceSet(CSSFontFaceSet::create(this)) 70 70 , m_fontModifiedObserver([this] { fontModified(); }) … … 83 83 } 84 84 85 FontCache::singleton().addClient(*this);85 m_fontCache->addClient(*this); 86 86 m_cssFontFaceSet->addFontModifiedObserver(m_fontModifiedObserver); 87 87 LOG(Fonts, "CSSFontSelector %p ctor", this); … … 95 95 96 96 stopLoadingAndClearFonts(); 97 FontCache::singleton().removeClient(*this);97 m_fontCache->removeClient(*this); 98 98 } 99 99 … … 309 309 310 310 // FIXME: The spec (and Firefox) says user specified generic families (sans-serif etc.) should be resolved before the @font-face lookup too. 311 bool resolveGenericFamilyFirst = familyName == m_fontFamilyNames [static_cast<int>(FamilyNamesIndex::StandardFamily)];311 bool resolveGenericFamilyFirst = familyName == m_fontFamilyNames.at(FamilyNamesIndex::StandardFamily); 312 312 313 313 AtomString familyForLookup = familyName; … … 331 331 if (!resolveGenericFamilyFirst) 332 332 resolveAndAssignGenericFamily(); 333 auto font = FontCache::singleton().fontForFamily(*fontDescriptionForLookup, familyForLookup);333 auto font = m_fontCache->fontForFamily(*fontDescriptionForLookup, familyForLookup); 334 334 if (document && RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled()) 335 335 ResourceLoadObserver::shared().logFontLoad(*document, familyForLookup.string(), !!font); … … 443 443 return nullptr; 444 444 auto& pictographFontFamily = m_context->settingsValues().fontGenericFamilies.pictographFontFamily(); 445 auto font = FontCache::singleton().fontForFamily(fontDescription, pictographFontFamily);445 auto font = m_fontCache->fontForFamily(fontDescription, pictographFontFamily); 446 446 if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled() && is<Document>(m_context.get())) 447 447 ResourceLoadObserver::shared().logFontLoad(downcast<Document>(*m_context), pictographFontFamily, !!font); -
trunk/Source/WebCore/css/CSSFontSelector.h
r274143 r275420 33 33 #include "FontSelector.h" 34 34 #include "Timer.h" 35 #include "WebKitFontFamilyNames.h" 35 36 #include <memory> 36 37 #include <wtf/Forward.h> … … 71 72 void addFontFaceRule(StyleRuleFontFace&, bool isInitiatingElementInUserAgentShadowTree); 72 73 74 FontCache& fontCache() const final { return m_fontCache.get(); } 73 75 void fontCacheInvalidated() final; 74 76 … … 124 126 125 127 WeakPtr<ScriptExecutionContext> m_context; 128 Ref<FontCache> m_fontCache; 126 129 RefPtr<FontFaceSet> m_fontFaceSet; 127 130 Ref<CSSFontFaceSet> m_cssFontFaceSet; … … 144 147 bool m_isStopped { false }; 145 148 146 W TF::Vector<AtomString> m_fontFamilyNames;149 WebKitFontFamilyNames::FamilyNamesList<AtomString> m_fontFamilyNames; 147 150 }; 148 151 -
trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
r275206 r275420 47 47 #include "RuntimeEnabledFeatures.h" 48 48 #include "StyleColor.h" 49 #include "WebKitFontFamilyNames.h" 49 50 #include <wtf/text/StringConcatenateNumbers.h> 50 51 … … 3062 3063 } 3063 3064 3064 const AtomString& genericFontFamily FromValueID(CSSValueID ident)3065 const AtomString& genericFontFamily(CSSValueID ident) 3065 3066 { 3066 3067 switch (ident) { … … 3084 3085 } 3085 3086 3087 WebKitFontFamilyNames::FamilyNamesIndex genericFontFamilyIndex(CSSValueID ident) 3088 { 3089 switch (ident) { 3090 case CSSValueSerif: 3091 return WebKitFontFamilyNames::FamilyNamesIndex::SerifFamily; 3092 case CSSValueSansSerif: 3093 return WebKitFontFamilyNames::FamilyNamesIndex::SansSerifFamily; 3094 case CSSValueCursive: 3095 return WebKitFontFamilyNames::FamilyNamesIndex::CursiveFamily; 3096 case CSSValueFantasy: 3097 return WebKitFontFamilyNames::FamilyNamesIndex::FantasyFamily; 3098 case CSSValueMonospace: 3099 return WebKitFontFamilyNames::FamilyNamesIndex::MonospaceFamily; 3100 case CSSValueWebkitPictograph: 3101 return WebKitFontFamilyNames::FamilyNamesIndex::PictographFamily; 3102 case CSSValueSystemUi: 3103 return WebKitFontFamilyNames::FamilyNamesIndex::SystemUiFamily; 3104 default: 3105 ASSERT_NOT_REACHED(); 3106 return WebKitFontFamilyNames::FamilyNamesIndex::StandardFamily; 3107 } 3108 } 3109 3086 3110 } // namespace CSSPropertyParserHelpers 3087 3111 -
trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h
r272870 r275420 43 43 namespace WebCore { 44 44 45 namespace WebKitFontFamilyNames { 46 enum class FamilyNamesIndex; 47 } 48 45 49 // When these functions are successful, they will consume all the relevant 46 50 // tokens from the range and also consume any whitespace which follows. When … … 170 174 Optional<LineHeightRaw> consumeLineHeightRaw(CSSParserTokenRange&, CSSParserMode); 171 175 Optional<FontRaw> consumeFontWorkerSafe(CSSParserTokenRange&, CSSParserMode); 172 const AtomString& genericFontFamilyFromValueID(CSSValueID); 176 const AtomString& genericFontFamily(CSSValueID); 177 WebKitFontFamilyNames::FamilyNamesIndex genericFontFamilyIndex(CSSValueID); 173 178 174 179 bool isFontStyleAngleInRange(double angleInDegrees); -
trunk/Source/WebCore/dom/Document.h
r275151 r275420 1646 1646 void detachParser(); 1647 1647 1648 // ScriptExecutionContext 1649 CSSFontSelector* cssFontSelector() final { return m_fontSelector.ptr(); } 1650 1648 1651 // FontSelectorClient 1649 1652 void fontsNeedUpdate(FontSelector&) final; -
trunk/Source/WebCore/dom/ScriptExecutionContext.cpp
r273438 r275420 36 36 #include "Document.h" 37 37 #include "ErrorEvent.h" 38 #include "FontCache.h" 38 39 #include "JSDOMExceptionHandling.h" 39 40 #include "JSDOMWindow.h" … … 227 228 } 228 229 230 FontCache& ScriptExecutionContext::fontCache() 231 { 232 return FontCache::singleton(); 233 } 234 229 235 void ScriptExecutionContext::forEachActiveDOMObject(const Function<ShouldContinue(ActiveDOMObject&)>& apply) const 230 236 { -
trunk/Source/WebCore/dom/ScriptExecutionContext.h
r275151 r275420 61 61 class EventLoop; 62 62 class CachedScript; 63 class CSSFontSelector; 63 64 class DatabaseContext; 64 65 class EventQueue; 65 66 class EventLoopTaskGroup; 66 67 class EventTarget; 68 class FontCache; 67 69 class MessagePort; 68 70 class PublicURLManager; … … 162 164 virtual void didLoadResourceSynchronously(const URL&); 163 165 166 virtual FontCache& fontCache(); 167 virtual CSSFontSelector* cssFontSelector() { return nullptr; } 168 164 169 void ref() { refScriptExecutionContext(); } 165 170 void deref() { derefScriptExecutionContext(); } -
trunk/Source/WebCore/dom/make_names.pl
r275410 r275420 106 106 END 107 107 108 print F "extern LazyNeverDestroyed<Vector<const StaticStringImpl*, ", scalar(keys %parameters), ">> familyNamesData;\n";109 print F "extern MainThreadLazyNeverDestroyed<Vector<AtomStringImpl*, ", scalar(keys %parameters), ">> familyNames;\n\n";110 printMacros($F, "extern MainThreadLazyNeverDestroyed<const AtomString>", "", \%parameters);111 print F "\n";112 108 print F "enum class FamilyNamesIndex {\n"; 113 109 for my $name (sort keys %parameters) { … … 115 111 } 116 112 print F "};\n\n"; 113 114 print F "template<typename T, size_t inlineCapacity = 0>\n"; 115 print F "class FamilyNamesList : public Vector<T, inlineCapacity> {\n"; 116 print F "public:\n"; 117 print F " T& at(FamilyNamesIndex i)\n"; 118 print F " {\n"; 119 print F " return Vector<T, inlineCapacity>::at(static_cast<size_t>(i));\n"; 120 print F " }\n"; 121 print F "};\n\n"; 122 print F "extern LazyNeverDestroyed<FamilyNamesList<const StaticStringImpl*, ", scalar(keys %parameters), ">> familyNamesData;\n"; 123 print F "extern MainThreadLazyNeverDestroyed<FamilyNamesList<AtomStringImpl*, ", scalar(keys %parameters), ">> familyNames;\n\n"; 124 printMacros($F, "extern MainThreadLazyNeverDestroyed<const AtomString>", "", \%parameters); 125 print F "\n"; 117 126 print F "#endif\n\n"; 118 127 … … 128 137 print F StaticString::GenerateStrings(\%parameters); 129 138 130 print F "LazyNeverDestroyed< Vector<const StaticStringImpl*, ", scalar(keys %parameters), ">> familyNamesData;\n";131 print F "MainThreadLazyNeverDestroyed< Vector<AtomStringImpl*, ", scalar(keys %parameters), ">> familyNames;\n\n";139 print F "LazyNeverDestroyed<FamilyNamesList<const StaticStringImpl*, ", scalar(keys %parameters), ">> familyNamesData;\n"; 140 print F "MainThreadLazyNeverDestroyed<FamilyNamesList<AtomStringImpl*, ", scalar(keys %parameters), ">> familyNames;\n\n"; 132 141 133 142 printMacros($F, "MainThreadLazyNeverDestroyed<const AtomString>", "", \%parameters); -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
r274461 r275420 2367 2367 return false; 2368 2368 2369 ScriptDisallowedScope::InMainThread scriptDisallowedScope;2370 2371 2369 auto* c = drawingContext(); 2372 2370 if (!c) -
trunk/Source/WebCore/html/canvas/OffscreenCanvasRenderingContext2D.cpp
r274101 r275420 39 39 #include "CSSParser.h" 40 40 #include "CSSPropertyParserHelpers.h" 41 #include "Document.h"42 41 #include "RenderStyle.h" 42 #include "ScriptExecutionContext.h" 43 43 #include "StyleResolveForFontRaw.h" 44 44 #include "TextMetrics.h" … … 64 64 { 65 65 auto& context = *canvasBase().scriptExecutionContext(); 66 if (!is<Document>(context))67 return;68 66 69 67 if (newFont.isEmpty()) … … 91 89 fontDescription.setComputedSize(DefaultFontSize); 92 90 93 auto& document = downcast<Document>(context); 94 auto fontCascade = Style::resolveForFontRaw(*fontRaw, WTFMove(fontDescription), document); 95 96 if (fontCascade) 97 modifiableState().font.initialize(document.fontSelector(), *fontCascade); 91 if (auto fontCascade = Style::resolveForFontRaw(*fontRaw, WTFMove(fontDescription), context)) { 92 ASSERT(context.cssFontSelector()); 93 modifiableState().font.initialize(*context.cssFontSelector(), *fontCascade); 94 } 98 95 } 99 96 -
trunk/Source/WebCore/platform/graphics/FontCache.cpp
r275364 r275420 50 50 using namespace WTF; 51 51 52 FontCache& FontCache::singleton()53 {54 static NeverDestroyed<FontCache> globalFontCache;55 return globalFontCache;56 }57 58 FontCache::FontCache()59 : m_purgeTimer(*this, &FontCache::purgeInactiveFontDataIfNeeded)60 , m_fontPlatformDataCache(makeUniqueRef<FontPlatformDataCache>())61 , m_fontDataCache(makeUniqueRef<FontDataCache>())62 #if ENABLE(OPENTYPE_VERTICAL)63 , m_fontVerticalDataCache(makeUniqueRef<FontVerticalDataCache>())64 #endif65 {66 }67 68 52 struct FontPlatformDataCacheKey { 69 53 WTF_MAKE_FAST_ALLOCATED; … … 128 112 } 129 113 130 static const bool safeToCompareToEmptyOrDeleted = true;114 static constexpr bool safeToCompareToEmptyOrDeleted = true; 131 115 }; 132 116 133 117 struct FontPlatformDataCacheKeyHashTraits : public SimpleClassHashTraits<FontPlatformDataCacheKey> { 134 static const bool emptyValueIsZero = false;118 static constexpr bool emptyValueIsZero = false; 135 119 }; 120 121 struct FontDataCacheKeyHash { 122 static unsigned hash(const FontPlatformData& platformData) 123 { 124 return platformData.hash(); 125 } 126 127 static bool equal(const FontPlatformData& a, const FontPlatformData& b) 128 { 129 return a == b; 130 } 131 132 static constexpr bool safeToCompareToEmptyOrDeleted = true; 133 }; 134 135 struct FontDataCacheKeyTraits : WTF::GenericHashTraits<FontPlatformData> { 136 static constexpr bool emptyValueIsZero = true; 137 static const FontPlatformData& emptyValue() 138 { 139 static NeverDestroyed<FontPlatformData> key(0.f, false, false); 140 return key; 141 } 142 static void constructDeletedValue(FontPlatformData& slot) 143 { 144 new (NotNull, &slot) FontPlatformData(HashTableDeletedValue); 145 } 146 static bool isDeletedValue(const FontPlatformData& value) 147 { 148 return value.isHashTableDeletedValue(); 149 } 150 }; 151 152 using FontPlatformDataCache = HashMap<FontPlatformDataCacheKey, std::unique_ptr<FontPlatformData>, FontPlatformDataCacheKeyHash, FontPlatformDataCacheKeyHashTraits>; 153 using FontDataCache = HashMap<FontPlatformData, Ref<Font>, FontDataCacheKeyHash, FontDataCacheKeyTraits>; 154 #if ENABLE(OPENTYPE_VERTICAL) 155 using FontVerticalDataCache = HashMap<FontPlatformData, RefPtr<OpenTypeVerticalData>, FontDataCacheKeyHash, FontDataCacheKeyTraits>; 156 #endif 157 158 struct FontCache::FontDataCaches { 159 WTF_MAKE_STRUCT_FAST_ALLOCATED; 160 161 FontDataCache data; 162 FontPlatformDataCache platformData; 163 #if ENABLE(OPENTYPE_VERTICAL) 164 FontVerticalDataCache verticalData; 165 #endif 166 }; 167 168 Ref<FontCache> FontCache::create() 169 { 170 ASSERT(!isMainThread()); 171 return adoptRef(*new FontCache()); 172 } 173 174 FontCache& FontCache::singleton() 175 { 176 static MainThreadNeverDestroyed<FontCache> globalFontCache; 177 return globalFontCache; 178 } 179 180 FontCache::~FontCache() = default; 181 182 FontCache::FontCache() 183 : m_purgeTimer(*this, &FontCache::purgeInactiveFontDataIfNeeded) 184 , m_fontDataCaches(makeUniqueRef<FontDataCaches>()) 185 { 186 } 136 187 137 188 Optional<ASCIILiteral> FontCache::alternateFamilyName(const String& familyName) … … 198 249 FontPlatformDataCacheKey key(familyName, fontDescription, fontFaceFeatures, fontFaceCapabilities); 199 250 200 auto addResult = m_font PlatformDataCache->add(key, nullptr);251 auto addResult = m_fontDataCaches->platformData.add(key, nullptr); 201 252 FontPlatformDataCache::iterator it = addResult.iterator; 202 253 if (addResult.isNewEntry) { … … 210 261 // Lookup the key in the hash table again as the previous iterator may have 211 262 // been invalidated by the recursive call to getCachedFontPlatformData(). 212 it = m_font PlatformDataCache->find(key);213 ASSERT(it != m_font PlatformDataCache->end());263 it = m_fontDataCaches->platformData.find(key); 264 ASSERT(it != m_fontDataCaches->platformData.end()); 214 265 if (fontPlatformDataForAlternateName) 215 266 it->value = makeUnique<FontPlatformData>(*fontPlatformDataForAlternateName); … … 220 271 return it->value.get(); 221 272 } 222 223 struct FontDataCacheKeyHash {224 static unsigned hash(const FontPlatformData& platformData)225 {226 return platformData.hash();227 }228 229 static bool equal(const FontPlatformData& a, const FontPlatformData& b)230 {231 return a == b;232 }233 234 static const bool safeToCompareToEmptyOrDeleted = true;235 };236 237 struct FontDataCacheKeyTraits : WTF::GenericHashTraits<FontPlatformData> {238 static const bool emptyValueIsZero = true;239 static const FontPlatformData& emptyValue()240 {241 static NeverDestroyed<FontPlatformData> key(0.f, false, false);242 return key;243 }244 static void constructDeletedValue(FontPlatformData& slot)245 {246 new (NotNull, &slot) FontPlatformData(HashTableDeletedValue);247 }248 static bool isDeletedValue(const FontPlatformData& value)249 {250 return value.isHashTableDeletedValue();251 }252 };253 254 #if ENABLE(OPENTYPE_VERTICAL)255 RefPtr<OpenTypeVerticalData> FontCache::verticalData(const FontPlatformData& platformData)256 {257 auto addResult = m_fontVerticalDataCache->ensure(platformData, [&platformData] {258 return OpenTypeVerticalData::create(platformData);259 });260 return addResult.iterator->value;261 }262 #endif263 273 264 274 #if PLATFORM(IOS_FAMILY) … … 290 300 #endif 291 301 292 auto addResult = m_fontDataCache ->ensure(platformData, [&] {302 auto addResult = m_fontDataCaches->data.ensure(platformData, [&] { 293 303 return Font::create(platformData); 294 304 }); … … 306 316 LOG(Fonts, "FontCache::purgeInactiveFontDataIfNeeded() - underMemoryPressure %d, inactiveFontDataLimit %u", underMemoryPressure, inactiveFontDataLimit); 307 317 308 if (m_fontDataCache ->size() < inactiveFontDataLimit)318 if (m_fontDataCaches->data.size() < inactiveFontDataLimit) 309 319 return; 310 320 unsigned inactiveCount = inactiveFontCount(); … … 329 339 while (purgeCount) { 330 340 Vector<Ref<Font>, 20> fontsToDelete; 331 for (auto& font : m_fontDataCache ->values()) {341 for (auto& font : m_fontDataCaches->data.values()) { 332 342 LOG(Fonts, " trying to purge font %s (has one ref %d)", font->platformData().description().utf8().data(), font->hasOneRef()); 333 343 if (!font->hasOneRef()) … … 341 351 break; 342 352 for (auto& font : fontsToDelete) { 343 bool success = m_fontDataCache ->remove(font->platformData());353 bool success = m_fontDataCaches->data.remove(font->platformData()); 344 354 ASSERT_UNUSED(success, success); 345 355 #if ENABLE(OPENTYPE_VERTICAL) 346 m_font VerticalDataCache->remove(font->platformData());356 m_fontDataCaches->verticalData.remove(font->platformData()); 347 357 #endif 348 358 } … … 350 360 351 361 Vector<FontPlatformDataCacheKey> keysToRemove; 352 keysToRemove.reserveInitialCapacity(m_font PlatformDataCache->size());353 for (auto& entry : m_font PlatformDataCache.get()) {354 if (entry.value && !m_fontDataCache ->contains(*entry.value))362 keysToRemove.reserveInitialCapacity(m_fontDataCaches->platformData.size()); 363 for (auto& entry : m_fontDataCaches->platformData) { 364 if (entry.value && !m_fontDataCaches->data.contains(*entry.value)) 355 365 keysToRemove.uncheckedAppend(entry.key); 356 366 } … … 359 369 360 370 for (auto& key : keysToRemove) 361 m_font PlatformDataCache->remove(key);371 m_fontDataCaches->platformData.remove(key); 362 372 363 373 platformPurgeInactiveFontData(); … … 403 413 } 404 414 415 #if ENABLE(OPENTYPE_VERTICAL) 416 RefPtr<OpenTypeVerticalData> FontCache::verticalData(const FontPlatformData& platformData) 417 { 418 auto addResult = m_fontDataCaches->verticalData.ensure(platformData, [&platformData] { 419 return OpenTypeVerticalData::create(platformData); 420 }); 421 return addResult.iterator->value; 422 } 423 #endif 424 405 425 static FontCascadeCacheKey makeFontCascadeCacheKey(const FontCascadeDescription& description, FontSelector* fontSelector) 406 426 { … … 459 479 size_t FontCache::fontCount() 460 480 { 461 return m_fontDataCache ->size();481 return m_fontDataCaches->data.size(); 462 482 } 463 483 … … 468 488 #endif 469 489 unsigned count = 0; 470 for (auto& font : m_fontDataCache ->values()) {490 for (auto& font : m_fontDataCaches->data.values()) { 471 491 if (font->hasOneRef()) 472 492 ++count; … … 490 510 void FontCache::invalidate() 491 511 { 492 m_font PlatformDataCache->clear();512 m_fontDataCaches->platformData.clear(); 493 513 #if ENABLE(OPENTYPE_VERTICAL) 494 m_font VerticalDataCache->clear();514 m_fontDataCaches->verticalData.clear(); 495 515 #endif 496 516 invalidateFontCascadeCache(); -
trunk/Source/WebCore/platform/graphics/FontCache.h
r275364 r275420 33 33 #include "FontDescription.h" 34 34 #include "FontPlatformData.h" 35 #include "FontSelector.h" 35 36 #include "FontTaggedSettings.h" 36 37 #include "Timer.h" … … 65 66 66 67 class FontCascade; 67 class FontSelector;68 68 class OpenTypeVerticalData; 69 69 class Font; 70 70 enum class IsForPlatformFont : uint8_t; 71 struct FontDataCacheKeyHash;72 struct FontDataCacheKeyTraits;73 struct FontPlatformDataCacheKey;74 struct FontPlatformDataCacheKeyHash;75 struct FontPlatformDataCacheKeyHashTraits;76 71 77 72 #if PLATFORM(WIN) … … 219 214 using FontCascadeCache = HashMap<FontCascadeCacheKey, std::unique_ptr<FontCascadeCacheEntry>, FontCascadeCacheKeyHash, FontCascadeCacheKeyHashTraits>; 220 215 221 typedef HashMap<FontPlatformDataCacheKey, std::unique_ptr<FontPlatformData>, FontPlatformDataCacheKeyHash, FontPlatformDataCacheKeyHashTraits> FontPlatformDataCache;222 typedef HashMap<FontPlatformData, Ref<Font>, FontDataCacheKeyHash, FontDataCacheKeyTraits> FontDataCache;223 #if ENABLE(OPENTYPE_VERTICAL)224 typedef HashMap<FontPlatformData, RefPtr<OpenTypeVerticalData>, FontDataCacheKeyHash, FontDataCacheKeyTraits> FontVerticalDataCache;225 #endif226 227 216 class FontCache : public RefCounted<FontCache> { 228 friend class WTF::NeverDestroyed<FontCache >;217 friend class WTF::NeverDestroyed<FontCache, MainThreadAccessTraits>; 229 218 230 219 WTF_MAKE_NONCOPYABLE(FontCache); WTF_MAKE_FAST_ALLOCATED; 231 220 public: 232 FontCache(); 233 221 static Ref<FontCache> create(); 234 222 WEBCORE_EXPORT static FontCache& singleton(); 223 static FontCache& fontCacheFallbackToSingleton(RefPtr<FontSelector>); 224 225 ~FontCache(); 235 226 236 227 // These methods are implemented by the platform. … … 304 295 305 296 private: 297 FontCache(); 298 306 299 WEBCORE_EXPORT void purgeInactiveFontDataIfNeeded(); 307 300 void pruneUnreferencedEntriesFromFontCascadeCache(); … … 323 316 324 317 HashSet<FontSelector*> m_clients; 325 UniqueRef<FontPlatformDataCache> m_fontPlatformDataCache; 326 UniqueRef<FontDataCache> m_fontDataCache; 327 #if ENABLE(OPENTYPE_VERTICAL) 328 UniqueRef<FontVerticalDataCache> m_fontVerticalDataCache; 329 #endif 318 struct FontDataCaches; 319 UniqueRef<FontDataCaches> m_fontDataCaches; 330 320 FontCascadeCache m_fontCascadeCache; 331 321 … … 389 379 } 390 380 391 } 381 inline FontCache& FontCache::fontCacheFallbackToSingleton(RefPtr<FontSelector> fontSelector) 382 { 383 return fontSelector ? fontSelector->fontCache() : FontCache::singleton(); 384 } 385 386 } -
trunk/Source/WebCore/platform/graphics/FontCascade.cpp
r275410 r275420 152 152 if (!m_fonts) 153 153 return false; 154 if (m_fonts->generation() != FontCache::singleton().generation())154 if (m_fonts->generation() != fontSelector.fontCache().generation()) 155 155 return false; 156 156 if (m_fonts->fontSelectorVersion() != fontSelector.version()) … … 170 170 void FontCascade::update(RefPtr<FontSelector>&& fontSelector) const 171 171 { 172 FontCache:: singleton().updateFontCascade(*this, WTFMove(fontSelector));172 FontCache::fontCacheFallbackToSingleton(fontSelector).updateFontCascade(*this, WTFMove(fontSelector)); 173 173 } 174 174 -
trunk/Source/WebCore/platform/graphics/FontCascadeFonts.cpp
r275364 r275420 103 103 , m_fontSelector(fontSelector) 104 104 , m_fontSelectorVersion(m_fontSelector ? m_fontSelector->version() : 0) 105 , m_generation(FontCache:: singleton().generation())105 , m_generation(FontCache::fontCacheFallbackToSingleton(m_fontSelector).generation()) 106 106 { 107 107 #if ASSERT_ENABLED … … 145 145 ASSERT(index < description.effectiveFamilyCount()); 146 146 147 auto& fontCache = FontCache:: singleton();147 auto& fontCache = FontCache::fontCacheFallbackToSingleton(fontSelector); 148 148 while (index < description.effectiveFamilyCount()) { 149 149 auto visitor = WTF::makeVisitor([&](const AtomString& family) -> FontRanges { … … 182 182 183 183 ASSERT(index == m_realizedFallbackRanges.size()); 184 ASSERT(FontCache:: singleton().generation() == m_generation);184 ASSERT(FontCache::fontCacheFallbackToSingleton(m_fontSelector).generation() == m_generation); 185 185 186 186 m_realizedFallbackRanges.append(FontRanges()); … … 192 192 fontRanges = m_fontSelector->fontRangesForFamily(description, standardFamily); 193 193 if (fontRanges.isNull()) 194 fontRanges = FontRanges(FontCache:: singleton().lastResortFallbackFont(description));194 fontRanges = FontRanges(FontCache::fontCacheFallbackToSingleton(m_fontSelector).lastResortFallbackFont(description)); 195 195 return fontRanges; 196 196 } -
trunk/Source/WebCore/platform/graphics/FontSelector.h
r246490 r275420 32 32 namespace WebCore { 33 33 34 class FontCache; 34 35 class FontCascadeDescription; 35 36 class FontDescription; … … 55 56 virtual void opportunisticallyStartFontDataURLLoading(const FontCascadeDescription&, const AtomString& family) = 0; 56 57 58 virtual FontCache& fontCache() const = 0; 57 59 virtual void fontCacheInvalidated() { } 58 60 -
trunk/Source/WebCore/platform/graphics/cairo/FontCairoHarfbuzzNG.cpp
r245393 r275420 139 139 } 140 140 141 if (auto systemFallback = FontCache:: singleton().systemFallbackForCharacters(m_fontDescription, baseFont, IsForPlatformFont::No, preferColoredFont ? FontCache::PreferColoredFont::Yes : FontCache::PreferColoredFont::No, characters, length)) {141 if (auto systemFallback = FontCache::fontCacheFallbackToSingleton(fontSelector()).systemFallbackForCharacters(m_fontDescription, baseFont, IsForPlatformFont::No, preferColoredFont ? FontCache::PreferColoredFont::Yes : FontCache::PreferColoredFont::No, characters, length)) { 142 142 if (systemFallback->canRenderCombiningCharacterSequence(characters, length) && (!preferColoredFont || systemFallback->platformData().isColorBitmapFont())) 143 143 return systemFallback.get(); -
trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp
r275364 r275420 339 339 return family; 340 340 341 if (family == familyNamesData->at( static_cast<unsigned>(FamilyNamesIndex::StandardFamily)) || family == familyNamesData->at(static_cast<unsigned>(FamilyNamesIndex::SerifFamily)))341 if (family == familyNamesData->at(FamilyNamesIndex::StandardFamily) || family == familyNamesData->at(FamilyNamesIndex::SerifFamily)) 342 342 return "serif"; 343 if (family == familyNamesData->at( static_cast<unsigned>(FamilyNamesIndex::SansSerifFamily)))343 if (family == familyNamesData->at(FamilyNamesIndex::SansSerifFamily)) 344 344 return "sans-serif"; 345 if (family == familyNamesData->at( static_cast<unsigned>(FamilyNamesIndex::MonospaceFamily)))345 if (family == familyNamesData->at(FamilyNamesIndex::MonospaceFamily)) 346 346 return "monospace"; 347 if (family == familyNamesData->at( static_cast<unsigned>(FamilyNamesIndex::CursiveFamily)))347 if (family == familyNamesData->at(FamilyNamesIndex::CursiveFamily)) 348 348 return "cursive"; 349 if (family == familyNamesData->at( static_cast<unsigned>(FamilyNamesIndex::FantasyFamily)))349 if (family == familyNamesData->at(FamilyNamesIndex::FantasyFamily)) 350 350 return "fantasy"; 351 351 352 352 #if PLATFORM(GTK) 353 if (family == familyNamesData->at( static_cast<unsigned>(FamilyNamesIndex::SystemUiFamily)) || family == "-webkit-system-font")353 if (family == familyNamesData->at(FamilyNamesIndex::SystemUiFamily) || family == "-webkit-system-font") 354 354 return defaultGtkSystemFont(); 355 355 #endif -
trunk/Source/WebCore/style/StyleBuilderCustom.h
r275199 r275420 1062 1062 else { 1063 1063 isGenericFamily = true; 1064 family = CSSPropertyParserHelpers::genericFontFamily FromValueID(contentValue.valueID());1064 family = CSSPropertyParserHelpers::genericFontFamily(contentValue.valueID()); 1065 1065 } 1066 1066 } -
trunk/Source/WebCore/style/StyleResolveForFontRaw.cpp
r273964 r275420 33 33 34 34 #include "CSSFontSelector.h" 35 #include "CSSHelper.h" 35 36 #include "CSSPropertyParserHelpers.h" 36 37 #include "Document.h" … … 38 39 #include "FontCascadeDescription.h" 39 40 #include "RenderStyle.h" 41 #include "ScriptExecutionContext.h" 40 42 #include "Settings.h" 41 43 #include "StyleFontSizeFunctions.h" 44 #include "WebKitFontFamilyNames.h" 42 45 43 46 namespace WebCore { … … 46 49 47 50 using namespace CSSPropertyParserHelpers; 48 49 Optional<FontCascade> resolveForFontRaw(const FontRaw& fontRaw, FontCascadeDescription&& fontDescription, Document& document) 51 using namespace WebKitFontFamilyNames; 52 53 static bool useFixedDefaultSize(const FontCascadeDescription& fontDescription) 50 54 { 55 return fontDescription.familyCount() == 1 && fontDescription.firstFamily() == familyNamesData->at(FamilyNamesIndex::MonospaceFamily); 56 } 57 58 Optional<FontCascade> resolveForFontRaw(const FontRaw& fontRaw, FontCascadeDescription&& fontDescription, ScriptExecutionContext& context) 59 { 60 ASSERT(context.cssFontSelector()); 61 51 62 // Map the font property longhands into the style. 52 63 float parentSize = fontDescription.specifiedSize(); … … 54 65 // Font family applied in the same way as StyleBuilderCustom::applyValueFontFamily 55 66 // Before mapping in a new font-family property, we should reset the generic family. 56 bool oldFamilyUsedFixedDefaultSize = fontDescription.useFixedDefaultSize();67 bool oldFamilyUsedFixedDefaultSize = useFixedDefaultSize(fontDescription); 57 68 58 69 Vector<AtomString> families; … … 64 75 switchOn(item, [&] (CSSValueID ident) { 65 76 isGenericFamily = ident != CSSValueWebkitBody; 66 family = isGenericFamily ? CSSPropertyParserHelpers::genericFontFamilyFromValueID(ident) : AtomString(document.settings().standardFontFamily()); 77 if (isGenericFamily) 78 family = familyNamesData->at(CSSPropertyParserHelpers::genericFontFamilyIndex(ident)); 79 else 80 family = AtomString(context.settingsValues().fontGenericFamilies.standardFontFamily()); 67 81 }, [&] (const String& familyString) { 68 82 family = familyString; … … 80 94 fontDescription.setFamilies(families); 81 95 82 if ( fontDescription.useFixedDefaultSize() != oldFamilyUsedFixedDefaultSize) {96 if (useFixedDefaultSize(fontDescription) != oldFamilyUsedFixedDefaultSize) { 83 97 if (CSSValueID sizeIdentifier = fontDescription.keywordSizeAsIdentifier()) { 84 auto size = Style::fontSizeForKeyword(sizeIdentifier, !oldFamilyUsedFixedDefaultSize, document);98 auto size = Style::fontSizeForKeyword(sizeIdentifier, !oldFamilyUsedFixedDefaultSize, context.settingsValues()); 85 99 fontDescription.setSpecifiedSize(size); 86 fontDescription.setComputedSize(Style::computedFontSizeFromSpecifiedSize(size, fontDescription.isAbsoluteSize(), 1.0, MinimumFontSizeRule::None, document.settingsValues()));100 fontDescription.setComputedSize(Style::computedFontSizeFromSpecifiedSize(size, fontDescription.isAbsoluteSize(), 1.0, MinimumFontSizeRule::None, context.settingsValues())); 87 101 } 88 102 } … … 177 191 case CSSValueWebkitXxxLarge: 178 192 fontDescription.setKeywordSizeFromIdentifier(ident); 179 return Style::fontSizeForKeyword(ident, fontDescription.useFixedDefaultSize(), document);193 return Style::fontSizeForKeyword(ident, fontDescription.useFixedDefaultSize(), context.settingsValues()); 180 194 case CSSValueLarger: 181 195 return parentSize * 1.2f; … … 188 202 return switchOn(lengthOrPercent, [&] (const CSSPropertyParserHelpers::LengthRaw& length) { 189 203 auto fontCascade = FontCascade(FontCascadeDescription(fontDescription)); 190 fontCascade.update(&document.fontSelector()); 191 return static_cast<float>(CSSPrimitiveValue::computeUnzoomedNonCalcLengthDouble(length.type, length.value, CSSPropertyFontSize, &fontCascade.fontMetrics(), &fontCascade.fontDescription(), &fontCascade.fontDescription(), document.renderView())); 204 fontCascade.update(context.cssFontSelector()); 205 // FIXME: Passing null for the RenderView parameter means that vw and vh units will evaluate to 206 // zero and vmin and vmax units will evaluate as if they were px units. 207 // It's unclear in the specification if they're expected to work on OffscreenCanvas, given 208 // that it's off-screen and therefore doesn't strictly have an associated viewport. 209 // This needs clarification and possibly fixing. 210 return static_cast<float>(CSSPrimitiveValue::computeUnzoomedNonCalcLengthDouble(length.type, length.value, CSSPropertyFontSize, &fontCascade.fontMetrics(), &fontCascade.fontDescription(), &fontCascade.fontDescription(), is<Document>(context) ? downcast<Document>(context).renderView() : nullptr)); 192 211 }, [&] (double percentage) { 193 212 return static_cast<float>((parentSize * percentage) / 100.0); … … 204 223 205 224 auto fontCascade = FontCascade(WTFMove(fontDescription)); 206 fontCascade.update( &document.fontSelector());225 fontCascade.update(context.cssFontSelector()); 207 226 return fontCascade; 208 227 } -
trunk/Source/WebCore/style/StyleResolveForFontRaw.h
r273964 r275420 33 33 namespace WebCore { 34 34 35 class Document;36 35 class FontCascade; 37 36 class FontCascadeDescription; 37 class ScriptExecutionContext; 38 38 39 39 namespace CSSPropertyParserHelpers { … … 43 43 namespace Style { 44 44 45 Optional<FontCascade> resolveForFontRaw(const CSSPropertyParserHelpers::FontRaw&, FontCascadeDescription&&, Document&);45 Optional<FontCascade> resolveForFontRaw(const CSSPropertyParserHelpers::FontRaw&, FontCascadeDescription&&, ScriptExecutionContext&); 46 46 47 47 } -
trunk/Source/WebCore/workers/WorkerGlobalScope.cpp
r275151 r275420 29 29 #include "WorkerGlobalScope.h" 30 30 31 #include "CSSFontSelector.h" 31 32 #include "CSSValueList.h" 32 33 #include "CSSValuePool.h" 33 34 #include "ContentSecurityPolicy.h" 34 35 #include "Crypto.h" 36 #include "FontCache.h" 35 37 #include "IDBConnectionProxy.h" 36 38 #include "ImageBitmapOptions.h" … … 91 93 removeFromContextsMap(); 92 94 95 if (m_cssFontSelector) 96 m_cssFontSelector->stopLoadingAndClearFonts(); 93 97 m_performance = nullptr; 94 98 m_crypto = nullptr; … … 479 483 } 480 484 485 CSSFontSelector* WorkerGlobalScope::cssFontSelector() 486 { 487 if (!m_cssFontSelector) 488 m_cssFontSelector = CSSFontSelector::create(*this); 489 return m_cssFontSelector.get(); 490 } 491 492 FontCache& WorkerGlobalScope::fontCache() 493 { 494 if (!m_fontCache) 495 m_fontCache = FontCache::create(); 496 return *m_fontCache; 497 } 498 481 499 ReferrerPolicy WorkerGlobalScope::referrerPolicy() const 482 500 { -
trunk/Source/WebCore/workers/WorkerGlobalScope.h
r275151 r275420 43 43 namespace WebCore { 44 44 45 class CSSFontSelector; 45 46 class CSSValuePool; 46 47 class ContentSecurityPolicyResponseHeaders; … … 117 118 118 119 CSSValuePool& cssValuePool(); 120 CSSFontSelector* cssFontSelector() final; 121 FontCache& fontCache() final; 119 122 120 123 ReferrerPolicy referrerPolicy() const final; … … 181 184 #endif 182 185 std::unique_ptr<CSSValuePool> m_cssValuePool; 186 RefPtr<CSSFontSelector> m_cssFontSelector; 187 RefPtr<FontCache> m_fontCache; 183 188 ReferrerPolicy m_referrerPolicy; 184 189 Settings::Values m_settingsValues;
Note: See TracChangeset
for help on using the changeset viewer.