Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(550)

Unified Diff: third_party/WebKit/Source/core/css/CSSFontFace.cpp

Issue 2610593002: Make CSSFontFace::setLoadStatus post a task (Closed)
Patch Set: Change loading logic for fonts from array buffers Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/CSSFontFace.cpp
diff --git a/third_party/WebKit/Source/core/css/CSSFontFace.cpp b/third_party/WebKit/Source/core/css/CSSFontFace.cpp
index e46ce5bbf3c7f5f4218a613e52a500cb83e4e4f2..5c676beb5d23b2148644e301698bd4f52ecb9010 100644
--- a/third_party/WebKit/Source/core/css/CSSFontFace.cpp
+++ b/third_party/WebKit/Source/core/css/CSSFontFace.cpp
@@ -30,7 +30,9 @@
#include "core/css/CSSSegmentedFontFace.h"
#include "core/css/FontFaceSet.h"
#include "core/css/RemoteFontFaceSource.h"
+#include "core/dom/TaskRunnerHelper.h"
#include "core/frame/UseCounter.h"
+#include "platform/WebTaskRunner.h"
#include "platform/fonts/FontDescription.h"
#include "platform/fonts/SimpleFontData.h"
#include <algorithm>
@@ -175,19 +177,33 @@ void CSSFontFace::load(const FontDescription& fontDescription) {
}
void CSSFontFace::setLoadStatus(FontFace::LoadStatusType newStatus) {
- ASSERT(m_fontFace);
- if (newStatus == FontFace::Error)
- m_fontFace->setError();
- else
+ DCHECK(m_fontFace);
+ m_loadStatus = newStatus;
+ if (newStatus == FontFace::Loading) {
m_fontFace->setLoadStatus(newStatus);
+ } else {
+ TaskRunnerHelper::get(TaskType::DOMManipulation,
+ m_fontFace->getExecutionContext())
+ ->postTask(BLINK_FROM_HERE, WTF::bind(&CSSFontFace::setLoadStatusHelper,
+ wrapPersistent(this), newStatus));
+ return;
+ }
if (!m_segmentedFontFace)
jbroman 2017/01/05 20:01:08 nit: it's a little confusing that stuff that only
return;
Document* document = m_segmentedFontFace->fontSelector()->document();
- if (document && newStatus == FontFace::Loading)
+ if (document)
FontFaceSet::from(*document)->beginFontLoading(m_fontFace);
}
+void CSSFontFace::setLoadStatusHelper(FontFace::LoadStatusType newStatus) {
+ DCHECK(m_fontFace);
+ if (newStatus == FontFace::Error)
+ m_fontFace->setError();
+ else
+ m_fontFace->setLoadStatus(newStatus);
+}
+
DEFINE_TRACE(CSSFontFace) {
visitor->trace(m_segmentedFontFace);
visitor->trace(m_sources);

Powered by Google App Engine
This is Rietveld 408576698