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

Side by Side Diff: third_party/WebKit/Source/core/css/CSSFontFaceSrcValue.cpp

Issue 2556683003: Reland: WebFonts cache-aware timeout adaptation (Closed)
Patch Set: rebase Created 4 years 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
OLDNEW
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
27 27
28 #include "core/css/CSSMarkup.h" 28 #include "core/css/CSSMarkup.h"
29 #include "core/css/StyleSheetContents.h" 29 #include "core/css/StyleSheetContents.h"
30 #include "core/dom/Document.h" 30 #include "core/dom/Document.h"
31 #include "core/dom/Node.h" 31 #include "core/dom/Node.h"
32 #include "core/fetch/FetchInitiatorTypeNames.h" 32 #include "core/fetch/FetchInitiatorTypeNames.h"
33 #include "core/fetch/FetchRequest.h" 33 #include "core/fetch/FetchRequest.h"
34 #include "core/fetch/ResourceFetcher.h" 34 #include "core/fetch/ResourceFetcher.h"
35 #include "core/loader/resource/FontResource.h" 35 #include "core/loader/resource/FontResource.h"
36 #include "platform/CrossOriginAttributeValue.h" 36 #include "platform/CrossOriginAttributeValue.h"
37 #include "platform/RuntimeEnabledFeatures.h"
37 #include "platform/fonts/FontCache.h" 38 #include "platform/fonts/FontCache.h"
38 #include "platform/fonts/FontCustomPlatformData.h" 39 #include "platform/fonts/FontCustomPlatformData.h"
39 #include "platform/weborigin/SecurityPolicy.h" 40 #include "platform/weborigin/SecurityPolicy.h"
40 #include "wtf/text/StringBuilder.h" 41 #include "wtf/text/StringBuilder.h"
41 42
42 namespace blink { 43 namespace blink {
43 44
44 bool CSSFontFaceSrcValue::isSupportedFormat() const { 45 bool CSSFontFaceSrcValue::isSupportedFormat() const {
45 // Normally we would just check the format, but in order to avoid conflicts 46 // Normally we would just check the format, but in order to avoid conflicts
46 // with the old WinIE style of font-face, we will also check to see if the URL 47 // with the old WinIE style of font-face, we will also check to see if the URL
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 return; 84 return;
84 85
85 request.setCrossOriginAccessControl(securityOrigin, 86 request.setCrossOriginAccessControl(securityOrigin,
86 CrossOriginAttributeAnonymous); 87 CrossOriginAttributeAnonymous);
87 } 88 }
88 89
89 FontResource* CSSFontFaceSrcValue::fetch(Document* document) const { 90 FontResource* CSSFontFaceSrcValue::fetch(Document* document) const {
90 if (!m_fetched) { 91 if (!m_fetched) {
91 FetchRequest request(ResourceRequest(m_absoluteResource), 92 FetchRequest request(ResourceRequest(m_absoluteResource),
92 FetchInitiatorTypeNames::css); 93 FetchInitiatorTypeNames::css);
94 if (RuntimeEnabledFeatures::webFontsCacheAwareTimeoutAdaptationEnabled())
95 request.setCacheAwareLoadingEnabled(IsCacheAwareLoadingEnabled);
93 request.setContentSecurityCheck(m_shouldCheckContentSecurityPolicy); 96 request.setContentSecurityCheck(m_shouldCheckContentSecurityPolicy);
94 SecurityOrigin* securityOrigin = document->getSecurityOrigin(); 97 SecurityOrigin* securityOrigin = document->getSecurityOrigin();
95 setCrossOriginAccessControl(request, securityOrigin); 98 setCrossOriginAccessControl(request, securityOrigin);
96 request.mutableResourceRequest().setHTTPReferrer( 99 request.mutableResourceRequest().setHTTPReferrer(
97 SecurityPolicy::generateReferrer(m_referrer.referrerPolicy, 100 SecurityPolicy::generateReferrer(m_referrer.referrerPolicy,
98 request.url(), m_referrer.referrer)); 101 request.url(), m_referrer.referrer));
99 FontResource* resource = FontResource::fetch(request, document->fetcher()); 102 FontResource* resource = FontResource::fetch(request, document->fetcher());
100 if (!resource) 103 if (!resource)
101 return nullptr; 104 return nullptr;
102 m_fetched = FontResourceHelper::create(resource); 105 m_fetched = FontResourceHelper::create(resource);
(...skipping 18 matching lines...) Expand all
121 WebURLRequest::RequestContextFont, FetchInitiatorTypeNames::css); 124 WebURLRequest::RequestContextFont, FetchInitiatorTypeNames::css);
122 } 125 }
123 126
124 bool CSSFontFaceSrcValue::equals(const CSSFontFaceSrcValue& other) const { 127 bool CSSFontFaceSrcValue::equals(const CSSFontFaceSrcValue& other) const {
125 return m_isLocal == other.m_isLocal && m_format == other.m_format && 128 return m_isLocal == other.m_isLocal && m_format == other.m_format &&
126 m_specifiedResource == other.m_specifiedResource && 129 m_specifiedResource == other.m_specifiedResource &&
127 m_absoluteResource == other.m_absoluteResource; 130 m_absoluteResource == other.m_absoluteResource;
128 } 131 }
129 132
130 } // namespace blink 133 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/BUILD.gn ('k') | third_party/WebKit/Source/core/loader/resource/FontResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698