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 19 matching lines...) Expand all Loading... |
30 #include "core/css/CSSFontFaceSource.h" | 30 #include "core/css/CSSFontFaceSource.h" |
31 #include "core/css/CSSFontSelector.h" | 31 #include "core/css/CSSFontSelector.h" |
32 #include "core/dom/Document.h" | 32 #include "core/dom/Document.h" |
33 #include "RuntimeEnabledFeatures.h" | 33 #include "RuntimeEnabledFeatures.h" |
34 #include "core/platform/graphics/FontDescription.h" | 34 #include "core/platform/graphics/FontDescription.h" |
35 #include "core/platform/graphics/SegmentedFontData.h" | 35 #include "core/platform/graphics/SegmentedFontData.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(CSSSegmentedFontFace); |
| 41 |
40 CSSSegmentedFontFace::CSSSegmentedFontFace(CSSFontSelector* fontSelector) | 42 CSSSegmentedFontFace::CSSSegmentedFontFace(CSSFontSelector* fontSelector) |
41 : m_fontSelector(fontSelector) | 43 : m_fontSelector(fontSelector) |
42 { | 44 { |
43 } | 45 } |
44 | 46 |
45 CSSSegmentedFontFace::~CSSSegmentedFontFace() | 47 CSSSegmentedFontFace::~CSSSegmentedFontFace() |
46 { | 48 { |
47 pruneTable(); | 49 pruneTable(); |
48 unsigned size = m_fontFaces.size(); | 50 unsigned size = m_fontFaces.size(); |
49 for (unsigned i = 0; i < size; i++) | 51 for (unsigned i = 0; i < size; i++) |
50 m_fontFaces[i]->removedFromSegmentedFontFace(this); | 52 m_fontFaces[i]->removedFromSegmentedFontFace(Handle<CSSSegmentedFontFace
>(this)); |
51 } | 53 } |
52 | 54 |
53 void CSSSegmentedFontFace::pruneTable() | 55 void CSSSegmentedFontFace::pruneTable() |
54 { | 56 { |
55 // Make sure the glyph page tree prunes out all uses of this custom font. | 57 // Make sure the glyph page tree prunes out all uses of this custom font. |
56 if (m_fontDataTable.isEmpty()) | 58 if (m_fontDataTable.isEmpty()) |
57 return; | 59 return; |
58 | 60 |
59 m_fontDataTable.clear(); | 61 m_fontDataTable.clear(); |
60 } | 62 } |
(...skipping 11 matching lines...) Expand all Loading... |
72 | 74 |
73 void CSSSegmentedFontFace::fontLoaded(CSSFontFace*) | 75 void CSSSegmentedFontFace::fontLoaded(CSSFontFace*) |
74 { | 76 { |
75 pruneTable(); | 77 pruneTable(); |
76 | 78 |
77 if (RuntimeEnabledFeatures::fontLoadEventsEnabled() && !isLoading()) { | 79 if (RuntimeEnabledFeatures::fontLoadEventsEnabled() && !isLoading()) { |
78 Vector<RefPtr<LoadFontCallback> > callbacks; | 80 Vector<RefPtr<LoadFontCallback> > callbacks; |
79 m_callbacks.swap(callbacks); | 81 m_callbacks.swap(callbacks); |
80 for (size_t index = 0; index < callbacks.size(); ++index) { | 82 for (size_t index = 0; index < callbacks.size(); ++index) { |
81 if (checkFont()) | 83 if (checkFont()) |
82 callbacks[index]->notifyLoaded(this); | 84 callbacks[index]->notifyLoaded(Handle<CSSSegmentedFontFace>(this
)); |
83 else | 85 else |
84 callbacks[index]->notifyError(this); | 86 callbacks[index]->notifyError(Handle<CSSSegmentedFontFace>(this)
); |
85 } | 87 } |
86 } | 88 } |
87 } | 89 } |
88 | 90 |
89 void CSSSegmentedFontFace::appendFontFace(PassRefPtr<CSSFontFace> fontFace) | 91 void CSSSegmentedFontFace::appendFontFace(PassRefPtr<CSSFontFace> fontFace) |
90 { | 92 { |
91 pruneTable(); | 93 pruneTable(); |
92 fontFace->addedToSegmentedFontFace(this); | 94 fontFace->addedToSegmentedFontFace(Handle<CSSSegmentedFontFace>(this)); |
93 m_fontFaces.append(fontFace); | 95 m_fontFaces.append(fontFace); |
94 } | 96 } |
95 | 97 |
96 static void appendFontDataWithInvalidUnicodeRangeIfLoading(SegmentedFontData* ne
wFontData, PassRefPtr<SimpleFontData> prpFaceFontData, const Vector<CSSFontFace:
:UnicodeRange>& ranges) | 98 static void appendFontDataWithInvalidUnicodeRangeIfLoading(SegmentedFontData* ne
wFontData, PassRefPtr<SimpleFontData> prpFaceFontData, const Vector<CSSFontFace:
:UnicodeRange>& ranges) |
97 { | 99 { |
98 RefPtr<SimpleFontData> faceFontData = prpFaceFontData; | 100 RefPtr<SimpleFontData> faceFontData = prpFaceFontData; |
99 if (faceFontData->isLoading()) { | 101 if (faceFontData->isLoading()) { |
100 newFontData->appendRange(FontDataRange(0, 0, faceFontData)); | 102 newFontData->appendRange(FontDataRange(0, 0, faceFontData)); |
101 return; | 103 return; |
102 } | 104 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 } | 170 } |
169 | 171 |
170 void CSSSegmentedFontFace::loadFont(const FontDescription& fontDescription, Pass
RefPtr<LoadFontCallback> callback) | 172 void CSSSegmentedFontFace::loadFont(const FontDescription& fontDescription, Pass
RefPtr<LoadFontCallback> callback) |
171 { | 173 { |
172 getFontData(fontDescription); // Kick off the load. | 174 getFontData(fontDescription); // Kick off the load. |
173 | 175 |
174 if (callback) { | 176 if (callback) { |
175 if (isLoading()) | 177 if (isLoading()) |
176 m_callbacks.append(callback); | 178 m_callbacks.append(callback); |
177 else if (checkFont()) | 179 else if (checkFont()) |
178 callback->notifyLoaded(this); | 180 callback->notifyLoaded(Handle<CSSSegmentedFontFace>(this)); |
179 else | 181 else |
180 callback->notifyError(this); | 182 callback->notifyError(Handle<CSSSegmentedFontFace>(this)); |
181 } | 183 } |
182 } | 184 } |
183 | 185 |
184 } | 186 } |
OLD | NEW |