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

Side by Side Diff: third_party/WebKit/Source/core/css/FontFace.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 unified diff | Download patch
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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 default: 343 default:
344 NOTREACHED(); 344 NOTREACHED();
345 } 345 }
346 return emptyString(); 346 return emptyString();
347 } 347 }
348 348
349 void FontFace::setLoadStatus(LoadStatusType status) { 349 void FontFace::setLoadStatus(LoadStatusType status) {
350 m_status = status; 350 m_status = status;
351 ASSERT(m_status != Error || m_error); 351 ASSERT(m_status != Error || m_error);
352 352
353 if (m_status == Loaded || m_status == Error) { 353 if (m_status == Loaded || m_status == Error) {
Kunihiko Sakamoto 2017/01/06 07:05:47 Having load status in both FontFace and CSSFontFac
adithyas 2017/01/06 14:56:13 SGTM, but this would mean that there would be a de
Kunihiko Sakamoto 2017/01/10 06:02:12 Yeah ideally we should change the status inside th
354 if (m_loadedProperty) { 354 if (m_loadedProperty) {
355 if (m_status == Loaded) 355 if (m_status == Loaded)
356 m_loadedProperty->resolve(this); 356 m_loadedProperty->resolve(this);
357 else 357 else
358 m_loadedProperty->reject(m_error.get()); 358 m_loadedProperty->reject(m_error.get());
359 } 359 }
360 360
361 HeapVector<Member<LoadFontCallback>> callbacks; 361 HeapVector<Member<LoadFontCallback>> callbacks;
362 m_callbacks.swap(callbacks); 362 m_callbacks.swap(callbacks);
363 for (size_t i = 0; i < callbacks.size(); ++i) { 363 for (size_t i = 0; i < callbacks.size(); ++i) {
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 } 608 }
609 609
610 void FontFace::initCSSFontFace(const unsigned char* data, size_t size) { 610 void FontFace::initCSSFontFace(const unsigned char* data, size_t size) {
611 m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get()); 611 m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get());
612 if (m_error) 612 if (m_error)
613 return; 613 return;
614 614
615 RefPtr<SharedBuffer> buffer = SharedBuffer::create(data, size); 615 RefPtr<SharedBuffer> buffer = SharedBuffer::create(data, size);
616 BinaryDataFontFaceSource* source = 616 BinaryDataFontFaceSource* source =
617 new BinaryDataFontFaceSource(buffer.get(), m_otsParseMessage); 617 new BinaryDataFontFaceSource(buffer.get(), m_otsParseMessage);
618 if (source->isValid()) 618 if (source->isValid()) {
619 setLoadStatus(Loaded); 619 m_cssFontFace->setLoadStatus(Loading);
620 else 620 m_cssFontFace->setLoadStatus(Loaded);
621 } else
621 setError( 622 setError(
622 DOMException::create(SyntaxError, "Invalid font data in ArrayBuffer.")); 623 DOMException::create(SyntaxError, "Invalid font data in ArrayBuffer."));
623 m_cssFontFace->addSource(source); 624 m_cssFontFace->addSource(source);
624 } 625 }
625 626
626 DEFINE_TRACE(FontFace) { 627 DEFINE_TRACE(FontFace) {
627 visitor->trace(m_style); 628 visitor->trace(m_style);
628 visitor->trace(m_weight); 629 visitor->trace(m_weight);
629 visitor->trace(m_stretch); 630 visitor->trace(m_stretch);
630 visitor->trace(m_unicodeRange); 631 visitor->trace(m_unicodeRange);
631 visitor->trace(m_variant); 632 visitor->trace(m_variant);
632 visitor->trace(m_featureSettings); 633 visitor->trace(m_featureSettings);
633 visitor->trace(m_display); 634 visitor->trace(m_display);
634 visitor->trace(m_error); 635 visitor->trace(m_error);
635 visitor->trace(m_loadedProperty); 636 visitor->trace(m_loadedProperty);
636 visitor->trace(m_cssFontFace); 637 visitor->trace(m_cssFontFace);
637 visitor->trace(m_callbacks); 638 visitor->trace(m_callbacks);
638 ContextClient::trace(visitor); 639 ContextClient::trace(visitor);
639 } 640 }
640 641
641 bool FontFace::hadBlankText() const { 642 bool FontFace::hadBlankText() const {
642 return m_cssFontFace->hadBlankText(); 643 return m_cssFontFace->hadBlankText();
643 } 644 }
644 645
645 bool FontFace::hasPendingActivity() const { 646 bool FontFace::hasPendingActivity() const {
646 return m_status == Loading && getExecutionContext(); 647 return m_status == Loading && getExecutionContext();
647 } 648 }
648 649
649 } // namespace blink 650 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698