2011-11-08 Nikolas Zimmermann <nzimmermann@rim.com>
Fold ImageBySizeCache again into CSSImageGeneratorValue
https://bugs.webkit.org/show_bug.cgi?id=71785
Reviewed by Zoltan Herczeg.
Remove ImageBySizeCache, and fold it into CSSImageGeneratorValue, as it used to be.
CachedImage has switched to SVGImageCache and no longer needs it.
* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSImageGeneratorValue.cpp:
(WebCore::CSSImageGeneratorValue::addClient):
(WebCore::CSSImageGeneratorValue::removeClient):
(WebCore::CSSImageGeneratorValue::getImage):
(WebCore::CSSImageGeneratorValue::putImage):
* css/CSSImageGeneratorValue.h:
(WebCore::SizeAndCount::SizeAndCount):
(WebCore::CSSImageGeneratorValue::clients):
* rendering/ImageBySizeCache.cpp: Removed.
* rendering/ImageBySizeCache.h: Removed.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@99549 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/css/CSSImageGeneratorValue.h b/Source/WebCore/css/CSSImageGeneratorValue.h
index bf993aa..8840c1d 100644
--- a/Source/WebCore/css/CSSImageGeneratorValue.h
+++ b/Source/WebCore/css/CSSImageGeneratorValue.h
@@ -27,7 +27,9 @@
#define CSSImageGeneratorValue_h
#include "CSSValue.h"
-#include "ImageBySizeCache.h"
+#include "IntSizeHash.h"
+#include <wtf/HashCountedSet.h>
+#include <wtf/RefPtr.h>
namespace WebCore {
@@ -35,6 +37,19 @@
class RenderObject;
class StyleGeneratedImage;
+struct SizeAndCount {
+ SizeAndCount(IntSize newSize = IntSize(), int newCount = 0)
+ : size(newSize)
+ , count(newCount)
+ {
+ }
+
+ IntSize size;
+ int count;
+};
+
+typedef HashMap<const RenderObject*, SizeAndCount> RenderObjectSizeCountMap;
+
class CSSImageGeneratorValue : public CSSValue {
public:
virtual ~CSSImageGeneratorValue();
@@ -53,11 +68,14 @@
Image* getImage(RenderObject*, const IntSize&);
void putImage(const IntSize&, PassRefPtr<Image>);
- const RenderObjectSizeCountMap& clients() const { return m_imageCache.clients(); }
+ const RenderObjectSizeCountMap& clients() const { return m_clients; }
- ImageBySizeCache m_imageCache;
RefPtr<StyleGeneratedImage> m_image;
bool m_accessedImage;
+
+ HashCountedSet<IntSize> m_sizes; // A count of how many times a given image size is in use.
+ RenderObjectSizeCountMap m_clients; // A map from RenderObjects (with entry count) to image sizes.
+ HashMap<IntSize, RefPtr<Image> > m_images; // A cache of Image objects by image size.
};
} // namespace WebCore