Title: [181597] trunk/Source/WebCore

Diff

Modified: trunk/Source/WebCore/ChangeLog (181596 => 181597)


--- trunk/Source/WebCore/ChangeLog	2015-03-16 23:46:43 UTC (rev 181596)
+++ trunk/Source/WebCore/ChangeLog	2015-03-16 23:55:50 UTC (rev 181597)
@@ -1,3 +1,16 @@
+2015-03-16  Commit Queue  <commit-qu...@webkit.org>
+
+        Unreviewed, rolling out r181492.
+        https://bugs.webkit.org/show_bug.cgi?id=142756
+
+        May have regressed PLT (Requested by anttik on #webkit).
+
+        Reverted changeset:
+
+        "Cache glyph widths to GlyphPages"
+        https://bugs.webkit.org/show_bug.cgi?id=142028
+        http://trac.webkit.org/changeset/181492
+
 2015-03-16  Roger Fong  <roger_f...@apple.com>
 
         [WebGL2] Instancing draw calls.

Modified: trunk/Source/WebCore/platform/graphics/Font.cpp (181596 => 181597)


--- trunk/Source/WebCore/platform/graphics/Font.cpp	2015-03-16 23:46:43 UTC (rev 181596)
+++ trunk/Source/WebCore/platform/graphics/Font.cpp	2015-03-16 23:55:50 UTC (rev 181597)
@@ -54,9 +54,16 @@
     : m_maxCharWidth(-1)
     , m_avgCharWidth(-1)
     , m_platformData(platformData)
+    , m_treatAsFixedPitch(false)
     , m_isCustomFont(isCustomFont)
     , m_isLoading(isLoading)
     , m_isTextOrientationFallback(isTextOrientationFallback)
+    , m_isBrokenIdeographFallback(false)
+    , m_mathData(nullptr)
+#if ENABLE(OPENTYPE_VERTICAL)
+    , m_verticalData(0)
+#endif
+    , m_hasVerticalGlyphs(false)
 {
     platformInit();
     platformGlyphInit();
@@ -72,11 +79,21 @@
 Font::Font(std::unique_ptr<SVGData> svgData, float fontSize, bool syntheticBold, bool syntheticItalic)
     : m_platformData(FontPlatformData(fontSize, syntheticBold, syntheticItalic))
     , m_svgData(WTF::move(svgData))
+    , m_treatAsFixedPitch(false)
     , m_isCustomFont(true)
+    , m_isLoading(false)
+    , m_isTextOrientationFallback(false)
+    , m_isBrokenIdeographFallback(false)
+    , m_mathData(nullptr)
+#if ENABLE(OPENTYPE_VERTICAL)
+    , m_verticalData(0)
+#endif
+    , m_hasVerticalGlyphs(false)
+#if PLATFORM(IOS)
+    , m_shouldNotBeUsedForArabic(false)
+#endif
 {
     m_svgData->initializeFont(this, fontSize);
-    if (m_glyphPageZero)
-        m_glyphPageZero->setImmutable();
 }
 
 // Estimates of avgCharWidth and maxCharWidth for platforms that don't support accessing these values from the font.
@@ -89,7 +106,7 @@
         static const UChar32 digitZeroChar = '0';
         Glyph digitZeroGlyph = glyphPageZero->glyphDataForCharacter(digitZeroChar).glyph;
         if (digitZeroGlyph)
-            m_avgCharWidth = computeWidthForGlyph(digitZeroGlyph);
+            m_avgCharWidth = widthForGlyph(digitZeroGlyph);
     }
 
     // If we can't retrieve the width of a '0', fall back to the x height.
@@ -104,37 +121,35 @@
 {
     auto* glyphPageZero = glyphPage(0);
     if (!glyphPageZero) {
+        m_spaceGlyph = 0;
+        m_spaceWidth = 0;
+        m_zeroGlyph = 0;
+        m_adjustedSpaceWidth = 0;
         determinePitch();
+        m_zeroWidthSpaceGlyph = 0;
         return;
     }
+
     // Ask for the glyph for 0 to avoid paging in ZERO WIDTH SPACE. Control characters, including 0,
     // are mapped to the ZERO WIDTH SPACE glyph.
     m_zeroWidthSpaceGlyph = glyphPageZero->glyphDataForCharacter(0).glyph;
+
     // Nasty hack to determine if we should round or ceil space widths.
     // If the font is monospace or fake monospace we ceil to ensure that 
     // every character and the space are the same width. Otherwise we round.
-    auto spaceGlyphData = glyphPageZero->glyphDataForCharacter(' ');
-    m_spaceGlyph = spaceGlyphData.glyph;
-    m_spaceWidth = spaceGlyphData.width;
-    m_fontMetrics.setZeroWidth(glyphPageZero->glyphDataForCharacter('0').width);
+    m_spaceGlyph = glyphPageZero->glyphDataForCharacter(' ').glyph;
+    float width = widthForGlyph(m_spaceGlyph);
+    m_spaceWidth = width;
+    m_zeroGlyph = glyphPageZero->glyphDataForCharacter('0').glyph;
+    m_fontMetrics.setZeroWidth(widthForGlyph(m_zeroGlyph));
     determinePitch();
-    m_adjustedSpaceWidth = m_treatAsFixedPitch ? ceilf(m_spaceWidth) : roundf(m_spaceWidth);
-    m_glyphZeroWidth = computeWidthForGlyph(0);
+    m_adjustedSpaceWidth = m_treatAsFixedPitch ? ceilf(width) : roundf(width);
 
     // Force the glyph for ZERO WIDTH SPACE to have zero width, unless it is shared with SPACE.
     // Helvetica is an example of a non-zero width ZERO WIDTH SPACE glyph.
     // See <http://bugs.webkit.org/show_bug.cgi?id=13178> and Font::isZeroWidthSpaceGlyph()
     if (m_zeroWidthSpaceGlyph == m_spaceGlyph)
         m_zeroWidthSpaceGlyph = 0;
-    else {
-        // Fixup the page zero now that we know the zero width glyph.
-        for (unsigned i = 0; i < GlyphPage::size; ++i) {
-            auto glyphData = m_glyphPageZero->glyphDataForIndex(i);
-            if (glyphData.glyph == m_zeroWidthSpaceGlyph)
-                m_glyphPageZero->setGlyphDataForIndex(i, { glyphData.glyph, 0, glyphData.font });
-        }
-    }
-    m_glyphPageZero->setImmutable();
 }
 
 Font::~Font()
@@ -156,7 +171,7 @@
     return hasGlyphs;
 }
 
-RefPtr<GlyphPage> createAndFillGlyphPage(unsigned pageNumber, const Font* font)
+static RefPtr<GlyphPage> createAndFillGlyphPage(unsigned pageNumber, const Font* font)
 {
 #if PLATFORM(IOS)
     // FIXME: Times New Roman contains Arabic glyphs, but Core Text doesn't know how to shape them. See <rdar://problem/9823975>.
@@ -229,45 +244,22 @@
     if (!haveGlyphs)
         return nullptr;
 
+    glyphPage->setImmutable();
     return glyphPage;
 }
 
-float Font::computeWidthForGlyph(Glyph glyph) const
-{
-    if (isZeroWidthSpaceGlyph(glyph))
-        return 0;
-    float width;
-    if (isSVGFont())
-        width = m_svgData->widthForSVGGlyph(glyph, m_platformData.size());
-#if ENABLE(OPENTYPE_VERTICAL)
-    else if (m_verticalData)
-#if USE(CG) || USE(CAIRO)
-        width = m_verticalData->advanceHeight(this, glyph) + m_syntheticBoldOffset;
-#else
-        width = m_verticalData->advanceHeight(this, glyph);
-#endif
-#endif
-    else
-        width = platformWidthForGlyph(glyph);
-    return width;
-}
-
 const GlyphPage* Font::glyphPage(unsigned pageNumber) const
 {
     if (!pageNumber) {
         if (!m_glyphPageZero)
             m_glyphPageZero = createAndFillGlyphPage(0, this);
-        // Zero page is marked immutable in platformGlyphInit.
         return m_glyphPageZero.get();
     }
     auto addResult = m_glyphPages.add(pageNumber, nullptr);
-    auto& page = addResult.iterator->value;
-    if (addResult.isNewEntry) {
-        page = createAndFillGlyphPage(pageNumber, this);
-        if (page)
-            page->setImmutable();
-    }
-    return page.get();
+    if (addResult.isNewEntry)
+        addResult.iterator->value = createAndFillGlyphPage(pageNumber, this);
+
+    return addResult.iterator->value.get();
 }
 
 Glyph Font::glyphForCharacter(UChar32 character) const
@@ -466,10 +458,4 @@
     }
 }
 
-void GlyphPage::setGlyphDataForIndex(unsigned index, Glyph glyph, const Font* font)
-{
-    setGlyphDataForIndex(index, { glyph, font ? font->computeWidthForGlyph(glyph) : 0, font });
-}
-
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/Font.h (181596 => 181597)


--- trunk/Source/WebCore/platform/graphics/Font.h	2015-03-16 23:46:43 UTC (rev 181596)
+++ trunk/Source/WebCore/platform/graphics/Font.h	2015-03-16 23:55:50 UTC (rev 181597)
@@ -140,9 +140,10 @@
     void setAvgCharWidth(float avgCharWidth) { m_avgCharWidth = avgCharWidth; }
 
     FloatRect boundsForGlyph(Glyph) const;
+    float widthForGlyph(Glyph) const;
+    FloatRect platformBoundsForGlyph(Glyph) const;
+    float platformWidthForGlyph(Glyph) const;
 
-    float computeWidthForGlyph(Glyph) const;
-
     float spaceWidth() const { return m_spaceWidth; }
     float adjustedSpaceWidth() const { return m_adjustedSpaceWidth; }
     void setSpaceWidths(float spaceWidth)
@@ -150,7 +151,6 @@
         m_spaceWidth = spaceWidth;
         m_adjustedSpaceWidth = spaceWidth;
     }
-    float glyphZeroWidth() const { return m_glyphZeroWidth; }
 
 #if USE(CG) || USE(CAIRO)
     float syntheticBoldOffset() const { return m_syntheticBoldOffset; }
@@ -161,6 +161,8 @@
     Glyph zeroWidthSpaceGlyph() const { return m_zeroWidthSpaceGlyph; }
     void setZeroWidthSpaceGlyph(Glyph spaceGlyph) { m_zeroWidthSpaceGlyph = spaceGlyph; }
     bool isZeroWidthSpaceGlyph(Glyph glyph) const { return glyph == m_zeroWidthSpaceGlyph && glyph; }
+    Glyph zeroGlyph() const { return m_zeroGlyph; }
+    void setZeroGlyph(Glyph zeroGlyph) { m_zeroGlyph = zeroGlyph; }
 
     GlyphData glyphDataForCharacter(UChar32) const;
     Glyph glyphForCharacter(UChar32) const;
@@ -225,13 +227,8 @@
     PassRefPtr<Font> createScaledFont(const FontDescription&, float scaleFactor) const;
     PassRefPtr<Font> platformCreateScaledFont(const FontDescription&, float scaleFactor) const;
 
-    float platformWidthForGlyph(Glyph) const;
-    FloatRect platformBoundsForGlyph(Glyph) const;
-
     void removeFromSystemFallbackCache();
 
-    friend RefPtr<GlyphPage> createAndFillGlyphPage(unsigned pageNumber, const Font*);
-
 #if PLATFORM(WIN)
     void initGDIFont();
     void platformCommonDestroy();
@@ -249,13 +246,14 @@
     mutable RefPtr<GlyphPage> m_glyphPageZero;
     mutable HashMap<unsigned, RefPtr<GlyphPage>> m_glyphPages;
     mutable std::unique_ptr<GlyphMetricsMap<FloatRect>> m_glyphToBoundsMap;
+    mutable GlyphMetricsMap<float> m_glyphToWidthMap;
 
-    bool m_treatAsFixedPitch { false };
-    bool m_isCustomFont { false }; // Whether or not we are custom font loaded via @font-face
-    bool m_isLoading { false }; // Whether or not this custom font is still in the act of loading.
+    bool m_treatAsFixedPitch;
+    bool m_isCustomFont; // Whether or not we are custom font loaded via @font-face
+    bool m_isLoading; // Whether or not this custom font is still in the act of loading.
 
-    bool m_isTextOrientationFallback { false };
-    bool m_isBrokenIdeographFallback { false };
+    bool m_isTextOrientationFallback;
+    bool m_isBrokenIdeographFallback;
 
     bool m_isUsedInSystemFallbackCache { false };
 
@@ -263,16 +261,15 @@
 #if ENABLE(OPENTYPE_VERTICAL)
     RefPtr<OpenTypeVerticalData> m_verticalData;
 #endif
-    bool m_hasVerticalGlyphs { false };
+    bool m_hasVerticalGlyphs;
 
-    Glyph m_spaceGlyph { 0 };
-    float m_spaceWidth { 0 };
-    float m_adjustedSpaceWidth { 0 };
+    Glyph m_spaceGlyph;
+    float m_spaceWidth;
+    Glyph m_zeroGlyph;
+    float m_adjustedSpaceWidth;
 
-    Glyph m_zeroWidthSpaceGlyph { 0 };
+    Glyph m_zeroWidthSpaceGlyph;
 
-    float m_glyphZeroWidth { 0 };
-
     struct DerivedFontData {
         explicit DerivedFontData(bool custom)
             : forCustomFont(custom)
@@ -312,7 +309,7 @@
     mutable SCRIPT_FONTPROPERTIES* m_scriptFontProperties;
 #endif
 #if PLATFORM(IOS)
-    bool m_shouldNotBeUsedForArabic { false };
+    bool m_shouldNotBeUsedForArabic;
 #endif
 };
 
@@ -335,6 +332,32 @@
     return bounds;
 }
 
+ALWAYS_INLINE float Font::widthForGlyph(Glyph glyph) const
+{
+    if (isZeroWidthSpaceGlyph(glyph))
+        return 0;
+
+    float width = m_glyphToWidthMap.metricsForGlyph(glyph);
+    if (width != cGlyphSizeUnknown)
+        return width;
+
+    if (isSVGFont())
+        width = m_svgData->widthForSVGGlyph(glyph, m_platformData.size());
+#if ENABLE(OPENTYPE_VERTICAL)
+    else if (m_verticalData)
+#if USE(CG) || USE(CAIRO)
+        width = m_verticalData->advanceHeight(this, glyph) + m_syntheticBoldOffset;
+#else
+        width = m_verticalData->advanceHeight(this, glyph);
+#endif
+#endif
+    else
+        width = platformWidthForGlyph(glyph);
+
+    m_glyphToWidthMap.setMetricsForGlyph(glyph, width);
+    return width;
+}
+
 } // namespace WebCore
 
 #endif // Font_h

Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (181596 => 181597)


--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp	2015-03-16 23:46:43 UTC (rev 181596)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp	2015-03-16 23:55:50 UTC (rev 181597)
@@ -1339,7 +1339,7 @@
         return bounds.x() + bounds.width() / 2;
     }
     // FIXME: Use glyph bounds once they make sense for vertical fonts.
-    return fontData->computeWidthForGlyph(glyph) / 2;
+    return fontData->widthForGlyph(glyph) / 2;
 }
 
 inline static float offsetToMiddleOfGlyphAtIndex(const GlyphBuffer& glyphBuffer, size_t i)

Modified: trunk/Source/WebCore/platform/graphics/FontCascadeFonts.cpp (181596 => 181597)


--- trunk/Source/WebCore/platform/graphics/FontCascadeFonts.cpp	2015-03-16 23:46:43 UTC (rev 181596)
+++ trunk/Source/WebCore/platform/graphics/FontCascadeFonts.cpp	2015-03-16 23:55:50 UTC (rev 181597)
@@ -387,7 +387,7 @@
             cachedPage = GlyphPage::createCopyForMixedFonts(*cachedPage);
 
         glyphData = glyphDataForNormalVariant(c, description);
-        cachedPage->setGlyphDataForCharacter(c, glyphData);
+        cachedPage->setGlyphDataForCharacter(c, glyphData.glyph, glyphData.font);
     }
     return glyphData;
 }

Modified: trunk/Source/WebCore/platform/graphics/GlyphPage.h (181596 => 181597)


--- trunk/Source/WebCore/platform/graphics/GlyphPage.h	2015-03-16 23:46:43 UTC (rev 181596)
+++ trunk/Source/WebCore/platform/graphics/GlyphPage.h	2015-03-16 23:55:50 UTC (rev 181597)
@@ -44,16 +44,13 @@
 // Holds the glyph index and the corresponding Font information for a given
 // character.
 struct GlyphData {
-    GlyphData() { }
-    GlyphData(Glyph glyph, float width, const Font* font)
-        : glyph(glyph)
-        , width(width)
-        , font(font)
-    { }
-
-    Glyph glyph { 0 };
-    float width { 0 };
-    const Font* font { nullptr };
+    GlyphData(Glyph g = 0, const Font* f = 0)
+        : glyph(g)
+        , font(f)
+    {
+    }
+    Glyph glyph;
+    const Font* font;
 };
 
 #if COMPILER(MSVC)
@@ -112,10 +109,9 @@
     {
         ASSERT_WITH_SECURITY_IMPLICATION(index < size);
         Glyph glyph = m_glyphs[index];
-        float width = m_widths[index];
         if (hasPerGlyphFontData())
-            return { glyph, width, m_perGlyphFontData[index] };
-        return { glyph, width, glyph ? m_fontForAllGlyphs : nullptr };
+            return GlyphData(glyph, m_perGlyphFontData[index]);
+        return GlyphData(glyph, glyph ? m_fontForAllGlyphs : 0);
     }
 
     ALWAYS_INLINE Glyph glyphAt(unsigned index) const
@@ -132,31 +128,33 @@
         return m_glyphs[index] ? m_fontForAllGlyphs : 0;
     }
 
-    void setGlyphDataForCharacter(UChar32 c, const GlyphData& glyphData)
+    void setGlyphDataForCharacter(UChar32 c, Glyph g, const Font* f)
     {
-        setGlyphDataForIndex(indexForCharacter(c), glyphData);
+        setGlyphDataForIndex(indexForCharacter(c), g, f);
     }
 
-    void setGlyphDataForIndex(unsigned index, Glyph, const Font*);
-
-    void setGlyphDataForIndex(unsigned index, const GlyphData& glyphData)
+    void setGlyphDataForIndex(unsigned index, Glyph glyph, const Font* font)
     {
         ASSERT_WITH_SECURITY_IMPLICATION(index < size);
         ASSERT(!m_isImmutable);
+        
+        m_glyphs[index] = glyph;
 
-        m_glyphs[index] = glyphData.glyph;
-        m_widths[index] = glyphData.width;
-
         // GlyphPage getters will always return a null Font* for glyph #0 if there's no per-glyph font array.
         if (hasPerGlyphFontData()) {
-            m_perGlyphFontData[index] =  glyphData.glyph ?  glyphData.font : 0;
+            m_perGlyphFontData[index] = glyph ? font : 0;
             return;
         }
 
         // A single-font GlyphPage already assigned m_fontForAllGlyphs in the constructor.
-        ASSERT(!glyphData.glyph || glyphData.font == m_fontForAllGlyphs);
+        ASSERT(!glyph || font == m_fontForAllGlyphs);
     }
 
+    void setGlyphDataForIndex(unsigned index, const GlyphData& glyphData)
+    {
+        setGlyphDataForIndex(index, glyphData.glyph, glyphData.font);
+    }
+
     // Implemented by the platform.
     bool fill(unsigned offset, unsigned length, UChar* characterBuffer, unsigned bufferLength, const Font*);
 #if PLATFORM(COCOA)
@@ -170,7 +168,6 @@
         : m_fontForAllGlyphs(fontForAllGlyphs)
     {
         memset(m_glyphs, 0, sizeof(m_glyphs));
-        memset(m_widths, 0, sizeof(m_widths));
         if (hasPerGlyphFontData())
             memset(m_perGlyphFontData, 0, sizeof(Font*) * GlyphPage::size);
         ++s_count;
@@ -178,9 +175,8 @@
 
     bool hasPerGlyphFontData() const { return !m_fontForAllGlyphs; }
 
-    const Font* m_fontForAllGlyphs { nullptr };
+    const Font* m_fontForAllGlyphs;
     Glyph m_glyphs[size];
-    float m_widths[size];
 
     bool m_isImmutable { false };
     // NOTE: This array has (GlyphPage::size) elements if m_fontForAllGlyphs is null.

Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.cpp (181596 => 181597)


--- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp	2015-03-16 23:46:43 UTC (rev 181596)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.cpp	2015-03-16 23:55:50 UTC (rev 181597)
@@ -191,7 +191,7 @@
         if (character == '\t' && m_run.allowTabs())
             width = m_font->tabWidth(*font, m_run.tabSize(), m_run.xPos() + m_runWidthSoFar + widthSinceLastRounding);
         else {
-            width = glyphData.width;
+            width = font->widthForGlyph(glyph);
 
             // SVG uses horizontalGlyphStretch(), when textLength is used to stretch/squeeze text.
             width *= m_run.horizontalGlyphStretch();

Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp (181596 => 181597)


--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp	2015-03-16 23:46:43 UTC (rev 181596)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp	2015-03-16 23:55:50 UTC (rev 181597)
@@ -638,7 +638,7 @@
             CGSize advance = treatAsSpace ? CGSizeMake(spaceWidth, advances[i].height) : advances[i];
 #if PLATFORM(IOS)
             if (isEmoji && advance.width)
-                advance.width = font.computeWidthForGlyph(glyph);
+                advance.width = font.widthForGlyph(glyph);
 #endif
 
             if (ch == '\t' && m_run.allowTabs())

Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm (181596 => 181597)


--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm	2015-03-16 23:46:43 UTC (rev 181596)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm	2015-03-16 23:55:50 UTC (rev 181597)
@@ -168,7 +168,7 @@
     // Synthesize a run of missing glyphs.
     m_glyphsVector.fill(0, m_glyphCount);
     m_glyphs = m_glyphsVector.data();
-    m_advancesVector.fill(CGSizeMake(m_font.glyphZeroWidth(), 0), m_glyphCount);
+    m_advancesVector.fill(CGSizeMake(m_font.widthForGlyph(0), 0), m_glyphCount);
     m_advances = m_advancesVector.data();
 }
 

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp (181596 => 181597)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp	2015-03-16 23:46:43 UTC (rev 181596)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp	2015-03-16 23:55:50 UTC (rev 181597)
@@ -1343,10 +1343,7 @@
 
 float RenderMathMLOperator::advanceForGlyph(const GlyphData& data) const
 {
-    // FIXME: MathML code synthesizes bad GlyphDatas.
-    if (!data.font)
-        return 0;
-    return data.width ? data.width : data.font->computeWidthForGlyph(data.glyph);
+    return data.font && data.glyph ? data.font->widthForGlyph(data.glyph) : 0;
 }
 
 void RenderMathMLOperator::computePreferredLogicalWidths()

Modified: trunk/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp (181596 => 181597)


--- trunk/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp	2015-03-16 23:46:43 UTC (rev 181596)
+++ trunk/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp	2015-03-16 23:55:50 UTC (rev 181597)
@@ -298,8 +298,7 @@
     SVGFontElement* fontElement;
     SVGFontFaceElement* fontFaceElement;
     svgFontAndFontFaceElementForFontData(&primaryFont, fontFaceElement, fontElement);
-    auto missingGlyph = fontElement->missingGlyph();
-    return { missingGlyph, primaryFont.computeWidthForGlyph(missingGlyph), &primaryFont };
+    return GlyphData(fontElement->missingGlyph(), &primaryFont);
 }
 
 GlyphData SVGTextRunRenderingContext::glyphDataForCharacter(const FontCascade& font, WidthIterator& iterator, UChar32 character, bool mirror, int currentCharacter, unsigned& advanceLength, String& normalizedSpacesStringCache)

Modified: trunk/Source/WebCore/svg/SVGFontData.cpp (181596 => 181597)


--- trunk/Source/WebCore/svg/SVGFontData.cpp	2015-03-16 23:46:43 UTC (rev 181596)
+++ trunk/Source/WebCore/svg/SVGFontData.cpp	2015-03-16 23:55:50 UTC (rev 181597)
@@ -79,7 +79,7 @@
     if (!xHeight && glyphPageZero) {
         // Fallback if x_heightAttr is not specified for the font element.
         Glyph letterXGlyph = glyphPageZero->glyphDataForCharacter('x').glyph;
-        xHeight = letterXGlyph ? font->computeWidthForGlyph(letterXGlyph) : 2 * ascent / 3;
+        xHeight = letterXGlyph ? font->widthForGlyph(letterXGlyph) : 2 * ascent / 3;
     }
 
     FontMetrics& fontMetrics = font->fontMetrics();
@@ -99,17 +99,17 @@
     }
 
     // Calculate space width.
-    auto spaceGlyphData = glyphPageZero->glyphDataForCharacter(' ');
-    font->setSpaceGlyph(spaceGlyphData.glyph);
-    font->setSpaceWidths(spaceGlyphData.width);
+    Glyph spaceGlyph = glyphPageZero->glyphDataForCharacter(' ').glyph;
+    font->setSpaceGlyph(spaceGlyph);
+    font->setSpaceWidths(font->widthForGlyph(spaceGlyph));
 
     // Estimate average character width.
-    auto numeralZeroGlyphData = glyphPageZero->glyphDataForCharacter('0');
-    font->setAvgCharWidth(numeralZeroGlyphData.glyph ? numeralZeroGlyphData.width : font->spaceWidth());
+    Glyph numeralZeroGlyph = glyphPageZero->glyphDataForCharacter('0').glyph;
+    font->setAvgCharWidth(numeralZeroGlyph ? font->widthForGlyph(numeralZeroGlyph) : font->spaceWidth());
 
     // Estimate maximum character width.
-    auto letterWGlyphData = glyphPageZero->glyphDataForCharacter('W');
-    font->setMaxCharWidth(letterWGlyphData.glyph ? letterWGlyphData.width : ascent);
+    Glyph letterWGlyph = glyphPageZero->glyphDataForCharacter('W').glyph;
+    font->setMaxCharWidth(letterWGlyph ? font->widthForGlyph(letterWGlyph) : ascent);
 }
 
 float SVGFontData::widthForSVGGlyph(Glyph glyph, float fontSize) const
@@ -177,7 +177,6 @@
             SVGGlyph& svgGlyph = glyphs[0];
             iterator.setLastGlyphName(svgGlyph.glyphName);
             glyphData.glyph = svgGlyph.tableEntry;
-            glyphData.width = glyphData.font->computeWidthForGlyph(glyphData.glyph);
             advanceLength = svgGlyph.unicodeStringLength;
             return true;
         }
@@ -201,7 +200,6 @@
             continue;
         iterator.setLastGlyphName(svgGlyph.glyphName);
         glyphData.glyph = svgGlyph.tableEntry;
-        glyphData.width = glyphData.font->computeWidthForGlyph(glyphData.glyph);
         advanceLength = svgGlyph.unicodeStringLength;
         return true;
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to