OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 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 10 matching lines...) Expand all Loading... |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef FontResource_h | 26 #ifndef FontResource_h |
27 #define FontResource_h | 27 #define FontResource_h |
28 | 28 |
29 #include "core/fetch/ResourceClient.h" | 29 #include "core/fetch/ResourceClient.h" |
30 #include "core/fetch/ResourcePtr.h" | 30 #include "core/fetch/ResourcePtr.h" |
| 31 #include "platform/Timer.h" |
31 #include "platform/fonts/FontOrientation.h" | 32 #include "platform/fonts/FontOrientation.h" |
32 #include "platform/fonts/FontWidthVariant.h" | 33 #include "platform/fonts/FontWidthVariant.h" |
33 #include "wtf/OwnPtr.h" | 34 #include "wtf/OwnPtr.h" |
34 | 35 |
35 namespace WebCore { | 36 namespace WebCore { |
36 | 37 |
37 class ResourceFetcher; | 38 class ResourceFetcher; |
38 class FontPlatformData; | 39 class FontPlatformData; |
39 class SVGDocument; | 40 class SVGDocument; |
40 class SVGFontElement; | 41 class SVGFontElement; |
41 class FontCustomPlatformData; | 42 class FontCustomPlatformData; |
42 | 43 |
43 class FontResource FINAL : public Resource { | 44 class FontResource FINAL : public Resource { |
44 public: | 45 public: |
45 typedef ResourceClient ClientType; | 46 typedef ResourceClient ClientType; |
46 | 47 |
47 FontResource(const ResourceRequest&); | 48 FontResource(const ResourceRequest&); |
48 virtual ~FontResource(); | 49 virtual ~FontResource(); |
49 | 50 |
50 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&) OVERRIDE; | 51 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&) OVERRIDE; |
51 | 52 |
52 virtual void didAddClient(ResourceClient*) OVERRIDE; | 53 virtual void didAddClient(ResourceClient*) OVERRIDE; |
53 | 54 |
54 virtual void allClientsRemoved() OVERRIDE; | 55 virtual void allClientsRemoved() OVERRIDE; |
55 void beginLoadIfNeeded(ResourceFetcher* dl); | 56 void beginLoadIfNeeded(ResourceFetcher* dl); |
56 virtual bool stillNeedsLoad() const OVERRIDE { return !m_loadInitiated; } | 57 virtual bool stillNeedsLoad() const OVERRIDE { return !m_loadInitiated; } |
| 58 bool exceedsFontLoadWaitLimit() const { return m_exceedsFontLoadWaitLimit; } |
57 | 59 |
58 bool ensureCustomFontData(); | 60 bool ensureCustomFontData(); |
59 FontPlatformData platformDataFromCustomData(float size, bool bold, bool ital
ic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth); | 61 FontPlatformData platformDataFromCustomData(float size, bool bold, bool ital
ic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth); |
60 | 62 |
61 #if ENABLE(SVG_FONTS) | 63 #if ENABLE(SVG_FONTS) |
62 bool ensureSVGFontData(); | 64 bool ensureSVGFontData(); |
63 SVGFontElement* getSVGFontById(const String&) const; | 65 SVGFontElement* getSVGFontById(const String&) const; |
64 #endif | 66 #endif |
65 | 67 |
66 private: | 68 private: |
67 virtual void checkNotify() OVERRIDE; | 69 virtual void checkNotify() OVERRIDE; |
| 70 void fontLoadWaitLimitCallback(Timer<FontResource>*); |
| 71 |
68 OwnPtr<FontCustomPlatformData> m_fontData; | 72 OwnPtr<FontCustomPlatformData> m_fontData; |
69 bool m_loadInitiated; | 73 bool m_loadInitiated; |
| 74 bool m_exceedsFontLoadWaitLimit; |
| 75 Timer<FontResource> m_fontLoadWaitLimitTimer; |
70 | 76 |
71 #if ENABLE(SVG_FONTS) | 77 #if ENABLE(SVG_FONTS) |
72 RefPtr<WebCore::SVGDocument> m_externalSVGDocument; | 78 RefPtr<WebCore::SVGDocument> m_externalSVGDocument; |
73 #endif | 79 #endif |
74 | 80 |
75 friend class MemoryCache; | 81 friend class MemoryCache; |
76 }; | 82 }; |
77 | 83 |
78 DEFINE_RESOURCE_TYPE_CASTS(Font); | 84 DEFINE_RESOURCE_TYPE_CASTS(Font); |
79 | 85 |
80 class FontResourceClient : public ResourceClient { | 86 class FontResourceClient : public ResourceClient { |
81 public: | 87 public: |
82 virtual ~FontResourceClient() { } | 88 virtual ~FontResourceClient() { } |
83 static ResourceClientType expectedType() { return FontType; } | 89 static ResourceClientType expectedType() { return FontType; } |
84 virtual ResourceClientType resourceClientType() const OVERRIDE FINAL { retur
n expectedType(); } | 90 virtual ResourceClientType resourceClientType() const OVERRIDE FINAL { retur
n expectedType(); } |
85 virtual void fontLoaded(FontResource*) { } | 91 virtual void fontLoaded(FontResource*) { } |
86 virtual void didStartFontLoad(FontResource*) { } | 92 virtual void didStartFontLoad(FontResource*) { } |
| 93 virtual void fontLoadWaitLimitExceeded(FontResource*) { } |
87 }; | 94 }; |
88 | 95 |
89 } | 96 } |
90 | 97 |
91 #endif | 98 #endif |
OLD | NEW |