OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google 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 are met: | 5 * modification, are permitted provided that the following conditions are met: |
6 * | 6 * |
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 visitor->trace(m_fontFaces); | 111 visitor->trace(m_fontFaces); |
112 visitor->trace(m_resolver); | 112 visitor->trace(m_resolver); |
113 LoadFontCallback::trace(visitor); | 113 LoadFontCallback::trace(visitor); |
114 } | 114 } |
115 | 115 |
116 FontFaceSet::FontFaceSet(Document& document) | 116 FontFaceSet::FontFaceSet(Document& document) |
117 : ActiveDOMObject(&document) | 117 : ActiveDOMObject(&document) |
118 , m_shouldFireLoadingEvent(false) | 118 , m_shouldFireLoadingEvent(false) |
119 , m_isLoading(false) | 119 , m_isLoading(false) |
120 , m_ready(new ReadyProperty(executionContext(), this, ReadyProperty::Ready)) | 120 , m_ready(new ReadyProperty(executionContext(), this, ReadyProperty::Ready)) |
121 , m_asyncRunner(this, &FontFaceSet::handlePendingEventsAndPromises) | 121 , m_asyncRunner(AsyncMethodRunner<FontFaceSet>::create(this, &FontFaceSet::h andlePendingEventsAndPromises)) |
122 { | 122 { |
123 suspendIfNeeded(); | 123 suspendIfNeeded(); |
124 } | 124 } |
125 | 125 |
126 FontFaceSet::~FontFaceSet() | 126 FontFaceSet::~FontFaceSet() |
127 { | 127 { |
128 #if !ENABLE(OILPAN) | |
129 stop(); | |
haraken
2016/01/13 07:41:56
Do we really need to call stop() here?
sof
2016/01/13 07:49:46
It is required.
If we don't (from this non-heap o
haraken
2016/01/13 07:57:34
Ah, makes sense.
| |
130 #endif | |
128 } | 131 } |
129 | 132 |
130 Document* FontFaceSet::document() const | 133 Document* FontFaceSet::document() const |
131 { | 134 { |
132 return toDocument(executionContext()); | 135 return toDocument(executionContext()); |
133 } | 136 } |
134 | 137 |
135 bool FontFaceSet::inActiveDocumentContext() const | 138 bool FontFaceSet::inActiveDocumentContext() const |
136 { | 139 { |
137 ExecutionContext* context = executionContext(); | 140 ExecutionContext* context = executionContext(); |
(...skipping 19 matching lines...) Expand all Loading... | |
157 AtomicString FontFaceSet::status() const | 160 AtomicString FontFaceSet::status() const |
158 { | 161 { |
159 DEFINE_STATIC_LOCAL(AtomicString, loading, ("loading", AtomicString::Constru ctFromLiteral)); | 162 DEFINE_STATIC_LOCAL(AtomicString, loading, ("loading", AtomicString::Constru ctFromLiteral)); |
160 DEFINE_STATIC_LOCAL(AtomicString, loaded, ("loaded", AtomicString::Construct FromLiteral)); | 163 DEFINE_STATIC_LOCAL(AtomicString, loaded, ("loaded", AtomicString::Construct FromLiteral)); |
161 return m_isLoading ? loading : loaded; | 164 return m_isLoading ? loading : loaded; |
162 } | 165 } |
163 | 166 |
164 void FontFaceSet::handlePendingEventsAndPromisesSoon() | 167 void FontFaceSet::handlePendingEventsAndPromisesSoon() |
165 { | 168 { |
166 // m_asyncRunner will be automatically stopped on destruction. | 169 // m_asyncRunner will be automatically stopped on destruction. |
167 m_asyncRunner.runAsync(); | 170 m_asyncRunner->runAsync(); |
168 } | 171 } |
169 | 172 |
170 void FontFaceSet::didLayout() | 173 void FontFaceSet::didLayout() |
171 { | 174 { |
172 if (document()->frame()->isMainFrame() && m_loadingFonts.isEmpty()) | 175 if (document()->frame()->isMainFrame() && m_loadingFonts.isEmpty()) |
173 m_histogram.record(); | 176 m_histogram.record(); |
174 if (!shouldSignalReady()) | 177 if (!shouldSignalReady()) |
175 return; | 178 return; |
176 handlePendingEventsAndPromisesSoon(); | 179 handlePendingEventsAndPromisesSoon(); |
177 } | 180 } |
(...skipping 14 matching lines...) Expand all Loading... | |
192 void FontFaceSet::fireLoadingEvent() | 195 void FontFaceSet::fireLoadingEvent() |
193 { | 196 { |
194 if (m_shouldFireLoadingEvent) { | 197 if (m_shouldFireLoadingEvent) { |
195 m_shouldFireLoadingEvent = false; | 198 m_shouldFireLoadingEvent = false; |
196 dispatchEvent(FontFaceSetLoadEvent::createForFontFaces(EventTypeNames::l oading)); | 199 dispatchEvent(FontFaceSetLoadEvent::createForFontFaces(EventTypeNames::l oading)); |
197 } | 200 } |
198 } | 201 } |
199 | 202 |
200 void FontFaceSet::suspend() | 203 void FontFaceSet::suspend() |
201 { | 204 { |
202 m_asyncRunner.suspend(); | 205 m_asyncRunner->suspend(); |
203 } | 206 } |
204 | 207 |
205 void FontFaceSet::resume() | 208 void FontFaceSet::resume() |
206 { | 209 { |
207 m_asyncRunner.resume(); | 210 m_asyncRunner->resume(); |
208 } | 211 } |
209 | 212 |
210 void FontFaceSet::stop() | 213 void FontFaceSet::stop() |
211 { | 214 { |
212 m_asyncRunner.stop(); | 215 m_asyncRunner->stop(); |
213 } | 216 } |
214 | 217 |
215 void FontFaceSet::beginFontLoading(FontFace* fontFace) | 218 void FontFaceSet::beginFontLoading(FontFace* fontFace) |
216 { | 219 { |
217 m_histogram.incrementCount(); | 220 m_histogram.incrementCount(); |
218 addToLoadingFonts(fontFace); | 221 addToLoadingFonts(fontFace); |
219 } | 222 } |
220 | 223 |
221 void FontFaceSet::fontLoaded(FontFace* fontFace) | 224 void FontFaceSet::fontLoaded(FontFace* fontFace) |
222 { | 225 { |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
532 } | 535 } |
533 | 536 |
534 DEFINE_TRACE(FontFaceSet) | 537 DEFINE_TRACE(FontFaceSet) |
535 { | 538 { |
536 #if ENABLE(OILPAN) | 539 #if ENABLE(OILPAN) |
537 visitor->trace(m_ready); | 540 visitor->trace(m_ready); |
538 visitor->trace(m_loadingFonts); | 541 visitor->trace(m_loadingFonts); |
539 visitor->trace(m_loadedFonts); | 542 visitor->trace(m_loadedFonts); |
540 visitor->trace(m_failedFonts); | 543 visitor->trace(m_failedFonts); |
541 visitor->trace(m_nonCSSConnectedFaces); | 544 visitor->trace(m_nonCSSConnectedFaces); |
545 visitor->trace(m_asyncRunner); | |
542 HeapSupplement<Document>::trace(visitor); | 546 HeapSupplement<Document>::trace(visitor); |
543 #endif | 547 #endif |
544 EventTargetWithInlineData::trace(visitor); | 548 EventTargetWithInlineData::trace(visitor); |
545 ActiveDOMObject::trace(visitor); | 549 ActiveDOMObject::trace(visitor); |
546 } | 550 } |
547 | 551 |
548 } // namespace blink | 552 } // namespace blink |
OLD | NEW |