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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 return SuspendableObject::GetExecutionContext(); | 151 return SuspendableObject::GetExecutionContext(); |
152 } | 152 } |
153 | 153 |
154 AtomicString FontFaceSet::status() const { | 154 AtomicString FontFaceSet::status() const { |
155 DEFINE_STATIC_LOCAL(AtomicString, loading, ("loading")); | 155 DEFINE_STATIC_LOCAL(AtomicString, loading, ("loading")); |
156 DEFINE_STATIC_LOCAL(AtomicString, loaded, ("loaded")); | 156 DEFINE_STATIC_LOCAL(AtomicString, loaded, ("loaded")); |
157 return is_loading_ ? loading : loaded; | 157 return is_loading_ ? loading : loaded; |
158 } | 158 } |
159 | 159 |
160 void FontFaceSet::HandlePendingEventsAndPromisesSoon() { | 160 void FontFaceSet::HandlePendingEventsAndPromisesSoon() { |
161 // m_asyncRunner will be automatically stopped on destruction. | 161 // async_runner_ will be automatically stopped on destruction. |
162 async_runner_->RunAsync(); | 162 async_runner_->RunAsync(); |
163 } | 163 } |
164 | 164 |
165 void FontFaceSet::DidLayout() { | 165 void FontFaceSet::DidLayout() { |
166 if (GetDocument()->GetFrame()->IsMainFrame() && loading_fonts_.IsEmpty()) | 166 if (GetDocument()->GetFrame()->IsMainFrame() && loading_fonts_.IsEmpty()) |
167 histogram_.Record(); | 167 histogram_.Record(); |
168 if (!ShouldSignalReady()) | 168 if (!ShouldSignalReady()) |
169 return; | 169 return; |
170 HandlePendingEventsAndPromisesSoon(); | 170 HandlePendingEventsAndPromisesSoon(); |
171 } | 171 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 239 |
240 void FontFaceSet::RemoveFromLoadingFonts(FontFace* font_face) { | 240 void FontFaceSet::RemoveFromLoadingFonts(FontFace* font_face) { |
241 loading_fonts_.erase(font_face); | 241 loading_fonts_.erase(font_face); |
242 if (loading_fonts_.IsEmpty()) | 242 if (loading_fonts_.IsEmpty()) |
243 HandlePendingEventsAndPromisesSoon(); | 243 HandlePendingEventsAndPromisesSoon(); |
244 } | 244 } |
245 | 245 |
246 ScriptPromise FontFaceSet::ready(ScriptState* script_state) { | 246 ScriptPromise FontFaceSet::ready(ScriptState* script_state) { |
247 if (ready_->GetState() != ReadyProperty::kPending && | 247 if (ready_->GetState() != ReadyProperty::kPending && |
248 InActiveDocumentContext()) { | 248 InActiveDocumentContext()) { |
249 // |m_ready| is already resolved, but there may be pending stylesheet | 249 // |ready_| is already resolved, but there may be pending stylesheet |
250 // changes and/or layout operations that may cause another font loads. | 250 // changes and/or layout operations that may cause another font loads. |
251 // So synchronously update style and layout here. | 251 // So synchronously update style and layout here. |
252 // This may trigger font loads, and replace |m_ready| with a new Promise. | 252 // This may trigger font loads, and replace |ready_| with a new Promise. |
253 GetDocument()->UpdateStyleAndLayout(); | 253 GetDocument()->UpdateStyleAndLayout(); |
254 } | 254 } |
255 return ready_->Promise(script_state->World()); | 255 return ready_->Promise(script_state->World()); |
256 } | 256 } |
257 | 257 |
258 FontFaceSet* FontFaceSet::addForBinding(ScriptState*, | 258 FontFaceSet* FontFaceSet::addForBinding(ScriptState*, |
259 FontFace* font_face, | 259 FontFace* font_face, |
260 ExceptionState&) { | 260 ExceptionState&) { |
261 DCHECK(font_face); | 261 DCHECK(font_face); |
262 if (!InActiveDocumentContext()) | 262 if (!InActiveDocumentContext()) |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 visitor->Trace(failed_fonts_); | 575 visitor->Trace(failed_fonts_); |
576 visitor->Trace(non_css_connected_faces_); | 576 visitor->Trace(non_css_connected_faces_); |
577 visitor->Trace(async_runner_); | 577 visitor->Trace(async_runner_); |
578 EventTargetWithInlineData::Trace(visitor); | 578 EventTargetWithInlineData::Trace(visitor); |
579 Supplement<Document>::Trace(visitor); | 579 Supplement<Document>::Trace(visitor); |
580 SuspendableObject::Trace(visitor); | 580 SuspendableObject::Trace(visitor); |
581 FontFace::LoadFontCallback::Trace(visitor); | 581 FontFace::LoadFontCallback::Trace(visitor); |
582 } | 582 } |
583 | 583 |
584 } // namespace blink | 584 } // namespace blink |
OLD | NEW |