2009-06-16 Brent Fulgham <bfulgham@webkit.org>
authorbfulgham@webkit.org <bfulgham@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Jun 2009 21:55:31 +0000 (21:55 +0000)
committerbfulgham@webkit.org <bfulgham@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Jun 2009 21:55:31 +0000 (21:55 +0000)
        Reviewed by Maciej Stachowiak.

        Update of https://bugs.webkit.org/show_bug.cgi?id=26353.
        Provide an assignment operator to avoid improper reference
        counts on the Cairo font objects.  This brings the Windows
        Cairo port in line with the GTK+ port.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@44740 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/graphics/win/FontPlatformData.h
WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp

index bdd59cb..4bfefae 100644 (file)
@@ -1,3 +1,17 @@
+2009-06-16  Brent Fulgham  <bfulgham@webkit.org>
+
+        Reviewed by Maciej Stachowiak.
+
+        Update of https://bugs.webkit.org/show_bug.cgi?id=26353.
+        Provide an assignment operator to avoid improper reference
+        counts on the Cairo font objects.  This brings the Windows
+        Cairo port in line with the GTK+ port.
+
+        * platform/graphics/win/FontPlatformData.h:
+        * platform/graphics/win/FontPlatformDataCairoWin.cpp:
+        (WebCore::FontPlatformData::FontPlatformData):
+        (WebCore::FontPlatformData::operator=):
+
 2009-06-16  Eric Carlson  <eric.carlson@apple.com>
 
         Reviewed by Simon Fraser.
index f357523..cb10afb 100644 (file)
@@ -65,6 +65,8 @@ public:
 #elif PLATFORM(CAIRO)
     FontPlatformData(cairo_font_face_t*, float size, bool bold, bool oblique);
     FontPlatformData(const FontPlatformData&);
+
+    FontPlatformData& operator=(const FontPlatformData&);
 #endif
     ~FontPlatformData();
 
index 9d55d5f..b56a71c 100644 (file)
@@ -83,12 +83,17 @@ FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, float size, bool
 FontPlatformData::FontPlatformData(const FontPlatformData& source)
     : m_font(source.m_font)
     , m_size(source.m_size)
-    , m_fontFace(cairo_font_face_reference(source.m_fontFace))
-    , m_scaledFont(cairo_scaled_font_reference(source.m_scaledFont))
+    , m_fontFace(0)
+    , m_scaledFont(0)
     , m_syntheticBold(source.m_syntheticBold)
     , m_syntheticOblique(source.m_syntheticOblique)
     , m_useGDI(source.m_useGDI)
 {
+    if (source.m_fontFace)
+        m_fontFace = cairo_font_face_reference(source.m_fontFace);
+
+    if (source.m_scaledFont)
+        m_scaledFont = cairo_scaled_font_reference(source.m_scaledFont);
 }
 
 void FontPlatformData::setFont(cairo_t* cr) const
@@ -104,4 +109,31 @@ FontPlatformData::~FontPlatformData()
     cairo_font_face_destroy(m_fontFace);
 }
 
+FontPlatformData& FontPlatformData::operator=(const FontPlatformData& other)
+{
+    // Check for self-assignment.
+    if (this == &other)
+        return *this;
+
+    m_font = other.m_font;
+    m_size = other.m_size;
+    m_syntheticBold = other.m_syntheticBold;
+    m_syntheticOblique = other.m_syntheticOblique;
+    m_useGDI = other.m_useGDI;
+
+    if (other.m_fontFace)
+        cairo_font_face_reference(other.m_fontFace);
+    if (m_fontFace)
+        cairo_font_face_destroy(m_fontFace);
+    m_fontFace = other.m_fontFace;
+
+    if (other.m_scaledFont)
+        cairo_scaled_font_reference(other.m_scaledFont);
+    if (m_scaledFont)
+        cairo_scaled_font_destroy(m_scaledFont);
+    m_scaledFont = other.m_scaledFont;
+
+    return *this;
+}
+
 }