| 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 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef CSSFontSelector_h | 26 #ifndef CSSFontSelector_h |
| 27 #define CSSFontSelector_h | 27 #define CSSFontSelector_h |
| 28 | 28 |
| 29 #include "core/CoreExport.h" | 29 #include "core/CoreExport.h" |
| 30 #include "core/css/FontFaceCache.h" | 30 #include "core/css/FontFaceCache.h" |
| 31 #include "core/dom/Document.h" |
| 31 #include "platform/fonts/FontSelector.h" | 32 #include "platform/fonts/FontSelector.h" |
| 32 #include "platform/fonts/GenericFontFamilySettings.h" | 33 #include "platform/fonts/GenericFontFamilySettings.h" |
| 33 #include "platform/heap/Handle.h" | 34 #include "platform/heap/Handle.h" |
| 34 #include "wtf/Forward.h" | 35 #include "wtf/Forward.h" |
| 35 #include "wtf/HashMap.h" | 36 #include "wtf/HashMap.h" |
| 36 #include "wtf/HashSet.h" | 37 #include "wtf/HashSet.h" |
| 37 | 38 |
| 38 namespace blink { | 39 namespace blink { |
| 39 | 40 |
| 40 class CSSFontSelectorClient; | 41 class CSSFontSelectorClient; |
| 41 class Document; | |
| 42 class FontDescription; | 42 class FontDescription; |
| 43 | 43 |
| 44 class CORE_EXPORT CSSFontSelector : public FontSelector { | 44 class CORE_EXPORT CSSFontSelector : public FontSelector { |
| 45 public: | 45 public: |
| 46 static CSSFontSelector* create(Document* document) { | 46 static CSSFontSelector* create(Document* document) { |
| 47 return new CSSFontSelector(document); | 47 return new CSSFontSelector(document); |
| 48 } | 48 } |
| 49 ~CSSFontSelector() override; | 49 ~CSSFontSelector() override; |
| 50 | 50 |
| 51 unsigned version() const override { return m_fontFaceCache.version(); } | 51 unsigned version() const override { |
| 52 return m_document->fontFaceCache()->version(); |
| 53 } |
| 52 | 54 |
| 53 PassRefPtr<FontData> getFontData(const FontDescription&, | 55 PassRefPtr<FontData> getFontData(const FontDescription&, |
| 54 const AtomicString&) override; | 56 const AtomicString&) override; |
| 55 void willUseFontData(const FontDescription&, | 57 void willUseFontData(const FontDescription&, |
| 56 const AtomicString& family, | 58 const AtomicString& family, |
| 57 const String& text) override; | 59 const String& text) override; |
| 58 void willUseRange(const FontDescription&, | 60 void willUseRange(const FontDescription&, |
| 59 const AtomicString& familyName, | 61 const AtomicString& familyName, |
| 60 const FontDataForRangeSet&) override; | 62 const FontDataForRangeSet&) override; |
| 61 bool isPlatformFontAvailable(const FontDescription&, | 63 bool isPlatformFontAvailable(const FontDescription&, |
| 62 const AtomicString& family); | 64 const AtomicString& family); |
| 63 | 65 |
| 64 void fontFaceInvalidated(); | 66 void fontFaceInvalidated(); |
| 65 | 67 |
| 66 // FontCacheClient implementation | 68 // FontCacheClient implementation |
| 67 void fontCacheInvalidated() override; | 69 void fontCacheInvalidated() override; |
| 68 | 70 |
| 69 void registerForInvalidationCallbacks(CSSFontSelectorClient*); | 71 void registerForInvalidationCallbacks(CSSFontSelectorClient*); |
| 70 void unregisterForInvalidationCallbacks(CSSFontSelectorClient*); | 72 void unregisterForInvalidationCallbacks(CSSFontSelectorClient*); |
| 71 | 73 |
| 72 Document* document() const { return m_document; } | 74 Document* document() const { return m_document; } |
| 73 FontFaceCache* fontFaceCache() { return &m_fontFaceCache; } | |
| 74 | 75 |
| 75 const GenericFontFamilySettings& genericFontFamilySettings() const { | 76 const GenericFontFamilySettings& genericFontFamilySettings() const { |
| 76 return m_genericFontFamilySettings; | 77 return m_genericFontFamilySettings; |
| 77 } | 78 } |
| 78 void updateGenericFontFamilySettings(Document&); | 79 void updateGenericFontFamilySettings(Document&); |
| 79 | 80 |
| 80 DECLARE_VIRTUAL_TRACE(); | 81 DECLARE_VIRTUAL_TRACE(); |
| 81 | 82 |
| 82 protected: | 83 protected: |
| 83 explicit CSSFontSelector(Document*); | 84 explicit CSSFontSelector(Document*); |
| 84 | 85 |
| 85 void dispatchInvalidationCallbacks(); | 86 void dispatchInvalidationCallbacks(); |
| 86 | 87 |
| 87 private: | 88 private: |
| 89 CSSSegmentedFontFace* getFontFaceFromCache( |
| 90 const FontDescription& fontDescription, |
| 91 const AtomicString& family) { |
| 92 return m_document->fontFaceCache()->get(fontDescription, family); |
| 93 } |
| 94 |
| 88 // TODO(Oilpan): Ideally this should just be a traced Member but that will | 95 // TODO(Oilpan): Ideally this should just be a traced Member but that will |
| 89 // currently leak because ComputedStyle and its data are not on the heap. | 96 // currently leak because ComputedStyle and its data are not on the heap. |
| 90 // See crbug.com/383860 for details. | 97 // See crbug.com/383860 for details. |
| 91 WeakMember<Document> m_document; | 98 WeakMember<Document> m_document; |
| 92 // FIXME: Move to Document or StyleEngine. | |
| 93 FontFaceCache m_fontFaceCache; | |
| 94 HeapHashSet<WeakMember<CSSFontSelectorClient>> m_clients; | 99 HeapHashSet<WeakMember<CSSFontSelectorClient>> m_clients; |
| 95 GenericFontFamilySettings m_genericFontFamilySettings; | 100 GenericFontFamilySettings m_genericFontFamilySettings; |
| 96 }; | 101 }; |
| 97 | 102 |
| 98 } // namespace blink | 103 } // namespace blink |
| 99 | 104 |
| 100 #endif // CSSFontSelector_h | 105 #endif // CSSFontSelector_h |
| OLD | NEW |