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

Side by Side Diff: sky/engine/core/css/CSSFontFace.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/CSSFontFace.h ('k') | sky/engine/core/css/CSSFontFaceSource.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2011 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 10 matching lines...) Expand all
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "sky/engine/core/css/CSSFontFace.h" 26 #include "sky/engine/core/css/CSSFontFace.h"
27 27
28 #include "sky/engine/core/css/CSSFontFaceSource.h" 28 #include "sky/engine/core/css/CSSFontFaceSource.h"
29 #include "sky/engine/core/css/CSSFontSelector.h" 29 #include "sky/engine/core/css/CSSFontSelector.h"
30 #include "sky/engine/core/css/CSSSegmentedFontFace.h" 30 #include "sky/engine/core/css/CSSSegmentedFontFace.h"
31 #include "sky/engine/core/css/FontFaceSet.h"
32 #include "sky/engine/core/css/RemoteFontFaceSource.h"
33 #include "sky/engine/platform/fonts/FontDescription.h" 31 #include "sky/engine/platform/fonts/FontDescription.h"
34 #include "sky/engine/platform/fonts/SimpleFontData.h" 32 #include "sky/engine/platform/fonts/SimpleFontData.h"
35 33
36 namespace blink { 34 namespace blink {
37 35
38 void CSSFontFace::addSource(PassOwnPtr<CSSFontFaceSource> source) 36 void CSSFontFace::addSource(PassOwnPtr<CSSFontFaceSource> source)
39 { 37 {
40 source->setFontFace(this); 38 source->setFontFace(this);
41 m_sources.append(source); 39 m_sources.append(source);
42 } 40 }
43 41
44 void CSSFontFace::setSegmentedFontFace(CSSSegmentedFontFace* segmentedFontFace) 42 void CSSFontFace::setSegmentedFontFace(CSSSegmentedFontFace* segmentedFontFace)
45 { 43 {
46 ASSERT(!m_segmentedFontFace); 44 ASSERT(!m_segmentedFontFace);
47 m_segmentedFontFace = segmentedFontFace; 45 m_segmentedFontFace = segmentedFontFace;
48 } 46 }
49 47
50 void CSSFontFace::didBeginLoad()
51 {
52 if (loadStatus() == FontFace::Unloaded)
53 setLoadStatus(FontFace::Loading);
54 }
55
56 void CSSFontFace::fontLoaded(RemoteFontFaceSource* source)
57 {
58 if (!isValid() || source != m_sources.first())
59 return;
60
61 if (loadStatus() == FontFace::Loading) {
62 if (source->ensureFontData()) {
63 setLoadStatus(FontFace::Loaded);
64 } else {
65 m_sources.removeFirst();
66 load();
67 }
68 }
69
70 if (m_segmentedFontFace)
71 m_segmentedFontFace->fontLoaded(this);
72 }
73
74 void CSSFontFace::fontLoadWaitLimitExceeded(RemoteFontFaceSource* source)
75 {
76 if (!isValid() || source != m_sources.first())
77 return;
78 if (m_segmentedFontFace)
79 m_segmentedFontFace->fontLoadWaitLimitExceeded(this);
80 }
81
82 PassRefPtr<SimpleFontData> CSSFontFace::getFontData(const FontDescription& fontD escription) 48 PassRefPtr<SimpleFontData> CSSFontFace::getFontData(const FontDescription& fontD escription)
83 { 49 {
84 if (!isValid()) 50 if (!isValid())
85 return nullptr; 51 return nullptr;
86 52
87 while (!m_sources.isEmpty()) { 53 while (!m_sources.isEmpty()) {
88 OwnPtr<CSSFontFaceSource>& source = m_sources.first(); 54 OwnPtr<CSSFontFaceSource>& source = m_sources.first();
89 if (RefPtr<SimpleFontData> result = source->getFontData(fontDescription) ) { 55 if (RefPtr<SimpleFontData> result = source->getFontData(fontDescription) ) {
90 if (loadStatus() == FontFace::Unloaded && (source->isLoading() || so urce->isLoaded())) 56 if (loadStatus() == FontFace::Unloaded && (source->isLoading() || so urce->isLoaded()))
91 setLoadStatus(FontFace::Loading); 57 setLoadStatus(FontFace::Loading);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 setLoadStatus(FontFace::Error); 116 setLoadStatus(FontFace::Error);
151 } 117 }
152 118
153 void CSSFontFace::setLoadStatus(FontFace::LoadStatus newStatus) 119 void CSSFontFace::setLoadStatus(FontFace::LoadStatus newStatus)
154 { 120 {
155 ASSERT(m_fontFace); 121 ASSERT(m_fontFace);
156 if (newStatus == FontFace::Error) 122 if (newStatus == FontFace::Error)
157 m_fontFace->setError(); 123 m_fontFace->setError();
158 else 124 else
159 m_fontFace->setLoadStatus(newStatus); 125 m_fontFace->setLoadStatus(newStatus);
160
161 if (!m_segmentedFontFace)
162 return;
163 Document* document = m_segmentedFontFace->fontSelector()->document();
164 if (!document)
165 return;
166
167 switch (newStatus) {
168 case FontFace::Loading:
169 FontFaceSet::from(*document)->beginFontLoading(m_fontFace);
170 break;
171 case FontFace::Loaded:
172 FontFaceSet::from(*document)->fontLoaded(m_fontFace);
173 break;
174 case FontFace::Error:
175 FontFaceSet::from(*document)->loadError(m_fontFace);
176 break;
177 default:
178 break;
179 }
180 } 126 }
181 127
182 CSSFontFace::UnicodeRangeSet::UnicodeRangeSet(const Vector<UnicodeRange>& ranges ) 128 CSSFontFace::UnicodeRangeSet::UnicodeRangeSet(const Vector<UnicodeRange>& ranges )
183 : m_ranges(ranges) 129 : m_ranges(ranges)
184 { 130 {
185 if (m_ranges.isEmpty()) 131 if (m_ranges.isEmpty())
186 return; 132 return;
187 133
188 std::sort(m_ranges.begin(), m_ranges.end()); 134 std::sort(m_ranges.begin(), m_ranges.end());
189 135
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 while (index < text.length()) { 171 while (index < text.length()) {
226 UChar32 c = text.characterStartingAt(index); 172 UChar32 c = text.characterStartingAt(index);
227 index += U16_LENGTH(c); 173 index += U16_LENGTH(c);
228 if (contains(c)) 174 if (contains(c))
229 return true; 175 return true;
230 } 176 }
231 return false; 177 return false;
232 } 178 }
233 179
234 } 180 }
OLDNEW
« no previous file with comments | « sky/engine/core/css/CSSFontFace.h ('k') | sky/engine/core/css/CSSFontFaceSource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698