OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009 Torch Mobile, Inc. | 3 * Copyright (C) 2009 Torch Mobile, Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 return PackageFormatSFNT; | 69 return PackageFormatSFNT; |
70 } | 70 } |
71 | 71 |
72 static void recordPackageFormatHistogram(FontPackageFormat format) | 72 static void recordPackageFormatHistogram(FontPackageFormat format) |
73 { | 73 { |
74 blink::Platform::current()->histogramEnumeration("WebFont.PackageFormat", fo
rmat, PackageFormatEnumMax); | 74 blink::Platform::current()->histogramEnumeration("WebFont.PackageFormat", fo
rmat, PackageFormatEnumMax); |
75 } | 75 } |
76 | 76 |
77 FontResource::FontResource(const ResourceRequest& resourceRequest) | 77 FontResource::FontResource(const ResourceRequest& resourceRequest) |
78 : Resource(resourceRequest, Font) | 78 : Resource(resourceRequest, Font) |
79 , m_loadInitiated(false) | 79 , m_state(Unloaded) |
80 , m_exceedsFontLoadWaitLimit(false) | 80 , m_exceedsFontLoadWaitLimit(false) |
81 , m_corsFailed(false) | 81 , m_corsFailed(false) |
82 , m_fontLoadWaitLimitTimer(this, &FontResource::fontLoadWaitLimitCallback) | 82 , m_fontLoadWaitLimitTimer(this, &FontResource::fontLoadWaitLimitCallback) |
83 { | 83 { |
84 } | 84 } |
85 | 85 |
86 FontResource::~FontResource() | 86 FontResource::~FontResource() |
87 { | 87 { |
88 } | 88 } |
89 | 89 |
90 void FontResource::trace(Visitor* visitor) | 90 void FontResource::trace(Visitor* visitor) |
91 { | 91 { |
92 #if ENABLE(SVG_FONTS) | 92 #if ENABLE(SVG_FONTS) |
93 visitor->trace(m_externalSVGDocument); | 93 visitor->trace(m_externalSVGDocument); |
94 #endif | 94 #endif |
95 Resource::trace(visitor); | 95 Resource::trace(visitor); |
96 } | 96 } |
97 | 97 |
| 98 void FontResource::didScheduleLoad() |
| 99 { |
| 100 if (m_state == Unloaded) |
| 101 m_state = LoadScheduled; |
| 102 } |
| 103 |
| 104 void FontResource::didUnscheduleLoad() |
| 105 { |
| 106 if (m_state == LoadScheduled) |
| 107 m_state = Unloaded; |
| 108 } |
| 109 |
98 void FontResource::load(ResourceFetcher*, const ResourceLoaderOptions& options) | 110 void FontResource::load(ResourceFetcher*, const ResourceLoaderOptions& options) |
99 { | 111 { |
100 // Don't load the file yet. Wait for an access before triggering the load. | 112 // Don't load the file yet. Wait for an access before triggering the load. |
101 setLoading(true); | 113 setLoading(true); |
102 m_options = options; | 114 m_options = options; |
103 } | 115 } |
104 | 116 |
105 void FontResource::didAddClient(ResourceClient* c) | 117 void FontResource::didAddClient(ResourceClient* c) |
106 { | 118 { |
107 ASSERT(c->resourceClientType() == FontResourceClient::expectedType()); | 119 ASSERT(c->resourceClientType() == FontResourceClient::expectedType()); |
108 Resource::didAddClient(c); | 120 Resource::didAddClient(c); |
109 if (!isLoading()) | 121 if (!isLoading()) |
110 static_cast<FontResourceClient*>(c)->fontLoaded(this); | 122 static_cast<FontResourceClient*>(c)->fontLoaded(this); |
111 } | 123 } |
112 | 124 |
113 void FontResource::beginLoadIfNeeded(ResourceFetcher* dl) | 125 void FontResource::beginLoadIfNeeded(ResourceFetcher* dl) |
114 { | 126 { |
115 if (!m_loadInitiated) { | 127 if (m_state != LoadInitiated) { |
116 m_loadInitiated = true; | 128 m_state = LoadInitiated; |
117 Resource::load(dl, m_options); | 129 Resource::load(dl, m_options); |
118 m_fontLoadWaitLimitTimer.startOneShot(fontLoadWaitLimitSec, FROM_HERE); | 130 m_fontLoadWaitLimitTimer.startOneShot(fontLoadWaitLimitSec, FROM_HERE); |
119 | 131 |
120 ResourceClientWalker<FontResourceClient> walker(m_clients); | 132 ResourceClientWalker<FontResourceClient> walker(m_clients); |
121 while (FontResourceClient* client = walker.next()) | 133 while (FontResourceClient* client = walker.next()) |
122 client->didStartFontLoad(this); | 134 client->didStartFontLoad(this); |
123 } | 135 } |
124 } | 136 } |
125 | 137 |
126 bool FontResource::ensureCustomFontData() | 138 bool FontResource::ensureCustomFontData() |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 | 241 |
230 void FontResource::checkNotify() | 242 void FontResource::checkNotify() |
231 { | 243 { |
232 m_fontLoadWaitLimitTimer.stop(); | 244 m_fontLoadWaitLimitTimer.stop(); |
233 ResourceClientWalker<FontResourceClient> w(m_clients); | 245 ResourceClientWalker<FontResourceClient> w(m_clients); |
234 while (FontResourceClient* c = w.next()) | 246 while (FontResourceClient* c = w.next()) |
235 c->fontLoaded(this); | 247 c->fontLoaded(this); |
236 } | 248 } |
237 | 249 |
238 } | 250 } |
OLD | NEW |