| 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 case Error: | 359 case Error: |
| 360 return "error"; | 360 return "error"; |
| 361 default: | 361 default: |
| 362 NOTREACHED(); | 362 NOTREACHED(); |
| 363 } | 363 } |
| 364 return emptyString; | 364 return emptyString; |
| 365 } | 365 } |
| 366 | 366 |
| 367 void FontFace::setLoadStatus(LoadStatusType status) { | 367 void FontFace::setLoadStatus(LoadStatusType status) { |
| 368 m_status = status; | 368 m_status = status; |
| 369 ASSERT(m_status != Error || m_error); | 369 DCHECK(m_status != Error || m_error); |
| 370 | 370 |
| 371 // When promises are resolved with 'thenables', instead of the object being | 371 // When promises are resolved with 'thenables', instead of the object being |
| 372 // returned directly, the 'then' method is executed (the resolver tries to | 372 // returned directly, the 'then' method is executed (the resolver tries to |
| 373 // resolve the thenable). This can lead to synchronous script execution, so we | 373 // resolve the thenable). This can lead to synchronous script execution, so we |
| 374 // post a task. This does not apply to promise rejection (i.e. a thenable | 374 // post a task. This does not apply to promise rejection (i.e. a thenable |
| 375 // would be returned as is). | 375 // would be returned as is). |
| 376 if (m_status == Loaded || m_status == Error) { | 376 if (m_status == Loaded || m_status == Error) { |
| 377 if (m_loadedProperty) { | 377 if (m_loadedProperty) { |
| 378 if (m_status == Loaded) { | 378 if (m_status == Loaded) { |
| 379 getTaskRunner()->postTask( | 379 getTaskRunner()->postTask( |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 case CSSValue100: | 536 case CSSValue100: |
| 537 weight = FontWeight100; | 537 weight = FontWeight100; |
| 538 break; | 538 break; |
| 539 // Although 'lighter' and 'bolder' are valid keywords for font-weights, | 539 // Although 'lighter' and 'bolder' are valid keywords for font-weights, |
| 540 // they are invalid inside font-face rules so they are ignored. Reference: | 540 // they are invalid inside font-face rules so they are ignored. Reference: |
| 541 // http://www.w3.org/TR/css3-fonts/#descdef-font-weight. | 541 // http://www.w3.org/TR/css3-fonts/#descdef-font-weight. |
| 542 case CSSValueLighter: | 542 case CSSValueLighter: |
| 543 case CSSValueBolder: | 543 case CSSValueBolder: |
| 544 break; | 544 break; |
| 545 default: | 545 default: |
| 546 ASSERT_NOT_REACHED(); | 546 NOTREACHED(); |
| 547 break; | 547 break; |
| 548 } | 548 } |
| 549 } | 549 } |
| 550 | 550 |
| 551 return FontTraits(style, weight, stretch); | 551 return FontTraits(style, weight, stretch); |
| 552 } | 552 } |
| 553 | 553 |
| 554 size_t FontFace::approximateBlankCharacterCount() const { | 554 size_t FontFace::approximateBlankCharacterCount() const { |
| 555 if (m_status == Loading) | 555 if (m_status == Loading) |
| 556 return m_cssFontFace->approximateBlankCharacterCount(); | 556 return m_cssFontFace->approximateBlankCharacterCount(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 return new CSSFontFace(fontFace, ranges); | 592 return new CSSFontFace(fontFace, ranges); |
| 593 } | 593 } |
| 594 | 594 |
| 595 void FontFace::initCSSFontFace(Document* document, const CSSValue* src) { | 595 void FontFace::initCSSFontFace(Document* document, const CSSValue* src) { |
| 596 m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get()); | 596 m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get()); |
| 597 if (m_error) | 597 if (m_error) |
| 598 return; | 598 return; |
| 599 | 599 |
| 600 // Each item in the src property's list is a single CSSFontFaceSource. Put | 600 // Each item in the src property's list is a single CSSFontFaceSource. Put |
| 601 // them all into a CSSFontFace. | 601 // them all into a CSSFontFace. |
| 602 ASSERT(src); | 602 DCHECK(src); |
| 603 ASSERT(src->isValueList()); | 603 DCHECK(src->isValueList()); |
| 604 const CSSValueList* srcList = toCSSValueList(src); | 604 const CSSValueList* srcList = toCSSValueList(src); |
| 605 int srcLength = srcList->length(); | 605 int srcLength = srcList->length(); |
| 606 | 606 |
| 607 for (int i = 0; i < srcLength; i++) { | 607 for (int i = 0; i < srcLength; i++) { |
| 608 // An item in the list either specifies a string (local font name) or a URL | 608 // An item in the list either specifies a string (local font name) or a URL |
| 609 // (remote font to download). | 609 // (remote font to download). |
| 610 const CSSFontFaceSrcValue& item = toCSSFontFaceSrcValue(srcList->item(i)); | 610 const CSSFontFaceSrcValue& item = toCSSFontFaceSrcValue(srcList->item(i)); |
| 611 CSSFontFaceSource* source = nullptr; | 611 CSSFontFaceSource* source = nullptr; |
| 612 | 612 |
| 613 if (!item.isLocal()) { | 613 if (!item.isLocal()) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 | 671 |
| 672 bool FontFace::hadBlankText() const { | 672 bool FontFace::hadBlankText() const { |
| 673 return m_cssFontFace->hadBlankText(); | 673 return m_cssFontFace->hadBlankText(); |
| 674 } | 674 } |
| 675 | 675 |
| 676 bool FontFace::hasPendingActivity() const { | 676 bool FontFace::hasPendingActivity() const { |
| 677 return m_status == Loading && getExecutionContext(); | 677 return m_status == Loading && getExecutionContext(); |
| 678 } | 678 } |
| 679 | 679 |
| 680 } // namespace blink | 680 } // namespace blink |
| OLD | NEW |