From 81bc750723a18f21cd17d1b173cd2a4dda9cea6e Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Tue, 24 May 2011 11:24:40 +0100 Subject: Merge WebKit at r80534: Intial merge by Git Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61 --- .../platform/graphics/qt/FontPlatformData.h | 134 +++++++++------------ 1 file changed, 56 insertions(+), 78 deletions(-) (limited to 'Source/WebCore/platform/graphics/qt/FontPlatformData.h') diff --git a/Source/WebCore/platform/graphics/qt/FontPlatformData.h b/Source/WebCore/platform/graphics/qt/FontPlatformData.h index f268370..32e8a2d 100644 --- a/Source/WebCore/platform/graphics/qt/FontPlatformData.h +++ b/Source/WebCore/platform/graphics/qt/FontPlatformData.h @@ -24,142 +24,120 @@ #ifndef FontPlatformData_h #define FontPlatformData_h -#include #include "FontDescription.h" #include "FontOrientation.h" #include #include +#include +#include namespace WebCore { -class FontPlatformDataPrivate { +class FontPlatformDataPrivate : public RefCounted { WTF_MAKE_NONCOPYABLE(FontPlatformDataPrivate); WTF_MAKE_FAST_ALLOCATED; public: FontPlatformDataPrivate() - : refCount(1) - , size(font.pixelSize()) + : size(font.pixelSize()) , bold(font.bold()) , oblique(false) - {} + , isDeletedValue(false) + { } FontPlatformDataPrivate(const float size, const bool bold, const bool oblique) - : refCount(1) - , size(size) + : size(size) , bold(bold) , oblique(oblique) - {} + , isDeletedValue(false) + { } FontPlatformDataPrivate(const QFont& font) - : refCount(1) - , font(font) + : font(font) , size(font.pixelSize()) , bold(font.bold()) , oblique(false) - {} - unsigned refCount; + , isDeletedValue(false) + { } + FontPlatformDataPrivate(WTF::HashTableDeletedValueType) + : isDeletedValue(true) + { } + QFont font; float size; bool bold : 1; bool oblique : 1; + bool isDeletedValue : 1; }; - - class FontPlatformData { WTF_MAKE_FAST_ALLOCATED; public: - FontPlatformData() { } FontPlatformData(float size, bool bold, bool oblique); - FontPlatformData(const FontPlatformData &); FontPlatformData(const FontDescription&, const AtomicString& familyName, int wordSpacing = 0, int letterSpacing = 0); FontPlatformData(const QFont& font) - : m_data(new FontPlatformDataPrivate(font)) - {} + : m_data(adoptRef(new FontPlatformDataPrivate(font))) + { } FontPlatformData(WTF::HashTableDeletedValueType) - : m_data(reinterpret_cast(-1)) - {} - - ~FontPlatformData(); + : m_data(adoptRef(new FontPlatformDataPrivate())) + { + m_data->isDeletedValue = true; + } - FontPlatformData& operator=(const FontPlatformData&); bool operator==(const FontPlatformData&) const; bool isHashTableDeletedValue() const { - return m_data == reinterpret_cast(-1); - } - - static inline QFont::Weight toQFontWeight(FontWeight fontWeight) - { - switch (fontWeight) { - case FontWeight100: - case FontWeight200: - return QFont::Light; // QFont::Light == Weight of 25 - case FontWeight600: - return QFont::DemiBold; // QFont::DemiBold == Weight of 63 - case FontWeight700: - case FontWeight800: - return QFont::Bold; // QFont::Bold == Weight of 75 - case FontWeight900: - return QFont::Black; // QFont::Black == Weight of 87 - case FontWeight300: - case FontWeight400: - case FontWeight500: - default: - return QFont::Normal; // QFont::Normal == Weight of 50 - } + return m_data && m_data->isDeletedValue; } QFont font() const { - Q_ASSERT(m_data != reinterpret_cast(-1)); - if (m_data) - return m_data->font; - return QFont(); + Q_ASSERT(!isHashTableDeletedValue()); + if (!m_data) + return QFont(); + return m_data->font; } float size() const { - Q_ASSERT(m_data != reinterpret_cast(-1)); - if (m_data) - return m_data->size; - return 0.0f; + Q_ASSERT(!isHashTableDeletedValue()); + if (!m_data) + return 0; + return m_data->size; } QString family() const { - Q_ASSERT(m_data != reinterpret_cast(-1)); - if (m_data) - return m_data->font.family(); - return QString(); + Q_ASSERT(!isHashTableDeletedValue()); + if (!m_data) + return QString(); + return m_data->font.family(); } bool bold() const { - Q_ASSERT(m_data != reinterpret_cast(-1)); - if (m_data) - return m_data->bold; - return false; + Q_ASSERT(!isHashTableDeletedValue()); + if (!m_data) + return false; + return m_data->bold; } bool italic() const { - Q_ASSERT(m_data != reinterpret_cast(-1)); - if (m_data) - return m_data->font.italic(); - return false; + Q_ASSERT(!isHashTableDeletedValue()); + if (!m_data) + return false; + return m_data->font.italic(); } bool smallCaps() const { - Q_ASSERT(m_data != reinterpret_cast(-1)); - if (m_data) - return m_data->font.capitalization() == QFont::SmallCaps; - return false; + Q_ASSERT(!isHashTableDeletedValue()); + if (!m_data) + return false; + return m_data->font.capitalization() == QFont::SmallCaps; } int pixelSize() const { - Q_ASSERT(m_data != reinterpret_cast(-1)); - if (m_data) { - // WebKit allows font size zero but QFont does not. - if (!m_data->size) - return m_data->size; - return m_data->font.pixelSize(); - } - return 0; + Q_ASSERT(!isHashTableDeletedValue()); + if (!m_data) + return 0; + // WebCore allows a font size of zero, but QFont does not. + if (!m_data->size) + return 0; + return m_data->font.pixelSize(); } FontOrientation orientation() const { return Horizontal; } // FIXME: Implement. @@ -170,7 +148,7 @@ public: String description() const; #endif private: - FontPlatformDataPrivate* m_data; + RefPtr m_data; }; } // namespace WebCore -- cgit v1.1