Title: [90149] releases/WebKitGTK/webkit-1.4/Source/WebCore

Diff

Modified: releases/WebKitGTK/webkit-1.4/Source/WebCore/ChangeLog (90148 => 90149)


--- releases/WebKitGTK/webkit-1.4/Source/WebCore/ChangeLog	2011-06-30 19:31:01 UTC (rev 90148)
+++ releases/WebKitGTK/webkit-1.4/Source/WebCore/ChangeLog	2011-06-30 19:31:20 UTC (rev 90149)
@@ -1,3 +1,34 @@
+2011-06-30  Martin Robinson  <[email protected]>
+
+        Reviewed by Xan Lopez.
+
+        [Freetype] Many tests report ERROR: Failed to get glyph page zero.
+        https://bugs.webkit.org/show_bug.cgi?id=63498
+
+        Instead of conditionally instantiating the m_scaledFont member of FontPlatformData,
+        always instantiate it. For times when the size is 0 and the instantiation would lead
+        to a Cairo error, we use size 1 and just make operations which would fail conditional
+        on the m_size > 0.
+
+        No new tests. This change is covered by existing tests. We should
+        observe no errors on the bots after landing.
+
+        * platform/graphics/cairo/FontCairo.cpp:
+        (WebCore::Font::drawGlyphs): Instead of looking at whether or not there is
+        a scaled font to determine whether to draw, just look at the size.
+        * platform/graphics/freetype/FontPlatformData.h: Remove the m_font member.
+        * platform/graphics/freetype/FontPlatformDataFreeType.cpp: Always instantiate
+        a scaled font member and remove references to m_font. If we are instantiating
+        a scaled font for a 0 size font, instantiate a size 1 font, so that we can
+        still use Cairo to query font properties.
+        * platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp:
+        (WebCore::GlyphPage::fill): We can assume there is always a scaled font now.
+        * platform/graphics/freetype/SimpleFontDataFreeType.cpp:
+        (WebCore::SimpleFontData::platformInit): Ditto.
+        (WebCore::SimpleFontData::createScaledFontData): Ditto.
+        (WebCore::SimpleFontData::containsCharacters): Ditto.
+        (WebCore::SimpleFontData::platformWidthForGlyph): Ditto.
+
 2011-06-30  Andras Becsi  <[email protected]>
 
         Reviewed by Csaba Osztrogonác.

Modified: releases/WebKitGTK/webkit-1.4/Source/WebCore/platform/graphics/cairo/FontCairo.cpp (90148 => 90149)


--- releases/WebKitGTK/webkit-1.4/Source/WebCore/platform/graphics/cairo/FontCairo.cpp	2011-06-30 19:31:01 UTC (rev 90148)
+++ releases/WebKitGTK/webkit-1.4/Source/WebCore/platform/graphics/cairo/FontCairo.cpp	2011-06-30 19:31:20 UTC (rev 90149)
@@ -97,7 +97,7 @@
 void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, const GlyphBuffer& glyphBuffer,
                       int from, int numGlyphs, const FloatPoint& point) const
 {
-    if (!font->platformData().scaledFont())
+    if (!font->platformData().size())
         return;
 
     GlyphBufferGlyph* glyphs = const_cast<GlyphBufferGlyph*>(glyphBuffer.glyphs(from));

Modified: releases/WebKitGTK/webkit-1.4/Source/WebCore/platform/graphics/freetype/FontPlatformData.h (90148 => 90149)


--- releases/WebKitGTK/webkit-1.4/Source/WebCore/platform/graphics/freetype/FontPlatformData.h	2011-06-30 19:31:01 UTC (rev 90148)
+++ releases/WebKitGTK/webkit-1.4/Source/WebCore/platform/graphics/freetype/FontPlatformData.h	2011-06-30 19:31:20 UTC (rev 90149)
@@ -97,7 +97,6 @@
     bool m_syntheticBold;
     bool m_syntheticOblique;
     bool m_fixedWidth;
-    RefPtr<cairo_font_face_t> m_font;
     cairo_scaled_font_t* m_scaledFont;
 
 private:

Modified: releases/WebKitGTK/webkit-1.4/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp (90148 => 90149)


--- releases/WebKitGTK/webkit-1.4/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp	2011-06-30 19:31:01 UTC (rev 90148)
+++ releases/WebKitGTK/webkit-1.4/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp	2011-06-30 19:31:20 UTC (rev 90149)
@@ -121,8 +121,8 @@
     , m_fixedWidth(false)
     , m_scaledFont(0)
 {
-    m_font = adoptRef(cairo_ft_font_face_create_for_pattern(m_pattern.get()));
-    initializeWithFontFace(m_font.get());
+    RefPtr<cairo_font_face_t> fontFace = adoptRef(cairo_ft_font_face_create_for_pattern(m_pattern.get()));
+    initializeWithFontFace(fontFace.get());
 
     int spacing;
     if (FcPatternGetInteger(pattern, FC_SPACING, 0, &spacing) == FcResultMatch && spacing == FC_MONO)
@@ -153,17 +153,14 @@
     , m_syntheticBold(bold)
     , m_syntheticOblique(italic)
     , m_fixedWidth(false)
-    , m_font(fontFace)
     , m_scaledFont(0)
 {
     initializeWithFontFace(fontFace);
 
-    if (m_scaledFont) {
-        FT_Face fontConfigFace = cairo_ft_scaled_font_lock_face(m_scaledFont);
-        if (fontConfigFace) {
-            m_fixedWidth = fontConfigFace->face_flags & FT_FACE_FLAG_FIXED_WIDTH;
-            cairo_ft_scaled_font_unlock_face(m_scaledFont);
-        }
+    FT_Face fontConfigFace = cairo_ft_scaled_font_lock_face(m_scaledFont);
+    if (fontConfigFace) {
+        m_fixedWidth = fontConfigFace->face_flags & FT_FACE_FLAG_FIXED_WIDTH;
+        cairo_ft_scaled_font_unlock_face(m_scaledFont);
     }
 }
 
@@ -188,7 +185,6 @@
     if (m_scaledFont && m_scaledFont != hashTableDeletedFontValue())
         cairo_scaled_font_destroy(m_scaledFont);
     m_scaledFont = cairo_scaled_font_reference(other.m_scaledFont);
-    m_font = other.m_font;
 
     return *this;
 }
@@ -230,7 +226,6 @@
 {
     return m_pattern == other.m_pattern
         && m_scaledFont == other.m_scaledFont
-        && m_font == other.m_font
         && m_size == other.m_size
         && m_syntheticOblique == other.m_syntheticOblique
         && m_syntheticBold == other.m_syntheticBold; 
@@ -245,20 +240,18 @@
 
 void FontPlatformData::initializeWithFontFace(cairo_font_face_t* fontFace)
 {
-    // Fonts with zero size lead to failed cairo_scaled_font_t instantiations. Instead
-    // we just do not instantiate the scaled font at all. This will cause all renders
-    // to be no-ops and all metrics to be zero, which is the desired behavior anyway.
-    if (!m_size)
-        return;
-
     cairo_font_options_t* options = getDefaultFontOptions();
 
     cairo_matrix_t ctm;
     cairo_matrix_init_identity(&ctm);
 
+    // Scaling a font with width zero size leads to a failed cairo_scaled_font_t instantiations.
+    // Instead we scale we scale the font to a very tiny size and just abort rendering later on.
+    float realSize = m_size ? m_size : 1;
+
     cairo_matrix_t fontMatrix;
     if (!m_pattern)
-        cairo_matrix_init_scale(&fontMatrix, m_size, m_size);
+        cairo_matrix_init_scale(&fontMatrix, realSize, realSize);
     else {
         setCairoFontOptionsFromFontConfigPattern(options, m_pattern.get());
 
@@ -273,8 +266,8 @@
         cairo_matrix_init(&fontMatrix, fontConfigMatrix.xx, -fontConfigMatrix.yx,
                           -fontConfigMatrix.xy, fontConfigMatrix.yy, 0, 0);
 
-        // The matrix from FontConfig does not include the scale.
-        cairo_matrix_scale(&fontMatrix, m_size, m_size);
+        // The matrix from FontConfig does not include the scale. 
+        cairo_matrix_scale(&fontMatrix, realSize, realSize);
     }
 
     m_scaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options);
@@ -283,11 +276,7 @@
 
 bool FontPlatformData::hasCompatibleCharmap()
 {
-    // If m_scaledFont is null, it means that this is a size zero font, which always
-    // has a compatible charmap since we never really read any font data from the font.
-    if (!m_scaledFont)
-        return true;
-
+    ASSERT(m_scaledFont);
     FT_Face freeTypeFace = cairo_ft_scaled_font_lock_face(m_scaledFont);
     bool hasCompatibleCharmap = !(FT_Select_Charmap(freeTypeFace, ft_encoding_unicode)
                                 && FT_Select_Charmap(freeTypeFace, ft_encoding_symbol)

Modified: releases/WebKitGTK/webkit-1.4/Source/WebCore/platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp (90148 => 90149)


--- releases/WebKitGTK/webkit-1.4/Source/WebCore/platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp	2011-06-30 19:31:01 UTC (rev 90148)
+++ releases/WebKitGTK/webkit-1.4/Source/WebCore/platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp	2011-06-30 19:31:20 UTC (rev 90149)
@@ -46,8 +46,7 @@
         return false;
 
     cairo_scaled_font_t* scaledFont = fontData->platformData().scaledFont();
-    if (!scaledFont)
-        return false;
+    ASSERT(scaledFont);
 
     FT_Face face = cairo_ft_scaled_font_lock_face(scaledFont);
     if (!face)

Modified: releases/WebKitGTK/webkit-1.4/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp (90148 => 90149)


--- releases/WebKitGTK/webkit-1.4/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp	2011-06-30 19:31:01 UTC (rev 90148)
+++ releases/WebKitGTK/webkit-1.4/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp	2011-06-30 19:31:20 UTC (rev 90149)
@@ -47,9 +47,10 @@
 
 void SimpleFontData::platformInit()
 {
-    if (!m_platformData.scaledFont())
+    if (!m_platformData.m_size)
         return;
 
+    ASSERT(m_platformData.scaledFont());
     cairo_font_extents_t font_extents;
     cairo_text_extents_t text_extents;
     cairo_scaled_font_extents(m_platformData.scaledFont(), &font_extents);
@@ -91,7 +92,7 @@
 
 SimpleFontData* SimpleFontData::scaledFontData(const FontDescription& fontDescription, float scaleFactor) const
 {
-    return new SimpleFontData(FontPlatformData(m_platformData.m_font.get(),
+    return new SimpleFontData(FontPlatformData(cairo_scaled_font_get_font_face(m_platformData.scaledFont()),
                                                scaleFactor * fontDescription.computedSize(),
                                                m_platformData.syntheticBold(),
                                                m_platformData.syntheticOblique()),
@@ -121,11 +122,7 @@
 
 bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
 {
-    // If this is a no-op font (zero size), then it should always contain the characters,
-    // since we never read from or render from this font.
-    if (!m_platformData.scaledFont())
-        return true;
-
+    ASSERT(m_platformData.scaledFont());
     FT_Face face = cairo_ft_scaled_font_lock_face(m_platformData.scaledFont());
     if (!face)
         return false;
@@ -153,7 +150,7 @@
 
 float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
 {
-    if (!m_platformData.scaledFont())
+    if (!m_platformData.size())
         return 0;
 
     cairo_glyph_t cglyph = { glyph, 0, 0 };
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to