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

Side by Side Diff: Source/core/css/CSSSegmentedFontFace.cpp

Issue 196383035: Fix promise resolution of FontFaceSet#load() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: naming Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSSegmentedFontFace.h ('k') | Source/core/css/FontFace.h » ('j') | 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) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 for (FontFaceList::const_iterator it = m_fontFaces.begin(); it != m_fontFace s.end(); ++it) { 65 for (FontFaceList::const_iterator it = m_fontFaces.begin(); it != m_fontFace s.end(); ++it) {
66 if ((*it)->cssFontFace()->isValid()) 66 if ((*it)->cssFontFace()->isValid())
67 return true; 67 return true;
68 } 68 }
69 return false; 69 return false;
70 } 70 }
71 71
72 void CSSSegmentedFontFace::fontLoaded(CSSFontFace*) 72 void CSSSegmentedFontFace::fontLoaded(CSSFontFace*)
73 { 73 {
74 pruneTable(); 74 pruneTable();
75
76 if (RuntimeEnabledFeatures::fontLoadEventsEnabled() && !isLoading()) {
77 Vector<RefPtr<LoadFontCallback> > callbacks;
78 m_callbacks.swap(callbacks);
79 for (size_t index = 0; index < callbacks.size(); ++index) {
80 if (isLoaded())
81 callbacks[index]->notifyLoaded(this);
82 else
83 callbacks[index]->notifyError(this);
84 }
85 }
86 } 75 }
87 76
88 void CSSSegmentedFontFace::fontLoadWaitLimitExceeded(CSSFontFace*) 77 void CSSSegmentedFontFace::fontLoadWaitLimitExceeded(CSSFontFace*)
89 { 78 {
90 m_fontSelector->fontLoaded(); 79 m_fontSelector->fontLoaded();
91 pruneTable(); 80 pruneTable();
92 } 81 }
93 82
94 void CSSSegmentedFontFace::addFontFace(PassRefPtr<FontFace> prpFontFace, bool cs sConnected) 83 void CSSSegmentedFontFace::addFontFace(PassRefPtr<FontFace> prpFontFace, bool cs sConnected)
95 { 84 {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 190
202 bool CSSSegmentedFontFace::checkFont(const String& text) const 191 bool CSSSegmentedFontFace::checkFont(const String& text) const
203 { 192 {
204 for (FontFaceList::const_iterator it = m_fontFaces.begin(); it != m_fontFace s.end(); ++it) { 193 for (FontFaceList::const_iterator it = m_fontFaces.begin(); it != m_fontFace s.end(); ++it) {
205 if ((*it)->loadStatus() != FontFace::Loaded && (*it)->cssFontFace()->ran ges().intersectsWith(text)) 194 if ((*it)->loadStatus() != FontFace::Loaded && (*it)->cssFontFace()->ran ges().intersectsWith(text))
206 return false; 195 return false;
207 } 196 }
208 return true; 197 return true;
209 } 198 }
210 199
211 void CSSSegmentedFontFace::loadFont(const FontDescription& fontDescription, cons t String& text, PassRefPtr<LoadFontCallback> callback) 200 void CSSSegmentedFontFace::match(const String& text, Vector<RefPtr<FontFace> >& faces) const
212 { 201 {
213 for (FontFaceList::iterator it = m_fontFaces.begin(); it != m_fontFaces.end( ); ++it) { 202 for (FontFaceList::const_iterator it = m_fontFaces.begin(); it != m_fontFace s.end(); ++it) {
214 if ((*it)->loadStatus() == FontFace::Unloaded && (*it)->cssFontFace()->r anges().intersectsWith(text)) 203 if ((*it)->cssFontFace()->ranges().intersectsWith(text))
215 (*it)->cssFontFace()->load(fontDescription); 204 faces.append(*it);
216 }
217
218 if (callback) {
219 if (isLoading())
220 m_callbacks.append(callback);
221 else if (isLoaded())
222 callback->notifyLoaded(this);
223 else
224 callback->notifyError(this);
225 } 205 }
226 } 206 }
227 207
228 } 208 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSSegmentedFontFace.h ('k') | Source/core/css/FontFace.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698