Title: [254741] trunk/Source/WebCore
Revision
254741
Author
[email protected]
Date
2020-01-17 03:59:59 -0800 (Fri, 17 Jan 2020)

Log Message

[GTK] Turn off antialiasing when rendering with Ahem (v2)
https://bugs.webkit.org/show_bug.cgi?id=204671

Reviewed by Carlos Garcia Campos.

Fix leak caused by r254567 where a RefPtr its created from a FcPattern without adoptRef().
Meanwhile at it, also change defaultFontconfigOptions() to return a RefPtr,
because after r254567 we always modify the pattern.
Change also the FontPlatformData() constructor to take an rvalue reference,
and some of its callers to move the RefPtr, avoiding extra not needed
reference increments/decrements.

Covered by existing tests.

* platform/graphics/FontPlatformData.h:
* platform/graphics/freetype/FontCacheFreeType.cpp:
(WebCore::FontCache::systemFallbackForCharacters):
(WebCore::FontCache::createFontPlatformData):
* platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp:
(WebCore::defaultFontconfigOptions):
(WebCore::FontCustomPlatformData::fontPlatformData):
* platform/graphics/freetype/FontPlatformDataFreeType.cpp:
(WebCore::FontPlatformData::FontPlatformData):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (254740 => 254741)


--- trunk/Source/WebCore/ChangeLog	2020-01-17 10:04:21 UTC (rev 254740)
+++ trunk/Source/WebCore/ChangeLog	2020-01-17 11:59:59 UTC (rev 254741)
@@ -1,3 +1,29 @@
+2020-01-16  Carlos Alberto Lopez Perez  <[email protected]>
+
+        [GTK] Turn off antialiasing when rendering with Ahem (v2)
+        https://bugs.webkit.org/show_bug.cgi?id=204671
+
+        Reviewed by Carlos Garcia Campos.
+
+        Fix leak caused by r254567 where a RefPtr its created from a FcPattern without adoptRef().
+        Meanwhile at it, also change defaultFontconfigOptions() to return a RefPtr,
+        because after r254567 we always modify the pattern.
+        Change also the FontPlatformData() constructor to take an rvalue reference,
+        and some of its callers to move the RefPtr, avoiding extra not needed
+        reference increments/decrements.
+
+        Covered by existing tests.
+
+        * platform/graphics/FontPlatformData.h:
+        * platform/graphics/freetype/FontCacheFreeType.cpp:
+        (WebCore::FontCache::systemFallbackForCharacters):
+        (WebCore::FontCache::createFontPlatformData):
+        * platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp:
+        (WebCore::defaultFontconfigOptions):
+        (WebCore::FontCustomPlatformData::fontPlatformData):
+        * platform/graphics/freetype/FontPlatformDataFreeType.cpp:
+        (WebCore::FontPlatformData::FontPlatformData):
+
 2020-01-16  Yusuke Suzuki  <[email protected]>
 
         Compact sizeof(HTMLAnchorElement) and sizeof(HTMLLinkElement)

Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.h (254740 => 254741)


--- trunk/Source/WebCore/platform/graphics/FontPlatformData.h	2020-01-17 10:04:21 UTC (rev 254740)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.h	2020-01-17 11:59:59 UTC (rev 254741)
@@ -111,7 +111,7 @@
 #endif
 
 #if USE(FREETYPE)
-    FontPlatformData(cairo_font_face_t*, FcPattern*, float size, bool fixedWidth, bool syntheticBold, bool syntheticOblique, FontOrientation);
+    FontPlatformData(cairo_font_face_t*, RefPtr<FcPattern>&&, float size, bool fixedWidth, bool syntheticBold, bool syntheticOblique, FontOrientation);
 #endif
 
 #if PLATFORM(WIN)

Modified: trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp (254740 => 254741)


--- trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp	2020-01-17 10:04:21 UTC (rev 254740)
+++ trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp	2020-01-17 11:59:59 UTC (rev 254741)
@@ -272,7 +272,7 @@
     getFontPropertiesFromPattern(resultPattern.get(), description, fixedWidth, syntheticBold, syntheticOblique);
 
     RefPtr<cairo_font_face_t> fontFace = adoptRef(cairo_ft_font_face_create_for_pattern(resultPattern.get()));
-    FontPlatformData alternateFontData(fontFace.get(), resultPattern.get(), description.computedPixelSize(), fixedWidth, syntheticBold, syntheticOblique, description.orientation());
+    FontPlatformData alternateFontData(fontFace.get(), WTFMove(resultPattern), description.computedPixelSize(), fixedWidth, syntheticBold, syntheticOblique, description.orientation());
     return fontForPlatformData(alternateFontData);
 }
 
@@ -579,7 +579,7 @@
             FcPatternAddString(resultPattern.get(), FC_FONT_VARIATIONS, reinterpret_cast<const FcChar8*>(variants.utf8().data()));
     }
 #endif
-    auto platformData = makeUnique<FontPlatformData>(fontFace.get(), resultPattern.get(), fontDescription.computedPixelSize(), fixedWidth, syntheticBold, syntheticOblique, fontDescription.orientation());
+    auto platformData = makeUnique<FontPlatformData>(fontFace.get(), WTFMove(resultPattern), fontDescription.computedPixelSize(), fixedWidth, syntheticBold, syntheticOblique, fontDescription.orientation());
     // Verify that this font has an encoding compatible with Fontconfig. Fontconfig currently
     // supports three encodings in FcFreeTypeCharIndex: Unicode, Symbol and AppleRoman.
     // If this font doesn't have one of these three encodings, don't select it.

Modified: trunk/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp (254740 => 254741)


--- trunk/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp	2020-01-17 10:04:21 UTC (rev 254740)
+++ trunk/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp	2020-01-17 11:59:59 UTC (rev 254741)
@@ -56,7 +56,7 @@
         reinterpret_cast<cairo_destroy_func_t>(reinterpret_cast<void(*)(void)>(FT_Done_Face)));
 }
 
-static FcPattern* defaultFontconfigOptions()
+static RefPtr<FcPattern> defaultFontconfigOptions()
 {
     // Get some generic default settings from fontconfig for web fonts. Strategy
     // from Behdad Esfahbod in https://code.google.com/p/chromium/issues/detail?id=173207#c35
@@ -72,7 +72,7 @@
         FcPatternDel(pattern, FC_FAMILY);
         FcConfigSubstitute(nullptr, pattern, FcMatchFont);
     }, pattern);
-    return pattern;
+    return adoptRef(FcPatternDuplicate(pattern));
 }
 
 FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& description, bool bold, bool italic, const FontFeatureSettings&, FontSelectionSpecifiedCapabilities)
@@ -79,7 +79,7 @@
 {
     auto* freeTypeFace = static_cast<FT_Face>(cairo_font_face_get_user_data(m_fontFace.get(), &freeTypeFaceKey));
     ASSERT(freeTypeFace);
-    RefPtr<FcPattern> pattern = FcPatternDuplicate(defaultFontconfigOptions());
+    RefPtr<FcPattern> pattern = defaultFontconfigOptions();
     FcPatternAddString(pattern.get(), FC_FAMILY, reinterpret_cast<const FcChar8*>(freeTypeFace->family_name));
 #if ENABLE(VARIATION_FONTS)
     auto variants = buildVariationSettings(freeTypeFace, description);
@@ -87,7 +87,7 @@
         FcPatternAddString(pattern.get(), FC_FONT_VARIATIONS, reinterpret_cast<const FcChar8*>(variants.utf8().data()));
     }
 #endif
-    return FontPlatformData(m_fontFace.get(), pattern.get(), description.computedPixelSize(), freeTypeFace->face_flags & FT_FACE_FLAG_FIXED_WIDTH, bold, italic, description.orientation());
+    return FontPlatformData(m_fontFace.get(), WTFMove(pattern), description.computedPixelSize(), freeTypeFace->face_flags & FT_FACE_FLAG_FIXED_WIDTH, bold, italic, description.orientation());
 }
 
 static bool initializeFreeTypeLibrary(FT_Library& library)

Modified: trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp (254740 => 254741)


--- trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp	2020-01-17 10:04:21 UTC (rev 254740)
+++ trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp	2020-01-17 11:59:59 UTC (rev 254741)
@@ -111,10 +111,10 @@
 #endif
 }
 
-FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, FcPattern* pattern, float size, bool fixedWidth, bool syntheticBold, bool syntheticOblique, FontOrientation orientation)
+FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, RefPtr<FcPattern>&& pattern, float size, bool fixedWidth, bool syntheticBold, bool syntheticOblique, FontOrientation orientation)
     : FontPlatformData(size, syntheticBold, syntheticOblique, orientation)
 {
-    m_pattern = pattern;
+    m_pattern = WTFMove(pattern);
     m_fixedWidth = fixedWidth;
 
     buildScaledFont(fontFace);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to