| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 static ResourcePtr<FontResource> fetch(FetchRequest&, ResourceFetcher*); | 46 static ResourcePtr<FontResource> fetch(FetchRequest&, ResourceFetcher*); |
| 47 ~FontResource() override; | 47 ~FontResource() override; |
| 48 | 48 |
| 49 void load(ResourceFetcher*, const ResourceLoaderOptions&) override; | 49 void load(ResourceFetcher*, const ResourceLoaderOptions&) override; |
| 50 | 50 |
| 51 void didAddClient(ResourceClient*) override; | 51 void didAddClient(ResourceClient*) override; |
| 52 | 52 |
| 53 void allClientsRemoved() override; | 53 void allClientsRemoved() override; |
| 54 void beginLoadIfNeeded(ResourceFetcher* dl); | 54 void beginLoadIfNeeded(ResourceFetcher* dl); |
| 55 bool stillNeedsLoad() const override { return m_state != LoadInitiated; } | 55 bool stillNeedsLoad() const override { return m_state != LoadInitiated; } |
| 56 bool exceedsFontLoadWaitLimit() const { return m_exceedsFontLoadWaitLimit; } | |
| 57 | 56 |
| 58 bool loadScheduled() const { return m_state != Unloaded; } | 57 bool loadScheduled() const { return m_state != Unloaded; } |
| 59 void didScheduleLoad(); | 58 void didScheduleLoad(); |
| 60 void didUnscheduleLoad(); | 59 void didUnscheduleLoad(); |
| 61 | 60 |
| 62 void setCORSFailed() override { m_corsFailed = true; } | 61 void setCORSFailed() override { m_corsFailed = true; } |
| 63 bool isCORSFailed() const { return m_corsFailed; } | 62 bool isCORSFailed() const { return m_corsFailed; } |
| 64 String otsParsingMessage() const { return m_otsParsingMessage; } | 63 String otsParsingMessage() const { return m_otsParsingMessage; } |
| 65 | 64 |
| 66 bool ensureCustomFontData(); | 65 bool ensureCustomFontData(); |
| 67 FontPlatformData platformDataFromCustomData(float size, bool bold, bool ital
ic, FontOrientation = FontOrientation::Horizontal); | 66 FontPlatformData platformDataFromCustomData(float size, bool bold, bool ital
ic, FontOrientation = FontOrientation::Horizontal); |
| 68 | 67 |
| 69 protected: | 68 protected: |
| 70 bool isSafeToUnlock() const override; | 69 bool isSafeToUnlock() const override; |
| 71 | 70 |
| 72 private: | 71 private: |
| 73 class FontResourceFactory : public ResourceFactory { | 72 class FontResourceFactory : public ResourceFactory { |
| 74 public: | 73 public: |
| 75 FontResourceFactory() | 74 FontResourceFactory() |
| 76 : ResourceFactory(Resource::Font) { } | 75 : ResourceFactory(Resource::Font) { } |
| 77 | 76 |
| 78 Resource* create(const ResourceRequest& request, const String& charset)
const override | 77 Resource* create(const ResourceRequest& request, const String& charset)
const override |
| 79 { | 78 { |
| 80 return new FontResource(request); | 79 return new FontResource(request); |
| 81 } | 80 } |
| 82 }; | 81 }; |
| 83 FontResource(const ResourceRequest&); | 82 FontResource(const ResourceRequest&); |
| 84 | 83 |
| 85 void checkNotify() override; | 84 void checkNotify() override; |
| 86 void fontLoadWaitLimitCallback(Timer<FontResource>*); | 85 void fontLoadShortLimitCallback(Timer<FontResource>*); |
| 86 void fontLoadLongLimitCallback(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; | |
| 94 bool m_corsFailed; | 93 bool m_corsFailed; |
| 95 Timer<FontResource> m_fontLoadWaitLimitTimer; | 94 Timer<FontResource> m_fontLoadShortLimitTimer; |
| 95 Timer<FontResource> m_fontLoadLongLimitTimer; |
| 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 ~FontResourceClient() override {} | 104 ~FontResourceClient() override {} |
| 105 static ResourceClientType expectedType() { return FontType; } | 105 static ResourceClientType expectedType() { return FontType; } |
| 106 ResourceClientType resourceClientType() const final { return 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 fontLoadShortLimitExceeded(FontResource*) {} |
| 110 virtual void fontLoadLongLimitExceeded(FontResource*) {} |
| 110 }; | 111 }; |
| 111 | 112 |
| 112 } | 113 } |
| 113 | 114 |
| 114 #endif | 115 #endif |
| OLD | NEW |