Title: [149070] trunk/Source/WebCore
Revision
149070
Author
beid...@apple.com
Date
2013-04-24 15:35:47 -0700 (Wed, 24 Apr 2013)

Log Message

Once a custom font is cached to disk, it starts failing to render until the page is refreshed.
<rdar://problem/13622998> and https://bugs.webkit.org/show_bug.cgi?id=115131

Reviewed by Alexey Proskuryakov.

No new tests (Not a tested config, nor are disk cache issues currently testable).

* loader/cache/CachedResource.h:
(WebCore::CachedResource:: mayTryReplaceEncodedData): Allow subclasses to refuse encoded data replacement.

* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::tryReplaceEncodedData): Only try if shouldTryReplaceEncodedData() is true.

* loader/cache/CachedFont.cpp:
(WebCore::CachedFont::CachedFont):
(WebCore::CachedFont::ensureCustomFontData):
(WebCore::CachedFont::mayTryReplaceEncodedData): Return false if the custom font data has ever been created.
* loader/cache/CachedFont.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (149069 => 149070)


--- trunk/Source/WebCore/ChangeLog	2013-04-24 22:22:39 UTC (rev 149069)
+++ trunk/Source/WebCore/ChangeLog	2013-04-24 22:35:47 UTC (rev 149070)
@@ -1,3 +1,24 @@
+2013-04-24  Brady Eidson  <beid...@apple.com>
+
+        Once a custom font is cached to disk, it starts failing to render until the page is refreshed.
+        <rdar://problem/13622998> and https://bugs.webkit.org/show_bug.cgi?id=115131
+
+        Reviewed by Alexey Proskuryakov.
+
+        No new tests (Not a tested config, nor are disk cache issues currently testable).
+
+        * loader/cache/CachedResource.h:
+        (WebCore::CachedResource:: mayTryReplaceEncodedData): Allow subclasses to refuse encoded data replacement.
+
+        * loader/cache/CachedResource.cpp:
+        (WebCore::CachedResource::tryReplaceEncodedData): Only try if shouldTryReplaceEncodedData() is true.
+
+        * loader/cache/CachedFont.cpp:
+        (WebCore::CachedFont::CachedFont):
+        (WebCore::CachedFont::ensureCustomFontData):
+        (WebCore::CachedFont::mayTryReplaceEncodedData): Return false if the custom font data has ever been created.
+        * loader/cache/CachedFont.h:
+
 2013-04-24  Beth Dakin  <bda...@apple.com>
 
         Vertical overlay scrollbar in iframes fades in and out rapidly when you scroll in 

Modified: trunk/Source/WebCore/loader/cache/CachedFont.cpp (149069 => 149070)


--- trunk/Source/WebCore/loader/cache/CachedFont.cpp	2013-04-24 22:22:39 UTC (rev 149069)
+++ trunk/Source/WebCore/loader/cache/CachedFont.cpp	2013-04-24 22:35:47 UTC (rev 149070)
@@ -52,6 +52,7 @@
     : CachedResource(resourceRequest, FontResource)
     , m_fontData(0)
     , m_loadInitiated(false)
+    , m_hasCreatedFontData(false)
 {
 }
 
@@ -97,7 +98,9 @@
 {
     if (!m_fontData && !errorOccurred() && !isLoading() && m_data) {
         m_fontData = createFontCustomPlatformData(m_data.get()->sharedBuffer());
-        if (!m_fontData)
+        if (m_fontData)
+            m_hasCreatedFontData = true;
+        else
             setStatus(DecodeError);
     }
     return m_fontData;
@@ -180,4 +183,13 @@
          c->fontLoaded(this);
 }
 
+bool CachedFont::mayTryReplaceEncodedData() const
+{
+    // If the FontCustomPlatformData has ever been constructed then it still might be in use somewhere.
+    // That platform font object might directly reference the encoded data buffer behind this CachedFont,
+    // so replacing it is unsafe.
+
+    return !m_hasCreatedFontData;
 }
+
+}

Modified: trunk/Source/WebCore/loader/cache/CachedFont.h (149069 => 149070)


--- trunk/Source/WebCore/loader/cache/CachedFont.h	2013-04-24 22:22:39 UTC (rev 149069)
+++ trunk/Source/WebCore/loader/cache/CachedFont.h	2013-04-24 22:35:47 UTC (rev 149070)
@@ -64,8 +64,11 @@
 
 private:
     virtual void checkNotify();
+    virtual bool mayTryReplaceEncodedData() const OVERRIDE;
+
     FontCustomPlatformData* m_fontData;
     bool m_loadInitiated;
+    bool m_hasCreatedFontData;
 
 #if ENABLE(SVG_FONTS)
     RefPtr<SVGDocument> m_externalSVGDocument;

Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (149069 => 149070)


--- trunk/Source/WebCore/loader/cache/CachedResource.cpp	2013-04-24 22:22:39 UTC (rev 149069)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp	2013-04-24 22:35:47 UTC (rev 149070)
@@ -906,6 +906,9 @@
     if (!m_data)
         return;
     
+    if (!mayTryReplaceEncodedData())
+        return;
+    
     // Because the disk cache is asynchronous and racey with regards to the data we might be asked to replace,
     // we need to verify that the new buffer has the same contents as our old buffer.
     if (m_data->size() != newBuffer->size() || memcmp(m_data->data(), newBuffer->data(), m_data->size()))

Modified: trunk/Source/WebCore/loader/cache/CachedResource.h (149069 => 149070)


--- trunk/Source/WebCore/loader/cache/CachedResource.h	2013-04-24 22:22:39 UTC (rev 149069)
+++ trunk/Source/WebCore/loader/cache/CachedResource.h	2013-04-24 22:35:47 UTC (rev 149070)
@@ -296,6 +296,7 @@
     void decodedDataDeletionTimerFired(Timer<CachedResource>*);
 
     virtual PurgePriority purgePriority() const { return PurgeDefault; }
+    virtual bool mayTryReplaceEncodedData() const { return true; }
 
     double currentAge() const;
     double freshnessLifetime() const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to