OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 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 20 matching lines...) Expand all Loading... |
31 #include "platform/fonts/SegmentedFontData.h" | 31 #include "platform/fonts/SegmentedFontData.h" |
32 #include "platform/heap/Handle.h" | 32 #include "platform/heap/Handle.h" |
33 #include "wtf/Forward.h" | 33 #include "wtf/Forward.h" |
34 #include "wtf/HashMap.h" | 34 #include "wtf/HashMap.h" |
35 #include "wtf/ListHashSet.h" | 35 #include "wtf/ListHashSet.h" |
36 #include "wtf/Vector.h" | 36 #include "wtf/Vector.h" |
37 #include "wtf/text/WTFString.h" | 37 #include "wtf/text/WTFString.h" |
38 | 38 |
39 namespace blink { | 39 namespace blink { |
40 | 40 |
41 class CSSFontSelector; | 41 class Document; |
42 class FontData; | 42 class FontData; |
43 class FontDescription; | 43 class FontDescription; |
44 class FontFace; | 44 class FontFace; |
45 class SegmentedFontData; | 45 class SegmentedFontData; |
46 | 46 |
47 class CSSSegmentedFontFace final | 47 class CSSSegmentedFontFace final |
48 : public GarbageCollectedFinalized<CSSSegmentedFontFace> { | 48 : public GarbageCollectedFinalized<CSSSegmentedFontFace> { |
49 public: | 49 public: |
50 static CSSSegmentedFontFace* create(CSSFontSelector* selector, | 50 static CSSSegmentedFontFace* create(FontTraits traits) { |
51 FontTraits traits) { | 51 return new CSSSegmentedFontFace(traits); |
52 return new CSSSegmentedFontFace(selector, traits); | |
53 } | 52 } |
54 ~CSSSegmentedFontFace(); | 53 ~CSSSegmentedFontFace(); |
55 | 54 |
56 CSSFontSelector* fontSelector() const { return m_fontSelector; } | |
57 FontTraits traits() const { return m_traits; } | 55 FontTraits traits() const { return m_traits; } |
58 | 56 |
59 // Called when status of a FontFace has changed (e.g. loaded or timed out) | 57 // Called when status of a FontFace has changed (e.g. loaded or timed out) |
60 // so cached FontData must be discarded. | 58 // so cached FontData must be discarded. |
61 void fontFaceInvalidated(); | 59 void fontFaceInvalidated(); |
62 | 60 |
63 void addFontFace(FontFace*, bool cssConnected); | 61 void addFontFace(FontFace*, bool cssConnected); |
64 void removeFontFace(FontFace*); | 62 void removeFontFace(FontFace*); |
65 bool isEmpty() const { return m_fontFaces.isEmpty(); } | 63 bool isEmpty() const { return m_fontFaces.isEmpty(); } |
66 | 64 |
67 PassRefPtr<FontData> getFontData(const FontDescription&); | 65 PassRefPtr<FontData> getFontData(const FontDescription&); |
68 | 66 |
69 bool checkFont(const String&) const; | 67 bool checkFont(const String&) const; |
70 void match(const String&, HeapVector<Member<FontFace>>&) const; | 68 void match(const String&, HeapVector<Member<FontFace>>&) const; |
71 void willUseFontData(const FontDescription&, const String& text); | 69 void willUseFontData(Document*, const FontDescription&, const String& text); |
72 void willUseRange(const FontDescription&, const blink::FontDataForRangeSet&); | 70 void willUseRange(Document*, |
| 71 const FontDescription&, |
| 72 const blink::FontDataForRangeSet&); |
73 size_t approximateCharacterCount() const { | 73 size_t approximateCharacterCount() const { |
74 return m_approximateCharacterCount; | 74 return m_approximateCharacterCount; |
75 } | 75 } |
76 | 76 |
77 DECLARE_TRACE(); | 77 DECLARE_TRACE(); |
78 | 78 |
79 private: | 79 private: |
80 CSSSegmentedFontFace(CSSFontSelector*, FontTraits); | 80 CSSSegmentedFontFace(FontTraits); |
81 | 81 |
82 void pruneTable(); | 82 void pruneTable(); |
83 bool isValid() const; | 83 bool isValid() const; |
84 | 84 |
85 using FontFaceList = HeapListHashSet<Member<FontFace>>; | 85 using FontFaceList = HeapListHashSet<Member<FontFace>>; |
86 | 86 |
87 Member<CSSFontSelector> m_fontSelector; | |
88 FontTraits m_traits; | 87 FontTraits m_traits; |
89 HashMap<FontCacheKey, | 88 HashMap<FontCacheKey, |
90 RefPtr<SegmentedFontData>, | 89 RefPtr<SegmentedFontData>, |
91 FontCacheKeyHash, | 90 FontCacheKeyHash, |
92 FontCacheKeyTraits> | 91 FontCacheKeyTraits> |
93 m_fontDataTable; | 92 m_fontDataTable; |
94 // All non-CSS-connected FontFaces are stored after the CSS-connected ones. | 93 // All non-CSS-connected FontFaces are stored after the CSS-connected ones. |
95 FontFaceList m_fontFaces; | 94 FontFaceList m_fontFaces; |
96 FontFaceList::iterator m_firstNonCssConnectedFace; | 95 FontFaceList::iterator m_firstNonCssConnectedFace; |
97 | 96 |
98 // Approximate number of characters styled with this CSSSegmentedFontFace. | 97 // Approximate number of characters styled with this CSSSegmentedFontFace. |
99 // LayoutText::styleDidChange() increments this on the first | 98 // LayoutText::styleDidChange() increments this on the first |
100 // CSSSegmentedFontFace in the style's font family list, so this is not | 99 // CSSSegmentedFontFace in the style's font family list, so this is not |
101 // counted if this font is used as a fallback font. Also, this may be double | 100 // counted if this font is used as a fallback font. Also, this may be double |
102 // counted by style recalcs. | 101 // counted by style recalcs. |
103 // TODO(ksakamoto): Revisit the necessity of this. crbug.com/613500 | 102 // TODO(ksakamoto): Revisit the necessity of this. crbug.com/613500 |
104 size_t m_approximateCharacterCount; | 103 size_t m_approximateCharacterCount; |
105 }; | 104 }; |
106 | 105 |
107 } // namespace blink | 106 } // namespace blink |
108 | 107 |
109 #endif // CSSSegmentedFontFace_h | 108 #endif // CSSSegmentedFontFace_h |
OLD | NEW |