OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, 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 * | 7 * |
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 27 matching lines...) Expand all Loading... |
38 namespace WebCore { | 38 namespace WebCore { |
39 | 39 |
40 FontFallbackList::FontFallbackList() | 40 FontFallbackList::FontFallbackList() |
41 : m_pageZero(0) | 41 : m_pageZero(0) |
42 , m_cachedPrimarySimpleFontData(0) | 42 , m_cachedPrimarySimpleFontData(0) |
43 , m_fontSelector(nullptr) | 43 , m_fontSelector(nullptr) |
44 , m_fontSelectorVersion(0) | 44 , m_fontSelectorVersion(0) |
45 , m_familyIndex(0) | 45 , m_familyIndex(0) |
46 , m_generation(FontCache::fontCache()->generation()) | 46 , m_generation(FontCache::fontCache()->generation()) |
47 , m_pitch(UnknownPitch) | 47 , m_pitch(UnknownPitch) |
48 , m_loadingCustomFonts(false) | 48 , m_hasLoadingFallback(false) |
49 { | 49 { |
50 } | 50 } |
51 | 51 |
52 void FontFallbackList::invalidate(PassRefPtr<FontSelector> fontSelector) | 52 void FontFallbackList::invalidate(PassRefPtr<FontSelector> fontSelector) |
53 { | 53 { |
54 releaseFontData(); | 54 releaseFontData(); |
55 m_fontList.clear(); | 55 m_fontList.clear(); |
56 m_pageZero = 0; | 56 m_pageZero = 0; |
57 m_pages.clear(); | 57 m_pages.clear(); |
58 m_cachedPrimarySimpleFontData = 0; | 58 m_cachedPrimarySimpleFontData = 0; |
59 m_familyIndex = 0; | 59 m_familyIndex = 0; |
60 m_pitch = UnknownPitch; | 60 m_pitch = UnknownPitch; |
61 m_loadingCustomFonts = false; | 61 m_hasLoadingFallback = false; |
62 m_fontSelector = fontSelector; | 62 m_fontSelector = fontSelector; |
63 m_fontSelectorVersion = m_fontSelector ? m_fontSelector->version() : 0; | 63 m_fontSelectorVersion = m_fontSelector ? m_fontSelector->version() : 0; |
64 m_generation = FontCache::fontCache()->generation(); | 64 m_generation = FontCache::fontCache()->generation(); |
65 m_widthCache.clear(); | 65 m_widthCache.clear(); |
66 } | 66 } |
67 | 67 |
68 void FontFallbackList::releaseFontData() | 68 void FontFallbackList::releaseFontData() |
69 { | 69 { |
70 unsigned numFonts = m_fontList.size(); | 70 unsigned numFonts = m_fontList.size(); |
71 for (unsigned i = 0; i < numFonts; ++i) { | 71 for (unsigned i = 0; i < numFonts; ++i) { |
(...skipping 14 matching lines...) Expand all Loading... |
86 unsigned numRanges = segmentedFontData->numRanges(); | 86 unsigned numRanges = segmentedFontData->numRanges(); |
87 if (numRanges == 1 && segmentedFontData->rangeAt(0).isEntireRange()) | 87 if (numRanges == 1 && segmentedFontData->rangeAt(0).isEntireRange()) |
88 m_pitch = segmentedFontData->rangeAt(0).fontData()->pitch(); | 88 m_pitch = segmentedFontData->rangeAt(0).fontData()->pitch(); |
89 else | 89 else |
90 m_pitch = VariablePitch; | 90 m_pitch = VariablePitch; |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 bool FontFallbackList::loadingCustomFonts() const | 94 bool FontFallbackList::loadingCustomFonts() const |
95 { | 95 { |
96 if (m_loadingCustomFonts) | 96 if (!m_hasLoadingFallback) |
97 return true; | 97 return false; |
98 | 98 |
99 unsigned numFonts = m_fontList.size(); | 99 unsigned numFonts = m_fontList.size(); |
100 for (unsigned i = 0; i < numFonts; ++i) { | 100 for (unsigned i = 0; i < numFonts; ++i) { |
101 if (m_fontList[i]->isCustomFont() && m_fontList[i]->isLoading()) { | 101 if (m_fontList[i]->isLoading()) |
102 m_loadingCustomFonts = true; | |
103 return true; | 102 return true; |
104 } | |
105 } | 103 } |
106 return false; | 104 return false; |
107 } | 105 } |
| 106 |
| 107 bool FontFallbackList::shouldSkipDrawing() const |
| 108 { |
| 109 if (!m_hasLoadingFallback) |
| 110 return false; |
| 111 |
| 112 unsigned numFonts = m_fontList.size(); |
| 113 for (unsigned i = 0; i < numFonts; ++i) { |
| 114 if (m_fontList[i]->shouldSkipDrawing()) |
| 115 return true; |
| 116 } |
| 117 return false; |
| 118 } |
108 | 119 |
109 const FontData* FontFallbackList::primaryFontData(const FontDescription& fontDes
cription) const | 120 const FontData* FontFallbackList::primaryFontData(const FontDescription& fontDes
cription) const |
110 { | 121 { |
111 bool shouldLoadCustomFont = true; | 122 bool shouldLoadCustomFont = true; |
112 | 123 |
113 for (unsigned fontIndex = 0; ; ++fontIndex) { | 124 for (unsigned fontIndex = 0; ; ++fontIndex) { |
114 const FontData* fontData = fontDataAt(fontDescription, fontIndex); | 125 const FontData* fontData = fontDataAt(fontDescription, fontIndex); |
115 if (!fontData) { | 126 if (!fontData) { |
116 // All fonts are custom fonts and are loading. Return the first Font
Data. | 127 // All fonts are custom fonts and are loading. Return the first Font
Data. |
117 fontData = fontDataAt(fontDescription, 0); | 128 fontData = fontDataAt(fontDescription, 0); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 return 0; | 203 return 0; |
193 | 204 |
194 // Ask the font cache for the font data. | 205 // Ask the font cache for the font data. |
195 // We are obtaining this font for the first time. We keep track of the fami
lies we've looked at before | 206 // We are obtaining this font for the first time. We keep track of the fami
lies we've looked at before |
196 // in |m_familyIndex|, so that we never scan the same spot in the list twice
. getFontData will adjust our | 207 // in |m_familyIndex|, so that we never scan the same spot in the list twice
. getFontData will adjust our |
197 // |m_familyIndex| as it scans for the right font to make. | 208 // |m_familyIndex| as it scans for the right font to make. |
198 ASSERT(FontCache::fontCache()->generation() == m_generation); | 209 ASSERT(FontCache::fontCache()->generation() == m_generation); |
199 RefPtr<FontData> result = getFontData(fontDescription, m_familyIndex); | 210 RefPtr<FontData> result = getFontData(fontDescription, m_familyIndex); |
200 if (result) { | 211 if (result) { |
201 m_fontList.append(result); | 212 m_fontList.append(result); |
202 if (result->isLoading()) | 213 if (result->isLoadingFallback()) |
203 m_loadingCustomFonts = true; | 214 m_hasLoadingFallback = true; |
204 } | 215 } |
205 return result.get(); | 216 return result.get(); |
206 } | 217 } |
207 | 218 |
208 } | 219 } |
OLD | NEW |