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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 if (fontFace->loadStatus() == FontFace::Loading) | 310 if (fontFace->loadStatus() == FontFace::Loading) |
311 removeFromLoadingFonts(fontFace); | 311 removeFromLoadingFonts(fontFace); |
312 fontSelector->fontFaceInvalidated(); | 312 fontSelector->fontFaceInvalidated(); |
313 return true; | 313 return true; |
314 } | 314 } |
315 if (isCSSConnectedFontFace(fontFace)) | 315 if (isCSSConnectedFontFace(fontFace)) |
316 exceptionState.throwDOMException(InvalidModificationError, "Cannot delet e a CSS-connected FontFace."); | 316 exceptionState.throwDOMException(InvalidModificationError, "Cannot delet e a CSS-connected FontFace."); |
317 return false; | 317 return false; |
318 } | 318 } |
319 | 319 |
320 bool FontFaceSet::has(FontFace* fontFace, ExceptionState& exceptionState) const | 320 bool FontFaceSet::hasForBinding(ScriptState*, const PassRefPtrWillBeRawPtr<FontF ace>& fontFace, ExceptionState& exceptionState) const |
321 { | 321 { |
322 if (!inActiveDocumentContext()) | 322 if (!inActiveDocumentContext()) |
323 return false; | 323 return false; |
324 if (!fontFace) { | 324 if (!fontFace) { |
325 exceptionState.throwTypeError("The argument is not a FontFace."); | 325 exceptionState.throwTypeError("The argument is not a FontFace."); |
326 return false; | 326 return false; |
327 } | 327 } |
328 return m_nonCSSConnectedFaces.contains(fontFace) || isCSSConnectedFontFace(f ontFace); | 328 return m_nonCSSConnectedFaces.contains(fontFace.get()) || isCSSConnectedFont Face(fontFace.get()); |
329 } | 329 } |
330 | 330 |
331 const WillBeHeapListHashSet<RefPtrWillBeMember<FontFace>>& FontFaceSet::cssConne ctedFontFaceList() const | 331 const WillBeHeapListHashSet<RefPtrWillBeMember<FontFace>>& FontFaceSet::cssConne ctedFontFaceList() const |
332 { | 332 { |
333 Document* d = document(); | 333 Document* d = document(); |
334 d->ensureStyleResolver(); // Flush pending style changes. | 334 d->ensureStyleResolver(); // Flush pending style changes. |
335 return d->styleEngine().fontSelector()->fontFaceCache()->cssConnectedFontFac es(); | 335 return d->styleEngine().fontSelector()->fontFaceCache()->cssConnectedFontFac es(); |
336 } | 336 } |
337 | 337 |
338 bool FontFaceSet::isCSSConnectedFontFace(FontFace* fontFace) const | 338 bool FontFaceSet::isCSSConnectedFontFace(FontFace* fontFace) const |
339 { | 339 { |
340 return cssConnectedFontFaceList().contains(fontFace); | 340 return cssConnectedFontFaceList().contains(fontFace); |
341 } | 341 } |
342 | 342 |
343 void FontFaceSet::forEach(FontFaceSetForEachCallback* callback, const ScriptValu e& thisArg) const | 343 size_t FontFaceSet::size() const |
344 { | |
345 forEachInternal(callback, &thisArg); | |
346 } | |
347 | |
348 void FontFaceSet::forEach(FontFaceSetForEachCallback* callback) const | |
349 { | |
350 forEachInternal(callback, 0); | |
351 } | |
352 | |
353 void FontFaceSet::forEachInternal(FontFaceSetForEachCallback* callback, const Sc riptValue* thisArg) const | |
354 { | |
355 if (!inActiveDocumentContext()) | |
356 return; | |
357 const WillBeHeapListHashSet<RefPtrWillBeMember<FontFace>>& cssConnectedFaces = cssConnectedFontFaceList(); | |
358 WillBeHeapVector<RefPtrWillBeMember<FontFace>> fontFaces; | |
359 fontFaces.reserveInitialCapacity(cssConnectedFaces.size() + m_nonCSSConnecte dFaces.size()); | |
360 for (const auto& fontFace : cssConnectedFaces) | |
361 fontFaces.append(fontFace); | |
362 for (const auto& fontFace : m_nonCSSConnectedFaces) | |
363 fontFaces.append(fontFace); | |
364 | |
365 for (size_t i = 0; i < fontFaces.size(); ++i) { | |
366 FontFace* face = fontFaces[i].get(); | |
367 if (thisArg) | |
368 callback->handleItem(*thisArg, face, face, const_cast<FontFaceSet*>( this)); | |
369 else | |
370 callback->handleItem(face, face, const_cast<FontFaceSet*>(this)); | |
371 } | |
372 } | |
373 | |
374 unsigned long FontFaceSet::size() const | |
375 { | 344 { |
376 if (!inActiveDocumentContext()) | 345 if (!inActiveDocumentContext()) |
377 return m_nonCSSConnectedFaces.size(); | 346 return m_nonCSSConnectedFaces.size(); |
378 return cssConnectedFontFaceList().size() + m_nonCSSConnectedFaces.size(); | 347 return cssConnectedFontFaceList().size() + m_nonCSSConnectedFaces.size(); |
379 } | 348 } |
380 | 349 |
381 void FontFaceSet::fireDoneEventIfPossible() | 350 void FontFaceSet::fireDoneEventIfPossible() |
382 { | 351 { |
383 if (m_shouldFireLoadingEvent) | 352 if (m_shouldFireLoadingEvent) |
384 return; | 353 return; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
543 | 512 |
544 return fonts.release(); | 513 return fonts.release(); |
545 } | 514 } |
546 | 515 |
547 void FontFaceSet::didLayout(Document& document) | 516 void FontFaceSet::didLayout(Document& document) |
548 { | 517 { |
549 if (FontFaceSet* fonts = static_cast<FontFaceSet*>(SupplementType::from(docu ment, supplementName()))) | 518 if (FontFaceSet* fonts = static_cast<FontFaceSet*>(SupplementType::from(docu ment, supplementName()))) |
550 fonts->didLayout(); | 519 fonts->didLayout(); |
551 } | 520 } |
552 | 521 |
522 FontFaceSetIterable::IterationSource* FontFaceSet::startIteration(ScriptState*, ExceptionState&) | |
523 { | |
524 // Setlike should iterate each item in insertion order, and items should | |
525 // be keep on up to date. But since blink does not have a way to hook up CSS | |
526 // modification, take a snapshot here, and make it ordered as follows. | |
527 WillBeHeapVector<RefPtrWillBeMember<FontFace>> fontFaces; | |
528 if (inActiveDocumentContext()) { | |
529 const WillBeHeapListHashSet<RefPtrWillBeMember<FontFace>>& cssConnectedF aces = cssConnectedFontFaceList(); | |
530 fontFaces.reserveInitialCapacity(cssConnectedFaces.size() + m_nonCSSConn ectedFaces.size()); | |
531 for (const auto& fontFace : cssConnectedFaces) | |
532 fontFaces.append(fontFace); | |
533 for (const auto& fontFace : m_nonCSSConnectedFaces) | |
534 fontFaces.append(fontFace); | |
535 } | |
536 return new IterationSource(fontFaces); | |
537 } | |
538 | |
539 bool FontFaceSet::IterationSource::next(ScriptState* scriptState, RefPtrWillBeMe mber<FontFace>& key, RefPtrWillBeMember<FontFace>& value, ExceptionState& except ionState) | |
Kunihiko Sakamoto
2015/10/16 09:50:07
nit: omit unused parameter names
Takashi Toyoshima
2015/10/16 10:07:03
Done.
| |
540 { | |
541 if (m_fontFaces.size() <= m_index) | |
542 return false; | |
543 key = value = m_fontFaces[m_index++]; | |
544 return true; | |
545 } | |
546 | |
553 DEFINE_TRACE(FontFaceSet) | 547 DEFINE_TRACE(FontFaceSet) |
554 { | 548 { |
555 #if ENABLE(OILPAN) | 549 #if ENABLE(OILPAN) |
556 visitor->trace(m_ready); | 550 visitor->trace(m_ready); |
557 visitor->trace(m_loadingFonts); | 551 visitor->trace(m_loadingFonts); |
558 visitor->trace(m_loadedFonts); | 552 visitor->trace(m_loadedFonts); |
559 visitor->trace(m_failedFonts); | 553 visitor->trace(m_failedFonts); |
560 visitor->trace(m_nonCSSConnectedFaces); | 554 visitor->trace(m_nonCSSConnectedFaces); |
561 HeapSupplement<Document>::trace(visitor); | 555 HeapSupplement<Document>::trace(visitor); |
562 #endif | 556 #endif |
563 EventTargetWithInlineData::trace(visitor); | 557 EventTargetWithInlineData::trace(visitor); |
564 ActiveDOMObject::trace(visitor); | 558 ActiveDOMObject::trace(visitor); |
565 } | 559 } |
566 | 560 |
567 } // namespace blink | 561 } // namespace blink |
OLD | NEW |