Changeset 101858 in webkit
- Timestamp:
- Dec 2, 2011, 2:49:53 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r101855 r101858 1 2011-12-02 Dan Bernstein <mitz@apple.com> 2 3 <rdar://problem/10520670> REGRESSION (r91738): didFinishLoad is called before custom fonts have finished loading 4 https://bugs.webkit.org/show_bug.cgi?id=73688 5 6 Reviewed by Darin Adler. 7 8 Reverted test chnages from r91738. These tests were made to wait for the fonts to finish loading 9 using a DOM. Now again they do not need to. 10 11 * fast/css/color-leakage.html: 12 * fast/css/custom-font-xheight.html: 13 * fast/css/font-face-multiple-faces.html: 14 * fast/css/font-face-multiple-remote-sources.html: 15 * fast/css/font-face-remote.html: 16 * fast/css/font-face-woff.html: 17 * fast/writing-mode/broken-ideograph-small-caps.html: 18 * svg/W3C-SVG-1.1-SE/text-intro-09-b.svg: 19 * svg/W3C-SVG-1.1/fonts-elem-07-b.svg: 20 * svg/custom/svg-fonts-fallback.xhtml: 21 * svg/custom/svg-fonts-in-html.html: 22 * svg/custom/svg-fonts-segmented.xhtml: 23 * svg/custom/svg-fonts-with-no-element-reference.html: 24 * svg/custom/svg-fonts-without-missing-glyph.xhtml: 25 * svg/text/text-overflow-ellipsis-svgfont.html: 26 1 27 2011-12-02 David Tseng <dtseng@google.com> 2 28 -
trunk/LayoutTests/fast/css/color-leakage.html
r91738 r101858 3 3 <!-- The Ahem font rendered in this test should be displayed black, not blue. --> 4 4 <style> 5 @font-face { 6 font-family: 'Ahem'; 7 src: url('resources/Ahem.ttf'); 8 } 5 9 div { 6 10 display: block; -
trunk/LayoutTests/fast/css/custom-font-xheight.html
r100930 r101858 38 38 39 39 <script> 40 if (window.layoutTestController) {40 if (window.layoutTestController) 41 41 layoutTestController.dumpAsText(); 42 layoutTestController.waitUntilDone();43 }44 42 45 43 function test() 46 44 { 47 document.body.offsetTop; 48 setTimeout(function() { 49 var totalHeight = document.defaultView.getComputedStyle(document.getElementById("test"), null).getPropertyCSSValue("height"); 50 totalHeight = totalHeight.getFloatValue(CSSPrimitiveValue.CSS_PX); 51 if (totalHeight > 150 && totalHeight < 300) 52 document.getElementById("result").innerHTML = "PASS"; 53 else 54 document.getElementById("result").innerHTML = "FAIL: " + totalHeight + "px"; 55 56 if (window.layoutTestController) 57 layoutTestController.notifyDone(); 58 }, 100); 45 var totalHeight = document.defaultView.getComputedStyle(document.getElementById("test"), null).getPropertyCSSValue("height"); 46 totalHeight = totalHeight.getFloatValue(CSSPrimitiveValue.CSS_PX); 47 if (totalHeight > 150 && totalHeight < 300) 48 document.getElementById("result").innerHTML = "PASS"; 49 else 50 document.getElementById("result").innerHTML = "FAIL: " + totalHeight + "px"; 59 51 } 60 52 </script> -
trunk/LayoutTests/fast/css/font-face-multiple-faces.html
r100930 r101858 149 149 AHEM <i>AHEM</i> 150 150 </div> 151 <script>152 if (window.layoutTestController) {153 layoutTestController.waitUntilDone();154 document.body.offsetTop;155 setTimeout(function() { layoutTestController.notifyDone(); }, 100);156 }157 </script> -
trunk/LayoutTests/fast/css/font-face-multiple-remote-sources.html
r91738 r101858 16 16 </div> 17 17 <script> 18 if (window.layoutTestController) { 19 layoutTestController.waitUntilDone(); 20 document.body.offsetTop; 21 setTimeout(function() { layoutTestController.notifyDone(); }, 100); 22 } 18 document.body.offsetTop; 23 19 </script> 24 20 </body> -
trunk/LayoutTests/fast/css/font-face-remote.html
r100930 r101858 9 9 </style> 10 10 </head> 11 <body >11 <body onload="finished()"> 12 12 <div> 13 13 FAIL_<br> … … 18 18 </div> 19 19 <script> 20 if (window.layoutTestController) {20 if (window.layoutTestController) 21 21 layoutTestController.waitUntilDone(); 22 document.body.offsetTop; 23 setTimeout(function() { layoutTestController.notifyDone(); }, 100); 22 23 // Kick off loading of the font 24 document.body.offsetTop; 25 26 function finished() 27 { 28 if (window.layoutTestController) 29 layoutTestController.notifyDone(); 24 30 } 25 31 </script> -
trunk/LayoutTests/fast/css/font-face-woff.html
r100930 r101858 9 9 10 10 <p style="font-family: family1; font-size: 4em;">Failure</p> 11 <script>12 if (window.layoutTestController) {13 layoutTestController.waitUntilDone();14 document.body.offsetTop;15 setTimeout(function() { layoutTestController.notifyDone(); }, 100);16 }17 </script> -
trunk/LayoutTests/fast/writing-mode/broken-ideograph-small-caps.html
r91738 r101858 58 58 </style> 59 59 60 <script type="text/javascript"> 61 62 </script> 63 60 64 </head> 61 65 <body> … … 66 70 </div> 67 71 68 <script>69 if (window.layoutTestController) {70 layoutTestController.waitUntilDone();71 document.body.offsetTop;72 setTimeout(function() { layoutTestController.notifyDone(); }, 100);73 }74 </script>75 72 </body> 76 73 </html> -
trunk/LayoutTests/svg/W3C-SVG-1.1-SE/text-intro-09-b.svg
r91738 r101858 87 87 text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text> 88 88 </g>--> 89 <script>90 if (window.layoutTestController) {91 layoutTestController.waitUntilDone();92 document.documentElement.offsetTop;93 setTimeout(function() { layoutTestController.notifyDone(); }, 100);94 }95 </script>96 89 </svg> -
trunk/LayoutTests/svg/W3C-SVG-1.1/fonts-elem-07-b.svg
r91738 r101858 114 114 <text id="revision" x="10" y="340" font-size="40" stroke="none" fill="black">$Revision: 1.7 $</text> 115 115 <rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000000"/> 116 <script>117 if (window.layoutTestController) {118 layoutTestController.waitUntilDone();119 document.documentElement.offsetTop;120 setTimeout(function() { layoutTestController.notifyDone(); }, 100);121 }122 </script>123 116 </svg> -
trunk/LayoutTests/svg/custom/svg-fonts-fallback.xhtml
r91738 r101858 77 77 <span style='font-family: TestFont2; font-size: 40px; '>a ௢ o</span><br/> 78 78 </p> 79 <script> 80 if (window.layoutTestController) { 81 layoutTestController.waitUntilDone(); 82 document.documentElement.offsetTop; 83 setTimeout(function() { layoutTestController.notifyDone(); }, 100); 84 } 85 </script> 79 86 80 </body> 87 81 </html> -
trunk/LayoutTests/svg/custom/svg-fonts-in-html.html
r91738 r101858 209 209 <div id="extraDiv1"><span></span></div><div id="extraDiv2"><span></span></div><div id="extraDiv3"><span></span></div> 210 210 <div id="extraDiv4"><span></span></div><div id="extraDiv5"><span></span></div><div id="extraDiv6"><span></span></div> 211 <script> 212 if (window.layoutTestController) { 213 layoutTestController.waitUntilDone(); 214 document.documentElement.offsetTop; 215 setTimeout(function() { layoutTestController.notifyDone(); }, 100); 216 } 217 </script> 211 218 212 </body> 219 213 </html> -
trunk/LayoutTests/svg/custom/svg-fonts-segmented.xhtml
r91738 r101858 38 38 <!-- 'ABC' should be rendered using Times, 'def' using Courier, 'o' using the SVG Font, and 'O' again by Times --> 39 39 <p style='font-family: TestFont; font-size: 40px; '>ABCdefoooO</p> 40 <script> 41 if (window.layoutTestController) { 42 layoutTestController.waitUntilDone(); 43 document.documentElement.offsetTop; 44 setTimeout(function() { layoutTestController.notifyDone(); }, 100); 45 } 46 </script> 40 47 41 </body> 48 42 </html> -
trunk/LayoutTests/svg/custom/svg-fonts-with-no-element-reference.html
r91738 r101858 32 32 <p class="first">This text should be rendered with a first font.</p> 33 33 <p class="second">This text should be rendered with a second font.</p> 34 <script>35 if (window.layoutTestController) {36 layoutTestController.waitUntilDone();37 document.documentElement.offsetTop;38 setTimeout(function() { layoutTestController.notifyDone(); }, 100);39 }40 </script>41 34 </body> 42 35 -
trunk/LayoutTests/svg/custom/svg-fonts-without-missing-glyph.xhtml
r91738 r101858 31 31 <p class="target">XXX</p> 32 32 <p class="target">AAA</p> 33 <script> 34 if (window.layoutTestController) { 35 layoutTestController.waitUntilDone(); 36 document.documentElement.offsetTop; 37 setTimeout(function() { layoutTestController.notifyDone(); }, 100); 38 } 39 </script> 33 40 34 </body> 41 35 </html> -
trunk/LayoutTests/svg/text/text-overflow-ellipsis-svgfont.html
r91738 r101858 37 37 </div> 38 38 39 <script>40 if (window.layoutTestController) {41 layoutTestController.waitUntilDone();42 document.documentElement.offsetTop;43 setTimeout(function() { layoutTestController.notifyDone(); }, 100);44 }45 </script>46 39 </body> 47 40 </html> -
trunk/Source/WebCore/ChangeLog
r101855 r101858 1 2011-12-02 Dan Bernstein <mitz@apple.com> 2 3 <rdar://problem/10520670> REGRESSION (r91738): didFinishLoad is called before custom fonts have finished loading 4 https://bugs.webkit.org/show_bug.cgi?id=73688 5 6 Reviewed by Darin Adler. 7 8 The problem was that after CSSFontFaceSource::getFontData() had scheduled a 0-delay timer to 9 begin loading the font, but before that timer fired, the subresource loader appeared to have 10 had no resources waiting to be loaded, and therefore didFinishLoad could be called. This change 11 reworks the fix for <http://webkit.org/b/65123> so that while the load is still started on a 12 0-dealy timer, the subresource loader’s request count is incremented immediately, preventing 13 it from hitting 0 while the font load is scheduled to begin. The delayed load mechanism is 14 moved from CSSFontFaceSource into CSSFontSelector in order to safely handle the possibility of 15 the latter being decommissioned while waiting for font loading to begin. 16 17 * css/CSSFontFaceSource.cpp: 18 (WebCore::CSSFontFaceSource::CSSFontFaceSource): Removed initializer for m_loadStartTimer. 19 (WebCore::CSSFontFaceSource::~CSSFontFaceSource): Removed stopping of m_loadStartTimer. 20 (WebCore::CSSFontFaceSource::getFontData): Replaced code to schedule loading on a timer with 21 a call to CSSFontSelector::beginLoadingFontSoon. 22 * css/CSSFontFaceSource.h: Removed m_loadStartTimer and m_fontSelector member variables. 23 * css/CSSFontSelector.cpp: 24 (WebCore::CSSFontSelector::CSSFontSelector): Added initialized for m_beginLoadingTimer. 25 (WebCore::CSSFontSelector::~CSSFontSelector): Added call to clearDocument(), to deal with 26 anything remaining in m_fontsToBeginLoading at this time. 27 (WebCore::CSSFontSelector::clearDocument): Now stops m_beginLoadingTimer and balances 28 incrementRequestCount() calls for anything remaining in m_fontsToBeginLoading. 29 (WebCore::CSSFontSelector::beginLoadingFontSoon): Added. Schedules the actual call to 30 CachedFont::beginLoadingIfNeeded on a 0-delay timer, and meanwhile increments the request count 31 on the CachedResourceLoader, which ensures that didFinishLoad will not be called while waiting 32 for the timer to fire. 33 (WebCore::CSSFontSelector::beginLoadTimerFired): Added. Actually calls 34 CachedFont::beginLoadIfNeeded and balances the incrementRequestCount() made when the timer was 35 scheduled. 36 * css/CSSFontSelector.h: 37 1 38 2011-12-02 David Tseng <dtseng@google.com> 2 39 -
trunk/Source/WebCore/css/CSSFontFaceSource.cpp
r97854 r101858 1 1 /* 2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2008, 2010, 2011 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 52 52 , m_font(font) 53 53 , m_face(0) 54 , m_loadStartTimer(this, &CSSFontFaceSource::startLoadingTimerFired)55 54 #if ENABLE(SVG_FONTS) 56 55 , m_hasExternalSVGFont(false) … … 63 62 CSSFontFaceSource::~CSSFontFaceSource() 64 63 { 65 m_loadStartTimer.stop();66 64 if (m_font) 67 65 m_font->removeClient(this); … … 178 176 } 179 177 } else { 180 // Kick off the load now. Do it on a zero-delay timer rather than synchronously, because we may be in 181 // the middle of layout, and the loader may invoke arbitrary delegate or event handler code. 182 m_fontSelector = fontSelector; 183 if (!m_loadStartTimer.isActive()) 184 m_loadStartTimer.startOneShot(0); 178 // Kick off the load. Do it soon rather than now, because we may be in the middle of layout, 179 // and the loader may invoke arbitrary delegate or event handler code. 180 fontSelector->beginLoadingFontSoon(m_font.get()); 185 181 186 182 // This temporary font is not retained and should not be returned. … … 199 195 } 200 196 201 void CSSFontFaceSource::startLoadingTimerFired(Timer<WebCore::CSSFontFaceSource>*)202 {203 ASSERT(m_font);204 ASSERT(m_fontSelector);205 206 if (CachedResourceLoader* cachedResourceLoader = m_fontSelector->cachedResourceLoader())207 m_font->beginLoadIfNeeded(cachedResourceLoader);208 209 m_fontSelector = nullptr;210 }211 212 197 #if ENABLE(SVG_FONTS) 213 198 SVGFontFaceElement* CSSFontFaceSource::svgFontFaceElement() const -
trunk/Source/WebCore/css/CSSFontFaceSource.h
r97854 r101858 1 1 /* 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 79 79 HashMap<unsigned, SimpleFontData*> m_fontDataTable; // The hash key is composed of size synthetic styles. 80 80 81 Timer<CSSFontFaceSource> m_loadStartTimer;82 RefPtr<CSSFontSelector> m_fontSelector;83 84 81 #if ENABLE(SVG_FONTS) 85 82 RefPtr<SVGFontFaceElement> m_svgFontFaceElement; -
trunk/Source/WebCore/css/CSSFontSelector.cpp
r101812 r101858 1 1 /* 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved. 3 3 * (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 4 4 * … … 61 61 CSSFontSelector::CSSFontSelector(Document* document) 62 62 : m_document(document) 63 , m_beginLoadingTimer(this, &CSSFontSelector::beginLoadTimerFired) 63 64 { 64 65 // FIXME: An old comment used to say there was no need to hold a reference to m_document … … 72 73 CSSFontSelector::~CSSFontSelector() 73 74 { 75 clearDocument(); 74 76 fontCache()->removeClient(this); 75 77 deleteAllValues(m_fontFaces); … … 81 83 { 82 84 return m_fonts.isEmpty(); 83 }84 85 CachedResourceLoader* CSSFontSelector::cachedResourceLoader() const86 {87 return m_document ? m_document->cachedResourceLoader() : 0;88 85 } 89 86 … … 581 578 } 582 579 583 } 580 void CSSFontSelector::clearDocument() 581 { 582 if (!m_document) { 583 ASSERT(!m_beginLoadingTimer.isActive()); 584 ASSERT(m_fontsToBeginLoading.isEmpty()); 585 return; 586 } 587 588 m_beginLoadingTimer.stop(); 589 590 CachedResourceLoader* cachedResourceLoader = m_document->cachedResourceLoader(); 591 for (size_t i = 0; i < m_fontsToBeginLoading.size(); ++i) { 592 // Balances incrementRequestCount() in beginLoadingFontSoon(). 593 cachedResourceLoader->decrementRequestCount(m_fontsToBeginLoading[i].get()); 594 } 595 596 m_fontsToBeginLoading.clear(); 597 598 m_document = 0; 599 } 600 601 void CSSFontSelector::beginLoadingFontSoon(CachedFont* font) 602 { 603 if (!m_document) 604 return; 605 606 m_fontsToBeginLoading.append(font); 607 // Increment the request count now, in order to prevent didFinishLoad from being dispatched 608 // after this font has been requested but before it began loading. Balanced by 609 // decrementRequestCount() in beginLoadTimerFired() and in clearDocument(). 610 m_document->cachedResourceLoader()->incrementRequestCount(font); 611 m_beginLoadingTimer.startOneShot(0); 612 } 613 614 void CSSFontSelector::beginLoadTimerFired(Timer<WebCore::CSSFontSelector>*) 615 { 616 Vector<CachedResourceHandle<CachedFont> > fontsToBeginLoading; 617 fontsToBeginLoading.swap(m_fontsToBeginLoading); 618 619 CachedResourceLoader* cachedResourceLoader = m_document->cachedResourceLoader(); 620 for (size_t i = 0; i < fontsToBeginLoading.size(); ++i) { 621 fontsToBeginLoading[i]->beginLoadIfNeeded(cachedResourceLoader); 622 // Balances incrementRequestCount() in beginLoadingFontSoon(). 623 cachedResourceLoader->decrementRequestCount(fontsToBeginLoading[i].get()); 624 } 625 } 626 627 } -
trunk/Source/WebCore/css/CSSFontSelector.h
r97854 r101858 1 1 /* 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 #define CSSFontSelector_h 28 28 29 #include "CachedResourceHandle.h" 29 30 #include "FontSelector.h" 31 #include "Timer.h" 30 32 #include <wtf/Forward.h> 31 33 #include <wtf/HashMap.h> … … 39 41 class CSSFontFaceRule; 40 42 class CSSSegmentedFontFace; 43 class CachedFont; 41 44 class Document; 42 class CachedResourceLoader;43 45 class FontDescription; 44 46 … … 53 55 virtual FontData* getFontData(const FontDescription& fontDescription, const AtomicString& familyName); 54 56 55 void clearDocument() { m_document = 0; }57 void clearDocument(); 56 58 57 59 void addFontFaceRule(const CSSFontFaceRule*); … … 62 64 bool isEmpty() const; 63 65 64 CachedResourceLoader* cachedResourceLoader() const;65 66 66 virtual void registerForInvalidationCallbacks(FontSelectorClient*); 67 67 virtual void unregisterForInvalidationCallbacks(FontSelectorClient*); 68 68 69 69 Document* document() const { return m_document; } 70 71 void beginLoadingFontSoon(CachedFont*); 70 72 71 73 private: … … 74 76 void dispatchInvalidationCallbacks(); 75 77 78 void beginLoadTimerFired(Timer<CSSFontSelector>*); 79 76 80 Document* m_document; 77 81 HashMap<String, Vector<RefPtr<CSSFontFace> >*, CaseFoldingHash> m_fontFaces; … … 79 83 HashMap<String, HashMap<unsigned, RefPtr<CSSSegmentedFontFace> >*, CaseFoldingHash> m_fonts; 80 84 HashSet<FontSelectorClient*> m_clients; 85 86 Vector<CachedResourceHandle<CachedFont> > m_fontsToBeginLoading; 87 Timer<CSSFontSelector> m_beginLoadingTimer; 81 88 }; 82 89
Note:
See TracChangeset
for help on using the changeset viewer.