| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // Begin to load the first custom font if needed. | 145 // Begin to load the first custom font if needed. |
| 146 if (shouldLoadCustomFont) { | 146 if (shouldLoadCustomFont) { |
| 147 shouldLoadCustomFont = false; | 147 shouldLoadCustomFont = false; |
| 148 fontDataForSpace->customFontData()->beginLoadIfNeeded(); | 148 fontDataForSpace->customFontData()->beginLoadIfNeeded(); |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 | 152 |
| 153 PassRefPtr<FontData> FontFallbackList::getFontData(const FontDescription& fontDe
scription, int& familyIndex) const | 153 PassRefPtr<FontData> FontFallbackList::getFontData(const FontDescription& fontDe
scription, int& familyIndex) const |
| 154 { | 154 { |
| 155 RefPtr<FontData> result; | 155 const FontFamily* currFamily = &fontDescription.family(); |
| 156 for (int i = 0; currFamily && i < familyIndex; i++) |
| 157 currFamily = currFamily->next(); |
| 156 | 158 |
| 157 int startIndex = familyIndex; | 159 for (; currFamily; currFamily = currFamily->next()) { |
| 158 const FontFamily* startFamily = &fontDescription.family(); | |
| 159 for (int i = 0; startFamily && i < startIndex; i++) | |
| 160 startFamily = startFamily->next(); | |
| 161 const FontFamily* currFamily = startFamily; | |
| 162 while (currFamily && !result) { | |
| 163 familyIndex++; | 160 familyIndex++; |
| 164 if (currFamily->family().length()) { | 161 if (currFamily->family().length()) { |
| 162 RefPtr<FontData> result; |
| 165 if (m_fontSelector) | 163 if (m_fontSelector) |
| 166 result = m_fontSelector->getFontData(fontDescription, currFamily
->family()); | 164 result = m_fontSelector->getFontData(fontDescription, currFamily
->family()); |
| 167 | |
| 168 if (!result) | 165 if (!result) |
| 169 result = FontCache::fontCache()->getFontData(fontDescription, cu
rrFamily->family()); | 166 result = FontCache::fontCache()->getFontData(fontDescription, cu
rrFamily->family()); |
| 167 if (result) |
| 168 return result.release(); |
| 170 } | 169 } |
| 171 currFamily = currFamily->next(); | |
| 172 } | 170 } |
| 173 | 171 familyIndex = cAllFamiliesScanned; |
| 174 if (!currFamily) | |
| 175 familyIndex = cAllFamiliesScanned; | |
| 176 | |
| 177 if (result || startIndex) | |
| 178 return result.release(); | |
| 179 | |
| 180 // If it's the primary font that we couldn't find, we try the following. In
all other cases, we will | |
| 181 // just use per-character system fallback. | |
| 182 | 172 |
| 183 if (m_fontSelector) { | 173 if (m_fontSelector) { |
| 184 // Try the user's preferred standard font. | 174 // Try the user's preferred standard font. |
| 185 if (RefPtr<FontData> data = m_fontSelector->getFontData(fontDescription,
FontFamilyNames::webkit_standard)) | 175 if (RefPtr<FontData> data = m_fontSelector->getFontData(fontDescription,
FontFamilyNames::webkit_standard)) |
| 186 return data.release(); | 176 return data.release(); |
| 187 } | 177 } |
| 188 | 178 |
| 189 // Still no result. Hand back our last resort fallback font. | 179 // Still no result. Hand back our last resort fallback font. |
| 190 return FontCache::fontCache()->getLastResortFallbackFont(fontDescription); | 180 return FontCache::fontCache()->getLastResortFallbackFont(fontDescription); |
| 191 } | 181 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 231 |
| 242 bool FontFallbackList::isValid() const | 232 bool FontFallbackList::isValid() const |
| 243 { | 233 { |
| 244 if (!m_fontSelector) | 234 if (!m_fontSelector) |
| 245 return m_fontSelectorVersion == 0; | 235 return m_fontSelectorVersion == 0; |
| 246 | 236 |
| 247 return m_fontSelector->version() == m_fontSelectorVersion; | 237 return m_fontSelector->version() == m_fontSelectorVersion; |
| 248 } | 238 } |
| 249 | 239 |
| 250 } // namespace blink | 240 } // namespace blink |
| OLD | NEW |