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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } | 383 } |
384 | 384 |
385 void FontFace::load(ExecutionContext* context) | 385 ScriptPromise FontFace::load(ExecutionContext* context) |
386 { | |
387 if (m_status != Unloaded) | |
388 return; | |
389 | |
390 FontDescription fontDescription; | |
391 FontFamily fontFamily; | |
392 fontFamily.setFamily(m_family); | |
393 fontDescription.setFamily(fontFamily); | |
394 fontDescription.setTraits(traits()); | |
395 | |
396 CSSFontSelector* fontSelector = toDocument(context)->styleEngine()->fontSele
ctor(); | |
397 m_cssFontFace->load(fontDescription, fontSelector); | |
398 fontSelector->loadPendingFonts(); | |
399 } | |
400 | |
401 ScriptPromise FontFace::ready(ExecutionContext* context) | |
402 { | 386 { |
403 OwnPtr<FontFaceReadyPromiseResolver> resolver = FontFaceReadyPromiseResolver
::create(context); | 387 OwnPtr<FontFaceReadyPromiseResolver> resolver = FontFaceReadyPromiseResolver
::create(context); |
404 ScriptPromise promise = resolver->promise(); | 388 ScriptPromise promise = resolver->promise(); |
405 if (m_status == Loaded || m_status == Error) | 389 if (m_status == Loaded || m_status == Error) |
406 resolver->resolve(this); | 390 resolver->resolve(this); |
407 else | 391 else |
408 m_readyResolvers.append(resolver.release()); | 392 m_readyResolvers.append(resolver.release()); |
| 393 |
| 394 if (m_status == Unloaded) { |
| 395 FontDescription fontDescription; |
| 396 FontFamily fontFamily; |
| 397 fontFamily.setFamily(m_family); |
| 398 fontDescription.setFamily(fontFamily); |
| 399 fontDescription.setTraits(traits()); |
| 400 |
| 401 CSSFontSelector* fontSelector = toDocument(context)->styleEngine()->font
Selector(); |
| 402 m_cssFontFace->load(fontDescription, fontSelector); |
| 403 fontSelector->loadPendingFonts(); |
| 404 } |
409 return promise; | 405 return promise; |
410 } | 406 } |
411 | 407 |
412 void FontFace::resolveReadyPromises() | 408 void FontFace::resolveReadyPromises() |
413 { | 409 { |
414 for (size_t i = 0; i < m_readyResolvers.size(); i++) | 410 for (size_t i = 0; i < m_readyResolvers.size(); i++) |
415 m_readyResolvers[i]->resolve(this); | 411 m_readyResolvers[i]->resolve(this); |
416 m_readyResolvers.clear(); | 412 m_readyResolvers.clear(); |
417 } | 413 } |
418 | 414 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 visitor->trace(m_featureSettings); | 597 visitor->trace(m_featureSettings); |
602 visitor->trace(m_error); | 598 visitor->trace(m_error); |
603 } | 599 } |
604 | 600 |
605 bool FontFace::hadBlankText() const | 601 bool FontFace::hadBlankText() const |
606 { | 602 { |
607 return m_cssFontFace->hadBlankText(); | 603 return m_cssFontFace->hadBlankText(); |
608 } | 604 } |
609 | 605 |
610 } // namespace WebCore | 606 } // namespace WebCore |
OLD | NEW |