Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (99548 => 99549)
--- trunk/Source/WebCore/CMakeLists.txt 2011-11-08 12:22:13 UTC (rev 99548)
+++ trunk/Source/WebCore/CMakeLists.txt 2011-11-08 12:29:38 UTC (rev 99549)
@@ -1217,7 +1217,6 @@
rendering/FixedTableLayout.cpp
rendering/HitTestingTransformState.cpp
rendering/HitTestResult.cpp
- rendering/ImageBySizeCache.cpp
rendering/InlineBox.cpp
rendering/InlineFlowBox.cpp
rendering/InlineTextBox.cpp
Modified: trunk/Source/WebCore/ChangeLog (99548 => 99549)
--- trunk/Source/WebCore/ChangeLog 2011-11-08 12:22:13 UTC (rev 99548)
+++ trunk/Source/WebCore/ChangeLog 2011-11-08 12:29:38 UTC (rev 99549)
@@ -1,3 +1,30 @@
+2011-11-08 Nikolas Zimmermann <nzimmerm...@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.
+
2011-11-08 Alexander Pavlov <apav...@chromium.org>
Web Inspector: Avoid automatic Console suggestions with empty _expression_
Modified: trunk/Source/WebCore/GNUmakefile.list.am (99548 => 99549)
--- trunk/Source/WebCore/GNUmakefile.list.am 2011-11-08 12:22:13 UTC (rev 99548)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2011-11-08 12:29:38 UTC (rev 99549)
@@ -3025,8 +3025,6 @@
Source/WebCore/rendering/HitTestingTransformState.h \
Source/WebCore/rendering/HitTestResult.cpp \
Source/WebCore/rendering/HitTestResult.h \
- Source/WebCore/rendering/ImageBySizeCache.cpp \
- Source/WebCore/rendering/ImageBySizeCache.h \
Source/WebCore/rendering/InlineBox.cpp \
Source/WebCore/rendering/InlineBox.h \
Source/WebCore/rendering/InlineFlowBox.cpp \
Modified: trunk/Source/WebCore/Target.pri (99548 => 99549)
--- trunk/Source/WebCore/Target.pri 2011-11-08 12:22:13 UTC (rev 99548)
+++ trunk/Source/WebCore/Target.pri 2011-11-08 12:29:38 UTC (rev 99549)
@@ -1169,7 +1169,6 @@
rendering/FixedTableLayout.cpp \
rendering/HitTestingTransformState.cpp \
rendering/HitTestResult.cpp \
- rendering/ImageBySizeCache.cpp \
rendering/InlineBox.cpp \
rendering/InlineFlowBox.cpp \
rendering/InlineTextBox.cpp \
@@ -2269,7 +2268,6 @@
rendering/FixedTableLayout.h \
rendering/HitTestingTransformState.h \
rendering/HitTestResult.h \
- rendering/ImageBySizeCache.h \
rendering/InlineBox.h \
rendering/InlineFlowBox.h \
rendering/InlineTextBox.h \
Modified: trunk/Source/WebCore/WebCore.gypi (99548 => 99549)
--- trunk/Source/WebCore/WebCore.gypi 2011-11-08 12:22:13 UTC (rev 99548)
+++ trunk/Source/WebCore/WebCore.gypi 2011-11-08 12:29:38 UTC (rev 99549)
@@ -892,7 +892,6 @@
'rendering/GapRects.h',
'rendering/HitTestRequest.h',
'rendering/HitTestResult.h',
- 'rendering/ImageBySizeCache.h',
'rendering/InlineBox.h',
'rendering/InlineFlowBox.h',
'rendering/InlineTextBox.h',
@@ -4545,7 +4544,6 @@
'rendering/HitTestingTransformState.cpp',
'rendering/HitTestingTransformState.h',
'rendering/HitTestResult.cpp',
- 'rendering/ImageBySizeCache.cpp',
'rendering/InlineBox.cpp',
'rendering/InlineFlowBox.cpp',
'rendering/InlineIterator.h',
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (99548 => 99549)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-11-08 12:22:13 UTC (rev 99548)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-11-08 12:29:38 UTC (rev 99549)
@@ -33418,14 +33418,6 @@
>
</File>
<File
- RelativePath="..\rendering\ImageBySizeCache.cpp"
- >
- </File>
- <File
- RelativePath="..\rendering\ImageBySizeCache.h"
- >
- </File>
- <File
RelativePath="..\rendering\InlineBox.cpp"
>
<FileConfiguration
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (99548 => 99549)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-11-08 12:22:13 UTC (rev 99548)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-11-08 12:29:38 UTC (rev 99549)
@@ -1715,8 +1715,6 @@
6EBF0E7712A9868800DB1709 /* JSOESTextureFloat.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EBF0E7512A9868800DB1709 /* JSOESTextureFloat.h */; };
6EE8A77210F803F3005A4A24 /* JSWebGLContextAttributes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6EE8A77010F803F3005A4A24 /* JSWebGLContextAttributes.cpp */; };
6EE8A77310F803F3005A4A24 /* JSWebGLContextAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EE8A77110F803F3005A4A24 /* JSWebGLContextAttributes.h */; };
- 71CCB49C144824AC00C676D6 /* ImageBySizeCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 71CCB49A144824AC00C676D6 /* ImageBySizeCache.cpp */; };
- 71CCB49D144824AC00C676D6 /* ImageBySizeCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 71CCB49B144824AC00C676D6 /* ImageBySizeCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
71FB967B1383D64600AC8A4C /* SVGAnimatedEnumerationPropertyTearOff.h in Headers */ = {isa = PBXBuildFile; fileRef = 71FB967A1383D64600AC8A4C /* SVGAnimatedEnumerationPropertyTearOff.h */; settings = {ATTRIBUTES = (Private, ); }; };
72626E020EF022FE00A07E20 /* FontFastPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 72626E010EF022FE00A07E20 /* FontFastPath.cpp */; };
750D029311D0E7F300BD1B27 /* RenderInputSpeech.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 750D029111D0E7F300BD1B27 /* RenderInputSpeech.cpp */; };
@@ -8918,8 +8916,6 @@
6EBF0E7512A9868800DB1709 /* JSOESTextureFloat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSOESTextureFloat.h; sourceTree = "<group>"; };
6EE8A77010F803F3005A4A24 /* JSWebGLContextAttributes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLContextAttributes.cpp; sourceTree = "<group>"; };
6EE8A77110F803F3005A4A24 /* JSWebGLContextAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLContextAttributes.h; sourceTree = "<group>"; };
- 71CCB49A144824AC00C676D6 /* ImageBySizeCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageBySizeCache.cpp; sourceTree = "<group>"; };
- 71CCB49B144824AC00C676D6 /* ImageBySizeCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageBySizeCache.h; sourceTree = "<group>"; };
71FB967A1383D64600AC8A4C /* SVGAnimatedEnumerationPropertyTearOff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedEnumerationPropertyTearOff.h; sourceTree = "<group>"; };
72626E010EF022FE00A07E20 /* FontFastPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFastPath.cpp; sourceTree = "<group>"; };
750D029111D0E7F300BD1B27 /* RenderInputSpeech.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderInputSpeech.cpp; sourceTree = "<group>"; };
@@ -20753,8 +20749,6 @@
930908900AF7EDE40081DF01 /* HitTestRequest.h */,
9307F1D50AF2D59000DBA31A /* HitTestResult.cpp */,
9307F1D60AF2D59000DBA31A /* HitTestResult.h */,
- 71CCB49A144824AC00C676D6 /* ImageBySizeCache.cpp */,
- 71CCB49B144824AC00C676D6 /* ImageBySizeCache.h */,
A8CFF5DF0A155A05000A4234 /* InlineBox.cpp */,
A8CFF5DE0A155A05000A4234 /* InlineBox.h */,
A8CFF5DD0A155A05000A4234 /* InlineFlowBox.cpp */,
@@ -24611,7 +24605,6 @@
29D7BCFA1444AF7D0070619C /* AccessibilitySpinButton.h in Headers */,
9B375EDB14478A0100F3CAE5 /* MicroDataItemList.h in Headers */,
49AF2D6914435D050016A784 /* DisplayRefreshMonitor.h in Headers */,
- 71CCB49D144824AC00C676D6 /* ImageBySizeCache.h in Headers */,
0753860314489E9800B78452 /* CachedTextTrack.h in Headers */,
8AA61D00144D595B00F37350 /* CSSRegionStyleRule.h in Headers */,
97665013144FAA4200F6BB51 /* EventFactory.h in Headers */,
@@ -27474,7 +27467,6 @@
973DC63F145A9409002842C2 /* ExceptionCodeDescription.cpp in Sources */,
49AF2D6C14435D210016A784 /* DisplayRefreshMonitorMac.cpp in Sources */,
49FC7A501444AF5F00A5D864 /* DisplayRefreshMonitor.cpp in Sources */,
- 71CCB49C144824AC00C676D6 /* ImageBySizeCache.cpp in Sources */,
0753860214489E9800B78452 /* CachedTextTrack.cpp in Sources */,
8AA61CFF144D595B00F37350 /* CSSRegionStyleRule.cpp in Sources */,
9766504F144FBFFE00F6BB51 /* EventFactory.cpp in Sources */,
Modified: trunk/Source/WebCore/css/CSSImageGeneratorValue.cpp (99548 => 99549)
--- trunk/Source/WebCore/css/CSSImageGeneratorValue.cpp 2011-11-08 12:22:13 UTC (rev 99548)
+++ trunk/Source/WebCore/css/CSSImageGeneratorValue.cpp 2011-11-08 12:29:38 UTC (rev 99549)
@@ -27,11 +27,9 @@
#include "CSSImageGeneratorValue.h"
#include "Image.h"
-#include "IntSize.h"
-#include "IntSizeHash.h"
-#include "PlatformString.h"
#include "RenderObject.h"
#include "StyleGeneratedImage.h"
+#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -48,25 +46,65 @@
void CSSImageGeneratorValue::addClient(RenderObject* renderer, const IntSize& size)
{
ref();
- m_imageCache.addClient(renderer, size);
+
+ ASSERT(renderer);
+ if (!size.isEmpty())
+ m_sizes.add(size);
+
+ RenderObjectSizeCountMap::iterator it = m_clients.find(renderer);
+ if (it == m_clients.end())
+ m_clients.add(renderer, SizeAndCount(size, 1));
+ else {
+ SizeAndCount& sizeCount = it->second;
+ ++sizeCount.count;
+ }
}
void CSSImageGeneratorValue::removeClient(RenderObject* renderer)
{
- m_imageCache.removeClient(renderer);
+ ASSERT(renderer);
+ RenderObjectSizeCountMap::iterator it = m_clients.find(renderer);
+ ASSERT(it != m_clients.end());
+
+ IntSize removedImageSize;
+ SizeAndCount& sizeCount = it->second;
+ IntSize size = sizeCount.size;
+ if (!size.isEmpty()) {
+ m_sizes.remove(size);
+ if (!m_sizes.contains(size))
+ m_images.remove(size);
+ }
+
+ if (!--sizeCount.count)
+ m_clients.remove(renderer);
+
deref();
}
Image* CSSImageGeneratorValue::getImage(RenderObject* renderer, const IntSize& size)
{
- // If renderer is the only client, make sure we don't delete this, if the size changes (as this will result in addClient/removeClient calls).
- RefPtr<CSSImageGeneratorValue> protect(this);
- return m_imageCache.getImage(renderer, size);
+ RenderObjectSizeCountMap::iterator it = m_clients.find(renderer);
+ if (it != m_clients.end()) {
+ SizeAndCount& sizeCount = it->second;
+ IntSize oldSize = sizeCount.size;
+ if (oldSize != size) {
+ RefPtr<CSSImageGeneratorValue> protect(this);
+ removeClient(renderer);
+ addClient(renderer, size);
+ }
+ }
+
+ // Don't generate an image for empty sizes.
+ if (size.isEmpty())
+ return 0;
+
+ // Look up the image in our cache.
+ return m_images.get(size).get();
}
void CSSImageGeneratorValue::putImage(const IntSize& size, PassRefPtr<Image> image)
{
- m_imageCache.putImage(size, image);
+ m_images.add(size, image);
}
StyleGeneratedImage* CSSImageGeneratorValue::generatedImage()
Modified: trunk/Source/WebCore/css/CSSImageGeneratorValue.h (99548 => 99549)
--- trunk/Source/WebCore/css/CSSImageGeneratorValue.h 2011-11-08 12:22:13 UTC (rev 99548)
+++ trunk/Source/WebCore/css/CSSImageGeneratorValue.h 2011-11-08 12:29:38 UTC (rev 99549)
@@ -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
Deleted: trunk/Source/WebCore/rendering/ImageBySizeCache.cpp (99548 => 99549)
--- trunk/Source/WebCore/rendering/ImageBySizeCache.cpp 2011-11-08 12:22:13 UTC (rev 99548)
+++ trunk/Source/WebCore/rendering/ImageBySizeCache.cpp 2011-11-08 12:29:38 UTC (rev 99549)
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "ImageBySizeCache.h"
-
-#include "Image.h"
-#include "IntSize.h"
-#include "RenderObject.h"
-
-namespace WebCore {
-
-ImageBySizeCache::ImageBySizeCache()
-{
-}
-
-void ImageBySizeCache::addClient(const RenderObject* renderer, const IntSize& size)
-{
- ASSERT(renderer);
- if (!size.isEmpty())
- m_sizes.add(size);
-
- RenderObjectSizeCountMap::iterator it = m_clients.find(renderer);
- if (it == m_clients.end())
- m_clients.add(renderer, SizeAndCount(size, 1));
- else {
- SizeAndCount& sizeCount = it->second;
- ++sizeCount.count;
- }
-}
-
-void ImageBySizeCache::removeClient(const RenderObject* renderer)
-{
- ASSERT(renderer);
- RenderObjectSizeCountMap::iterator it = m_clients.find(renderer);
- ASSERT(it != m_clients.end());
-
- IntSize removedImageSize;
- SizeAndCount& sizeCount = it->second;
- IntSize size = sizeCount.size;
- if (!size.isEmpty()) {
- m_sizes.remove(size);
- if (!m_sizes.contains(size))
- m_images.remove(size);
- }
-
- if (!--sizeCount.count)
- m_clients.remove(renderer);
-}
-
-Image* ImageBySizeCache::getImage(const RenderObject* renderer, const IntSize& size)
-{
- RenderObjectSizeCountMap::iterator it = m_clients.find(renderer);
- if (it != m_clients.end()) {
- SizeAndCount& sizeCount = it->second;
- IntSize oldSize = sizeCount.size;
- if (oldSize != size) {
- removeClient(renderer);
- addClient(renderer, size);
- }
- }
-
- // Don't generate an image for empty sizes.
- if (size.isEmpty())
- return 0;
-
- // Look up the image in our cache.
- return m_images.get(size).get();
-}
-
-void ImageBySizeCache::putImage(const IntSize& size, PassRefPtr<Image> image)
-{
- m_images.add(size, image);
-}
-
-} // namespace WebCore
Deleted: trunk/Source/WebCore/rendering/ImageBySizeCache.h (99548 => 99549)
--- trunk/Source/WebCore/rendering/ImageBySizeCache.h 2011-11-08 12:22:13 UTC (rev 99548)
+++ trunk/Source/WebCore/rendering/ImageBySizeCache.h 2011-11-08 12:29:38 UTC (rev 99549)
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef ImageBySizeCache_h
-#define ImageBySizeCache_h
-
-#include "IntSizeHash.h"
-#include <wtf/HashCountedSet.h>
-#include <wtf/HashMap.h>
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-class Image;
-class RenderObject;
-
-struct SizeAndCount {
- SizeAndCount(IntSize newSize = IntSize(), int newCount = 0)
- : size(newSize)
- , count(newCount)
- {
- }
-
- IntSize size;
- int count;
-};
-
-typedef HashMap<const RenderObject*, SizeAndCount> RenderObjectSizeCountMap;
-
-class ImageBySizeCache {
-public:
- ImageBySizeCache();
-
- void addClient(const RenderObject*, const IntSize&);
- void removeClient(const RenderObject*);
-
- Image* getImage(const RenderObject*, const IntSize&);
- void putImage(const IntSize&, PassRefPtr<Image>);
-
- const RenderObjectSizeCountMap& clients() const { return m_clients; }
-
-private:
- 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
-
-#endif // ImageBySizeCache_h