Title: [200104] trunk/Source/WebCore
Revision
200104
Author
mmaxfi...@apple.com
Date
2016-04-26 12:49:19 -0700 (Tue, 26 Apr 2016)

Log Message

Use auto-generated operators in FontPlatformData
https://bugs.webkit.org/show_bug.cgi?id=157037

Reviewed by Geoffrey Garen.

The only reason why they weren't used before is because Cairo was
using a raw pointer. However, RefPtr supports Cairo types, so this
patch migrates that pointer to a RefPtr. Therefore, we can remove
our custom operators (because they work the same way as auto-
generated ones do).

No new tests because there is no behavior change.

* platform/graphics/FontPlatformData.cpp:
(WebCore::FontPlatformData::FontPlatformData): Deleted.
(WebCore::FontPlatformData::operator=): Deleted.
* platform/graphics/FontPlatformData.h:
(WebCore::FontPlatformData::scaledFont):
(WebCore::FontPlatformData::hash):
* platform/graphics/cocoa/FontPlatformDataCocoa.mm:
(WebCore::FontPlatformData::~FontPlatformData): Deleted.
(WebCore::FontPlatformData::platformDataInit): Deleted.
(WebCore::FontPlatformData::platformDataAssign): Deleted.
* platform/graphics/win/FontPlatformDataCGWin.cpp:
(WebCore::FontPlatformData::~FontPlatformData): Deleted.
(WebCore::FontPlatformData::platformDataInit): Deleted.
(WebCore::FontPlatformData::platformDataAssign): Deleted.
* platform/graphics/win/FontPlatformDataCairoWin.cpp:
(WebCore::FontPlatformData::platformDataInit):
(WebCore::FontPlatformData::FontPlatformData):
(WebCore::FontPlatformData::~FontPlatformData): Deleted.
(WebCore::FontPlatformData::platformDataAssign): Deleted.
* platform/graphics/win/FontPlatformDataWin.cpp:
(WebCore::FontPlatformData::FontPlatformData): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (200103 => 200104)


--- trunk/Source/WebCore/ChangeLog	2016-04-26 19:07:14 UTC (rev 200103)
+++ trunk/Source/WebCore/ChangeLog	2016-04-26 19:49:19 UTC (rev 200104)
@@ -1,3 +1,40 @@
+2016-04-26  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Use auto-generated operators in FontPlatformData
+        https://bugs.webkit.org/show_bug.cgi?id=157037
+
+        Reviewed by Geoffrey Garen.
+
+        The only reason why they weren't used before is because Cairo was
+        using a raw pointer. However, RefPtr supports Cairo types, so this
+        patch migrates that pointer to a RefPtr. Therefore, we can remove
+        our custom operators (because they work the same way as auto-
+        generated ones do).
+
+        No new tests because there is no behavior change.
+
+        * platform/graphics/FontPlatformData.cpp:
+        (WebCore::FontPlatformData::FontPlatformData): Deleted.
+        (WebCore::FontPlatformData::operator=): Deleted.
+        * platform/graphics/FontPlatformData.h:
+        (WebCore::FontPlatformData::scaledFont):
+        (WebCore::FontPlatformData::hash):
+        * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
+        (WebCore::FontPlatformData::~FontPlatformData): Deleted.
+        (WebCore::FontPlatformData::platformDataInit): Deleted.
+        (WebCore::FontPlatformData::platformDataAssign): Deleted.
+        * platform/graphics/win/FontPlatformDataCGWin.cpp:
+        (WebCore::FontPlatformData::~FontPlatformData): Deleted.
+        (WebCore::FontPlatformData::platformDataInit): Deleted.
+        (WebCore::FontPlatformData::platformDataAssign): Deleted.
+        * platform/graphics/win/FontPlatformDataCairoWin.cpp:
+        (WebCore::FontPlatformData::platformDataInit):
+        (WebCore::FontPlatformData::FontPlatformData):
+        (WebCore::FontPlatformData::~FontPlatformData): Deleted.
+        (WebCore::FontPlatformData::platformDataAssign): Deleted.
+        * platform/graphics/win/FontPlatformDataWin.cpp:
+        (WebCore::FontPlatformData::FontPlatformData): Deleted.
+
 2016-04-26  Zalan Bujtas  <za...@apple.com>
 
         Add renderer address and needslayout state to inlineboxtree dump.

Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp (200103 => 200104)


--- trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp	2016-04-26 19:07:14 UTC (rev 200103)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp	2016-04-26 19:49:19 UTC (rev 200104)
@@ -62,15 +62,6 @@
 }
 #endif
 
-FontPlatformData::FontPlatformData(const FontPlatformData& source)
-    : FontPlatformData(source.m_size, source.m_syntheticBold, source.m_syntheticOblique, source.m_orientation, source.m_widthVariant, source.m_textRenderingMode)
-{
-    m_isHashTableDeletedValue = source.m_isHashTableDeletedValue;
-    m_isColorBitmapFont = source.m_isColorBitmapFont;
-    m_isSystemFont = source.m_isSystemFont;
-    platformDataInit(source);
-}
-
 FontPlatformData FontPlatformData::cloneWithOrientation(const FontPlatformData& source, FontOrientation orientation)
 {
     FontPlatformData copy(source);
@@ -92,23 +83,4 @@
     return copy;
 }
 
-const FontPlatformData& FontPlatformData::operator=(const FontPlatformData& other)
-{
-    // Check for self-assignment.
-    if (this == &other)
-        return *this;
-
-    m_isHashTableDeletedValue = other.m_isHashTableDeletedValue;
-    m_syntheticBold = other.m_syntheticBold;
-    m_syntheticOblique = other.m_syntheticOblique;
-    m_orientation = other.m_orientation;
-    m_size = other.m_size;
-    m_widthVariant = other.m_widthVariant;
-    m_isColorBitmapFont = other.m_isColorBitmapFont;
-    m_textRenderingMode = other.m_textRenderingMode;
-    m_isSystemFont = other.m_isSystemFont;
-
-    return platformDataAssign(other);
 }
-
-}

Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.h (200103 => 200104)


--- trunk/Source/WebCore/platform/graphics/FontPlatformData.h	2016-04-26 19:07:14 UTC (rev 200103)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.h	2016-04-26 19:49:19 UTC (rev 200104)
@@ -37,6 +37,7 @@
 #endif
 
 #if USE(CAIRO)
+#include "RefPtrCairo.h"
 #include <wtf/HashFunctions.h>
 #include <cairo.h>
 #endif
@@ -80,7 +81,8 @@
 public:
     FontPlatformData(WTF::HashTableDeletedValueType);
     FontPlatformData();
-    FontPlatformData(const FontPlatformData&);
+    FontPlatformData(const FontPlatformData&) = default;
+    FontPlatformData(FontPlatformData&&) = default;
     FontPlatformData(const FontDescription&, const AtomicString& family);
     FontPlatformData(float size, bool syntheticBold, bool syntheticOblique, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, TextRenderingMode = AutoTextRendering);
 
@@ -106,8 +108,6 @@
 #endif
 #endif
 
-    WEBCORE_EXPORT ~FontPlatformData();
-
 #if PLATFORM(WIN)
     HFONT hfont() const { return m_font ? m_font->get() : 0; }
     bool useGDI() const { return m_useGDI; }
@@ -146,7 +146,7 @@
     bool isForTextCombine() const { return widthVariant() != RegularWidth; } // Keep in sync with callers of FontDescription::setWidthVariant().
 
 #if USE(CAIRO)
-    cairo_scaled_font_t* scaledFont() const { return m_scaledFont; }
+    cairo_scaled_font_t* scaledFont() const { return m_scaledFont.get(); }
 #endif
 
     unsigned hash() const
@@ -163,11 +163,11 @@
         uintptr_t hashCodes[3] = { fontHash, m_widthVariant, flags };
         return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes);
 #elif USE(CAIRO)
-        return PtrHash<cairo_scaled_font_t*>::hash(m_scaledFont);
+        return PtrHash<cairo_scaled_font_t*>::hash(m_scaledFont.get());
 #endif
     }
 
-    const FontPlatformData& operator=(const FontPlatformData&);
+    FontPlatformData& operator=(const FontPlatformData&) = default;
 
     bool operator==(const FontPlatformData& other) const
     {
@@ -206,8 +206,6 @@
 
 private:
     bool platformIsEqual(const FontPlatformData&) const;
-    void platformDataInit(const FontPlatformData&);
-    const FontPlatformData& platformDataAssign(const FontPlatformData&);
 #if PLATFORM(COCOA)
     CGFloat ctFontSize() const;
 #endif
@@ -227,7 +225,7 @@
     RetainPtr<CGFontRef> m_cgFont;
 #endif
 #if USE(CAIRO)
-    cairo_scaled_font_t* m_scaledFont { nullptr };
+    RefPtr<cairo_scaled_font_t> m_scaledFont;
 #endif
 
     // The values below are common to all ports

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm (200103 => 200104)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm	2016-04-26 19:07:14 UTC (rev 200103)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm	2016-04-26 19:49:19 UTC (rev 200104)
@@ -54,37 +54,6 @@
 #endif
 }
 
-FontPlatformData::~FontPlatformData()
-{
-}
-
-void FontPlatformData::platformDataInit(const FontPlatformData& f)
-{
-    m_font = f.m_font;
-
-    m_cgFont = f.m_cgFont;
-    m_ctFont = f.m_ctFont;
-
-#if PLATFORM(IOS)
-    m_isEmoji = f.m_isEmoji;
-#endif
-}
-
-const FontPlatformData& FontPlatformData::platformDataAssign(const FontPlatformData& f)
-{
-    m_cgFont = f.m_cgFont;
-    if (m_font && f.m_font && CFEqual(m_font.get(), f.m_font.get()))
-        return *this;
-    m_font = f.m_font;
-    m_ctFont = f.m_ctFont;
-
-#if PLATFORM(IOS)
-    m_isEmoji = f.m_isEmoji;
-#endif
-
-    return *this;
-}
-
 bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const
 {
     bool result = false;

Modified: trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp (200103 => 200104)


--- trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp	2016-04-26 19:07:14 UTC (rev 200103)
+++ trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp	2016-04-26 19:49:19 UTC (rev 200104)
@@ -130,26 +130,6 @@
 {
 }
 
-FontPlatformData::~FontPlatformData()
-{
-}
-
-void FontPlatformData::platformDataInit(const FontPlatformData& source)
-{
-    m_font = source.m_font;
-    m_cgFont = source.m_cgFont;
-    m_useGDI = source.m_useGDI;
-}
-
-const FontPlatformData& FontPlatformData::platformDataAssign(const FontPlatformData& other)
-{
-    m_font = other.m_font;
-    m_cgFont = other.m_cgFont;
-    m_useGDI = other.m_useGDI;
-
-    return *this;
-}
-
 bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const
 {
     return m_font == other.m_font

Modified: trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp (200103 => 200104)


--- trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp	2016-04-26 19:07:14 UTC (rev 200103)
+++ trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp	2016-04-26 19:49:19 UTC (rev 200104)
@@ -52,7 +52,7 @@
        cairo_font_options_set_antialias(fontOptions, CAIRO_ANTIALIAS_SUBPIXEL);
     }
 
-    m_scaledFont = cairo_scaled_font_create(fontFace, &sizeMatrix, &ctm, fontOptions);
+    m_scaledFont = adoptRef(cairo_scaled_font_create(fontFace, &sizeMatrix, &ctm, fontOptions));
     cairo_font_face_destroy(fontFace);
 
     if (!m_useGDI && m_size)
@@ -64,22 +64,21 @@
     , m_size(size)
     , m_orientation(Horizontal)
     , m_widthVariant(RegularWidth)
-    , m_scaledFont(0)
     , m_isColorBitmapFont(false)
     , m_syntheticBold(bold)
     , m_syntheticOblique(oblique)
     , m_useGDI(false)
 {
-   cairo_matrix_t fontMatrix;
-   cairo_matrix_init_scale(&fontMatrix, size, size);
-   cairo_matrix_t ctm;
-   cairo_matrix_init_identity(&ctm);
-   cairo_font_options_t* options = cairo_font_options_create();
+    cairo_matrix_t fontMatrix;
+    cairo_matrix_init_scale(&fontMatrix, size, size);
+    cairo_matrix_t ctm;
+    cairo_matrix_init_identity(&ctm);
+    cairo_font_options_t* options = cairo_font_options_create();
 
-   // We force antialiasing and disable hinting to provide consistent
-   // typographic qualities for custom fonts on all platforms.
-   cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
-   cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_BEST);
+    // We force antialiasing and disable hinting to provide consistent
+    // typographic qualities for custom fonts on all platforms.
+    cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
+    cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_BEST);
 
     if (syntheticOblique()) {
         static const float syntheticObliqueSkew = -tanf(14 * acosf(0) / 90);
@@ -87,39 +86,10 @@
         cairo_matrix_multiply(&fontMatrix, &skew, &fontMatrix);
     }
 
-   m_scaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options);
-   cairo_font_options_destroy(options);
+    m_scaledFont = adoptRef(cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options));
+    cairo_font_options_destroy(options);
 }
 
-FontPlatformData::~FontPlatformData()
-{
-    if (m_scaledFont)
-        cairo_scaled_font_destroy(m_scaledFont);
-}
-
-void FontPlatformData::platformDataInit(const FontPlatformData& source)
-{
-    m_font = source.m_font;
-    m_useGDI = source.m_useGDI;
-    m_scaledFont = nullptr;
-
-    if (source.m_scaledFont)
-        m_scaledFont = cairo_scaled_font_reference(source.m_scaledFont);
-}
-
-const FontPlatformData& FontPlatformData::platformDataAssign(const FontPlatformData& other)
-{
-    m_font = other.m_font;
-    m_useGDI = other.m_useGDI;
-
-    if (m_scaledFont)
-        cairo_scaled_font_destroy(m_scaledFont);
-
-    m_scaledFont = cairo_scaled_font_reference(other.m_scaledFont);
-
-    return *this;
-}
-
 bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const
 {
     return m_font == other.m_font

Modified: trunk/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp (200103 => 200104)


--- trunk/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp	2016-04-26 19:07:14 UTC (rev 200103)
+++ trunk/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp	2016-04-26 19:49:19 UTC (rev 200104)
@@ -42,11 +42,6 @@
     , m_size(size)
     , m_orientation(Horizontal)
     , m_widthVariant(RegularWidth)
-#if USE(CG)
-    , m_cgFont(0)
-#elif USE(CAIRO)
-    , m_scaledFont(0)
-#endif
     , m_isColorBitmapFont(false)
     , m_syntheticBold(bold)
     , m_syntheticOblique(oblique)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to