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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 FontFaceSet::from(*document)->fontLoaded(m_fontFace); | 188 FontFaceSet::from(*document)->fontLoaded(m_fontFace); |
189 break; | 189 break; |
190 case FontFace::Error: | 190 case FontFace::Error: |
191 FontFaceSet::from(*document)->loadError(m_fontFace); | 191 FontFaceSet::from(*document)->loadError(m_fontFace); |
192 break; | 192 break; |
193 default: | 193 default: |
194 break; | 194 break; |
195 } | 195 } |
196 } | 196 } |
197 | 197 |
198 CSSFontFace::UnicodeRangeSet::UnicodeRangeSet(const Vector<UnicodeRange>& ranges
) | |
199 : m_ranges(ranges) | |
200 { | |
201 if (m_ranges.isEmpty()) | |
202 return; | |
203 | |
204 std::sort(m_ranges.begin(), m_ranges.end()); | |
205 | |
206 // Unify overlapping ranges. | |
207 UChar32 from = m_ranges[0].from(); | |
208 UChar32 to = m_ranges[0].to(); | |
209 size_t targetIndex = 0; | |
210 for (size_t i = 1; i < m_ranges.size(); i++) { | |
211 if (to + 1 >= m_ranges[i].from()) { | |
212 to = std::max(to, m_ranges[i].to()); | |
213 } else { | |
214 m_ranges[targetIndex++] = UnicodeRange(from, to); | |
215 from = m_ranges[i].from(); | |
216 to = m_ranges[i].to(); | |
217 } | |
218 } | |
219 m_ranges[targetIndex++] = UnicodeRange(from, to); | |
220 m_ranges.shrink(targetIndex); | |
221 } | |
222 | |
223 bool CSSFontFace::UnicodeRangeSet::contains(UChar32 c) const | |
224 { | |
225 if (isEntireRange()) | |
226 return true; | |
227 Vector<UnicodeRange>::const_iterator it = std::lower_bound(m_ranges.begin(),
m_ranges.end(), c); | |
228 return it != m_ranges.end() && it->contains(c); | |
229 } | |
230 | |
231 bool CSSFontFace::UnicodeRangeSet::contains(const FontDataRange& range) const | |
232 { | |
233 for (auto it = m_ranges.begin(); it != m_ranges.end(); ++it) { | |
234 if (*it == range) | |
235 return true; | |
236 } | |
237 return false; | |
238 } | |
239 | |
240 bool CSSFontFace::UnicodeRangeSet::intersectsWith(const String& text) const | |
241 { | |
242 if (text.isEmpty()) | |
243 return false; | |
244 if (isEntireRange()) | |
245 return true; | |
246 if (text.is8Bit() && m_ranges[0].from() >= 0x100) | |
247 return false; | |
248 | |
249 unsigned index = 0; | |
250 while (index < text.length()) { | |
251 UChar32 c = text.characterStartingAt(index); | |
252 index += U16_LENGTH(c); | |
253 if (contains(c)) | |
254 return true; | |
255 } | |
256 return false; | |
257 } | |
258 | |
259 DEFINE_TRACE(CSSFontFace) | 198 DEFINE_TRACE(CSSFontFace) |
260 { | 199 { |
261 visitor->trace(m_segmentedFontFace); | 200 visitor->trace(m_segmentedFontFace); |
262 visitor->trace(m_sources); | 201 visitor->trace(m_sources); |
263 visitor->trace(m_fontFace); | 202 visitor->trace(m_fontFace); |
264 } | 203 } |
265 | 204 |
266 } // namespace blink | 205 } // namespace blink |
OLD | NEW |