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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 m_sources.removeFirst(); | 119 m_sources.removeFirst(); |
120 } | 120 } |
121 | 121 |
122 if (loadStatus() == FontFace::Unloaded) | 122 if (loadStatus() == FontFace::Unloaded) |
123 setLoadStatus(FontFace::Loading); | 123 setLoadStatus(FontFace::Loading); |
124 if (loadStatus() == FontFace::Loading) | 124 if (loadStatus() == FontFace::Loading) |
125 setLoadStatus(FontFace::Error); | 125 setLoadStatus(FontFace::Error); |
126 return nullptr; | 126 return nullptr; |
127 } | 127 } |
128 | 128 |
129 bool CSSFontFace::maybeScheduleFontLoad(const FontDescription& fontDescription,
UChar32 character) | 129 void CSSFontFace::willUseFontData(const FontDescription& fontDescription) |
130 { | 130 { |
131 if (m_ranges.contains(character)) { | 131 // Kicks off font load here only if the @font-face has no unicode-range. |
| 132 // @font-faces with unicode-range will be loaded when a GlyphPage for the |
| 133 // font is created. |
| 134 // FIXME: Pass around the text to render from RenderText, and kick download |
| 135 // if m_ranges intersects with the text. Make sure this does not cause |
| 136 // performance regression. |
| 137 if (m_ranges.isEntireRange()) |
132 load(fontDescription); | 138 load(fontDescription); |
133 return true; | |
134 } | |
135 return false; | |
136 } | 139 } |
137 | 140 |
138 void CSSFontFace::load(const FontDescription& fontDescription, CSSFontSelector*
fontSelector) | 141 void CSSFontFace::load(const FontDescription& fontDescription, CSSFontSelector*
fontSelector) |
139 { | 142 { |
140 if (loadStatus() != FontFace::Unloaded) | 143 if (loadStatus() != FontFace::Unloaded) |
141 return; | 144 return; |
142 setLoadStatus(FontFace::Loading); | 145 setLoadStatus(FontFace::Loading); |
143 | 146 |
144 while (!m_sources.isEmpty()) { | 147 while (!m_sources.isEmpty()) { |
145 OwnPtr<CSSFontFaceSource>& source = m_sources.first(); | 148 OwnPtr<CSSFontFaceSource>& source = m_sources.first(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 } else { | 210 } else { |
208 m_ranges[targetIndex++] = UnicodeRange(from, to); | 211 m_ranges[targetIndex++] = UnicodeRange(from, to); |
209 from = m_ranges[i].from(); | 212 from = m_ranges[i].from(); |
210 to = m_ranges[i].to(); | 213 to = m_ranges[i].to(); |
211 } | 214 } |
212 } | 215 } |
213 m_ranges[targetIndex++] = UnicodeRange(from, to); | 216 m_ranges[targetIndex++] = UnicodeRange(from, to); |
214 m_ranges.shrink(targetIndex); | 217 m_ranges.shrink(targetIndex); |
215 } | 218 } |
216 | 219 |
217 bool CSSFontFace::UnicodeRangeSet::contains(UChar32 c) const | |
218 { | |
219 if (isEntireRange()) | |
220 return true; | |
221 Vector<UnicodeRange>::const_iterator it = std::lower_bound(m_ranges.begin(),
m_ranges.end(), c); | |
222 return it != m_ranges.end() && it->contains(c); | |
223 } | |
224 | |
225 bool CSSFontFace::UnicodeRangeSet::intersectsWith(const String& text) const | 220 bool CSSFontFace::UnicodeRangeSet::intersectsWith(const String& text) const |
226 { | 221 { |
227 if (text.isEmpty()) | 222 if (text.isEmpty()) |
228 return false; | 223 return false; |
229 if (isEntireRange()) | 224 if (isEntireRange()) |
230 return true; | 225 return true; |
231 if (text.is8Bit() && m_ranges[0].from() >= 0x100) | 226 if (text.is8Bit() && m_ranges[0].from() >= 0x100) |
232 return false; | 227 return false; |
233 | 228 |
234 unsigned index = 0; | 229 unsigned index = 0; |
235 while (index < text.length()) { | 230 while (index < text.length()) { |
236 UChar32 c = text.characterStartingAt(index); | 231 UChar32 c = text.characterStartingAt(index); |
237 index += U16_LENGTH(c); | 232 index += U16_LENGTH(c); |
238 if (contains(c)) | 233 Vector<UnicodeRange>::const_iterator it = std::lower_bound(m_ranges.begi
n(), m_ranges.end(), c); |
| 234 if (it != m_ranges.end() && it->contains(c)) |
239 return true; | 235 return true; |
240 } | 236 } |
241 return false; | 237 return false; |
242 } | 238 } |
243 | 239 |
244 void CSSFontFace::trace(Visitor* visitor) | 240 void CSSFontFace::trace(Visitor* visitor) |
245 { | 241 { |
246 visitor->trace(m_segmentedFontFace); | 242 visitor->trace(m_segmentedFontFace); |
247 visitor->trace(m_fontFace); | 243 visitor->trace(m_fontFace); |
248 } | 244 } |
249 | 245 |
250 } | 246 } |
OLD | NEW |