OLD | NEW |
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 26 matching lines...) Expand all Loading... |
37 | 37 |
38 namespace blink { | 38 namespace blink { |
39 | 39 |
40 void CSSFontFace::addSource(CSSFontFaceSource* source) { | 40 void CSSFontFace::addSource(CSSFontFaceSource* source) { |
41 source->setFontFace(this); | 41 source->setFontFace(this); |
42 m_sources.push_back(source); | 42 m_sources.push_back(source); |
43 } | 43 } |
44 | 44 |
45 void CSSFontFace::setSegmentedFontFace( | 45 void CSSFontFace::setSegmentedFontFace( |
46 CSSSegmentedFontFace* segmentedFontFace) { | 46 CSSSegmentedFontFace* segmentedFontFace) { |
47 ASSERT(!m_segmentedFontFace); | 47 DCHECK(!m_segmentedFontFace); |
48 m_segmentedFontFace = segmentedFontFace; | 48 m_segmentedFontFace = segmentedFontFace; |
49 } | 49 } |
50 | 50 |
51 void CSSFontFace::didBeginLoad() { | 51 void CSSFontFace::didBeginLoad() { |
52 if (loadStatus() == FontFace::Unloaded) | 52 if (loadStatus() == FontFace::Unloaded) |
53 setLoadStatus(FontFace::Loading); | 53 setLoadStatus(FontFace::Loading); |
54 } | 54 } |
55 | 55 |
56 void CSSFontFace::fontLoaded(RemoteFontFaceSource* source) { | 56 void CSSFontFace::fontLoaded(RemoteFontFaceSource* source) { |
57 if (!isValid() || source != m_sources.front()) | 57 if (!isValid() || source != m_sources.front()) |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 FontFamily fontFamily; | 144 FontFamily fontFamily; |
145 fontFamily.setFamily(m_fontFace->family()); | 145 fontFamily.setFamily(m_fontFace->family()); |
146 fontDescription.setFamily(fontFamily); | 146 fontDescription.setFamily(fontFamily); |
147 fontDescription.setTraits(m_fontFace->traits()); | 147 fontDescription.setTraits(m_fontFace->traits()); |
148 load(fontDescription); | 148 load(fontDescription); |
149 } | 149 } |
150 | 150 |
151 void CSSFontFace::load(const FontDescription& fontDescription) { | 151 void CSSFontFace::load(const FontDescription& fontDescription) { |
152 if (loadStatus() == FontFace::Unloaded) | 152 if (loadStatus() == FontFace::Unloaded) |
153 setLoadStatus(FontFace::Loading); | 153 setLoadStatus(FontFace::Loading); |
154 ASSERT(loadStatus() == FontFace::Loading); | 154 DCHECK_EQ(loadStatus(), FontFace::Loading); |
155 | 155 |
156 while (!m_sources.isEmpty()) { | 156 while (!m_sources.isEmpty()) { |
157 Member<CSSFontFaceSource>& source = m_sources.front(); | 157 Member<CSSFontFaceSource>& source = m_sources.front(); |
158 if (source->isValid()) { | 158 if (source->isValid()) { |
159 if (source->isLocal()) { | 159 if (source->isLocal()) { |
160 if (source->isLocalFontAvailable(fontDescription)) { | 160 if (source->isLocalFontAvailable(fontDescription)) { |
161 setLoadStatus(FontFace::Loaded); | 161 setLoadStatus(FontFace::Loaded); |
162 return; | 162 return; |
163 } | 163 } |
164 } else { | 164 } else { |
165 if (!source->isLoaded()) | 165 if (!source->isLoaded()) |
166 source->beginLoadIfNeeded(); | 166 source->beginLoadIfNeeded(); |
167 else | 167 else |
168 setLoadStatus(FontFace::Loaded); | 168 setLoadStatus(FontFace::Loaded); |
169 return; | 169 return; |
170 } | 170 } |
171 } | 171 } |
172 m_sources.pop_front(); | 172 m_sources.pop_front(); |
173 } | 173 } |
174 setLoadStatus(FontFace::Error); | 174 setLoadStatus(FontFace::Error); |
175 } | 175 } |
176 | 176 |
177 void CSSFontFace::setLoadStatus(FontFace::LoadStatusType newStatus) { | 177 void CSSFontFace::setLoadStatus(FontFace::LoadStatusType newStatus) { |
178 ASSERT(m_fontFace); | 178 DCHECK(m_fontFace); |
179 if (newStatus == FontFace::Error) | 179 if (newStatus == FontFace::Error) |
180 m_fontFace->setError(); | 180 m_fontFace->setError(); |
181 else | 181 else |
182 m_fontFace->setLoadStatus(newStatus); | 182 m_fontFace->setLoadStatus(newStatus); |
183 | 183 |
184 if (!m_segmentedFontFace) | 184 if (!m_segmentedFontFace) |
185 return; | 185 return; |
186 Document* document = m_segmentedFontFace->fontSelector()->document(); | 186 Document* document = m_segmentedFontFace->fontSelector()->document(); |
187 if (document && newStatus == FontFace::Loading) | 187 if (document && newStatus == FontFace::Loading) |
188 FontFaceSet::from(*document)->beginFontLoading(m_fontFace); | 188 FontFaceSet::from(*document)->beginFontLoading(m_fontFace); |
189 } | 189 } |
190 | 190 |
191 DEFINE_TRACE(CSSFontFace) { | 191 DEFINE_TRACE(CSSFontFace) { |
192 visitor->trace(m_segmentedFontFace); | 192 visitor->trace(m_segmentedFontFace); |
193 visitor->trace(m_sources); | 193 visitor->trace(m_sources); |
194 visitor->trace(m_fontFace); | 194 visitor->trace(m_fontFace); |
195 } | 195 } |
196 | 196 |
197 } // namespace blink | 197 } // namespace blink |
OLD | NEW |