Changeset 91699 in webkit
- Timestamp:
- Jul 25, 2011 1:00:49 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r91694 r91699 1 2011-07-25 Dan Bernstein <mitz@apple.com> 2 3 <rdar://problem/9835028> Font loading during layout can cause layout code to be re-entered via resource load delegate 4 https://bugs.webkit.org/show_bug.cgi?id=65123 5 6 Reviewed by Anders Carlsson. 7 8 Since CSSFontFaceSource::getFontData() can get called during layout, avoid calling out to loader 9 code from under it, and instead defer that work using a zero-delay timer. 10 11 * css/CSSFontFaceSource.cpp: 12 (WebCore::CSSFontFaceSource::CSSFontFaceSource): 13 (WebCore::CSSFontFaceSource::~CSSFontFaceSource): 14 (WebCore::CSSFontFaceSource::getFontData): Rather than starting the font load here, schedule 15 a zero-delay timer to do it. 16 (WebCore::CSSFontFaceSource::startLoadingTimerFired): Added. Starts loading the font if needed. 17 * css/CSSFontFaceSource.h: 18 1 19 2011-07-25 Andrew Wason <rectalogic@rectalogic.com> 2 20 -
trunk/Source/WebCore/css/CSSFontFaceSource.cpp
r89340 r91699 51 51 , m_font(font) 52 52 , m_face(0) 53 , m_startLoadingTimer(this, &CSSFontFaceSource::startLoadingTimerFired) 53 54 #if ENABLE(SVG_FONTS) 54 55 , m_hasExternalSVGFont(false) … … 61 62 CSSFontFaceSource::~CSSFontFaceSource() 62 63 { 64 m_startLoadingTimer.stop(); 63 65 if (m_font) 64 66 m_font->removeClient(this); … … 173 175 } 174 176 } else { 175 // Kick off the load now. 176 if (CachedResourceLoader* cachedResourceLoader = fontSelector->cachedResourceLoader()) 177 m_font->beginLoadIfNeeded(cachedResourceLoader); 177 // Kick off the load now. Do it on a zero-delay timer rather than synchronously, because we may be in 178 // the middle of layout, and the loader may invoke aribtrary delegate or event handler code. 179 m_fontSelector = fontSelector; 180 if (!m_startLoadingTimer.isActive()) 181 m_startLoadingTimer.startOneShot(0); 182 178 183 // FIXME: m_string is a URL so it makes no sense to pass it as a family name. 179 184 SimpleFontData* tempData = fontCache()->getCachedFontData(fontDescription, m_string); … … 190 195 } 191 196 197 void CSSFontFaceSource::startLoadingTimerFired(Timer<WebCore::CSSFontFaceSource>*) 198 { 199 ASSERT(m_font); 200 ASSERT(m_fontSelector); 201 202 if (CachedResourceLoader* cachedResourceLoader = m_fontSelector->cachedResourceLoader()) 203 m_font->beginLoadIfNeeded(cachedResourceLoader); 204 205 m_fontSelector = nullptr; 206 } 207 192 208 #if ENABLE(SVG_FONTS) 193 209 SVGFontFaceElement* CSSFontFaceSource::svgFontFaceElement() const -
trunk/Source/WebCore/css/CSSFontFaceSource.h
r83896 r91699 29 29 #include "CachedResourceClient.h" 30 30 #include "CachedResourceHandle.h" 31 #include "Timer.h" 31 32 #include <wtf/HashMap.h> 32 33 #include <wtf/text/AtomicString.h> … … 71 72 72 73 private: 74 void startLoadingTimerFired(Timer<CSSFontFaceSource>*); 75 73 76 AtomicString m_string; // URI for remote, built-in font name for local. 74 77 CachedResourceHandle<CachedFont> m_font; // For remote fonts, a pointer to our cached resource. 75 78 CSSFontFace* m_face; // Our owning font face. 76 79 HashMap<unsigned, SimpleFontData*> m_fontDataTable; // The hash key is composed of size synthetic styles. 80 81 Timer<CSSFontFaceSource> m_startLoadingTimer; 82 RefPtr<CSSFontSelector> m_fontSelector; 77 83 78 84 #if ENABLE(SVG_FONTS)
Note: See TracChangeset
for help on using the changeset viewer.