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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 this, LoadedProperty::Loaded); | 381 this, LoadedProperty::Loaded); |
382 if (m_status == Loaded) | 382 if (m_status == Loaded) |
383 m_loadedProperty->resolve(this); | 383 m_loadedProperty->resolve(this); |
384 else if (m_status == Error) | 384 else if (m_status == Error) |
385 m_loadedProperty->reject(m_error.get()); | 385 m_loadedProperty->reject(m_error.get()); |
386 } | 386 } |
387 return m_loadedProperty->promise(scriptState->world()); | 387 return m_loadedProperty->promise(scriptState->world()); |
388 } | 388 } |
389 | 389 |
390 ScriptPromise FontFace::load(ScriptState* scriptState) { | 390 ScriptPromise FontFace::load(ScriptState* scriptState) { |
391 loadInternal(scriptState->getExecutionContext()); | 391 if (m_status == Unloaded) |
| 392 m_cssFontFace->load(); |
392 return fontStatusPromise(scriptState); | 393 return fontStatusPromise(scriptState); |
393 } | 394 } |
394 | 395 |
395 void FontFace::loadWithCallback(LoadFontCallback* callback, | 396 void FontFace::loadWithCallback(LoadFontCallback* callback) { |
396 ExecutionContext* context) { | 397 if (m_status == Unloaded) |
397 loadInternal(context); | 398 m_cssFontFace->load(); |
398 addCallback(callback); | 399 addCallback(callback); |
399 } | 400 } |
400 | 401 |
401 void FontFace::addCallback(LoadFontCallback* callback) { | 402 void FontFace::addCallback(LoadFontCallback* callback) { |
402 if (m_status == Loaded) | 403 if (m_status == Loaded) |
403 callback->notifyLoaded(this); | 404 callback->notifyLoaded(this); |
404 else if (m_status == Error) | 405 else if (m_status == Error) |
405 callback->notifyError(this); | 406 callback->notifyError(this); |
406 else | 407 else |
407 m_callbacks.push_back(callback); | 408 m_callbacks.push_back(callback); |
408 } | 409 } |
409 | 410 |
410 void FontFace::loadInternal(ExecutionContext* context) { | |
411 if (m_status != Unloaded) | |
412 return; | |
413 | |
414 m_cssFontFace->load(); | |
415 } | |
416 | |
417 FontTraits FontFace::traits() const { | 411 FontTraits FontFace::traits() const { |
418 FontStretch stretch = FontStretchNormal; | 412 FontStretch stretch = FontStretchNormal; |
419 if (m_stretch) { | 413 if (m_stretch) { |
420 if (!m_stretch->isIdentifierValue()) | 414 if (!m_stretch->isIdentifierValue()) |
421 return 0; | 415 return 0; |
422 | 416 |
423 switch (toCSSIdentifierValue(m_stretch.get())->getValueID()) { | 417 switch (toCSSIdentifierValue(m_stretch.get())->getValueID()) { |
424 case CSSValueUltraCondensed: | 418 case CSSValueUltraCondensed: |
425 stretch = FontStretchUltraCondensed; | 419 stretch = FontStretchUltraCondensed; |
426 break; | 420 break; |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 | 634 |
641 bool FontFace::hadBlankText() const { | 635 bool FontFace::hadBlankText() const { |
642 return m_cssFontFace->hadBlankText(); | 636 return m_cssFontFace->hadBlankText(); |
643 } | 637 } |
644 | 638 |
645 bool FontFace::hasPendingActivity() const { | 639 bool FontFace::hasPendingActivity() const { |
646 return m_status == Loading && getExecutionContext(); | 640 return m_status == Loading && getExecutionContext(); |
647 } | 641 } |
648 | 642 |
649 } // namespace blink | 643 } // namespace blink |
OLD | NEW |