Skip to content
Permalink
Browse files
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.


Canonical link: https://commits.webkit.org/175159@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200104 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
litherum committed Apr 26, 2016
1 parent a428261 commit 085321f336bce934332915bc67a87ce1ff334031
@@ -1,3 +1,40 @@
2016-04-26 Myles C. Maxfield <mmaxfield@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 <zalan@apple.com>

Add renderer address and needslayout state to inlineboxtree dump.
@@ -62,15 +62,6 @@ FontPlatformData::FontPlatformData(CGFontRef cgFont, float size, bool syntheticB
}
#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 @@ FontPlatformData FontPlatformData::cloneWithSize(const FontPlatformData& source,
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);
}

}
@@ -37,6 +37,7 @@
#endif

#if USE(CAIRO)
#include "RefPtrCairo.h"
#include <wtf/HashFunctions.h>
#include <cairo.h>
#endif
@@ -80,7 +81,8 @@ class FontPlatformData {
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 @@ class FontPlatformData {
#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 @@ class FontPlatformData {
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 @@ class FontPlatformData {
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 @@ class FontPlatformData {

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 @@ class FontPlatformData {
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
@@ -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;
@@ -130,26 +130,6 @@ FontPlatformData::FontPlatformData(GDIObject<HFONT> hfont, CGFontRef font, float
{
}

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
@@ -52,7 +52,7 @@ void FontPlatformData::platformDataInit(HFONT font, float size, HDC hdc, WCHAR*
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,60 +64,30 @@ FontPlatformData::FontPlatformData(GDIObject<HFONT> font, cairo_font_face_t* fon
, 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);
cairo_matrix_t skew = {1, 0, syntheticObliqueSkew, 1, 0, 0};
cairo_matrix_multiply(&fontMatrix, &skew, &fontMatrix);
}

m_scaledFont = 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;
m_scaledFont = adoptRef(cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options));
cairo_font_options_destroy(options);
}

bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const
@@ -42,11 +42,6 @@ FontPlatformData::FontPlatformData(GDIObject<HFONT> font, float size, bool bold,
, 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)

0 comments on commit 085321f

Please sign in to comment.