Title: [133290] trunk/Source/WebCore
Revision
133290
Author
schen...@chromium.org
Date
2012-11-02 06:33:57 -0700 (Fri, 02 Nov 2012)

Log Message

SVG classes cause layering violations in platform Font code
https://bugs.webkit.org/show_bug.cgi?id=98513

Reviewed by Eric Seidel.

Add a contained class to save and restore GlpyhPage state in FontFallbackList.
This allows us to remove the layering violation, and several methods, that
previously existed to support SVGTextRunRenderingContext.

No new tests because no change at all in functionality.

* platform/graphics/FontFallbackList.h:
(FontFallbackList):
(GlyphPagesStateSaver): New state save and restore class
(WebCore::FontFallbackList::GlyphPagesStateSaver::GlyphPagesStateSaver): Save GlyphPage state
(WebCore::FontFallbackList::GlyphPagesStateSaver::~GlyphPagesStateSaver): Restore GlyphPage state
* rendering/svg/SVGTextRunRenderingContext.cpp:
(WebCore::SVGTextRunRenderingContext::glyphDataForCharacter): Shift to usage of the new class.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (133289 => 133290)


--- trunk/Source/WebCore/ChangeLog	2012-11-02 13:00:41 UTC (rev 133289)
+++ trunk/Source/WebCore/ChangeLog	2012-11-02 13:33:57 UTC (rev 133290)
@@ -1,3 +1,24 @@
+2012-11-02  Stephen Chenney  <schen...@chromium.org>
+
+        SVG classes cause layering violations in platform Font code
+        https://bugs.webkit.org/show_bug.cgi?id=98513
+
+        Reviewed by Eric Seidel.
+
+        Add a contained class to save and restore GlpyhPage state in FontFallbackList.
+        This allows us to remove the layering violation, and several methods, that
+        previously existed to support SVGTextRunRenderingContext.
+
+        No new tests because no change at all in functionality.
+
+        * platform/graphics/FontFallbackList.h:
+        (FontFallbackList):
+        (GlyphPagesStateSaver): New state save and restore class
+        (WebCore::FontFallbackList::GlyphPagesStateSaver::GlyphPagesStateSaver): Save GlyphPage state
+        (WebCore::FontFallbackList::GlyphPagesStateSaver::~GlyphPagesStateSaver): Restore GlyphPage state
+        * rendering/svg/SVGTextRunRenderingContext.cpp:
+        (WebCore::SVGTextRunRenderingContext::glyphDataForCharacter): Shift to usage of the new class.
+
 2012-11-02  Vsevolod Vlasov  <vse...@chromium.org>
 
         Web Inspector: Fix compilation errors

Modified: trunk/Source/WebCore/platform/graphics/FontFallbackList.h (133289 => 133290)


--- trunk/Source/WebCore/platform/graphics/FontFallbackList.h	2012-11-02 13:00:41 UTC (rev 133289)
+++ trunk/Source/WebCore/platform/graphics/FontFallbackList.h	2012-11-02 13:33:57 UTC (rev 133290)
@@ -41,6 +41,29 @@
 class FontFallbackList : public RefCounted<FontFallbackList> {
     WTF_MAKE_NONCOPYABLE(FontFallbackList);
 public:
+    typedef HashMap<int, GlyphPageTreeNode*, DefaultHash<int>::Hash> GlyphPages;
+
+    class GlyphPagesStateSaver {
+    public:
+        GlyphPagesStateSaver(FontFallbackList& fallbackList)
+            : m_fallbackList(fallbackList)
+            , m_pages(fallbackList.m_pages)
+            , m_pageZero(fallbackList.m_pageZero)
+        {
+        }
+
+        ~GlyphPagesStateSaver()
+        {
+            m_fallbackList.m_pages = m_pages;
+            m_fallbackList.m_pageZero = m_pageZero;
+        }
+
+    private:
+        FontFallbackList& m_fallbackList;
+        GlyphPages& m_pages;
+        GlyphPageTreeNode* m_pageZero;
+    };
+
     static PassRefPtr<FontFallbackList> create() { return adoptRef(new FontFallbackList()); }
 
     ~FontFallbackList() { releaseFontData(); }
@@ -56,10 +79,6 @@
     unsigned fontSelectorVersion() const { return m_fontSelectorVersion; }
     unsigned generation() const { return m_generation; }
 
-    typedef HashMap<int, GlyphPageTreeNode*, DefaultHash<int>::Hash> GlyphPages;
-    GlyphPageTreeNode* glyphPageZero() const { return m_pageZero; }
-    const GlyphPages& glyphPages() const { return m_pages; }
-
 private:
     FontFallbackList();
 
@@ -77,8 +96,6 @@
     void setPlatformFont(const FontPlatformData&);
 
     void releaseFontData();
-    void setGlyphPageZero(GlyphPageTreeNode* pageZero) { m_pageZero = pageZero; }
-    void setGlyphPages(const GlyphPages& pages) { m_pages = pages; }
     
     mutable Vector<RefPtr<FontData>, 1> m_fontList;
     mutable GlyphPages m_pages;
@@ -92,7 +109,6 @@
     mutable bool m_loadingCustomFonts : 1;
 
     friend class Font;
-    friend class SVGTextRunRenderingContext;
 };
 
 }

Modified: trunk/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp (133289 => 133290)


--- trunk/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp	2012-11-02 13:00:41 UTC (rev 133289)
+++ trunk/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp	2012-11-02 13:33:57 UTC (rev 133290)
@@ -188,6 +188,12 @@
         return glyphData;
     }
 
+    // Save data fromt he font fallback list because we may modify it later. Do this before the
+    // potential change to glyphData.fontData below.
+    FontFallbackList* fontList = font.fontList();
+    ASSERT(fontList);
+    FontFallbackList::GlyphPagesStateSaver glyphPagesSaver(*fontList);
+
     // Characters enclosed by an <altGlyph> element, may not be registered in the GlyphPage.
     const SimpleFontData* originalFontData = glyphData.fontData;
     if (glyphData.fontData && !glyphData.fontData->isSVGFont()) {
@@ -225,14 +231,9 @@
     GlyphPage* page = pair.second;
     ASSERT(page);
 
-    FontFallbackList* fontList = font.fontList();
-    ASSERT(fontList);
-
     // No suitable glyph found that is compatible with the requirments (same language, arabic-form, orientation etc.)
     // Even though our GlyphPage contains an entry for eg. glyph "a", it's not compatible. So we have to temporarily
     // remove the glyph data information from the GlyphPage, and retry the lookup, which handles font fallbacks correctly.
-    GlyphPageTreeNode* originalGlyphPageZero = fontList->glyphPageZero();
-    const FontFallbackList::GlyphPages& originalGlyphPages = fontList->glyphPages();
     page->setGlyphDataForCharacter(character, glyphData.glyph, 0);
 
     // Assure that the font fallback glyph selection worked, aka. the fallbackGlyphData font data is not the same as before.
@@ -242,8 +243,6 @@
     // Restore original state of the SVG Font glyph table and the current font fallback list,
     // to assure the next lookup of the same glyph won't immediately return the fallback glyph.
     page->setGlyphDataForCharacter(character, glyphData.glyph, originalFontData);
-    fontList->setGlyphPageZero(originalGlyphPageZero);
-    fontList->setGlyphPages(originalGlyphPages);
     ASSERT(fallbackGlyphData.fontData);
     return fallbackGlyphData;
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to