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 met: | 5 * modification, are permitted provided that the following conditions are met: |
6 * | 6 * |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
472 { | 472 { |
473 if (!inActiveDocumentContext()) | 473 if (!inActiveDocumentContext()) |
474 return false; | 474 return false; |
475 | 475 |
476 Font font; | 476 Font font; |
477 if (!resolveFontStyle(fontString, font)) { | 477 if (!resolveFontStyle(fontString, font)) { |
478 exceptionState.throwDOMException(SyntaxError, "Could not resolve '" + fo ntString + "' as a font."); | 478 exceptionState.throwDOMException(SyntaxError, "Could not resolve '" + fo ntString + "' as a font."); |
479 return false; | 479 return false; |
480 } | 480 } |
481 | 481 |
482 FontFaceCache* fontFaceCache = document()->styleEngine()->fontSelector()->fo ntFaceCache(); | 482 CSSFontSelector* fontSelector = document()->styleEngine()->fontSelector(); |
483 FontFaceCache* fontFaceCache = fontSelector->fontFaceCache(); | |
484 | |
485 bool hasLoadedFaces = false; | |
483 for (const FontFamily* f = &font.fontDescription().family(); f; f = f->next( )) { | 486 for (const FontFamily* f = &font.fontDescription().family(); f; f = f->next( )) { |
484 CSSSegmentedFontFace* face = fontFaceCache->get(font.fontDescription(), f->family()); | 487 CSSSegmentedFontFace* face = fontFaceCache->get(font.fontDescription(), f->family()); |
485 if (face && !face->checkFont(nullToSpace(text))) | 488 if (face) { |
486 return false; | 489 if (!face->checkFont(nullToSpace(text))) |
490 return false; | |
491 hasLoadedFaces = true; | |
492 } | |
bashi
2014/06/13 06:55:15
Question: If face is null, it seems that we assume
| |
487 } | 493 } |
488 return true; | 494 if (hasLoadedFaces) |
495 return true; | |
496 for (const FontFamily* f = &font.fontDescription().family(); f; f = f->next( )) { | |
497 if (fontSelector->isPlatformFontAvailable(font.fontDescription(), f->fam ily())) | |
498 return true; | |
499 } | |
500 return false; | |
489 } | 501 } |
490 | 502 |
491 bool FontFaceSet::resolveFontStyle(const String& fontString, Font& font) | 503 bool FontFaceSet::resolveFontStyle(const String& fontString, Font& font) |
492 { | 504 { |
493 if (fontString.isEmpty()) | 505 if (fontString.isEmpty()) |
494 return false; | 506 return false; |
495 | 507 |
496 // Interpret fontString in the same way as the 'font' attribute of CanvasRen deringContext2D. | 508 // Interpret fontString in the same way as the 'font' attribute of CanvasRen deringContext2D. |
497 RefPtrWillBeRawPtr<MutableStylePropertySet> parsedStyle = MutableStyleProper tySet::create(); | 509 RefPtrWillBeRawPtr<MutableStylePropertySet> parsedStyle = MutableStyleProper tySet::create(); |
498 BisonCSSParser::parseValue(parsedStyle.get(), CSSPropertyFont, fontString, t rue, HTMLStandardMode, 0); | 510 BisonCSSParser::parseValue(parsedStyle.get(), CSSPropertyFont, fontString, t rue, HTMLStandardMode, 0); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
584 visitor->trace(m_loadingFonts); | 596 visitor->trace(m_loadingFonts); |
585 visitor->trace(m_loadedFonts); | 597 visitor->trace(m_loadedFonts); |
586 visitor->trace(m_failedFonts); | 598 visitor->trace(m_failedFonts); |
587 visitor->trace(m_nonCSSConnectedFaces); | 599 visitor->trace(m_nonCSSConnectedFaces); |
588 DocumentSupplement::trace(visitor); | 600 DocumentSupplement::trace(visitor); |
589 EventTargetWithInlineData::trace(visitor); | 601 EventTargetWithInlineData::trace(visitor); |
590 } | 602 } |
591 #endif | 603 #endif |
592 | 604 |
593 } // namespace WebCore | 605 } // namespace WebCore |
OLD | NEW |