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 26 matching lines...) Expand all Loading... |
37 class FetchRequest; | 37 class FetchRequest; |
38 class ResourceFetcher; | 38 class ResourceFetcher; |
39 class FontPlatformData; | 39 class FontPlatformData; |
40 class FontCustomPlatformData; | 40 class FontCustomPlatformData; |
41 | 41 |
42 class FontResource final : public Resource { | 42 class FontResource final : public Resource { |
43 public: | 43 public: |
44 typedef ResourceClient ClientType; | 44 typedef ResourceClient ClientType; |
45 | 45 |
46 static ResourcePtr<FontResource> fetch(FetchRequest&, ResourceFetcher*); | 46 static ResourcePtr<FontResource> fetch(FetchRequest&, ResourceFetcher*); |
47 virtual ~FontResource(); | 47 ~FontResource() override; |
48 | 48 |
49 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&) override; | 49 void load(ResourceFetcher*, const ResourceLoaderOptions&) override; |
50 | 50 |
51 virtual void didAddClient(ResourceClient*) override; | 51 void didAddClient(ResourceClient*) override; |
52 | 52 |
53 virtual void allClientsRemoved() override; | 53 void allClientsRemoved() override; |
54 void beginLoadIfNeeded(ResourceFetcher* dl); | 54 void beginLoadIfNeeded(ResourceFetcher* dl); |
55 virtual bool stillNeedsLoad() const override { return m_state != LoadInitiat
ed; } | 55 bool stillNeedsLoad() const override { return m_state != LoadInitiated; } |
56 bool exceedsFontLoadWaitLimit() const { return m_exceedsFontLoadWaitLimit; } | 56 bool exceedsFontLoadWaitLimit() const { return m_exceedsFontLoadWaitLimit; } |
57 | 57 |
58 bool loadScheduled() const { return m_state != Unloaded; } | 58 bool loadScheduled() const { return m_state != Unloaded; } |
59 void didScheduleLoad(); | 59 void didScheduleLoad(); |
60 void didUnscheduleLoad(); | 60 void didUnscheduleLoad(); |
61 | 61 |
62 void setCORSFailed() override { m_corsFailed = true; } | 62 void setCORSFailed() override { m_corsFailed = true; } |
63 bool isCORSFailed() const { return m_corsFailed; } | 63 bool isCORSFailed() const { return m_corsFailed; } |
64 String otsParsingMessage() const { return m_otsParsingMessage; } | 64 String otsParsingMessage() const { return m_otsParsingMessage; } |
65 | 65 |
66 bool ensureCustomFontData(); | 66 bool ensureCustomFontData(); |
67 FontPlatformData platformDataFromCustomData(float size, bool bold, bool ital
ic, FontOrientation = FontOrientation::Horizontal); | 67 FontPlatformData platformDataFromCustomData(float size, bool bold, bool ital
ic, FontOrientation = FontOrientation::Horizontal); |
68 | 68 |
69 protected: | 69 protected: |
70 virtual bool isSafeToUnlock() const override; | 70 bool isSafeToUnlock() const override; |
71 | 71 |
72 private: | 72 private: |
73 class FontResourceFactory : public ResourceFactory { | 73 class FontResourceFactory : public ResourceFactory { |
74 public: | 74 public: |
75 FontResourceFactory() | 75 FontResourceFactory() |
76 : ResourceFactory(Resource::Font) { } | 76 : ResourceFactory(Resource::Font) { } |
77 | 77 |
78 Resource* create(const ResourceRequest& request, const String& charset)
const override | 78 Resource* create(const ResourceRequest& request, const String& charset)
const override |
79 { | 79 { |
80 return new FontResource(request); | 80 return new FontResource(request); |
81 } | 81 } |
82 }; | 82 }; |
83 FontResource(const ResourceRequest&); | 83 FontResource(const ResourceRequest&); |
84 | 84 |
85 virtual void checkNotify() override; | 85 void checkNotify() override; |
86 void fontLoadWaitLimitCallback(Timer<FontResource>*); | 86 void fontLoadWaitLimitCallback(Timer<FontResource>*); |
87 | 87 |
88 enum State { Unloaded, LoadScheduled, LoadInitiated }; | 88 enum State { Unloaded, LoadScheduled, LoadInitiated }; |
89 | 89 |
90 OwnPtr<FontCustomPlatformData> m_fontData; | 90 OwnPtr<FontCustomPlatformData> m_fontData; |
91 String m_otsParsingMessage; | 91 String m_otsParsingMessage; |
92 State m_state; | 92 State m_state; |
93 bool m_exceedsFontLoadWaitLimit; | 93 bool m_exceedsFontLoadWaitLimit; |
94 bool m_corsFailed; | 94 bool m_corsFailed; |
95 Timer<FontResource> m_fontLoadWaitLimitTimer; | 95 Timer<FontResource> m_fontLoadWaitLimitTimer; |
96 | 96 |
97 friend class MemoryCache; | 97 friend class MemoryCache; |
98 }; | 98 }; |
99 | 99 |
100 DEFINE_RESOURCE_TYPE_CASTS(Font); | 100 DEFINE_RESOURCE_TYPE_CASTS(Font); |
101 | 101 |
102 class FontResourceClient : public ResourceClient { | 102 class FontResourceClient : public ResourceClient { |
103 public: | 103 public: |
104 virtual ~FontResourceClient() { } | 104 ~FontResourceClient() override {} |
105 static ResourceClientType expectedType() { return FontType; } | 105 static ResourceClientType expectedType() { return FontType; } |
106 virtual ResourceClientType resourceClientType() const override final { retur
n expectedType(); } | 106 ResourceClientType resourceClientType() const final { return expectedType();
} |
107 virtual void fontLoaded(FontResource*) { } | 107 virtual void fontLoaded(FontResource*) {} |
108 virtual void didStartFontLoad(FontResource*) { } | 108 virtual void didStartFontLoad(FontResource*) {} |
109 virtual void fontLoadWaitLimitExceeded(FontResource*) { } | 109 virtual void fontLoadWaitLimitExceeded(FontResource*) {} |
110 }; | 110 }; |
111 | 111 |
112 } | 112 } |
113 | 113 |
114 #endif | 114 #endif |
OLD | NEW |