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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 if (m_fontSelector != fontSelector) | 56 if (m_fontSelector != fontSelector) |
57 m_fontSelector = fontSelector; | 57 m_fontSelector = fontSelector; |
58 m_fontSelectorVersion = m_fontSelector ? m_fontSelector->version() : 0; | 58 m_fontSelectorVersion = m_fontSelector ? m_fontSelector->version() : 0; |
59 m_generation = FontCache::fontCache()->generation(); | 59 m_generation = FontCache::fontCache()->generation(); |
60 } | 60 } |
61 | 61 |
62 void FontFallbackList::releaseFontData() { | 62 void FontFallbackList::releaseFontData() { |
63 unsigned numFonts = m_fontList.size(); | 63 unsigned numFonts = m_fontList.size(); |
64 for (unsigned i = 0; i < numFonts; ++i) { | 64 for (unsigned i = 0; i < numFonts; ++i) { |
65 if (!m_fontList[i]->isCustomFont()) { | 65 if (!m_fontList[i]->isCustomFont()) { |
66 ASSERT(!m_fontList[i]->isSegmented()); | 66 DCHECK(!m_fontList[i]->isSegmented()); |
67 FontCache::fontCache()->releaseFontData(toSimpleFontData(m_fontList[i])); | 67 FontCache::fontCache()->releaseFontData(toSimpleFontData(m_fontList[i])); |
68 } | 68 } |
69 } | 69 } |
70 m_shapeCache.reset(); // Clear the weak pointer to the cache instance. | 70 m_shapeCache.reset(); // Clear the weak pointer to the cache instance. |
71 } | 71 } |
72 | 72 |
73 bool FontFallbackList::loadingCustomFonts() const { | 73 bool FontFallbackList::loadingCustomFonts() const { |
74 if (!m_hasLoadingFallback) | 74 if (!m_hasLoadingFallback) |
75 return false; | 75 return false; |
76 | 76 |
(...skipping 26 matching lines...) Expand all Loading... |
103 if (!fontData) { | 103 if (!fontData) { |
104 // All fonts are custom fonts and are loading. Return the first FontData. | 104 // All fonts are custom fonts and are loading. Return the first FontData. |
105 fontData = fontDataAt(fontDescription, 0); | 105 fontData = fontDataAt(fontDescription, 0); |
106 if (fontData) | 106 if (fontData) |
107 return fontData->fontDataForCharacter(spaceCharacter); | 107 return fontData->fontDataForCharacter(spaceCharacter); |
108 | 108 |
109 SimpleFontData* lastResortFallback = | 109 SimpleFontData* lastResortFallback = |
110 FontCache::fontCache() | 110 FontCache::fontCache() |
111 ->getLastResortFallbackFont(fontDescription) | 111 ->getLastResortFallbackFont(fontDescription) |
112 .get(); | 112 .get(); |
113 ASSERT(lastResortFallback); | 113 DCHECK(lastResortFallback); |
114 return lastResortFallback; | 114 return lastResortFallback; |
115 } | 115 } |
116 | 116 |
117 if (fontData->isSegmented() && | 117 if (fontData->isSegmented() && |
118 !toSegmentedFontData(fontData)->containsCharacter(spaceCharacter)) | 118 !toSegmentedFontData(fontData)->containsCharacter(spaceCharacter)) |
119 continue; | 119 continue; |
120 | 120 |
121 const SimpleFontData* fontDataForSpace = | 121 const SimpleFontData* fontDataForSpace = |
122 fontData->fontDataForCharacter(spaceCharacter); | 122 fontData->fontDataForCharacter(spaceCharacter); |
123 ASSERT(fontDataForSpace); | 123 DCHECK(fontDataForSpace); |
124 | 124 |
125 // When a custom font is loading, we should use the correct fallback font to | 125 // When a custom font is loading, we should use the correct fallback font to |
126 // layout the text. Here skip the temporary font for the loading custom | 126 // layout the text. Here skip the temporary font for the loading custom |
127 // font which may not act as the correct fallback font. | 127 // font which may not act as the correct fallback font. |
128 if (!fontDataForSpace->isLoadingFallback()) | 128 if (!fontDataForSpace->isLoadingFallback()) |
129 return fontDataForSpace; | 129 return fontDataForSpace; |
130 | 130 |
131 if (fontData->isSegmented()) { | 131 if (fontData->isSegmented()) { |
132 const SegmentedFontData* segmented = toSegmentedFontData(fontData); | 132 const SegmentedFontData* segmented = toSegmentedFontData(fontData); |
133 for (unsigned i = 0; i < segmented->numFaces(); i++) { | 133 for (unsigned i = 0; i < segmented->numFaces(); i++) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 } | 213 } |
214 | 214 |
215 const FontData* FontFallbackList::fontDataAt( | 215 const FontData* FontFallbackList::fontDataAt( |
216 const FontDescription& fontDescription, | 216 const FontDescription& fontDescription, |
217 unsigned realizedFontIndex) const { | 217 unsigned realizedFontIndex) const { |
218 if (realizedFontIndex < m_fontList.size()) | 218 if (realizedFontIndex < m_fontList.size()) |
219 return m_fontList[realizedFontIndex] | 219 return m_fontList[realizedFontIndex] |
220 .get(); // This fallback font is already in our list. | 220 .get(); // This fallback font is already in our list. |
221 | 221 |
222 // Make sure we're not passing in some crazy value here. | 222 // Make sure we're not passing in some crazy value here. |
223 ASSERT(realizedFontIndex == m_fontList.size()); | 223 DCHECK_EQ(realizedFontIndex, m_fontList.size()); |
224 | 224 |
225 if (m_familyIndex == cAllFamiliesScanned) | 225 if (m_familyIndex == cAllFamiliesScanned) |
226 return 0; | 226 return 0; |
227 | 227 |
228 // Ask the font cache for the font data. | 228 // Ask the font cache for the font data. |
229 // We are obtaining this font for the first time. We keep track of the | 229 // We are obtaining this font for the first time. We keep track of the |
230 // families we've looked at before in |m_familyIndex|, so that we never scan | 230 // families we've looked at before in |m_familyIndex|, so that we never scan |
231 // the same spot in the list twice. getFontData will adjust our | 231 // the same spot in the list twice. getFontData will adjust our |
232 // |m_familyIndex| as it scans for the right font to make. | 232 // |m_familyIndex| as it scans for the right font to make. |
233 ASSERT(FontCache::fontCache()->generation() == m_generation); | 233 DCHECK_EQ(FontCache::fontCache()->generation(), m_generation); |
234 RefPtr<FontData> result = getFontData(fontDescription, m_familyIndex); | 234 RefPtr<FontData> result = getFontData(fontDescription, m_familyIndex); |
235 if (result) { | 235 if (result) { |
236 m_fontList.push_back(result); | 236 m_fontList.push_back(result); |
237 if (result->isLoadingFallback()) | 237 if (result->isLoadingFallback()) |
238 m_hasLoadingFallback = true; | 238 m_hasLoadingFallback = true; |
239 } | 239 } |
240 return result.get(); | 240 return result.get(); |
241 } | 241 } |
242 | 242 |
243 bool FontFallbackList::isValid() const { | 243 bool FontFallbackList::isValid() const { |
244 if (!m_fontSelector) | 244 if (!m_fontSelector) |
245 return m_fontSelectorVersion == 0; | 245 return m_fontSelectorVersion == 0; |
246 | 246 |
247 return m_fontSelector->version() == m_fontSelectorVersion; | 247 return m_fontSelector->version() == m_fontSelectorVersion; |
248 } | 248 } |
249 | 249 |
250 } // namespace blink | 250 } // namespace blink |
OLD | NEW |