OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved. |
3 * (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 3 * (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "core/css/CSSFontFaceSource.h" | 33 #include "core/css/CSSFontFaceSource.h" |
34 #include "core/css/CSSSegmentedFontFace.h" | 34 #include "core/css/CSSSegmentedFontFace.h" |
35 #include "core/css/CSSValueList.h" | 35 #include "core/css/CSSValueList.h" |
36 #include "core/css/resolver/StyleResolver.h" | 36 #include "core/css/resolver/StyleResolver.h" |
37 #include "core/dom/Document.h" | 37 #include "core/dom/Document.h" |
38 #include "core/fetch/FontResource.h" | 38 #include "core/fetch/FontResource.h" |
39 #include "core/fetch/ResourceFetcher.h" | 39 #include "core/fetch/ResourceFetcher.h" |
40 #include "core/loader/FrameLoader.h" | 40 #include "core/loader/FrameLoader.h" |
41 #include "core/frame/Frame.h" | 41 #include "core/frame/Frame.h" |
42 #include "core/page/Settings.h" | 42 #include "core/page/Settings.h" |
43 #include "core/platform/graphics/FontCache.h" | 43 #include "platform/fonts/FontCache.h" |
44 #include "core/platform/graphics/SimpleFontData.h" | 44 #include "platform/fonts/SimpleFontData.h" |
45 #include "wtf/text/AtomicString.h" | 45 #include "wtf/text/AtomicString.h" |
46 | 46 |
47 using namespace std; | 47 using namespace std; |
48 | 48 |
49 namespace WebCore { | 49 namespace WebCore { |
50 | 50 |
51 FontLoader::FontLoader(ResourceFetcher* resourceFetcher) | 51 FontLoader::FontLoader(ResourceFetcher* resourceFetcher) |
52 : m_beginLoadingTimer(this, &FontLoader::beginLoadTimerFired) | 52 : m_beginLoadingTimer(this, &FontLoader::beginLoadTimerFired) |
53 , m_resourceFetcher(resourceFetcher) | 53 , m_resourceFetcher(resourceFetcher) |
54 { | 54 { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 : m_document(document) | 109 : m_document(document) |
110 , m_fontLoader(document->fetcher()) | 110 , m_fontLoader(document->fetcher()) |
111 , m_genericFontFamilySettings(document->frame()->settings()->genericFontFami
lySettings()) | 111 , m_genericFontFamilySettings(document->frame()->settings()->genericFontFami
lySettings()) |
112 { | 112 { |
113 // FIXME: An old comment used to say there was no need to hold a reference t
o m_document | 113 // FIXME: An old comment used to say there was no need to hold a reference t
o m_document |
114 // because "we are guaranteed to be destroyed before the document". But ther
e does not | 114 // because "we are guaranteed to be destroyed before the document". But ther
e does not |
115 // seem to be any such guarantee. | 115 // seem to be any such guarantee. |
116 | 116 |
117 ASSERT(m_document); | 117 ASSERT(m_document); |
118 ASSERT(m_document->frame()); | 118 ASSERT(m_document->frame()); |
119 fontCache()->addClient(this); | 119 FontCache::fontCache()->addClient(this); |
120 } | 120 } |
121 | 121 |
122 CSSFontSelector::~CSSFontSelector() | 122 CSSFontSelector::~CSSFontSelector() |
123 { | 123 { |
124 clearDocument(); | 124 clearDocument(); |
125 fontCache()->removeClient(this); | 125 FontCache::fontCache()->removeClient(this); |
126 } | 126 } |
127 | 127 |
128 void CSSFontSelector::registerForInvalidationCallbacks(FontSelectorClient* clien
t) | 128 void CSSFontSelector::registerForInvalidationCallbacks(FontSelectorClient* clien
t) |
129 { | 129 { |
130 m_clients.add(client); | 130 m_clients.add(client); |
131 } | 131 } |
132 | 132 |
133 void CSSFontSelector::unregisterForInvalidationCallbacks(FontSelectorClient* cli
ent) | 133 void CSSFontSelector::unregisterForInvalidationCallbacks(FontSelectorClient* cli
ent) |
134 { | 134 { |
135 m_clients.remove(client); | 135 m_clients.remove(client); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 PassRefPtr<FontData> CSSFontSelector::getFontData(const FontDescription& fontDes
cription, const AtomicString& familyName) | 194 PassRefPtr<FontData> CSSFontSelector::getFontData(const FontDescription& fontDes
cription, const AtomicString& familyName) |
195 { | 195 { |
196 if (CSSSegmentedFontFace* face = m_cssSegmentedFontFaceCache.get(fontDescrip
tion, familyName)) | 196 if (CSSSegmentedFontFace* face = m_cssSegmentedFontFaceCache.get(fontDescrip
tion, familyName)) |
197 return face->getFontData(fontDescription); | 197 return face->getFontData(fontDescription); |
198 | 198 |
199 // Try to return the correct font based off our settings, in case we were ha
nded the generic font family name. | 199 // Try to return the correct font based off our settings, in case we were ha
nded the generic font family name. |
200 AtomicString settingsFamilyName = familyNameFromSettings(m_genericFontFamily
Settings, fontDescription, familyName); | 200 AtomicString settingsFamilyName = familyNameFromSettings(m_genericFontFamily
Settings, fontDescription, familyName); |
201 if (settingsFamilyName.isEmpty()) | 201 if (settingsFamilyName.isEmpty()) |
202 return 0; | 202 return 0; |
203 | 203 |
204 return fontCache()->getFontData(fontDescription, settingsFamilyName); | 204 return FontCache::fontCache()->getFontData(fontDescription, settingsFamilyNa
me); |
205 } | 205 } |
206 | 206 |
207 CSSSegmentedFontFace* CSSFontSelector::getFontFace(const FontDescription& fontDe
scription, const AtomicString& familyName) | 207 CSSSegmentedFontFace* CSSFontSelector::getFontFace(const FontDescription& fontDe
scription, const AtomicString& familyName) |
208 { | 208 { |
209 return m_cssSegmentedFontFaceCache.get(fontDescription, familyName); | 209 return m_cssSegmentedFontFaceCache.get(fontDescription, familyName); |
210 } | 210 } |
211 | 211 |
212 void CSSFontSelector::willUseFontData(const FontDescription& fontDescription, co
nst AtomicString& family) | 212 void CSSFontSelector::willUseFontData(const FontDescription& fontDescription, co
nst AtomicString& family) |
213 { | 213 { |
214 CSSSegmentedFontFace* face = getFontFace(fontDescription, family); | 214 CSSSegmentedFontFace* face = getFontFace(fontDescription, family); |
(...skipping 11 matching lines...) Expand all Loading... |
226 { | 226 { |
227 m_fontLoader.addFontToBeginLoading(font); | 227 m_fontLoader.addFontToBeginLoading(font); |
228 } | 228 } |
229 | 229 |
230 void CSSFontSelector::loadPendingFonts() | 230 void CSSFontSelector::loadPendingFonts() |
231 { | 231 { |
232 m_fontLoader.loadPendingFonts(); | 232 m_fontLoader.loadPendingFonts(); |
233 } | 233 } |
234 | 234 |
235 } | 235 } |
OLD | NEW |