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

Side by Side Diff: third_party/WebKit/Source/core/css/FontFace.cpp

Issue 2610593002: Make CSSFontFace::setLoadStatus post a task (Closed)
Patch Set: Revert changes to CSSFontFace and post task in FontFace 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/css/fontface-properties.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "core/css/RemoteFontFaceSource.h" 47 #include "core/css/RemoteFontFaceSource.h"
48 #include "core/css/StylePropertySet.h" 48 #include "core/css/StylePropertySet.h"
49 #include "core/css/StyleRule.h" 49 #include "core/css/StyleRule.h"
50 #include "core/css/parser/CSSParser.h" 50 #include "core/css/parser/CSSParser.h"
51 #include "core/dom/DOMArrayBuffer.h" 51 #include "core/dom/DOMArrayBuffer.h"
52 #include "core/dom/DOMArrayBufferView.h" 52 #include "core/dom/DOMArrayBufferView.h"
53 #include "core/dom/DOMException.h" 53 #include "core/dom/DOMException.h"
54 #include "core/dom/Document.h" 54 #include "core/dom/Document.h"
55 #include "core/dom/ExceptionCode.h" 55 #include "core/dom/ExceptionCode.h"
56 #include "core/dom/StyleEngine.h" 56 #include "core/dom/StyleEngine.h"
57 #include "core/dom/TaskRunnerHelper.h"
57 #include "core/frame/LocalFrame.h" 58 #include "core/frame/LocalFrame.h"
58 #include "core/frame/Settings.h" 59 #include "core/frame/Settings.h"
59 #include "core/frame/UseCounter.h" 60 #include "core/frame/UseCounter.h"
60 #include "platform/FontFamilyNames.h" 61 #include "platform/FontFamilyNames.h"
61 #include "platform/Histogram.h" 62 #include "platform/Histogram.h"
62 #include "platform/SharedBuffer.h" 63 #include "platform/SharedBuffer.h"
64 #include "platform/WebTaskRunner.h"
63 65
64 namespace blink { 66 namespace blink {
65 67
66 static const CSSValue* parseCSSValue(const Document* document, 68 static const CSSValue* parseCSSValue(const Document* document,
67 const String& value, 69 const String& value,
68 CSSPropertyID propertyID) { 70 CSSPropertyID propertyID) {
69 CSSParserContext context(*document, UseCounter::getFrom(document)); 71 CSSParserContext context(*document, UseCounter::getFrom(document));
70 return CSSParser::parseFontFaceDescriptor(propertyID, value, context); 72 return CSSParser::parseFontFaceDescriptor(propertyID, value, context);
71 } 73 }
72 74
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 } 347 }
346 return emptyString(); 348 return emptyString();
347 } 349 }
348 350
349 void FontFace::setLoadStatus(LoadStatusType status) { 351 void FontFace::setLoadStatus(LoadStatusType status) {
350 m_status = status; 352 m_status = status;
351 ASSERT(m_status != Error || m_error); 353 ASSERT(m_status != Error || m_error);
352 354
353 if (m_status == Loaded || m_status == Error) { 355 if (m_status == Loaded || m_status == Error) {
354 if (m_loadedProperty) { 356 if (m_loadedProperty) {
355 if (m_status == Loaded) 357 if (m_status == Loaded) {
356 m_loadedProperty->resolve(this); 358 TaskRunnerHelper::get(TaskType::DOMManipulation, getExecutionContext())
357 else 359 ->postTask(BLINK_FROM_HERE,
360 WTF::bind(&LoadedProperty::resolve<FontFace*>,
361 wrapPersistent(m_loadedProperty.get()),
362 wrapPersistent(this)));
363 } else
358 m_loadedProperty->reject(m_error.get()); 364 m_loadedProperty->reject(m_error.get());
Kunihiko Sakamoto 2017/01/10 06:02:12 Need to post a task for rejection too?
adithyas 2017/01/10 17:52:46 Rejection is always asynchronous so we don't have
Kunihiko Sakamoto 2017/01/11 05:25:45 Ah interesting, didn't know that.
adithyas 2017/01/11 17:59:39 Technically, resolution is also always asynchronou
359 } 365 }
360 366
361 HeapVector<Member<LoadFontCallback>> callbacks; 367 HeapVector<Member<LoadFontCallback>> callbacks;
362 m_callbacks.swap(callbacks); 368 m_callbacks.swap(callbacks);
363 for (size_t i = 0; i < callbacks.size(); ++i) { 369 for (size_t i = 0; i < callbacks.size(); ++i) {
364 if (m_status == Loaded) 370 if (m_status == Loaded)
365 callbacks[i]->notifyLoaded(this); 371 callbacks[i]->notifyLoaded(this);
Kunihiko Sakamoto 2017/01/10 06:02:12 This may resolve a promise (that is created by Fon
adithyas 2017/01/10 17:52:46 FontFaceSet uses an AsyncMethodRunner to resolve t
Kunihiko Sakamoto 2017/01/11 05:25:45 FontFaceSet::notifyLoaded() is OK, but LoadFontPro
adithyas 2017/01/11 17:59:39 Ahh okay, I've changed it to run the callbacks in
366 else 372 else
367 callbacks[i]->notifyError(this); 373 callbacks[i]->notifyError(this);
368 } 374 }
369 } 375 }
370 } 376 }
371 377
372 void FontFace::setError(DOMException* error) { 378 void FontFace::setError(DOMException* error) {
373 if (!m_error) 379 if (!m_error)
374 m_error = error ? error : DOMException::create(NetworkError); 380 m_error = error ? error : DOMException::create(NetworkError);
375 setLoadStatus(Error); 381 setLoadStatus(Error);
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 646
641 bool FontFace::hadBlankText() const { 647 bool FontFace::hadBlankText() const {
642 return m_cssFontFace->hadBlankText(); 648 return m_cssFontFace->hadBlankText();
643 } 649 }
644 650
645 bool FontFace::hasPendingActivity() const { 651 bool FontFace::hasPendingActivity() const {
646 return m_status == Loading && getExecutionContext(); 652 return m_status == Loading && getExecutionContext();
647 } 653 }
648 654
649 } // namespace blink 655 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/css/fontface-properties.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698