| 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 12 matching lines...) Expand all Loading... |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "sky/engine/core/css/CSSFontSelector.h" | 27 #include "sky/engine/core/css/CSSFontSelector.h" |
| 28 | 28 |
| 29 #include "gen/sky/platform/RuntimeEnabledFeatures.h" | 29 #include "gen/sky/platform/RuntimeEnabledFeatures.h" |
| 30 #include "sky/engine/core/css/CSSFontSelectorClient.h" | 30 #include "sky/engine/core/css/CSSFontSelectorClient.h" |
| 31 #include "sky/engine/core/css/CSSSegmentedFontFace.h" | 31 #include "sky/engine/core/css/CSSSegmentedFontFace.h" |
| 32 #include "sky/engine/core/css/CSSValueList.h" | 32 #include "sky/engine/core/css/CSSValueList.h" |
| 33 #include "sky/engine/core/css/FontFaceSet.h" | 33 #include "sky/engine/core/css/FontFace.h" |
| 34 #include "sky/engine/core/css/resolver/StyleResolver.h" | 34 #include "sky/engine/core/css/resolver/StyleResolver.h" |
| 35 #include "sky/engine/core/dom/Document.h" | 35 #include "sky/engine/core/dom/Document.h" |
| 36 #include "sky/engine/core/frame/LocalFrame.h" | 36 #include "sky/engine/core/frame/LocalFrame.h" |
| 37 #include "sky/engine/core/frame/Settings.h" | 37 #include "sky/engine/core/frame/Settings.h" |
| 38 #include "sky/engine/platform/fonts/FontCache.h" | 38 #include "sky/engine/platform/fonts/FontCache.h" |
| 39 #include "sky/engine/platform/fonts/SimpleFontData.h" | 39 #include "sky/engine/platform/fonts/SimpleFontData.h" |
| 40 #include "sky/engine/wtf/text/AtomicString.h" | 40 #include "sky/engine/wtf/text/AtomicString.h" |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| 44 CSSFontSelector::CSSFontSelector(Document* document) | 44 CSSFontSelector::CSSFontSelector(Document* document) |
| 45 : m_document(document) | 45 : m_document(document) |
| 46 , m_fontLoader(FontLoader::create(this, document->fetcher())) | |
| 47 , m_genericFontFamilySettings(document->frame()->settings()->genericFontFami
lySettings()) | 46 , m_genericFontFamilySettings(document->frame()->settings()->genericFontFami
lySettings()) |
| 48 { | 47 { |
| 49 // FIXME: An old comment used to say there was no need to hold a reference t
o m_document | 48 // FIXME: An old comment used to say there was no need to hold a reference t
o m_document |
| 50 // because "we are guaranteed to be destroyed before the document". But ther
e does not | 49 // because "we are guaranteed to be destroyed before the document". But ther
e does not |
| 51 // seem to be any such guarantee. | 50 // seem to be any such guarantee. |
| 52 | 51 |
| 53 ASSERT(m_document); | 52 ASSERT(m_document); |
| 54 ASSERT(m_document->frame()); | 53 ASSERT(m_document->frame()); |
| 55 FontCache::fontCache()->addClient(this); | 54 FontCache::fontCache()->addClient(this); |
| 56 FontFaceSet::from(*document)->addFontFacesToFontFaceCache(&m_fontFaceCache,
this); | |
| 57 } | 55 } |
| 58 | 56 |
| 59 CSSFontSelector::~CSSFontSelector() | 57 CSSFontSelector::~CSSFontSelector() |
| 60 { | 58 { |
| 61 #if !ENABLE(OILPAN) | 59 #if !ENABLE(OILPAN) |
| 62 clearDocument(); | 60 clearDocument(); |
| 63 FontCache::fontCache()->removeClient(this); | 61 FontCache::fontCache()->removeClient(this); |
| 64 #endif | 62 #endif |
| 65 } | 63 } |
| 66 | 64 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 { | 147 { |
| 150 AtomicString family = familyNameFromSettings(m_genericFontFamilySettings, fo
ntDescription, passedFamily); | 148 AtomicString family = familyNameFromSettings(m_genericFontFamilySettings, fo
ntDescription, passedFamily); |
| 151 if (family.isEmpty()) | 149 if (family.isEmpty()) |
| 152 family = passedFamily; | 150 family = passedFamily; |
| 153 return FontCache::fontCache()->isPlatformFontAvailable(fontDescription, fami
ly); | 151 return FontCache::fontCache()->isPlatformFontAvailable(fontDescription, fami
ly); |
| 154 } | 152 } |
| 155 | 153 |
| 156 #if !ENABLE(OILPAN) | 154 #if !ENABLE(OILPAN) |
| 157 void CSSFontSelector::clearDocument() | 155 void CSSFontSelector::clearDocument() |
| 158 { | 156 { |
| 159 m_fontLoader->clearResourceFetcherAndFontSelector(); | |
| 160 m_document = nullptr; | 157 m_document = nullptr; |
| 161 m_fontFaceCache.clearAll(); | 158 m_fontFaceCache.clearAll(); |
| 162 } | 159 } |
| 163 #endif | 160 #endif |
| 164 | 161 |
| 165 void CSSFontSelector::updateGenericFontFamilySettings(Document& document) | 162 void CSSFontSelector::updateGenericFontFamilySettings(Document& document) |
| 166 { | 163 { |
| 167 if (!document.settings()) | 164 if (!document.settings()) |
| 168 return; | 165 return; |
| 169 m_genericFontFamilySettings = document.settings()->genericFontFamilySettings
(); | 166 m_genericFontFamilySettings = document.settings()->genericFontFamilySettings
(); |
| 170 // Need to increment FontFaceCache version to update RenderStyles. | 167 // Need to increment FontFaceCache version to update RenderStyles. |
| 171 m_fontFaceCache.incrementVersion(); | 168 m_fontFaceCache.incrementVersion(); |
| 172 } | 169 } |
| 173 | 170 |
| 174 } | 171 } |
| OLD | NEW |