Made the QWebSettings::webGraphic functions static. The implementation was using...
authorhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2007 14:30:57 +0000 (14:30 +0000)
committerhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2007 14:30:57 +0000 (14:30 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27550 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/graphics/qt/ImageQt.cpp
WebKit/qt/Api/qwebsettings.cpp
WebKit/qt/Api/qwebsettings.h
WebKit/qt/ChangeLog

index d4ae5c9427094f77ab2a7c77420c81c40f87c251..35b3ef7459891c21bf4497a580ab0f6aedc556fd 100644 (file)
@@ -1,3 +1,14 @@
+2007-11-07  Simon Hausmann  <hausmann@kde.org>
+
+        Reviewed by Lars.
+
+        Made the QWebSettings::webGraphic functions static. The implementation was using QWebSettings::global() anyway.
+
+        WARNING: NO TEST CASES ADDED OR CHANGED
+
+        * platform/graphics/qt/ImageQt.cpp:
+        (loadResourcePixmap):
+
 2007-11-07  Simon Hausmann  <hausmann@kde.org>
 
         Reviewed by Lars.
index 136685cefb7d990cc4809284eaac7d9b34acf096..206aee32cf57b584cd42871811b61ea5a5312c55 100644 (file)
 // This function loads resources into WebKit
 static QPixmap loadResourcePixmap(const char *name)
 {
-    const QWebSettings settings = QWebSettings::global();
     const QString resource = name;
 
     QPixmap pixmap;
     if (resource == "missingImage")
-        pixmap = settings.webGraphic(QWebSettings::MissingImageGraphic);
+        pixmap = QWebSettings::webGraphic(QWebSettings::MissingImageGraphic);
     else if (resource == "nullPlugin")
-        pixmap = settings.webGraphic(QWebSettings::MissingPluginGraphic);
+        pixmap = QWebSettings::webGraphic(QWebSettings::MissingPluginGraphic);
     else if (resource == "urlIcon")
-        pixmap = settings.webGraphic(QWebSettings::DefaultFaviconGraphic);
+        pixmap = QWebSettings::webGraphic(QWebSettings::DefaultFaviconGraphic);
     else if (resource == "textAreaResizeCorner")
-        pixmap = settings.webGraphic(QWebSettings::TextAreaResizeCornerGraphic);
+        pixmap = QWebSettings::webGraphic(QWebSettings::TextAreaResizeCornerGraphic);
 
     return pixmap;
 }
index 060bbcafbae043fdb41c95eabbb2722f7baf387d..d89b163637813985aff6044a32d64000e65f70db 100644 (file)
@@ -60,10 +60,12 @@ public:
     int defaultFontSize;
     int defaultFixedFontSize;
     QHash<int, bool> attributes;
-    QHash<int, QPixmap> graphics;
     QString userStyleSheetLocation;
 };
 
+typedef QHash<int, QPixmap> WebGraphicHash;
+Q_GLOBAL_STATIC(WebGraphicHash, graphics)
+
 static QWebSettings globalSettings;
 
 QWebSettings::QWebSettings()
@@ -153,15 +155,16 @@ bool QWebSettings::iconDatabaseEnabled()
 
 void QWebSettings::setWebGraphic(WebGraphic type, const QPixmap &graphic)
 {
-    d->graphics[type] = graphic;
+    WebGraphicHash *h = graphics();
+    if (graphic.isNull())
+        h->remove(type);
+    else
+        h->insert(type, graphic);
 }
 
-QPixmap QWebSettings::webGraphic(WebGraphic type) const
+QPixmap QWebSettings::webGraphic(WebGraphic type)
 {
-    if (d->graphics.contains(type))
-      return d->graphics[type];
-    else
-      return QPixmap();
+    return graphics()->value(type);
 }
 
 QWebSettings::QWebSettings(const QWebSettings &other)
index 2ce0ff6495e4f2e29153ec69052734639dff0b5d..f0b5132b5228acfd8457b16127d6c3538779ef22 100644 (file)
@@ -91,8 +91,8 @@ public:
     static void setIconDatabaseEnabled(bool enabled, const QString &location = QString());
     static bool iconDatabaseEnabled();
 
-    void setWebGraphic(WebGraphic type, const QPixmap &graphic);
-    QPixmap webGraphic(WebGraphic type) const;
+    static void setWebGraphic(WebGraphic type, const QPixmap &graphic);
+    static QPixmap webGraphic(WebGraphic type);
 
 private:
     QSharedDataPointer<QWebSettingsPrivate> d;
index b54c0b27a70920cb6d62c8b49b9382f6a6ab054d..7bc95a040689f2959abe74710f3c0b81faf5ead9 100644 (file)
@@ -1,3 +1,13 @@
+2007-11-07  Simon Hausmann  <hausmann@kde.org>
+
+        Reviewed by Lars.
+
+        Made the QWebSettings::webGraphic functions static. The implementation was using QWebSettings::global() anyway.
+
+        * Api/qwebsettings.cpp:
+        (QWebSettings::setWebGraphic):
+        * Api/qwebsettings.h:
+
 2007-11-07  Simon Hausmann  <hausmann@kde.org>
 
         Reviewed by Lars.