Patch from Adam Treat to implement default icons / resources for Qt. Also does
a small cleanup to QWebPage::icon. This is a great example of how QWebSettings
is not ideal.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@23733 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/platform/graphics/qt/ImageQt.cpp b/WebCore/platform/graphics/qt/ImageQt.cpp
index aba4a87..f3cec6c 100644
--- a/WebCore/platform/graphics/qt/ImageQt.cpp
+++ b/WebCore/platform/graphics/qt/ImageQt.cpp
@@ -49,8 +49,8 @@
#include <math.h>
-// This function loads resources from WebKit
-Vector<char> loadResourceIntoArray(const char*);
+// This function loads resources into WebKit
+QPixmap loadResourcePixmap(const char*);
namespace WebCore {
@@ -71,10 +71,7 @@
Image* Image::loadPlatformResource(const char* name)
{
- Vector<char> arr = loadResourceIntoArray(name);
- Image* img = new BitmapImage();
- RefPtr<SharedBuffer> buffer = new SharedBuffer(arr.data(), arr.size());
- img->setData(buffer, true);
+ BitmapImage* img = new BitmapImage(loadResourcePixmap(name));
return img;
}
@@ -85,13 +82,33 @@
notImplemented();
}
+BitmapImage::BitmapImage(const QPixmap &pixmap, ImageObserver *observer)
+ : Image(observer)
+ , m_currentFrame(0)
+ , m_frames(0)
+ , m_frameTimer(0)
+ , m_repetitionCount(0)
+ , m_repetitionsComplete(0)
+ , m_isSolidColor(false)
+ , m_animatingImageType(true)
+ , m_animationFinished(false)
+ , m_allDataReceived(false)
+ , m_haveSize(false)
+ , m_sizeAvailable(false)
+ , m_decodedSize(0)
+{
+ m_pixmap = new QPixmap(pixmap);
+}
void BitmapImage::initPlatformData()
{
+ m_pixmap = 0;
}
void BitmapImage::invalidatePlatformData()
{
+ delete m_pixmap;
+ m_pixmap = 0;
}
// Drawing Routines
@@ -167,7 +184,10 @@
QPixmap* BitmapImage::getPixmap() const
{
- return const_cast<BitmapImage*>(this)->frameAtIndex(0);
+ if (!m_pixmap)
+ return const_cast<BitmapImage*>(this)->frameAtIndex(0);
+ else
+ return m_pixmap;
}
}