| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2010 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 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 16 matching lines...) Expand all Loading... |
| 27 #include "core/css/CSSFontFaceSrcValue.h" | 27 #include "core/css/CSSFontFaceSrcValue.h" |
| 28 | 28 |
| 29 #include "core/FetchInitiatorTypeNames.h" | 29 #include "core/FetchInitiatorTypeNames.h" |
| 30 #include "core/css/StyleSheetContents.h" | 30 #include "core/css/StyleSheetContents.h" |
| 31 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
| 32 #include "core/dom/Node.h" | 32 #include "core/dom/Node.h" |
| 33 #include "core/fetch/FetchRequest.h" | 33 #include "core/fetch/FetchRequest.h" |
| 34 #include "core/fetch/FontResource.h" | 34 #include "core/fetch/FontResource.h" |
| 35 #include "core/fetch/ResourceFetcher.h" | 35 #include "core/fetch/ResourceFetcher.h" |
| 36 #include "core/svg/SVGFontFaceElement.h" | 36 #include "core/svg/SVGFontFaceElement.h" |
| 37 #include "platform/fonts/FontCache.h" |
| 37 #include "platform/fonts/FontCustomPlatformData.h" | 38 #include "platform/fonts/FontCustomPlatformData.h" |
| 38 #include "wtf/text/StringBuilder.h" | 39 #include "wtf/text/StringBuilder.h" |
| 39 | 40 |
| 40 namespace WebCore { | 41 namespace WebCore { |
| 41 | 42 |
| 42 #if ENABLE(SVG_FONTS) | 43 #if ENABLE(SVG_FONTS) |
| 43 bool CSSFontFaceSrcValue::isSVGFontFaceSrc() const | 44 bool CSSFontFaceSrcValue::isSVGFontFaceSrc() const |
| 44 { | 45 { |
| 45 return equalIgnoringCase(m_format, "svg"); | 46 return equalIgnoringCase(m_format, "svg"); |
| 46 } | 47 } |
| 47 #endif | 48 #endif |
| 48 | 49 |
| 49 bool CSSFontFaceSrcValue::isSupportedFormat() const | 50 bool CSSFontFaceSrcValue::isSupportedFormat() const |
| 50 { | 51 { |
| 51 // Normally we would just check the format, but in order to avoid conflicts
with the old WinIE style of font-face, | 52 // Normally we would just check the format, but in order to avoid conflicts
with the old WinIE style of font-face, |
| 52 // we will also check to see if the URL ends with .eot. If so, we'll go ahe
ad and assume that we shouldn't load it. | 53 // we will also check to see if the URL ends with .eot. If so, we'll go ahe
ad and assume that we shouldn't load it. |
| 53 if (m_format.isEmpty()) { | 54 if (m_format.isEmpty()) { |
| 54 // Check for .eot. | 55 // Check for .eot. |
| 55 if (!m_resource.startsWith("data:", false) && m_resource.endsWith(".eot"
, false)) | 56 if (!m_resource.startsWith("data:", false) && m_resource.endsWith(".eot"
, false)) |
| 56 return false; | 57 return false; |
| 57 return true; | 58 return true; |
| 58 } | 59 } |
| 59 | 60 |
| 60 return FontCustomPlatformData::supportsFormat(m_format) | 61 if (FontCustomPlatformData::supportsFormat(m_format)) |
| 62 return true; |
| 63 |
| 64 // We have removed SVG font support on non-gdi platforms. For details, see: |
| 65 // https://groups.google.com/a/chromium.org/d/msg/blink-dev/pYbbUcYvlYY/LQvF
vM8KZZEJ |
| 61 #if ENABLE(SVG_FONTS) | 66 #if ENABLE(SVG_FONTS) |
| 62 || isSVGFontFaceSrc() | 67 if (RuntimeEnabledFeatures::svgFontsOnNonGDIPlatformsEnabled() |
| 68 #if OS(WIN) |
| 69 || !FontCache::useDirectWrite() |
| 63 #endif | 70 #endif |
| 64 ; | 71 ) |
| 72 return isSVGFontFaceSrc(); |
| 73 #endif |
| 74 return false; |
| 65 } | 75 } |
| 66 | 76 |
| 67 String CSSFontFaceSrcValue::customCSSText() const | 77 String CSSFontFaceSrcValue::customCSSText() const |
| 68 { | 78 { |
| 69 StringBuilder result; | 79 StringBuilder result; |
| 70 if (isLocal()) | 80 if (isLocal()) |
| 71 result.appendLiteral("local("); | 81 result.appendLiteral("local("); |
| 72 else | 82 else |
| 73 result.appendLiteral("url("); | 83 result.appendLiteral("url("); |
| 74 result.append(m_resource); | 84 result.append(m_resource); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 FetchRequest request(ResourceRequest(resourceURL), FetchInitiatorTypeNames::
css); | 135 FetchRequest request(ResourceRequest(resourceURL), FetchInitiatorTypeNames::
css); |
| 126 document->fetcher()->requestLoadStarted(m_fetched.get(), request, ResourceFe
tcher::ResourceLoadingFromCache); | 136 document->fetcher()->requestLoadStarted(m_fetched.get(), request, ResourceFe
tcher::ResourceLoadingFromCache); |
| 127 } | 137 } |
| 128 | 138 |
| 129 bool CSSFontFaceSrcValue::equals(const CSSFontFaceSrcValue& other) const | 139 bool CSSFontFaceSrcValue::equals(const CSSFontFaceSrcValue& other) const |
| 130 { | 140 { |
| 131 return m_isLocal == other.m_isLocal && m_format == other.m_format && m_resou
rce == other.m_resource; | 141 return m_isLocal == other.m_isLocal && m_format == other.m_format && m_resou
rce == other.m_resource; |
| 132 } | 142 } |
| 133 | 143 |
| 134 } | 144 } |
| OLD | NEW |