Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: Source/core/fetch/FontResource.h

Issue 457273002: Webfonts should not block load event for more than one frame (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Merge flags into an enum Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/css/FontLoader.cpp ('k') | Source/core/fetch/FontResource.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 FontResource(const ResourceRequest&); 48 FontResource(const ResourceRequest&);
49 virtual ~FontResource(); 49 virtual ~FontResource();
50 virtual void trace(Visitor*) OVERRIDE; 50 virtual void trace(Visitor*) OVERRIDE;
51 51
52 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&) OVERRIDE; 52 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&) OVERRIDE;
53 53
54 virtual void didAddClient(ResourceClient*) OVERRIDE; 54 virtual void didAddClient(ResourceClient*) OVERRIDE;
55 55
56 virtual void allClientsRemoved() OVERRIDE; 56 virtual void allClientsRemoved() OVERRIDE;
57 void beginLoadIfNeeded(ResourceFetcher* dl); 57 void beginLoadIfNeeded(ResourceFetcher* dl);
58 virtual bool stillNeedsLoad() const OVERRIDE { return !m_loadInitiated; } 58 virtual bool stillNeedsLoad() const OVERRIDE { return m_state != LoadInitiat ed; }
59 bool exceedsFontLoadWaitLimit() const { return m_exceedsFontLoadWaitLimit; } 59 bool exceedsFontLoadWaitLimit() const { return m_exceedsFontLoadWaitLimit; }
60 60
61 bool loadScheduled() const { return m_state != Unloaded; }
62 void didScheduleLoad();
63 void didUnscheduleLoad();
64
61 void setCORSFailed() { m_corsFailed = true; } 65 void setCORSFailed() { m_corsFailed = true; }
62 bool isCORSFailed() const { return m_corsFailed; } 66 bool isCORSFailed() const { return m_corsFailed; }
63 67
64 bool ensureCustomFontData(); 68 bool ensureCustomFontData();
65 FontPlatformData platformDataFromCustomData(float size, bool bold, bool ital ic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth); 69 FontPlatformData platformDataFromCustomData(float size, bool bold, bool ital ic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth);
66 70
67 #if ENABLE(SVG_FONTS) 71 #if ENABLE(SVG_FONTS)
68 bool ensureSVGFontData(); 72 bool ensureSVGFontData();
69 SVGFontElement* getSVGFontById(const String&) const; 73 SVGFontElement* getSVGFontById(const String&) const;
70 #endif 74 #endif
71 75
72 protected: 76 protected:
73 virtual bool isSafeToUnlock() const OVERRIDE; 77 virtual bool isSafeToUnlock() const OVERRIDE;
74 78
75 private: 79 private:
76 virtual void checkNotify() OVERRIDE; 80 virtual void checkNotify() OVERRIDE;
77 void fontLoadWaitLimitCallback(Timer<FontResource>*); 81 void fontLoadWaitLimitCallback(Timer<FontResource>*);
78 82
83 enum State { Unloaded, LoadScheduled, LoadInitiated };
84
79 OwnPtr<FontCustomPlatformData> m_fontData; 85 OwnPtr<FontCustomPlatformData> m_fontData;
80 bool m_loadInitiated; 86 State m_state;
81 bool m_exceedsFontLoadWaitLimit; 87 bool m_exceedsFontLoadWaitLimit;
82 bool m_corsFailed; 88 bool m_corsFailed;
83 Timer<FontResource> m_fontLoadWaitLimitTimer; 89 Timer<FontResource> m_fontLoadWaitLimitTimer;
84 90
85 #if ENABLE(SVG_FONTS) 91 #if ENABLE(SVG_FONTS)
86 RefPtrWillBeMember<Document> m_externalSVGDocument; 92 RefPtrWillBeMember<Document> m_externalSVGDocument;
87 #endif 93 #endif
88 94
89 friend class MemoryCache; 95 friend class MemoryCache;
90 }; 96 };
91 97
92 DEFINE_RESOURCE_TYPE_CASTS(Font); 98 DEFINE_RESOURCE_TYPE_CASTS(Font);
93 99
94 class FontResourceClient : public ResourceClient { 100 class FontResourceClient : public ResourceClient {
95 public: 101 public:
96 virtual ~FontResourceClient() { } 102 virtual ~FontResourceClient() { }
97 static ResourceClientType expectedType() { return FontType; } 103 static ResourceClientType expectedType() { return FontType; }
98 virtual ResourceClientType resourceClientType() const OVERRIDE FINAL { retur n expectedType(); } 104 virtual ResourceClientType resourceClientType() const OVERRIDE FINAL { retur n expectedType(); }
99 virtual void fontLoaded(FontResource*) { } 105 virtual void fontLoaded(FontResource*) { }
100 virtual void didStartFontLoad(FontResource*) { } 106 virtual void didStartFontLoad(FontResource*) { }
101 virtual void fontLoadWaitLimitExceeded(FontResource*) { } 107 virtual void fontLoadWaitLimitExceeded(FontResource*) { }
102 }; 108 };
103 109
104 } 110 }
105 111
106 #endif 112 #endif
OLDNEW
« no previous file with comments | « Source/core/css/FontLoader.cpp ('k') | Source/core/fetch/FontResource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698