OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2011 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 source->setFontFace(this); | 60 source->setFontFace(this); |
61 m_sources.append(source); | 61 m_sources.append(source); |
62 } | 62 } |
63 | 63 |
64 void CSSFontFace::setSegmentedFontFace(CSSSegmentedFontFace* segmentedFontFace) | 64 void CSSFontFace::setSegmentedFontFace(CSSSegmentedFontFace* segmentedFontFace) |
65 { | 65 { |
66 ASSERT(!m_segmentedFontFace); | 66 ASSERT(!m_segmentedFontFace); |
67 m_segmentedFontFace = segmentedFontFace; | 67 m_segmentedFontFace = segmentedFontFace; |
68 } | 68 } |
69 | 69 |
| 70 void CSSFontFace::beginLoadingFontSoon(FontResource* resource) |
| 71 { |
| 72 if (!m_segmentedFontFace) |
| 73 return; |
| 74 |
| 75 CSSFontSelector* fontSelector = m_segmentedFontFace->fontSelector(); |
| 76 fontSelector->beginLoadingFontSoon(resource); |
| 77 |
| 78 if (m_loadState == NotLoaded) |
| 79 setLoadState(Loading); |
| 80 } |
| 81 |
70 void CSSFontFace::fontLoaded(CSSFontFaceSource* source) | 82 void CSSFontFace::fontLoaded(CSSFontFaceSource* source) |
71 { | 83 { |
72 if (source != m_activeSource) | 84 if (source != m_activeSource) |
73 return; | 85 return; |
74 | 86 |
75 // FIXME: Can we assert that m_segmentedFontFace is non-null? That may | 87 // FIXME: Can we assert that m_segmentedFontFace is non-null? That may |
76 // require stopping in-progress font loading when the last | 88 // require stopping in-progress font loading when the last |
77 // CSSSegmentedFontFace is removed. | 89 // CSSSegmentedFontFace is removed. |
78 if (!m_segmentedFontFace) | 90 if (!m_segmentedFontFace) |
79 return; | 91 return; |
(...skipping 13 matching lines...) Expand all Loading... |
93 | 105 |
94 PassRefPtr<SimpleFontData> CSSFontFace::getFontData(const FontDescription& fontD
escription, bool syntheticBold, bool syntheticItalic) | 106 PassRefPtr<SimpleFontData> CSSFontFace::getFontData(const FontDescription& fontD
escription, bool syntheticBold, bool syntheticItalic) |
95 { | 107 { |
96 m_activeSource = 0; | 108 m_activeSource = 0; |
97 if (!isValid()) | 109 if (!isValid()) |
98 return 0; | 110 return 0; |
99 | 111 |
100 ASSERT(m_segmentedFontFace); | 112 ASSERT(m_segmentedFontFace); |
101 CSSFontSelector* fontSelector = m_segmentedFontFace->fontSelector(); | 113 CSSFontSelector* fontSelector = m_segmentedFontFace->fontSelector(); |
102 | 114 |
103 if (m_loadState == NotLoaded) | |
104 setLoadState(Loading); | |
105 | |
106 size_t size = m_sources.size(); | 115 size_t size = m_sources.size(); |
107 for (size_t i = 0; i < size; ++i) { | 116 for (size_t i = 0; i < size; ++i) { |
108 if (RefPtr<SimpleFontData> result = m_sources[i]->getFontData(fontDescri
ption, syntheticBold, syntheticItalic, fontSelector)) { | 117 if (RefPtr<SimpleFontData> result = m_sources[i]->getFontData(fontDescri
ption, syntheticBold, syntheticItalic, fontSelector)) { |
109 m_activeSource = m_sources[i].get(); | 118 m_activeSource = m_sources[i].get(); |
| 119 if (m_loadState == NotLoaded && (m_sources[i]->isLoading() || m_sour
ces[i]->isLoaded())) |
| 120 setLoadState(Loading); |
110 if (m_loadState == Loading && m_sources[i]->isLoaded()) | 121 if (m_loadState == Loading && m_sources[i]->isLoaded()) |
111 setLoadState(Loaded); | 122 setLoadState(Loaded); |
112 return result.release(); | 123 return result.release(); |
113 } | 124 } |
114 } | 125 } |
115 | 126 |
| 127 if (m_loadState == NotLoaded) |
| 128 setLoadState(Loading); |
116 if (m_loadState == Loading) | 129 if (m_loadState == Loading) |
117 setLoadState(Error); | 130 setLoadState(Error); |
118 return 0; | 131 return 0; |
119 } | 132 } |
120 | 133 |
121 void CSSFontFace::willUseFontData(const FontDescription& fontDescription) | 134 void CSSFontFace::willUseFontData(const FontDescription& fontDescription) |
122 { | 135 { |
123 if (m_loadState != NotLoaded) | 136 if (m_loadState != NotLoaded) |
124 return; | 137 return; |
125 | 138 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 size_t size = m_sources.size(); | 178 size_t size = m_sources.size(); |
166 for (size_t i = 0; i < size; i++) { | 179 for (size_t i = 0; i < size; i++) { |
167 if (m_sources[i]->isSVGFontFaceSource()) | 180 if (m_sources[i]->isSVGFontFaceSource()) |
168 return true; | 181 return true; |
169 } | 182 } |
170 return false; | 183 return false; |
171 } | 184 } |
172 #endif | 185 #endif |
173 | 186 |
174 } | 187 } |
OLD | NEW |