OLD | NEW |
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 28 matching lines...) Expand all Loading... |
39 | 39 |
40 DEFINE_GC_TYPE_MARKER(CSSSegmentedFontFace); | 40 DEFINE_GC_TYPE_MARKER(CSSSegmentedFontFace); |
41 | 41 |
42 CSSSegmentedFontFace::CSSSegmentedFontFace(CSSFontSelector* fontSelector) | 42 CSSSegmentedFontFace::CSSSegmentedFontFace(CSSFontSelector* fontSelector) |
43 : m_fontSelector(fontSelector) | 43 : m_fontSelector(fontSelector) |
44 { | 44 { |
45 } | 45 } |
46 | 46 |
47 CSSSegmentedFontFace::~CSSSegmentedFontFace() | 47 CSSSegmentedFontFace::~CSSSegmentedFontFace() |
48 { | 48 { |
49 dispose(); | 49 pruneTable(); |
50 } | 50 } |
51 | 51 |
| 52 // FIXME(oilpan): Move CSSFontFaceSource and CSSFontSelector to the managed heap
. |
| 53 // Then all of CSSFontSelector, CSSSegmentedFontFace, CSSFontFace and CSSFontFac
eSource |
| 54 // die in the same round of GC, and thus we don't need to call dispose(). |
52 void CSSSegmentedFontFace::dispose() | 55 void CSSSegmentedFontFace::dispose() |
53 { | 56 { |
54 pruneTable(); | 57 pruneTable(); |
55 unsigned size = m_fontFaces.size(); | 58 unsigned size = m_fontFaces.size(); |
56 for (unsigned i = 0; i < size; i++) | 59 for (unsigned i = 0; i < size; i++) |
57 m_fontFaces[i]->removedFromSegmentedFontFace(Handle<CSSSegmentedFontFace
>(this)); | 60 m_fontFaces[i]->dispose(); |
58 m_fontFaces.clear(); | |
59 m_fontSelector = 0; | 61 m_fontSelector = 0; |
60 } | 62 } |
61 | 63 |
62 void CSSSegmentedFontFace::pruneTable() | 64 void CSSSegmentedFontFace::pruneTable() |
63 { | 65 { |
64 // Make sure the glyph page tree prunes out all uses of this custom font. | 66 // Make sure the glyph page tree prunes out all uses of this custom font. |
65 if (m_fontDataTable.isEmpty()) | 67 if (m_fontDataTable.isEmpty()) |
66 return; | 68 return; |
67 | 69 |
68 m_fontDataTable.clear(); | 70 m_fontDataTable.clear(); |
69 } | 71 } |
70 | 72 |
71 bool CSSSegmentedFontFace::isValid() const | 73 bool CSSSegmentedFontFace::isValid() const |
72 { | 74 { |
73 // Valid if at least one font face is valid. | 75 // Valid if at least one font face is valid. |
74 unsigned size = m_fontFaces.size(); | 76 unsigned size = m_fontFaces.size(); |
75 for (unsigned i = 0; i < size; i++) { | 77 for (unsigned i = 0; i < size; i++) { |
76 if (m_fontFaces[i]->isValid()) | 78 if (m_fontFaces[i]->isValid()) |
77 return true; | 79 return true; |
78 } | 80 } |
79 return false; | 81 return false; |
80 } | 82 } |
81 | 83 |
82 void CSSSegmentedFontFace::fontLoaded(CSSFontFace*) | 84 void CSSSegmentedFontFace::fontLoaded(Handle<CSSFontFace>) |
83 { | 85 { |
84 pruneTable(); | 86 pruneTable(); |
85 | 87 |
86 if (RuntimeEnabledFeatures::fontLoadEventsEnabled() && !isLoading()) { | 88 if (RuntimeEnabledFeatures::fontLoadEventsEnabled() && !isLoading()) { |
87 Vector<RefPtr<LoadFontCallback> > callbacks; | 89 Vector<RefPtr<LoadFontCallback> > callbacks; |
88 m_callbacks.swap(callbacks); | 90 m_callbacks.swap(callbacks); |
89 for (size_t index = 0; index < callbacks.size(); ++index) { | 91 for (size_t index = 0; index < callbacks.size(); ++index) { |
90 if (checkFont()) | 92 if (checkFont()) |
91 callbacks[index]->notifyLoaded(Handle<CSSSegmentedFontFace>(this
)); | 93 callbacks[index]->notifyLoaded(Handle<CSSSegmentedFontFace>(this
)); |
92 else | 94 else |
93 callbacks[index]->notifyError(Handle<CSSSegmentedFontFace>(this)
); | 95 callbacks[index]->notifyError(Handle<CSSSegmentedFontFace>(this)
); |
94 } | 96 } |
95 } | 97 } |
96 } | 98 } |
97 | 99 |
98 void CSSSegmentedFontFace::appendFontFace(PassRefPtr<CSSFontFace> fontFace) | 100 void CSSSegmentedFontFace::appendFontFace(Handle<CSSFontFace> fontFace) |
99 { | 101 { |
100 pruneTable(); | 102 pruneTable(); |
101 fontFace->addedToSegmentedFontFace(Handle<CSSSegmentedFontFace>(this)); | 103 fontFace->addedToSegmentedFontFace(Handle<CSSSegmentedFontFace>(this)); |
102 m_fontFaces.append(fontFace); | 104 m_fontFaces.append(fontFace); |
103 } | 105 } |
104 | 106 |
105 static void appendFontDataWithInvalidUnicodeRangeIfLoading(SegmentedFontData* ne
wFontData, PassRefPtr<SimpleFontData> prpFaceFontData, const Vector<CSSFontFace:
:UnicodeRange>& ranges) | 107 static void appendFontDataWithInvalidUnicodeRangeIfLoading(SegmentedFontData* ne
wFontData, PassRefPtr<SimpleFontData> prpFaceFontData, const Vector<CSSFontFace:
:UnicodeRange>& ranges) |
106 { | 108 { |
107 RefPtr<SimpleFontData> faceFontData = prpFaceFontData; | 109 RefPtr<SimpleFontData> faceFontData = prpFaceFontData; |
108 if (faceFontData->isLoading()) { | 110 if (faceFontData->isLoading()) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 if (callback) { | 185 if (callback) { |
184 if (isLoading()) | 186 if (isLoading()) |
185 m_callbacks.append(callback); | 187 m_callbacks.append(callback); |
186 else if (checkFont()) | 188 else if (checkFont()) |
187 callback->notifyLoaded(Handle<CSSSegmentedFontFace>(this)); | 189 callback->notifyLoaded(Handle<CSSSegmentedFontFace>(this)); |
188 else | 190 else |
189 callback->notifyError(Handle<CSSSegmentedFontFace>(this)); | 191 callback->notifyError(Handle<CSSSegmentedFontFace>(this)); |
190 } | 192 } |
191 } | 193 } |
192 | 194 |
| 195 void CSSSegmentedFontFace::accept(Visitor* visitor) const |
| 196 { |
| 197 visitor->visit(m_fontFaces); |
193 } | 198 } |
| 199 |
| 200 } |
OLD | NEW |