Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(713)

Side by Side Diff: sky/engine/core/css/CSSFontFaceSrcValue.cpp

Issue 1223843003: Remove support for loading remote font faces (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/core/css/CSSFontFaceSrcValue.h ('k') | sky/engine/core/css/CSSFontSelector.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2007, 2010 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #include "sky/engine/core/css/CSSFontFaceSrcValue.h"
27
28 #include "gen/sky/core/FetchInitiatorTypeNames.h"
29 #include "sky/engine/core/css/StyleSheetContents.h"
30 #include "sky/engine/core/dom/Document.h"
31 #include "sky/engine/core/dom/Node.h"
32 #include "sky/engine/core/fetch/FetchRequest.h"
33 #include "sky/engine/core/fetch/FontResource.h"
34 #include "sky/engine/core/fetch/ResourceFetcher.h"
35 #include "sky/engine/platform/fonts/FontCache.h"
36 #include "sky/engine/platform/fonts/FontCustomPlatformData.h"
37 #include "sky/engine/wtf/text/StringBuilder.h"
38
39 namespace blink {
40
41 bool CSSFontFaceSrcValue::isSupportedFormat() const
42 {
43 // Normally we would just check the format, but in order to avoid conflicts with the old WinIE style of font-face,
44 // 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 if (m_format.isEmpty()) {
46 // Check for .eot.
47 if (!m_resource.startsWith("data:", false) && m_resource.endsWith(".eot" , false))
48 return false;
49 return true;
50 }
51
52 if (FontCustomPlatformData::supportsFormat(m_format))
53 return true;
54
55 // We have removed SVG font support on non-gdi platforms. For details, see:
56 // https://groups.google.com/a/chromium.org/d/msg/blink-dev/pYbbUcYvlYY/LQvF vM8KZZEJ
57 return false;
58 }
59
60 String CSSFontFaceSrcValue::customCSSText() const
61 {
62 StringBuilder result;
63 if (isLocal())
64 result.appendLiteral("local(");
65 else
66 result.appendLiteral("url(");
67 result.append(m_resource);
68 result.append(')');
69 if (!m_format.isEmpty()) {
70 result.appendLiteral(" format(");
71 result.append(m_format);
72 result.append(')');
73 }
74 return result.toString();
75 }
76
77 FontResource* CSSFontFaceSrcValue::fetch(Document* document)
78 {
79 if (!m_fetched) {
80 FetchRequest request(ResourceRequest(document->completeURL(m_resource)), FetchInitiatorTypeNames::css);
81 request.mutableResourceRequest().setHTTPReferrer(m_referrer);
82 m_fetched = document->fetcher()->fetchFont(request);
83 } else {
84 // FIXME: CSSFontFaceSrcValue::fetch is invoked when @font-face rule
85 // is processed by StyleResolver / StyleEngine.
86 restoreCachedResourceIfNeeded(document);
87 }
88 return m_fetched.get();
89 }
90
91 void CSSFontFaceSrcValue::restoreCachedResourceIfNeeded(Document* document)
92 {
93 ASSERT(m_fetched);
94 ASSERT(document && document->fetcher());
95
96 const String resourceURL = document->completeURL(m_resource);
97 if (document->fetcher()->cachedResource(KURL(ParsedURLString, resourceURL)))
98 return;
99
100 FetchRequest request(ResourceRequest(resourceURL), FetchInitiatorTypeNames:: css);
101 document->fetcher()->requestLoadStarted(m_fetched.get(), request, ResourceFe tcher::ResourceLoadingFromCache);
102 }
103
104 bool CSSFontFaceSrcValue::equals(const CSSFontFaceSrcValue& other) const
105 {
106 return m_isLocal == other.m_isLocal && m_format == other.m_format && m_resou rce == other.m_resource;
107 }
108
109 }
OLDNEW
« no previous file with comments | « sky/engine/core/css/CSSFontFaceSrcValue.h ('k') | sky/engine/core/css/CSSFontSelector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698