Title: [103440] branches/safari-534.54-branch

Diff

Modified: branches/safari-534.54-branch/LayoutTests/ChangeLog (103439 => 103440)


--- branches/safari-534.54-branch/LayoutTests/ChangeLog	2011-12-21 21:40:37 UTC (rev 103439)
+++ branches/safari-534.54-branch/LayoutTests/ChangeLog	2011-12-21 21:45:37 UTC (rev 103440)
@@ -1,5 +1,18 @@
 2011-12-21  Lucas Forschler  <[email protected]>
 
+    Merge 94508
+
+    2011-09-04  Dan Bernstein  <[email protected]>
+
+            <rdar://problem/10071256> Retain retired custom fonts until the next style recalc
+
+            Reviewed by Darin Adler.
+
+            * fast/css/font-face-used-after-retired-expected.txt: Added.
+            * fast/css/font-face-used-after-retired.html: Added.
+
+2011-12-21  Lucas Forschler  <[email protected]>
+
     Merge 94455
 
     2011-09-02  Dan Bernstein  <[email protected]>

Copied: branches/safari-534.54-branch/LayoutTests/fast/css/font-face-used-after-retired-expected.txt (from rev 94508, trunk/LayoutTests/fast/css/font-face-used-after-retired-expected.txt) (0 => 103440)


--- branches/safari-534.54-branch/LayoutTests/fast/css/font-face-used-after-retired-expected.txt	                        (rev 0)
+++ branches/safari-534.54-branch/LayoutTests/fast/css/font-face-used-after-retired-expected.txt	2011-12-21 21:45:37 UTC (rev 103440)
@@ -0,0 +1,2 @@
+
+PASS

Copied: branches/safari-534.54-branch/LayoutTests/fast/css/font-face-used-after-retired.html (from rev 94508, trunk/LayoutTests/fast/css/font-face-used-after-retired.html) (0 => 103440)


--- branches/safari-534.54-branch/LayoutTests/fast/css/font-face-used-after-retired.html	                        (rev 0)
+++ branches/safari-534.54-branch/LayoutTests/fast/css/font-face-used-after-retired.html	2011-12-21 21:45:37 UTC (rev 103440)
@@ -0,0 +1,20 @@
+<style>
+    @font-face {
+        font-family: custom;
+        src: url(no-such-file.ttf);
+    }
+</style>
+<!-- content: counter(page) causes the style diff to be "detach" -->
+<div style="font-family: custom; content: counter(page);">
+    <br>PASS
+</div>
+<script>
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+        // Must wait for the font to fail to load.
+        setTimeout(function() { layoutTestController.notifyDone() }, 100);
+    }
+
+    document.execCommand("SelectAll");
+</script>

Modified: branches/safari-534.54-branch/Source/WebCore/ChangeLog (103439 => 103440)


--- branches/safari-534.54-branch/Source/WebCore/ChangeLog	2011-12-21 21:40:37 UTC (rev 103439)
+++ branches/safari-534.54-branch/Source/WebCore/ChangeLog	2011-12-21 21:45:37 UTC (rev 103440)
@@ -1,5 +1,43 @@
 2011-12-21  Lucas Forschler  <[email protected]>
 
+    Merge 94508
+
+    2011-09-04  Dan Bernstein  <[email protected]>
+
+            <rdar://problem/10071256> Retain retired custom fonts until the next style recalc
+
+            Reviewed by Darin Adler.
+
+            Test: fast/css/font-face-used-after-retired.html
+
+            During style recalc, existing renderers may reference their old style, including font data.
+            Allow them to do so safely by keeping retired custom font data around until after style recalc.
+
+            * css/CSSFontFace.cpp:
+            (WebCore::CSSFontFace::retireCustomFont): Added. Calls through to CSSFontSelector, if the font
+            face is still part of any segmented font face. Otherwise, deletes the custom font data.
+            * css/CSSFontFace.h:
+            * css/CSSFontFaceSource.cpp:
+            (WebCore::CSSFontFaceSource::pruneTable): Changed to call retireCustomFont() instead of deleting
+            retired font data.
+            * css/CSSFontSelector.cpp:
+            (WebCore::CSSFontSelector::retireCustomFont): Added. Calls through to the Document, if this is
+            still the active font selector for a document. Otherwise, deletes the custom font data.
+            * css/CSSFontSelector.h:
+            * css/CSSSegmentedFontFace.cpp:
+            (WebCore::CSSSegmentedFontFace::pruneTable): Changed to call retireCustomFont() instead of
+            deleting retired font data.
+            * dom/Document.cpp:
+            (WebCore::Document::~Document): Added a call to deleteRetiredCustomFonts(), in case the Document
+            is destroyed before getting a chance to recalc style after custom fonts have been retired.
+            (WebCore::Document::recalcStyle): Added a call to deleteRetiredCustomFonts() after style recalc.
+            (WebCore::Document::deleteRetiredCustomFonts): Added. Deletes all previously-retired custom font
+            data.
+            * dom/Document.h:
+            (WebCore::Document::retireCustomFont): Added.
+
+2011-12-21  Lucas Forschler  <[email protected]>
+
     Merge 94455
 
     2011-09-02  Dan Bernstein  <[email protected]>

Modified: branches/safari-534.54-branch/Source/WebCore/css/CSSFontFace.cpp (103439 => 103440)


--- branches/safari-534.54-branch/Source/WebCore/css/CSSFontFace.cpp	2011-12-21 21:40:37 UTC (rev 103439)
+++ branches/safari-534.54-branch/Source/WebCore/css/CSSFontFace.cpp	2011-12-21 21:45:37 UTC (rev 103440)
@@ -118,6 +118,19 @@
     return 0;
 }
 
+void CSSFontFace::retireCustomFont(SimpleFontData* fontData)
+{
+    if (m_segmentedFontFaces.isEmpty()) {
+        GlyphPageTreeNode::pruneTreeCustomFontData(fontData);
+        delete fontData;
+        return;
+    }
+
+    // Use one of the CSSSegmentedFontFaces' font selector. They all have
+    // the same font selector.
+    (*m_segmentedFontFaces.begin())->fontSelector()->retireCustomFont(fontData);
+}
+
 #if ENABLE(SVG_FONTS)
 bool CSSFontFace::hasSVGFontFaceSource() const
 {

Modified: branches/safari-534.54-branch/Source/WebCore/css/CSSFontFace.h (103439 => 103440)


--- branches/safari-534.54-branch/Source/WebCore/css/CSSFontFace.h	2011-12-21 21:40:37 UTC (rev 103439)
+++ branches/safari-534.54-branch/Source/WebCore/css/CSSFontFace.h	2011-12-21 21:45:37 UTC (rev 103440)
@@ -63,6 +63,7 @@
     void addSource(CSSFontFaceSource*);
 
     void fontLoaded(CSSFontFaceSource*);
+    void retireCustomFont(SimpleFontData*);
 
     SimpleFontData* getFontData(const FontDescription&, bool syntheticBold, bool syntheticItalic);
 

Modified: branches/safari-534.54-branch/Source/WebCore/css/CSSFontFaceSource.cpp (103439 => 103440)


--- branches/safari-534.54-branch/Source/WebCore/css/CSSFontFaceSource.cpp	2011-12-21 21:40:37 UTC (rev 103439)
+++ branches/safari-534.54-branch/Source/WebCore/css/CSSFontFaceSource.cpp	2011-12-21 21:45:37 UTC (rev 103440)
@@ -69,10 +69,11 @@
 {
     if (m_fontDataTable.isEmpty())
         return;
+
     HashMap<unsigned, SimpleFontData*>::iterator end = m_fontDataTable.end();
     for (HashMap<unsigned, SimpleFontData*>::iterator it = m_fontDataTable.begin(); it != end; ++it)
-        GlyphPageTreeNode::pruneTreeCustomFontData(it->second);
-    deleteAllValues(m_fontDataTable);
+        m_face->retireCustomFont(it->second);
+
     m_fontDataTable.clear();
 }
 

Modified: branches/safari-534.54-branch/Source/WebCore/css/CSSFontSelector.cpp (103439 => 103440)


--- branches/safari-534.54-branch/Source/WebCore/css/CSSFontSelector.cpp	2011-12-21 21:40:37 UTC (rev 103439)
+++ branches/safari-534.54-branch/Source/WebCore/css/CSSFontSelector.cpp	2011-12-21 21:45:37 UTC (rev 103440)
@@ -378,6 +378,16 @@
     dispatchInvalidationCallbacks();
 }
 
+void CSSFontSelector::retireCustomFont(FontData* fontData)
+{
+    if (m_document)
+        m_document->retireCustomFont(fontData);
+    else {
+        GlyphPageTreeNode::pruneTreeCustomFontData(fontData);
+        delete fontData;
+    }
+}
+
 static FontData* fontDataForGenericFamily(Document* document, const FontDescription& fontDescription, const AtomicString& familyName)
 {
     if (!document || !document->frame())

Modified: branches/safari-534.54-branch/Source/WebCore/css/CSSFontSelector.h (103439 => 103440)


--- branches/safari-534.54-branch/Source/WebCore/css/CSSFontSelector.h	2011-12-21 21:40:37 UTC (rev 103439)
+++ branches/safari-534.54-branch/Source/WebCore/css/CSSFontSelector.h	2011-12-21 21:45:37 UTC (rev 103440)
@@ -59,6 +59,8 @@
     void fontLoaded();
     virtual void fontCacheInvalidated();
 
+    void retireCustomFont(FontData*);
+
     bool isEmpty() const;
 
     CachedResourceLoader* cachedResourceLoader() const;

Modified: branches/safari-534.54-branch/Source/WebCore/css/CSSSegmentedFontFace.cpp (103439 => 103440)


--- branches/safari-534.54-branch/Source/WebCore/css/CSSSegmentedFontFace.cpp	2011-12-21 21:40:37 UTC (rev 103439)
+++ branches/safari-534.54-branch/Source/WebCore/css/CSSSegmentedFontFace.cpp	2011-12-21 21:45:37 UTC (rev 103440)
@@ -52,10 +52,11 @@
     // Make sure the glyph page tree prunes out all uses of this custom font.
     if (m_fontDataTable.isEmpty())
         return;
+
     HashMap<unsigned, SegmentedFontData*>::iterator end = m_fontDataTable.end();
     for (HashMap<unsigned, SegmentedFontData*>::iterator it = m_fontDataTable.begin(); it != end; ++it)
-        GlyphPageTreeNode::pruneTreeCustomFontData(it->second);
-    deleteAllValues(m_fontDataTable);
+        m_fontSelector->retireCustomFont(it->second);
+
     m_fontDataTable.clear();
 }
 

Modified: branches/safari-534.54-branch/Source/WebCore/dom/Document.cpp (103439 => 103440)


--- branches/safari-534.54-branch/Source/WebCore/dom/Document.cpp	2011-12-21 21:40:37 UTC (rev 103439)
+++ branches/safari-534.54-branch/Source/WebCore/dom/Document.cpp	2011-12-21 21:45:37 UTC (rev 103440)
@@ -544,6 +544,8 @@
             (*m_pageGroupUserSheets)[i]->clearOwnerNode();
     }
 
+    deleteRetiredCustomFonts();
+
     m_weakReference->clear();
 
     if (m_mediaQueryMatcher)
@@ -1526,6 +1528,9 @@
         if (change >= Inherit || n->childNeedsStyleRecalc() || n->needsStyleRecalc())
             n->recalcStyle(change);
 
+    // Now that all RenderStyles that pointed to retired fonts have been updated, the fonts can safely be deleted.
+    deleteRetiredCustomFonts();
+
 #if USE(ACCELERATED_COMPOSITING)
     if (view()) {
         bool layoutPending = view()->layoutPending() || renderer()->needsLayout();
@@ -1662,6 +1667,20 @@
     return style.release();
 }
 
+void Document::retireCustomFont(FontData* fontData)
+{
+    m_retiredCustomFonts.append(adoptPtr(fontData));
+}
+
+void Document::deleteRetiredCustomFonts()
+{
+    size_t size = m_retiredCustomFonts.size();
+    for (size_t i = 0; i < size; ++i)
+        GlyphPageTreeNode::pruneTreeCustomFontData(m_retiredCustomFonts[i].get());
+
+    m_retiredCustomFonts.clear();
+}
+
 bool Document::isPageBoxVisible(int pageIndex)
 {
     RefPtr<RenderStyle> style = styleForPage(pageIndex);

Modified: branches/safari-534.54-branch/Source/WebCore/dom/Document.h (103439 => 103440)


--- branches/safari-534.54-branch/Source/WebCore/dom/Document.h	2011-12-21 21:40:37 UTC (rev 103439)
+++ branches/safari-534.54-branch/Source/WebCore/dom/Document.h	2011-12-21 21:45:37 UTC (rev 103440)
@@ -80,6 +80,7 @@
 class Event;
 class EventListener;
 class EventQueue;
+class FontData;
 class FormAssociatedElement;
 class Frame;
 class FrameView;
@@ -543,6 +544,8 @@
     PassRefPtr<RenderStyle> styleForElementIgnoringPendingStylesheets(Element*);
     PassRefPtr<RenderStyle> styleForPage(int pageIndex);
 
+    void retireCustomFont(FontData*);
+
     // Returns true if page box (margin boxes and page borders) is visible.
     bool isPageBoxVisible(int pageIndex);
 
@@ -1158,6 +1161,8 @@
 
     void createStyleSelector();
 
+    void deleteRetiredCustomFonts();
+
     PassRefPtr<NodeList> handleZeroPadding(const HitTestRequest&, HitTestResult&) const;
 
     void loadEventDelayTimerFired(Timer<Document>*);
@@ -1171,7 +1176,8 @@
     OwnPtr<CSSStyleSelector> m_styleSelector;
     bool m_didCalculateStyleSelector;
     bool m_hasDirtyStyleSelector;
-    
+    Vector<OwnPtr<FontData> > m_retiredCustomFonts;
+
     mutable RefPtr<CSSPrimitiveValueCache> m_cssPrimitiveValueCache;
 
     Frame* m_frame;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to