OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google 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 are met: | 5 * modification, are permitted provided that the following conditions are met: |
6 * | 6 * |
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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 } | 154 } |
155 | 155 |
156 bool FontFaceSet::inActiveDocumentContext() const | 156 bool FontFaceSet::inActiveDocumentContext() const |
157 { | 157 { |
158 ExecutionContext* context = executionContext(); | 158 ExecutionContext* context = executionContext(); |
159 return context && toDocument(context)->isActive(); | 159 return context && toDocument(context)->isActive(); |
160 } | 160 } |
161 | 161 |
162 void FontFaceSet::addFontFacesToFontFaceCache(FontFaceCache* fontFaceCache, CSSF
ontSelector* fontSelector) | 162 void FontFaceSet::addFontFacesToFontFaceCache(FontFaceCache* fontFaceCache, CSSF
ontSelector* fontSelector) |
163 { | 163 { |
164 for (WillBeHeapListHashSet<RefPtrWillBeMember<FontFace> >::iterator it = m_n
onCSSConnectedFaces.begin(); it != m_nonCSSConnectedFaces.end(); ++it) | 164 for (const auto& fontFace : m_nonCSSConnectedFaces) |
165 fontFaceCache->addFontFace(fontSelector, *it, false); | 165 fontFaceCache->addFontFace(fontSelector, fontFace, false); |
166 } | 166 } |
167 | 167 |
168 const AtomicString& FontFaceSet::interfaceName() const | 168 const AtomicString& FontFaceSet::interfaceName() const |
169 { | 169 { |
170 return EventTargetNames::FontFaceSet; | 170 return EventTargetNames::FontFaceSet; |
171 } | 171 } |
172 | 172 |
173 ExecutionContext* FontFaceSet::executionContext() const | 173 ExecutionContext* FontFaceSet::executionContext() const |
174 { | 174 { |
175 return ActiveDOMObject::executionContext(); | 175 return ActiveDOMObject::executionContext(); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 addToLoadingFonts(fontFace); | 294 addToLoadingFonts(fontFace); |
295 fontSelector->fontFaceInvalidated(); | 295 fontSelector->fontFaceInvalidated(); |
296 } | 296 } |
297 | 297 |
298 void FontFaceSet::clear() | 298 void FontFaceSet::clear() |
299 { | 299 { |
300 if (!inActiveDocumentContext() || m_nonCSSConnectedFaces.isEmpty()) | 300 if (!inActiveDocumentContext() || m_nonCSSConnectedFaces.isEmpty()) |
301 return; | 301 return; |
302 CSSFontSelector* fontSelector = document()->styleEngine()->fontSelector(); | 302 CSSFontSelector* fontSelector = document()->styleEngine()->fontSelector(); |
303 FontFaceCache* fontFaceCache = fontSelector->fontFaceCache(); | 303 FontFaceCache* fontFaceCache = fontSelector->fontFaceCache(); |
304 for (WillBeHeapListHashSet<RefPtrWillBeMember<FontFace> >::iterator it = m_n
onCSSConnectedFaces.begin(); it != m_nonCSSConnectedFaces.end(); ++it) { | 304 for (const auto& fontFace : m_nonCSSConnectedFaces) { |
305 fontFaceCache->removeFontFace(it->get(), false); | 305 fontFaceCache->removeFontFace(fontFace.get(), false); |
306 if ((*it)->loadStatus() == FontFace::Loading) | 306 if (fontFace->loadStatus() == FontFace::Loading) |
307 removeFromLoadingFonts(*it); | 307 removeFromLoadingFonts(fontFace); |
308 } | 308 } |
309 m_nonCSSConnectedFaces.clear(); | 309 m_nonCSSConnectedFaces.clear(); |
310 fontSelector->fontFaceInvalidated(); | 310 fontSelector->fontFaceInvalidated(); |
311 } | 311 } |
312 | 312 |
313 bool FontFaceSet::remove(FontFace* fontFace, ExceptionState& exceptionState) | 313 bool FontFaceSet::remove(FontFace* fontFace, ExceptionState& exceptionState) |
314 { | 314 { |
315 if (!inActiveDocumentContext()) | 315 if (!inActiveDocumentContext()) |
316 return false; | 316 return false; |
317 if (!fontFace) { | 317 if (!fontFace) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 forEachInternal(callback, 0); | 366 forEachInternal(callback, 0); |
367 } | 367 } |
368 | 368 |
369 void FontFaceSet::forEachInternal(FontFaceSetForEachCallback* callback, const Sc
riptValue* thisArg) const | 369 void FontFaceSet::forEachInternal(FontFaceSetForEachCallback* callback, const Sc
riptValue* thisArg) const |
370 { | 370 { |
371 if (!inActiveDocumentContext()) | 371 if (!inActiveDocumentContext()) |
372 return; | 372 return; |
373 const WillBeHeapListHashSet<RefPtrWillBeMember<FontFace> >& cssConnectedFace
s = cssConnectedFontFaceList(); | 373 const WillBeHeapListHashSet<RefPtrWillBeMember<FontFace> >& cssConnectedFace
s = cssConnectedFontFaceList(); |
374 WillBeHeapVector<RefPtrWillBeMember<FontFace> > fontFaces; | 374 WillBeHeapVector<RefPtrWillBeMember<FontFace> > fontFaces; |
375 fontFaces.reserveInitialCapacity(cssConnectedFaces.size() + m_nonCSSConnecte
dFaces.size()); | 375 fontFaces.reserveInitialCapacity(cssConnectedFaces.size() + m_nonCSSConnecte
dFaces.size()); |
376 for (WillBeHeapListHashSet<RefPtrWillBeMember<FontFace> >::const_iterator it
= cssConnectedFaces.begin(); it != cssConnectedFaces.end(); ++it) | 376 for (const auto& fontFace : cssConnectedFaces) |
377 fontFaces.append(*it); | 377 fontFaces.append(fontFace); |
378 for (WillBeHeapListHashSet<RefPtrWillBeMember<FontFace> >::const_iterator it
= m_nonCSSConnectedFaces.begin(); it != m_nonCSSConnectedFaces.end(); ++it) | 378 for (const auto& fontFace : m_nonCSSConnectedFaces) |
379 fontFaces.append(*it); | 379 fontFaces.append(fontFace); |
380 | 380 |
381 for (size_t i = 0; i < fontFaces.size(); ++i) { | 381 for (size_t i = 0; i < fontFaces.size(); ++i) { |
382 FontFace* face = fontFaces[i].get(); | 382 FontFace* face = fontFaces[i].get(); |
383 if (thisArg) | 383 if (thisArg) |
384 callback->handleItem(*thisArg, face, face, const_cast<FontFaceSet*>(
this)); | 384 callback->handleItem(*thisArg, face, face, const_cast<FontFaceSet*>(
this)); |
385 else | 385 else |
386 callback->handleItem(face, face, const_cast<FontFaceSet*>(this)); | 386 callback->handleItem(face, face, const_cast<FontFaceSet*>(this)); |
387 } | 387 } |
388 } | 388 } |
389 | 389 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 visitor->trace(m_loadingFonts); | 586 visitor->trace(m_loadingFonts); |
587 visitor->trace(m_loadedFonts); | 587 visitor->trace(m_loadedFonts); |
588 visitor->trace(m_failedFonts); | 588 visitor->trace(m_failedFonts); |
589 visitor->trace(m_nonCSSConnectedFaces); | 589 visitor->trace(m_nonCSSConnectedFaces); |
590 DocumentSupplement::trace(visitor); | 590 DocumentSupplement::trace(visitor); |
591 EventTargetWithInlineData::trace(visitor); | 591 EventTargetWithInlineData::trace(visitor); |
592 } | 592 } |
593 #endif | 593 #endif |
594 | 594 |
595 } // namespace blink | 595 } // namespace blink |
OLD | NEW |