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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 break; | 526 break; |
527 default: | 527 default: |
528 break; | 528 break; |
529 } | 529 } |
530 } | 530 } |
531 } | 531 } |
532 | 532 |
533 return FontTraits(style, variant, weight, stretch); | 533 return FontTraits(style, variant, weight, stretch); |
534 } | 534 } |
535 | 535 |
| 536 bool FontFace::isBlank() const |
| 537 { |
| 538 return m_status == Loading && m_charCount > 200 && m_cssFontFace->isBlank(); |
| 539 } |
| 540 |
536 static FontDisplay CSSValueToFontDisplay(CSSValue* value) | 541 static FontDisplay CSSValueToFontDisplay(CSSValue* value) |
537 { | 542 { |
538 if (value && value->isPrimitiveValue()) { | 543 if (value && value->isPrimitiveValue()) { |
539 switch (toCSSPrimitiveValue(value)->getValueID()) { | 544 switch (toCSSPrimitiveValue(value)->getValueID()) { |
540 case CSSValueAuto: | 545 case CSSValueAuto: |
541 return FontDisplayAuto; | 546 return FontDisplayAuto; |
542 case CSSValueBlock: | 547 case CSSValueBlock: |
543 return FontDisplayBlock; | 548 return FontDisplayBlock; |
544 case CSSValueSwap: | 549 case CSSValueSwap: |
545 return FontDisplaySwap; | 550 return FontDisplaySwap; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 | 622 |
618 RefPtr<SharedBuffer> buffer = SharedBuffer::create(data, size); | 623 RefPtr<SharedBuffer> buffer = SharedBuffer::create(data, size); |
619 BinaryDataFontFaceSource* source = new BinaryDataFontFaceSource(buffer.get()
, m_otsParseMessage); | 624 BinaryDataFontFaceSource* source = new BinaryDataFontFaceSource(buffer.get()
, m_otsParseMessage); |
620 if (source->isValid()) | 625 if (source->isValid()) |
621 setLoadStatus(Loaded); | 626 setLoadStatus(Loaded); |
622 else | 627 else |
623 setError(DOMException::create(SyntaxError, "Invalid font data in ArrayBu
ffer.")); | 628 setError(DOMException::create(SyntaxError, "Invalid font data in ArrayBu
ffer.")); |
624 m_cssFontFace->addSource(source); | 629 m_cssFontFace->addSource(source); |
625 } | 630 } |
626 | 631 |
| 632 bool FontFace::willUseFontData(const FontDescription& fontDescription, const Str
ing& text) |
| 633 { |
| 634 if (m_status != Loaded) { |
| 635 m_charCount += text.length(); |
| 636 // if (m_cssFontFace->isBlank()) |
| 637 // fprintf(stderr, "%s %u %u\n", m_family.getString().ascii().data()
, length, m_charCount); |
| 638 } |
| 639 if (loadStatus() != Unloaded) |
| 640 return true; |
| 641 if (cssFontFace()->maybeScheduleFontLoad(fontDescription, text.characterStar
tingAt(0))) { |
| 642 return true; |
| 643 } |
| 644 return false; |
| 645 } |
| 646 |
627 DEFINE_TRACE(FontFace) | 647 DEFINE_TRACE(FontFace) |
628 { | 648 { |
629 visitor->trace(m_style); | 649 visitor->trace(m_style); |
630 visitor->trace(m_weight); | 650 visitor->trace(m_weight); |
631 visitor->trace(m_stretch); | 651 visitor->trace(m_stretch); |
632 visitor->trace(m_unicodeRange); | 652 visitor->trace(m_unicodeRange); |
633 visitor->trace(m_variant); | 653 visitor->trace(m_variant); |
634 visitor->trace(m_featureSettings); | 654 visitor->trace(m_featureSettings); |
635 visitor->trace(m_display); | 655 visitor->trace(m_display); |
636 visitor->trace(m_error); | 656 visitor->trace(m_error); |
637 visitor->trace(m_loadedProperty); | 657 visitor->trace(m_loadedProperty); |
638 visitor->trace(m_cssFontFace); | 658 visitor->trace(m_cssFontFace); |
639 visitor->trace(m_callbacks); | 659 visitor->trace(m_callbacks); |
640 ActiveDOMObject::trace(visitor); | 660 ActiveDOMObject::trace(visitor); |
641 } | 661 } |
642 | 662 |
643 bool FontFace::hadBlankText() const | 663 bool FontFace::hadBlankText() const |
644 { | 664 { |
645 return m_cssFontFace->hadBlankText(); | 665 return m_cssFontFace->hadBlankText(); |
646 } | 666 } |
647 | 667 |
648 bool FontFace::hasPendingActivity() const | 668 bool FontFace::hasPendingActivity() const |
649 { | 669 { |
650 return m_status == Loading && getExecutionContext() && !getExecutionContext(
)->activeDOMObjectsAreStopped(); | 670 return m_status == Loading && getExecutionContext() && !getExecutionContext(
)->activeDOMObjectsAreStopped(); |
651 } | 671 } |
652 | 672 |
653 } // namespace blink | 673 } // namespace blink |
OLD | NEW |