| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "core/css/parser/CSSParser.h" | 49 #include "core/css/parser/CSSParser.h" |
| 50 #include "core/dom/DOMArrayBuffer.h" | 50 #include "core/dom/DOMArrayBuffer.h" |
| 51 #include "core/dom/DOMArrayBufferView.h" | 51 #include "core/dom/DOMArrayBufferView.h" |
| 52 #include "core/dom/DOMException.h" | 52 #include "core/dom/DOMException.h" |
| 53 #include "core/dom/Document.h" | 53 #include "core/dom/Document.h" |
| 54 #include "core/dom/ExceptionCode.h" | 54 #include "core/dom/ExceptionCode.h" |
| 55 #include "core/dom/StyleEngine.h" | 55 #include "core/dom/StyleEngine.h" |
| 56 #include "core/frame/LocalFrame.h" | 56 #include "core/frame/LocalFrame.h" |
| 57 #include "core/frame/Settings.h" | 57 #include "core/frame/Settings.h" |
| 58 #include "core/frame/UseCounter.h" | 58 #include "core/frame/UseCounter.h" |
| 59 #include "core/svg/SVGFontFaceElement.h" | |
| 60 #include "core/svg/SVGFontFaceSource.h" | |
| 61 #include "core/svg/SVGRemoteFontFaceSource.h" | |
| 62 #include "platform/FontFamilyNames.h" | 59 #include "platform/FontFamilyNames.h" |
| 63 #include "platform/SharedBuffer.h" | 60 #include "platform/SharedBuffer.h" |
| 64 #include "wtf/ArrayBufferView.h" | 61 #include "wtf/ArrayBufferView.h" |
| 65 | 62 |
| 66 namespace blink { | 63 namespace blink { |
| 67 | 64 |
| 68 static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document,
const String& s, CSSPropertyID propertyID) | 65 static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document,
const String& s, CSSPropertyID propertyID) |
| 69 { | 66 { |
| 70 CSSParserContext context(*document, UseCounter::getFrom(document)); | 67 CSSParserContext context(*document, UseCounter::getFrom(document)); |
| 71 return CSSParser::parseSingleValue(propertyID, s, context); | 68 return CSSParser::parseSingleValue(propertyID, s, context); |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get()); | 502 m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get()); |
| 506 if (m_error) | 503 if (m_error) |
| 507 return; | 504 return; |
| 508 | 505 |
| 509 // Each item in the src property's list is a single CSSFontFaceSource. Put t
hem all into a CSSFontFace. | 506 // Each item in the src property's list is a single CSSFontFaceSource. Put t
hem all into a CSSFontFace. |
| 510 ASSERT(src); | 507 ASSERT(src); |
| 511 ASSERT(src->isValueList()); | 508 ASSERT(src->isValueList()); |
| 512 CSSValueList* srcList = toCSSValueList(src.get()); | 509 CSSValueList* srcList = toCSSValueList(src.get()); |
| 513 int srcLength = srcList->length(); | 510 int srcLength = srcList->length(); |
| 514 | 511 |
| 515 bool foundSVGFont = false; | |
| 516 | |
| 517 for (int i = 0; i < srcLength; i++) { | 512 for (int i = 0; i < srcLength; i++) { |
| 518 // An item in the list either specifies a string (local font name) or a
URL (remote font to download). | 513 // An item in the list either specifies a string (local font name) or a
URL (remote font to download). |
| 519 CSSFontFaceSrcValue* item = toCSSFontFaceSrcValue(srcList->item(i)); | 514 CSSFontFaceSrcValue* item = toCSSFontFaceSrcValue(srcList->item(i)); |
| 520 OwnPtrWillBeRawPtr<CSSFontFaceSource> source = nullptr; | 515 OwnPtrWillBeRawPtr<CSSFontFaceSource> source = nullptr; |
| 521 | 516 |
| 522 #if ENABLE(SVG_FONTS) | |
| 523 foundSVGFont = item->isSVGFontFaceSrc() || item->svgFontFaceElement(); | |
| 524 #endif | |
| 525 if (!item->isLocal()) { | 517 if (!item->isLocal()) { |
| 526 Settings* settings = document ? document->frame() ? document->frame(
)->settings() : 0 : 0; | 518 Settings* settings = document ? document->frame() ? document->frame(
)->settings() : 0 : 0; |
| 527 bool allowDownloading = foundSVGFont || (settings && settings->downl
oadableBinaryFontsEnabled()); | 519 bool allowDownloading = settings && settings->downloadableBinaryFont
sEnabled(); |
| 528 if (allowDownloading && item->isSupportedFormat() && document) { | 520 if (allowDownloading && item->isSupportedFormat() && document) { |
| 529 FontResource* fetched = item->fetch(document); | 521 FontResource* fetched = item->fetch(document); |
| 530 if (fetched) { | 522 if (fetched) { |
| 531 FontLoader* fontLoader = document->styleEngine()->fontSelect
or()->fontLoader(); | 523 FontLoader* fontLoader = document->styleEngine()->fontSelect
or()->fontLoader(); |
| 532 | 524 source = adoptPtrWillBeNoop(new RemoteFontFaceSource(fetched
, fontLoader)); |
| 533 #if ENABLE(SVG_FONTS) | |
| 534 if (foundSVGFont) { | |
| 535 source = adoptPtrWillBeNoop(new SVGRemoteFontFaceSource(
item->resource(), fetched, fontLoader)); | |
| 536 } else | |
| 537 #endif | |
| 538 { | |
| 539 source = adoptPtrWillBeNoop(new RemoteFontFaceSource(fet
ched, fontLoader)); | |
| 540 } | |
| 541 } | 525 } |
| 542 } | 526 } |
| 543 } else { | 527 } else { |
| 544 #if ENABLE(SVG_FONTS) | 528 source = adoptPtrWillBeNoop(new LocalFontFaceSource(item->resource()
)); |
| 545 if (item->svgFontFaceElement()) { | |
| 546 RefPtrWillBeRawPtr<SVGFontFaceElement> fontfaceElement = item->s
vgFontFaceElement(); | |
| 547 // SVGFontFaceSource assumes that it is the case where <font-fac
e> element resides in the same document. | |
| 548 // We put a RELEASE_ASSERT here as it will cause UAF if the assu
mption is false. | |
| 549 RELEASE_ASSERT(fontfaceElement->inDocument()); | |
| 550 RELEASE_ASSERT(fontfaceElement->document() == document); | |
| 551 source = adoptPtrWillBeNoop(new SVGFontFaceSource(fontfaceElemen
t.get())); | |
| 552 } else | |
| 553 #endif | |
| 554 { | |
| 555 source = adoptPtrWillBeNoop(new LocalFontFaceSource(item->resour
ce())); | |
| 556 } | |
| 557 } | 529 } |
| 558 | 530 |
| 559 if (source) | 531 if (source) |
| 560 m_cssFontFace->addSource(source.release()); | 532 m_cssFontFace->addSource(source.release()); |
| 561 } | 533 } |
| 562 } | 534 } |
| 563 | 535 |
| 564 void FontFace::initCSSFontFace(const unsigned char* data, unsigned size) | 536 void FontFace::initCSSFontFace(const unsigned char* data, unsigned size) |
| 565 { | 537 { |
| 566 m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get()); | 538 m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 595 { | 567 { |
| 596 return m_cssFontFace->hadBlankText(); | 568 return m_cssFontFace->hadBlankText(); |
| 597 } | 569 } |
| 598 | 570 |
| 599 bool FontFace::hasPendingActivity() const | 571 bool FontFace::hasPendingActivity() const |
| 600 { | 572 { |
| 601 return m_status == Loading && executionContext() && !executionContext()->act
iveDOMObjectsAreStopped(); | 573 return m_status == Loading && executionContext() && !executionContext()->act
iveDOMObjectsAreStopped(); |
| 602 } | 574 } |
| 603 | 575 |
| 604 } // namespace blink | 576 } // namespace blink |
| OLD | NEW |