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 19 matching lines...) Expand all Loading... |
30 #include "core/css/CSSFontSelector.h" | 30 #include "core/css/CSSFontSelector.h" |
31 #include "core/css/CSSSegmentedFontFace.h" | 31 #include "core/css/CSSSegmentedFontFace.h" |
32 #include "core/css/FontLoader.h" | 32 #include "core/css/FontLoader.h" |
33 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
34 #include "RuntimeEnabledFeatures.h" | 34 #include "RuntimeEnabledFeatures.h" |
35 #include "core/platform/graphics/FontDescription.h" | 35 #include "core/platform/graphics/FontDescription.h" |
36 #include "core/platform/graphics/SimpleFontData.h" | 36 #include "core/platform/graphics/SimpleFontData.h" |
37 | 37 |
38 namespace WebCore { | 38 namespace WebCore { |
39 | 39 |
| 40 DEFINE_GC_TYPE_MARKER(CSSFontFace); |
| 41 |
40 bool CSSFontFace::isLoaded() const | 42 bool CSSFontFace::isLoaded() const |
41 { | 43 { |
42 size_t size = m_sources.size(); | 44 size_t size = m_sources.size(); |
43 for (size_t i = 0; i < size; i++) { | 45 for (size_t i = 0; i < size; i++) { |
44 if (!m_sources[i]->isLoaded()) | 46 if (!m_sources[i]->isLoaded()) |
45 return false; | 47 return false; |
46 } | 48 } |
47 return true; | 49 return true; |
48 } | 50 } |
49 | 51 |
50 bool CSSFontFace::isValid() const | 52 bool CSSFontFace::isValid() const |
51 { | 53 { |
52 size_t size = m_sources.size(); | 54 size_t size = m_sources.size(); |
53 for (size_t i = 0; i < size; i++) { | 55 for (size_t i = 0; i < size; i++) { |
54 if (m_sources[i]->isValid()) | 56 if (m_sources[i]->isValid()) |
55 return true; | 57 return true; |
56 } | 58 } |
57 return false; | 59 return false; |
58 } | 60 } |
59 | 61 |
60 void CSSFontFace::addedToSegmentedFontFace(CSSSegmentedFontFace* segmentedFontFa
ce) | 62 void CSSFontFace::addedToSegmentedFontFace(Handle<CSSSegmentedFontFace> segmente
dFontFace) |
61 { | 63 { |
62 m_segmentedFontFaces.add(segmentedFontFace); | 64 m_segmentedFontFaces.add(segmentedFontFace); |
63 } | 65 } |
64 | 66 |
65 void CSSFontFace::removedFromSegmentedFontFace(CSSSegmentedFontFace* segmentedFo
ntFace) | |
66 { | |
67 m_segmentedFontFaces.remove(segmentedFontFace); | |
68 } | |
69 | |
70 void CSSFontFace::addSource(PassOwnPtr<CSSFontFaceSource> source) | 67 void CSSFontFace::addSource(PassOwnPtr<CSSFontFaceSource> source) |
71 { | 68 { |
72 source->setFontFace(this); | 69 source->setFontFace(Handle<CSSFontFace>(this)); |
73 m_sources.append(source); | 70 m_sources.append(source); |
74 } | 71 } |
75 | 72 |
76 void CSSFontFace::fontLoaded(CSSFontFaceSource* source) | 73 void CSSFontFace::fontLoaded(CSSFontFaceSource* source) |
77 { | 74 { |
78 if (source != m_activeSource) | 75 if (source != m_activeSource) |
79 return; | 76 return; |
80 | 77 |
81 // FIXME: Can we assert that m_segmentedFontFaces is not empty? That may | 78 // FIXME: Can we assert that m_segmentedFontFaces is not empty? That may |
82 // require stopping in-progress font loading when the last | 79 // require stopping in-progress font loading when the last |
83 // CSSSegmentedFontFace is removed. | 80 // CSSSegmentedFontFace is removed. |
84 if (m_segmentedFontFaces.isEmpty()) | 81 if (m_segmentedFontFaces.isEmpty()) |
85 return; | 82 return; |
86 | 83 |
87 // Use one of the CSSSegmentedFontFaces' font selector. They all have | 84 // Use one of the CSSSegmentedFontFaces' font selector. They all have |
88 // the same font selector, so it's wasteful to store it in the CSSFontFace. | 85 // the same font selector, so it's wasteful to store it in the CSSFontFace. |
89 CSSFontSelector* fontSelector = (*m_segmentedFontFaces.begin())->fontSelecto
r(); | 86 CSSFontSelector* fontSelector = (*m_segmentedFontFaces.begin())->fontSelecto
r(); |
90 fontSelector->fontLoaded(); | 87 fontSelector->fontLoaded(); |
91 | 88 |
92 if (RuntimeEnabledFeatures::fontLoadEventsEnabled() && m_loadState == Loadin
g) { | 89 if (RuntimeEnabledFeatures::fontLoadEventsEnabled() && m_loadState == Loadin
g) { |
93 if (source->ensureFontData()) | 90 if (source->ensureFontData()) |
94 notifyFontLoader(Loaded); | 91 notifyFontLoader(Loaded); |
95 else if (!isValid()) | 92 else if (!isValid()) |
96 notifyFontLoader(Error); | 93 notifyFontLoader(Error); |
97 } | 94 } |
98 | 95 |
99 HashSet<CSSSegmentedFontFace*>::iterator end = m_segmentedFontFaces.end(); | 96 HashSet<Member<CSSSegmentedFontFace> >::iterator end = m_segmentedFontFaces.
end(); |
100 for (HashSet<CSSSegmentedFontFace*>::iterator it = m_segmentedFontFaces.begi
n(); it != end; ++it) | 97 for (HashSet<Member<CSSSegmentedFontFace> >::iterator it = m_segmentedFontFa
ces.begin(); it != end; ++it) |
101 (*it)->fontLoaded(this); | 98 (*it)->fontLoaded(Handle<CSSFontFace>(this)); |
102 } | 99 } |
103 | 100 |
104 PassRefPtr<SimpleFontData> CSSFontFace::getFontData(const FontDescription& fontD
escription, bool syntheticBold, bool syntheticItalic) | 101 PassRefPtr<SimpleFontData> CSSFontFace::getFontData(const FontDescription& fontD
escription, bool syntheticBold, bool syntheticItalic) |
105 { | 102 { |
106 m_activeSource = 0; | 103 m_activeSource = 0; |
107 if (!isValid()) | 104 if (!isValid()) |
108 return 0; | 105 return 0; |
109 | 106 |
110 ASSERT(!m_segmentedFontFaces.isEmpty()); | 107 ASSERT(!m_segmentedFontFaces.isEmpty()); |
111 CSSFontSelector* fontSelector = (*m_segmentedFontFaces.begin())->fontSelecto
r(); | 108 CSSFontSelector* fontSelector = (*m_segmentedFontFaces.begin())->fontSelecto
r(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 { | 153 { |
157 size_t size = m_sources.size(); | 154 size_t size = m_sources.size(); |
158 for (size_t i = 0; i < size; i++) { | 155 for (size_t i = 0; i < size; i++) { |
159 if (m_sources[i]->isSVGFontFaceSource()) | 156 if (m_sources[i]->isSVGFontFaceSource()) |
160 return true; | 157 return true; |
161 } | 158 } |
162 return false; | 159 return false; |
163 } | 160 } |
164 #endif | 161 #endif |
165 | 162 |
| 163 void CSSFontFace::accept(Visitor* visitor) const |
| 164 { |
| 165 visitor->visit(m_rule); |
| 166 visitor->visit(m_segmentedFontFaces); |
166 } | 167 } |
| 168 |
| 169 } |
OLD | NEW |