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 25 matching lines...) Expand all Loading... |
36 #include "platform/fonts/FontCache.h" | 36 #include "platform/fonts/FontCache.h" |
37 #include "platform/fonts/FontCustomPlatformData.h" | 37 #include "platform/fonts/FontCustomPlatformData.h" |
38 #include "wtf/text/StringBuilder.h" | 38 #include "wtf/text/StringBuilder.h" |
39 | 39 |
40 namespace blink { | 40 namespace blink { |
41 | 41 |
42 bool CSSFontFaceSrcValue::isSupportedFormat() const | 42 bool CSSFontFaceSrcValue::isSupportedFormat() const |
43 { | 43 { |
44 // Normally we would just check the format, but in order to avoid conflicts
with the old WinIE style of font-face, | 44 // Normally we would just check the format, but in order to avoid conflicts
with the old WinIE style of font-face, |
45 // 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. | 45 // 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. |
46 if (m_format.isEmpty()) { | 46 if (m_format.isEmpty()) |
47 // Check for .eot. | 47 return m_resource.startsWith("data:", false) || !m_resource.endsWith(".e
ot", false); |
48 if (!m_resource.startsWith("data:", false) && m_resource.endsWith(".eot"
, false)) | |
49 return false; | |
50 return true; | |
51 } | |
52 | 48 |
53 if (FontCustomPlatformData::supportsFormat(m_format)) | 49 return FontCustomPlatformData::supportsFormat(m_format); |
54 return true; | |
55 | |
56 return false; | |
57 } | 50 } |
58 | 51 |
59 String CSSFontFaceSrcValue::customCSSText() const | 52 String CSSFontFaceSrcValue::customCSSText() const |
60 { | 53 { |
61 StringBuilder result; | 54 StringBuilder result; |
62 if (isLocal()) | 55 if (isLocal()) |
63 result.appendLiteral("local("); | 56 result.appendLiteral("local("); |
64 else | 57 else |
65 result.appendLiteral("url("); | 58 result.appendLiteral("url("); |
66 result.append(m_resource); | 59 result.append(m_resource); |
67 result.append(')'); | 60 result.append(')'); |
68 if (!m_format.isEmpty()) { | 61 if (!m_format.isEmpty()) { |
69 result.appendLiteral(" format("); | 62 result.appendLiteral(" format("); |
70 result.append(m_format); | 63 result.append(m_format); |
71 result.append(')'); | 64 result.append(')'); |
72 } | 65 } |
73 return result.toString(); | 66 return result.toString(); |
74 } | 67 } |
75 | 68 |
76 bool CSSFontFaceSrcValue::hasFailedOrCanceledSubresources() const | 69 bool CSSFontFaceSrcValue::hasFailedOrCanceledSubresources() const |
77 { | 70 { |
78 if (!m_fetched) | 71 return m_fetched && m_fetched->loadFailedOrCanceled(); |
79 return false; | |
80 return m_fetched->loadFailedOrCanceled(); | |
81 } | 72 } |
82 | 73 |
83 bool CSSFontFaceSrcValue::shouldSetCrossOriginAccessControl(const KURL& resource
, SecurityOrigin* securityOrigin) | 74 bool CSSFontFaceSrcValue::shouldSetCrossOriginAccessControl(const KURL& resource
, SecurityOrigin* securityOrigin) |
84 { | 75 { |
85 if (resource.isLocalFile() || resource.protocolIsData()) | 76 if (resource.isLocalFile() || resource.protocolIsData()) |
86 return false; | 77 return false; |
87 return !securityOrigin->canRequest(resource); | 78 return !securityOrigin->canRequest(resource); |
88 } | 79 } |
89 | 80 |
90 FontResource* CSSFontFaceSrcValue::fetch(Document* document) | 81 FontResource* CSSFontFaceSrcValue::fetch(Document* document) |
(...skipping 27 matching lines...) Expand all Loading... |
118 document->fetcher()->maybeNotifyInsecureContent(m_fetched.get()); | 109 document->fetcher()->maybeNotifyInsecureContent(m_fetched.get()); |
119 document->fetcher()->requestLoadStarted(m_fetched.get(), request, ResourceFe
tcher::ResourceLoadingFromCache); | 110 document->fetcher()->requestLoadStarted(m_fetched.get(), request, ResourceFe
tcher::ResourceLoadingFromCache); |
120 } | 111 } |
121 | 112 |
122 bool CSSFontFaceSrcValue::equals(const CSSFontFaceSrcValue& other) const | 113 bool CSSFontFaceSrcValue::equals(const CSSFontFaceSrcValue& other) const |
123 { | 114 { |
124 return m_isLocal == other.m_isLocal && m_format == other.m_format && m_resou
rce == other.m_resource; | 115 return m_isLocal == other.m_isLocal && m_format == other.m_format && m_resou
rce == other.m_resource; |
125 } | 116 } |
126 | 117 |
127 } | 118 } |
OLD | NEW |