Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/FontFace.cpp |
| diff --git a/third_party/WebKit/Source/core/css/FontFace.cpp b/third_party/WebKit/Source/core/css/FontFace.cpp |
| index f199686ac84782f0a69d487cd8a31fb09e8d7d5d..dcfa68daeb42b211e0bb9a845b868b839b9b116e 100644 |
| --- a/third_party/WebKit/Source/core/css/FontFace.cpp |
| +++ b/third_party/WebKit/Source/core/css/FontFace.cpp |
| @@ -54,12 +54,14 @@ |
| #include "core/dom/Document.h" |
| #include "core/dom/ExceptionCode.h" |
| #include "core/dom/StyleEngine.h" |
| +#include "core/dom/TaskRunnerHelper.h" |
| #include "core/frame/LocalFrame.h" |
| #include "core/frame/Settings.h" |
| #include "core/frame/UseCounter.h" |
| #include "platform/FontFamilyNames.h" |
| #include "platform/Histogram.h" |
| #include "platform/SharedBuffer.h" |
| +#include "platform/WebTaskRunner.h" |
| namespace blink { |
| @@ -352,20 +354,34 @@ void FontFace::setLoadStatus(LoadStatusType status) { |
| if (m_status == Loaded || m_status == Error) { |
| if (m_loadedProperty) { |
| - if (m_status == Loaded) |
| - m_loadedProperty->resolve(this); |
| - else |
| + if (m_status == Loaded) { |
|
jbroman
2017/01/12 18:40:46
Would you mind adding a comment explaining why thi
adithyas
2017/01/13 16:08:39
Added a comment.
|
| + getTaskRunner()->postTask( |
| + BLINK_FROM_HERE, WTF::bind(&LoadedProperty::resolve<FontFace*>, |
| + wrapPersistent(m_loadedProperty.get()), |
| + wrapPersistent(this))); |
| + } else |
| m_loadedProperty->reject(m_error.get()); |
| } |
| - HeapVector<Member<LoadFontCallback>> callbacks; |
| - m_callbacks.swap(callbacks); |
| - for (size_t i = 0; i < callbacks.size(); ++i) { |
| - if (m_status == Loaded) |
| - callbacks[i]->notifyLoaded(this); |
| - else |
| - callbacks[i]->notifyError(this); |
| - } |
| + getTaskRunner()->postTask( |
| + BLINK_FROM_HERE, |
| + WTF::bind(&FontFace::runCallbacks, wrapPersistent(this))); |
| + } |
| +} |
| + |
| +WebTaskRunner* FontFace::getTaskRunner() { |
| + return TaskRunnerHelper::get(TaskType::DOMManipulation, getExecutionContext()) |
| + .get(); |
| +} |
| + |
| +void FontFace::runCallbacks() { |
| + HeapVector<Member<LoadFontCallback>> callbacks; |
| + m_callbacks.swap(callbacks); |
| + for (size_t i = 0; i < callbacks.size(); ++i) { |
| + if (m_status == Loaded) |
| + callbacks[i]->notifyLoaded(this); |
| + else |
| + callbacks[i]->notifyError(this); |
| } |
| } |