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 12 matching lines...) Expand all Loading... | |
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 "core/css/CSSFontFace.h" | 26 #include "core/css/CSSFontFace.h" |
27 | 27 |
28 #include "core/css/CSSFontFaceSource.h" | 28 #include "core/css/CSSFontFaceSource.h" |
29 #include "core/css/CSSFontSelector.h" | 29 #include "core/css/CSSFontSelector.h" |
30 #include "core/css/CSSSegmentedFontFace.h" | 30 #include "core/css/CSSSegmentedFontFace.h" |
31 #include "core/css/FontFaceSet.h" | 31 #include "core/css/FontFaceSet.h" |
32 #include "core/css/RemoteFontFaceSource.h" | 32 #include "core/css/RemoteFontFaceSource.h" |
33 #include "core/dom/TaskRunnerHelper.h" | |
33 #include "core/frame/UseCounter.h" | 34 #include "core/frame/UseCounter.h" |
35 #include "platform/WebTaskRunner.h" | |
34 #include "platform/fonts/FontDescription.h" | 36 #include "platform/fonts/FontDescription.h" |
35 #include "platform/fonts/SimpleFontData.h" | 37 #include "platform/fonts/SimpleFontData.h" |
36 #include <algorithm> | 38 #include <algorithm> |
37 | 39 |
38 namespace blink { | 40 namespace blink { |
39 | 41 |
40 void CSSFontFace::addSource(CSSFontFaceSource* source) { | 42 void CSSFontFace::addSource(CSSFontFaceSource* source) { |
41 source->setFontFace(this); | 43 source->setFontFace(this); |
42 m_sources.append(source); | 44 m_sources.append(source); |
43 } | 45 } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 setLoadStatus(FontFace::Loaded); | 170 setLoadStatus(FontFace::Loaded); |
169 return; | 171 return; |
170 } | 172 } |
171 } | 173 } |
172 m_sources.removeFirst(); | 174 m_sources.removeFirst(); |
173 } | 175 } |
174 setLoadStatus(FontFace::Error); | 176 setLoadStatus(FontFace::Error); |
175 } | 177 } |
176 | 178 |
177 void CSSFontFace::setLoadStatus(FontFace::LoadStatusType newStatus) { | 179 void CSSFontFace::setLoadStatus(FontFace::LoadStatusType newStatus) { |
178 ASSERT(m_fontFace); | 180 DCHECK(m_fontFace); |
181 m_loadStatus = newStatus; | |
182 if (newStatus == FontFace::Loading) { | |
183 m_fontFace->setLoadStatus(newStatus); | |
184 } else { | |
185 TaskRunnerHelper::get(TaskType::DOMManipulation, | |
186 m_fontFace->getExecutionContext()) | |
187 ->postTask(BLINK_FROM_HERE, WTF::bind(&CSSFontFace::setLoadStatusHelper, | |
188 wrapPersistent(this), newStatus)); | |
189 return; | |
190 } | |
191 | |
192 if (!m_segmentedFontFace) | |
jbroman
2017/01/05 20:01:08
nit: it's a little confusing that stuff that only
| |
193 return; | |
194 Document* document = m_segmentedFontFace->fontSelector()->document(); | |
195 if (document) | |
196 FontFaceSet::from(*document)->beginFontLoading(m_fontFace); | |
197 } | |
198 | |
199 void CSSFontFace::setLoadStatusHelper(FontFace::LoadStatusType newStatus) { | |
200 DCHECK(m_fontFace); | |
179 if (newStatus == FontFace::Error) | 201 if (newStatus == FontFace::Error) |
180 m_fontFace->setError(); | 202 m_fontFace->setError(); |
181 else | 203 else |
182 m_fontFace->setLoadStatus(newStatus); | 204 m_fontFace->setLoadStatus(newStatus); |
183 | |
184 if (!m_segmentedFontFace) | |
185 return; | |
186 Document* document = m_segmentedFontFace->fontSelector()->document(); | |
187 if (document && newStatus == FontFace::Loading) | |
188 FontFaceSet::from(*document)->beginFontLoading(m_fontFace); | |
189 } | 205 } |
190 | 206 |
191 DEFINE_TRACE(CSSFontFace) { | 207 DEFINE_TRACE(CSSFontFace) { |
192 visitor->trace(m_segmentedFontFace); | 208 visitor->trace(m_segmentedFontFace); |
193 visitor->trace(m_sources); | 209 visitor->trace(m_sources); |
194 visitor->trace(m_fontFace); | 210 visitor->trace(m_fontFace); |
195 } | 211 } |
196 | 212 |
197 } // namespace blink | 213 } // namespace blink |
OLD | NEW |