| 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 11 matching lines...) Expand all Loading... |
| 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 "base/gtest_prod_util.h" | 29 #include "base/gtest_prod_util.h" |
| 30 #include "core/CoreExport.h" | 30 #include "core/CoreExport.h" |
| 31 #include "platform/Timer.h" | 31 #include "platform/Timer.h" |
| 32 #include "platform/fonts/FontOrientation.h" | |
| 33 #include "platform/heap/Handle.h" | 32 #include "platform/heap/Handle.h" |
| 34 #include "platform/loader/fetch/Resource.h" | 33 #include "platform/loader/fetch/Resource.h" |
| 35 #include "platform/loader/fetch/ResourceClient.h" | 34 #include "platform/loader/fetch/ResourceClient.h" |
| 36 #include <memory> | 35 #include "wtf/RefPtr.h" |
| 37 | 36 |
| 38 namespace blink { | 37 namespace blink { |
| 39 | 38 |
| 40 class FetchRequest; | 39 class FetchRequest; |
| 41 class ResourceFetcher; | 40 class ResourceFetcher; |
| 42 class FontPlatformData; | |
| 43 class FontCustomPlatformData; | 41 class FontCustomPlatformData; |
| 44 class FontResourceClient; | 42 class FontResourceClient; |
| 45 class FontVariationSettings; | |
| 46 | 43 |
| 47 class CORE_EXPORT FontResource final : public Resource { | 44 class CORE_EXPORT FontResource final : public Resource { |
| 48 public: | 45 public: |
| 49 using ClientType = FontResourceClient; | 46 using ClientType = FontResourceClient; |
| 50 | 47 |
| 51 static FontResource* fetch(FetchRequest&, ResourceFetcher*); | 48 static FontResource* fetch(FetchRequest&, ResourceFetcher*); |
| 52 ~FontResource() override; | 49 ~FontResource() override; |
| 53 | 50 |
| 54 void didAddClient(ResourceClient*) override; | 51 void didAddClient(ResourceClient*) override; |
| 55 | 52 |
| 56 void setRevalidatingRequest(const ResourceRequest&) override; | 53 void setRevalidatingRequest(const ResourceRequest&) override; |
| 57 | 54 |
| 58 void allClientsAndObserversRemoved() override; | 55 void allClientsAndObserversRemoved() override; |
| 59 void startLoadLimitTimers(); | 56 void startLoadLimitTimers(); |
| 60 | 57 |
| 61 void setCORSFailed() override { m_corsFailed = true; } | 58 void setCORSFailed() override { m_corsFailed = true; } |
| 62 bool isCORSFailed() const { return m_corsFailed; } | 59 bool isCORSFailed() const { return m_corsFailed; } |
| 63 String otsParsingMessage() const { return m_otsParsingMessage; } | 60 String otsParsingMessage() const { return m_otsParsingMessage; } |
| 64 | 61 |
| 65 bool ensureCustomFontData(); | 62 PassRefPtr<FontCustomPlatformData> getCustomFontData(); |
| 66 FontPlatformData platformDataFromCustomData( | |
| 67 float size, | |
| 68 bool bold, | |
| 69 bool italic, | |
| 70 FontOrientation = FontOrientation::Horizontal, | |
| 71 FontVariationSettings* = nullptr); | |
| 72 | 63 |
| 73 // Returns true if the loading priority of the remote font resource can be | 64 // Returns true if the loading priority of the remote font resource can be |
| 74 // lowered. The loading priority of the font can be lowered only if the | 65 // lowered. The loading priority of the font can be lowered only if the |
| 75 // font is not needed for painting the text. | 66 // font is not needed for painting the text. |
| 76 bool isLowPriorityLoadingAllowedForRemoteFont() const; | 67 bool isLowPriorityLoadingAllowedForRemoteFont() const; |
| 77 | 68 |
| 78 void willReloadAfterDiskCacheMiss() override; | 69 void willReloadAfterDiskCacheMiss() override; |
| 79 | 70 |
| 80 void onMemoryDump(WebMemoryDumpLevelOfDetail, | 71 void onMemoryDump(WebMemoryDumpLevelOfDetail, |
| 81 WebProcessMemoryDump*) const override; | 72 WebProcessMemoryDump*) const override; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 101 | 92 |
| 102 // This is used in UMA histograms, should not change order. | 93 // This is used in UMA histograms, should not change order. |
| 103 enum LoadLimitState { | 94 enum LoadLimitState { |
| 104 LoadNotStarted, | 95 LoadNotStarted, |
| 105 UnderLimit, | 96 UnderLimit, |
| 106 ShortLimitExceeded, | 97 ShortLimitExceeded, |
| 107 LongLimitExceeded, | 98 LongLimitExceeded, |
| 108 LoadLimitStateEnumMax | 99 LoadLimitStateEnumMax |
| 109 }; | 100 }; |
| 110 | 101 |
| 111 std::unique_ptr<FontCustomPlatformData> m_fontData; | 102 RefPtr<FontCustomPlatformData> m_fontData; |
| 112 String m_otsParsingMessage; | 103 String m_otsParsingMessage; |
| 113 LoadLimitState m_loadLimitState; | 104 LoadLimitState m_loadLimitState; |
| 114 bool m_corsFailed; | 105 bool m_corsFailed; |
| 115 Timer<FontResource> m_fontLoadShortLimitTimer; | 106 Timer<FontResource> m_fontLoadShortLimitTimer; |
| 116 Timer<FontResource> m_fontLoadLongLimitTimer; | 107 Timer<FontResource> m_fontLoadLongLimitTimer; |
| 117 | 108 |
| 118 friend class MemoryCache; | 109 friend class MemoryCache; |
| 119 FRIEND_TEST_ALL_PREFIXES(FontResourceTest, CacheAwareFontLoading); | 110 FRIEND_TEST_ALL_PREFIXES(FontResourceTest, CacheAwareFontLoading); |
| 120 }; | 111 }; |
| 121 | 112 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 140 // Only the RemoteFontFaceSources clients can prevent lowering of loading | 131 // Only the RemoteFontFaceSources clients can prevent lowering of loading |
| 141 // priority of the remote fonts. Set the default to true to prevent | 132 // priority of the remote fonts. Set the default to true to prevent |
| 142 // other clients from incorrectly returning false. | 133 // other clients from incorrectly returning false. |
| 143 return true; | 134 return true; |
| 144 } | 135 } |
| 145 }; | 136 }; |
| 146 | 137 |
| 147 } // namespace blink | 138 } // namespace blink |
| 148 | 139 |
| 149 #endif | 140 #endif |
| OLD | NEW |