Reviewed/landed by Adam.
authoraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Aug 2006 16:51:15 +0000 (16:51 +0000)
committeraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Aug 2006 16:51:15 +0000 (16:51 +0000)
        Finally fix font caching. WebKit+Qt now works
        out of the box without any further patches :-)

        * platform/qt/FontDataQt.cpp:
        (WebCore::FontData::platformDestroy):
        * platform/qt/FontPlatformData.h:
        * platform/qt/FontPlatformDataQt.cpp:
        (WebCore::FontPlatformData::FontPlatformData):
        (WebCore::FontPlatformData::isFixedPitch):
        (WebCore::FontPlatformData::font):
        (WebCore::FontPlatformData::fontPtr):
        (WebCore::FontPlatformData::hash):
        (WebCore::FontPlatformData::operator==):

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

WebCore/ChangeLog
WebCore/platform/qt/FontDataQt.cpp
WebCore/platform/qt/FontPlatformData.h
WebCore/platform/qt/FontPlatformDataQt.cpp

index c01f994b7f48cd032be4b364816f31f60cd947c7..c5c0fe3fc95c50c0b56020858435deae13670d8c 100644 (file)
@@ -1,3 +1,21 @@
+2006-08-25  Nikolas Zimmermann  <zimmermann@kde.org>
+
+        Reviewed/landed by Adam.
+
+        Finally fix font caching. WebKit+Qt now works
+        out of the box without any further patches :-)
+
+        * platform/qt/FontDataQt.cpp:
+        (WebCore::FontData::platformDestroy):
+        * platform/qt/FontPlatformData.h:
+        * platform/qt/FontPlatformDataQt.cpp:
+        (WebCore::FontPlatformData::FontPlatformData):
+        (WebCore::FontPlatformData::isFixedPitch):
+        (WebCore::FontPlatformData::font):
+        (WebCore::FontPlatformData::fontPtr):
+        (WebCore::FontPlatformData::hash):
+        (WebCore::FontPlatformData::operator==):
+
 2006-08-25  Nikolas Zimmermann  <zimmermann@kde.org>
 
         Reviewed/landed by Adam.
index 9055c6c8d1f84b8947b6e41903fb4e580119b73f..c21b0a5737a97f04f4519d804ec3fd65f45dc5b8 100644 (file)
@@ -39,6 +39,7 @@
 #include "GlyphBuffer.h"
 #include "FontDescription.h"
 
+#include <QFont>
 #include <QFontMetrics>
 
 namespace WebCore {
@@ -56,6 +57,7 @@ void FontData::platformInit()
 
 void FontData::platformDestroy()
 {
+    delete m_font.fontPtr();
 }
 
 FontData* FontData::smallCapsFontData(const FontDescription& fontDescription) const
index a07d6b3eae2a06c973463e8cb4c7ba57eb3841fc..3f8362559ee316ae4c4427bebdfb9598c8d282ee 100644 (file)
@@ -39,9 +39,6 @@ namespace WebCore {
 
 class FontPlatformData {
 public:
-    FontPlatformData(const FontPlatformData&);
-    FontPlatformData& operator=(const FontPlatformData&);
-
     class Deleted { };
     FontPlatformData(Deleted);
 
@@ -51,15 +48,16 @@ public:
 
     bool isFixedPitch();
 
-    void setFont(const QFont&);
     QFont font() const;
+    QFont* fontPtr() const;
 
     unsigned hash() const;
 
     bool operator==(const FontPlatformData&) const;
 
 private:
-    QFont m_font;
+    QFont* m_font;
+    FontDescription m_fontDescription;
 };
 
 }
index 773135a7ca54de6751dd185b84ee07f79957ec7a..3d767664825d57644b13961d688ac7018f5c4c7e 100644 (file)
 #include "DeprecatedString.h"
 #include "FontDescription.h"
 
-#include <QHash>
 #include <QFontInfo>
 
 namespace WebCore {
 
 FontPlatformData::FontPlatformData()
+    : m_font(0)
 {
 }
 
 FontPlatformData::FontPlatformData(Deleted)
+    : m_font((QFont*) -1)
 {
 }
 
 FontPlatformData::FontPlatformData(const FontDescription& fontDescription, const AtomicString& familyName)
+    : m_font(new QFont("Times New Roman", 12))
+    , m_fontDescription(fontDescription)
 {
-    QFont font("Times New Roman", 12);
-    font.setFamily(familyName.domString());
-    font.setPixelSize(fontDescription.computedSize());
-    font.setItalic(fontDescription.italic());
-    font.setWeight(fontDescription.weight());
-    setFont(font);
-}
-
-FontPlatformData::FontPlatformData(const FontPlatformData& other)
-    : m_font(other.m_font)
-{
-}
-
-FontPlatformData& FontPlatformData::operator=(const FontPlatformData& other)
-{
-    m_font = other.m_font;
-    return *this;
+    m_font->setFamily(familyName.domString());
+    m_font->setPixelSize(fontDescription.computedSize());
+    m_font->setItalic(fontDescription.italic());
+    m_font->setWeight(fontDescription.weight());
 }
 
 FontPlatformData::~FontPlatformData()
@@ -74,27 +64,37 @@ FontPlatformData::~FontPlatformData()
 
 bool FontPlatformData::isFixedPitch()
 {
-    return QFontInfo(m_font).fixedPitch();
+    return QFontInfo(*m_font).fixedPitch();
 }
 
-void FontPlatformData::setFont(const QFont& other)
+QFont FontPlatformData::font() const
 {
-    m_font = other;
+    if (m_font)
+        return *m_font;
+
+    return QFont();
 }
 
-QFont FontPlatformData::font() const
+QFont* FontPlatformData::fontPtr() const
 {
     return m_font;
 }
 
 unsigned FontPlatformData::hash() const
 {
-    return qHash(&m_font);
+    return StringImpl::computeHash((UChar*) &m_fontDescription, sizeof(FontDescription) / sizeof(UChar));
 }
 
 bool FontPlatformData::operator==(const FontPlatformData& other) const
 {
-    return (other.m_font == m_font);
+    if (m_font == other.m_font)
+        return true;
+
+    if (!m_font || m_font == (QFont*) -1 ||
+        !other.m_font || other.m_font == (QFont*) -1)
+        return false;
+
+    return (*m_font == *other.m_font);
 }
 
 }