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 | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
371 ASSERT_NOT_REACHED(); | 371 ASSERT_NOT_REACHED(); |
372 } | 372 } |
373 return emptyString(); | 373 return emptyString(); |
374 } | 374 } |
375 | 375 |
376 void FontFace::setLoadStatus(LoadStatus status) | 376 void FontFace::setLoadStatus(LoadStatus status) |
377 { | 377 { |
378 m_status = status; | 378 m_status = status; |
379 if (m_status == Error) | 379 if (m_status == Error) |
380 m_error = DOMError::create(NetworkError); | 380 m_error = DOMError::create(NetworkError); |
381 if (m_status == Loaded || m_status == Error) | 381 if (m_status == Loaded || m_status == Error) { |
382 resolveReadyPromises(); | 382 resolveReadyPromises(); |
383 | |
384 Vector<RefPtr<LoadFontCallback> > callbacks; | |
385 m_callbacks.swap(callbacks); | |
386 for (size_t i = 0; i < callbacks.size(); ++i) { | |
387 if (m_status == Loaded) | |
388 callbacks[i]->notifyLoaded(this); | |
389 else | |
390 callbacks[i]->notifyError(this); | |
391 } | |
392 } | |
383 } | 393 } |
384 | 394 |
385 ScriptPromise FontFace::load(ExecutionContext* context) | 395 ScriptPromise FontFace::load(ExecutionContext* context) |
dglazkov
2014/03/19 15:42:34
This is the actual Promise FontFace.load. Maybe it
Kunihiko Sakamoto
2014/03/20 01:06:32
This is a method of the FontFace interface, so it'
| |
386 { | 396 { |
387 OwnPtr<FontFaceReadyPromiseResolver> resolver = FontFaceReadyPromiseResolver ::create(context); | 397 OwnPtr<FontFaceReadyPromiseResolver> resolver = FontFaceReadyPromiseResolver ::create(context); |
388 ScriptPromise promise = resolver->promise(); | 398 ScriptPromise promise = resolver->promise(); |
389 if (m_status == Loaded || m_status == Error) | 399 if (m_status == Loaded || m_status == Error) |
390 resolver->resolve(this); | 400 resolver->resolve(this); |
391 else | 401 else |
392 m_readyResolvers.append(resolver.release()); | 402 m_readyResolvers.append(resolver.release()); |
393 | 403 |
394 if (m_status == Unloaded) { | 404 loadInternal(context); |
395 FontDescription fontDescription; | 405 return promise; |
396 FontFamily fontFamily; | 406 } |
397 fontFamily.setFamily(m_family); | |
398 fontDescription.setFamily(fontFamily); | |
399 fontDescription.setTraits(traits()); | |
400 | 407 |
401 CSSFontSelector* fontSelector = toDocument(context)->styleEngine()->font Selector(); | 408 void FontFace::load(PassRefPtr<LoadFontCallback> callback, ExecutionContext* con text) |
402 m_cssFontFace->load(fontDescription, fontSelector); | 409 { |
403 fontSelector->loadPendingFonts(); | 410 loadInternal(context); |
404 } | 411 if (m_status == Loaded) |
405 return promise; | 412 callback->notifyLoaded(this); |
413 else if (m_status == Error) | |
414 callback->notifyError(this); | |
415 else | |
416 m_callbacks.append(callback); | |
417 } | |
418 | |
419 void FontFace::loadInternal(ExecutionContext* context) | |
dglazkov
2014/03/19 15:42:34
This is the actual "load"
| |
420 { | |
421 if (m_status != Unloaded) | |
422 return; | |
423 | |
424 FontDescription fontDescription; | |
425 FontFamily fontFamily; | |
426 fontFamily.setFamily(m_family); | |
427 fontDescription.setFamily(fontFamily); | |
428 fontDescription.setTraits(traits()); | |
429 | |
430 CSSFontSelector* fontSelector = toDocument(context)->styleEngine()->fontSele ctor(); | |
431 m_cssFontFace->load(fontDescription, fontSelector); | |
432 fontSelector->loadPendingFonts(); | |
406 } | 433 } |
407 | 434 |
408 void FontFace::resolveReadyPromises() | 435 void FontFace::resolveReadyPromises() |
409 { | 436 { |
410 for (size_t i = 0; i < m_readyResolvers.size(); i++) | 437 for (size_t i = 0; i < m_readyResolvers.size(); i++) |
411 m_readyResolvers[i]->resolve(this); | 438 m_readyResolvers[i]->resolve(this); |
412 m_readyResolvers.clear(); | 439 m_readyResolvers.clear(); |
413 } | 440 } |
414 | 441 |
415 FontTraits FontFace::traits() const | 442 FontTraits FontFace::traits() const |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
597 visitor->trace(m_featureSettings); | 624 visitor->trace(m_featureSettings); |
598 visitor->trace(m_error); | 625 visitor->trace(m_error); |
599 } | 626 } |
600 | 627 |
601 bool FontFace::hadBlankText() const | 628 bool FontFace::hadBlankText() const |
602 { | 629 { |
603 return m_cssFontFace->hadBlankText(); | 630 return m_cssFontFace->hadBlankText(); |
604 } | 631 } |
605 | 632 |
606 } // namespace WebCore | 633 } // namespace WebCore |
OLD | NEW |