Subpixel rendering: Transition class CSSImageGeneratorValue/class StyleImage (and...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Apr 2014 14:18:58 +0000 (14:18 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Apr 2014 14:18:58 +0000 (14:18 +0000)
IntSize to FloatSize to enable subpixel sized (generated)images.
https://bugs.webkit.org/show_bug.cgi?id=130659

Reviewed by Simon Fraser and Andreas Kling.

This is in preparation to support subpixel positioned/sized background images. Generated images
needs to be able to sized on device pixels.

No change in behavior.

* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSCanvasValue.cpp:
(WebCore::CSSCanvasValue::fixedSize):
(WebCore::CSSCanvasValue::image):
* css/CSSCanvasValue.h:
* css/CSSCrossfadeValue.cpp:
(WebCore::CSSCrossfadeValue::fixedSize):
(WebCore::CSSCrossfadeValue::image):
* css/CSSCrossfadeValue.h:
* css/CSSFilterImageValue.cpp:
(WebCore::CSSFilterImageValue::fixedSize):
(WebCore::CSSFilterImageValue::image):
* css/CSSFilterImageValue.h:
* css/CSSGradientValue.cpp:
(WebCore::CSSGradientValue::image):
(WebCore::positionFromValue):
(WebCore::CSSGradientValue::computeEndPoint):
(WebCore::endPointsFromAngle):
(WebCore::CSSLinearGradientValue::createGradient):
(WebCore::CSSRadialGradientValue::createGradient):
* css/CSSGradientValue.h:
(WebCore::CSSGradientValue::fixedSize):
* css/CSSImageGeneratorValue.cpp:
(WebCore::CSSImageGeneratorValue::cachedImageForSize):
(WebCore::CSSImageGeneratorValue::saveCachedImageForSize):
(WebCore::CSSImageGeneratorValue::evictCachedGeneratedImage):
(WebCore::CSSImageGeneratorValue::CachedGeneratedImage::CachedGeneratedImage):
(WebCore::CSSImageGeneratorValue::image):
(WebCore::CSSImageGeneratorValue::fixedSize):
* css/CSSImageGeneratorValue.h:
* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::setContainerSizeForRenderer):
* loader/cache/CachedImage.h:
* platform/graphics/FloatSizeHash.h: Added.
(WTF::FloatHash<WebCore::FloatSize>::hash):
(WTF::FloatHash<WebCore::FloatSize>::equal):
(WTF::HashTraits<WebCore::FloatSize>::constructDeletedValue):
(WTF::HashTraits<WebCore::FloatSize>::isDeletedValue):
* platform/graphics/LayoutSize.h:
(WebCore::flooredForPainting):
* rendering/RenderImageResourceStyleImage.h:
* rendering/RenderListMarker.cpp:
(WebCore::RenderListMarker::computePreferredLogicalWidths):
* rendering/style/StyleCachedImage.cpp:
(WebCore::StyleCachedImage::imageSize):
(WebCore::StyleCachedImage::setContainerSizeForRenderer):
(WebCore::StyleCachedImage::image):
* rendering/style/StyleCachedImage.h:
* rendering/style/StyleCachedImageSet.cpp:
(WebCore::StyleCachedImageSet::imageSize):
(WebCore::StyleCachedImageSet::setContainerSizeForRenderer):
(WebCore::StyleCachedImageSet::image):
* rendering/style/StyleCachedImageSet.h:
* rendering/style/StyleGeneratedImage.cpp:
(WebCore::StyleGeneratedImage::imageSize):
(WebCore::StyleGeneratedImage::computeIntrinsicDimensions):
(WebCore::StyleGeneratedImage::image):
* rendering/style/StyleGeneratedImage.h:
* rendering/style/StyleImage.h:
* rendering/style/StylePendingImage.h:
* svg/graphics/SVGImageCache.cpp:
(WebCore::SVGImageCache::setContainerSizeForRenderer):
* svg/graphics/SVGImageCache.h:

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

30 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSCanvasValue.cpp
Source/WebCore/css/CSSCanvasValue.h
Source/WebCore/css/CSSCrossfadeValue.cpp
Source/WebCore/css/CSSCrossfadeValue.h
Source/WebCore/css/CSSFilterImageValue.cpp
Source/WebCore/css/CSSFilterImageValue.h
Source/WebCore/css/CSSGradientValue.cpp
Source/WebCore/css/CSSGradientValue.h
Source/WebCore/css/CSSImageGeneratorValue.cpp
Source/WebCore/css/CSSImageGeneratorValue.h
Source/WebCore/loader/cache/CachedImage.cpp
Source/WebCore/loader/cache/CachedImage.h
Source/WebCore/platform/graphics/FloatSizeHash.h [new file with mode: 0644]
Source/WebCore/platform/graphics/LayoutSize.h
Source/WebCore/rendering/RenderImageResourceStyleImage.h
Source/WebCore/rendering/RenderListMarker.cpp
Source/WebCore/rendering/style/StyleCachedImage.cpp
Source/WebCore/rendering/style/StyleCachedImage.h
Source/WebCore/rendering/style/StyleCachedImageSet.cpp
Source/WebCore/rendering/style/StyleCachedImageSet.h
Source/WebCore/rendering/style/StyleGeneratedImage.cpp
Source/WebCore/rendering/style/StyleGeneratedImage.h
Source/WebCore/rendering/style/StyleImage.h
Source/WebCore/rendering/style/StylePendingImage.h
Source/WebCore/svg/graphics/SVGImageCache.cpp
Source/WebCore/svg/graphics/SVGImageCache.h

index ac65b7e..f8272bb 100644 (file)
@@ -1,3 +1,82 @@
+2014-04-02  Zalan Bujtas  <zalan@apple.com>
+
+        Subpixel rendering: Transition class CSSImageGeneratorValue/class StyleImage (and its dependencies) from 
+        IntSize to FloatSize to enable subpixel sized (generated)images.
+        https://bugs.webkit.org/show_bug.cgi?id=130659
+
+        Reviewed by Simon Fraser and Andreas Kling.
+
+        This is in preparation to support subpixel positioned/sized background images. Generated images
+        needs to be able to sized on device pixels.
+
+        No change in behavior.
+
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.vcxproj/WebCore.vcxproj.filters:
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSCanvasValue.cpp:
+        (WebCore::CSSCanvasValue::fixedSize):
+        (WebCore::CSSCanvasValue::image):
+        * css/CSSCanvasValue.h:
+        * css/CSSCrossfadeValue.cpp:
+        (WebCore::CSSCrossfadeValue::fixedSize):
+        (WebCore::CSSCrossfadeValue::image):
+        * css/CSSCrossfadeValue.h:
+        * css/CSSFilterImageValue.cpp:
+        (WebCore::CSSFilterImageValue::fixedSize):
+        (WebCore::CSSFilterImageValue::image):
+        * css/CSSFilterImageValue.h:
+        * css/CSSGradientValue.cpp:
+        (WebCore::CSSGradientValue::image):
+        (WebCore::positionFromValue):
+        (WebCore::CSSGradientValue::computeEndPoint):
+        (WebCore::endPointsFromAngle):
+        (WebCore::CSSLinearGradientValue::createGradient):
+        (WebCore::CSSRadialGradientValue::createGradient):
+        * css/CSSGradientValue.h:
+        (WebCore::CSSGradientValue::fixedSize):
+        * css/CSSImageGeneratorValue.cpp:
+        (WebCore::CSSImageGeneratorValue::cachedImageForSize):
+        (WebCore::CSSImageGeneratorValue::saveCachedImageForSize):
+        (WebCore::CSSImageGeneratorValue::evictCachedGeneratedImage):
+        (WebCore::CSSImageGeneratorValue::CachedGeneratedImage::CachedGeneratedImage):
+        (WebCore::CSSImageGeneratorValue::image):
+        (WebCore::CSSImageGeneratorValue::fixedSize):
+        * css/CSSImageGeneratorValue.h:
+        * loader/cache/CachedImage.cpp:
+        (WebCore::CachedImage::setContainerSizeForRenderer):
+        * loader/cache/CachedImage.h:
+        * platform/graphics/FloatSizeHash.h: Added.
+        (WTF::FloatHash<WebCore::FloatSize>::hash):
+        (WTF::FloatHash<WebCore::FloatSize>::equal):
+        (WTF::HashTraits<WebCore::FloatSize>::constructDeletedValue):
+        (WTF::HashTraits<WebCore::FloatSize>::isDeletedValue):
+        * platform/graphics/LayoutSize.h:
+        (WebCore::flooredForPainting):
+        * rendering/RenderImageResourceStyleImage.h:
+        * rendering/RenderListMarker.cpp:
+        (WebCore::RenderListMarker::computePreferredLogicalWidths):
+        * rendering/style/StyleCachedImage.cpp:
+        (WebCore::StyleCachedImage::imageSize):
+        (WebCore::StyleCachedImage::setContainerSizeForRenderer):
+        (WebCore::StyleCachedImage::image):
+        * rendering/style/StyleCachedImage.h:
+        * rendering/style/StyleCachedImageSet.cpp:
+        (WebCore::StyleCachedImageSet::imageSize):
+        (WebCore::StyleCachedImageSet::setContainerSizeForRenderer):
+        (WebCore::StyleCachedImageSet::image):
+        * rendering/style/StyleCachedImageSet.h:
+        * rendering/style/StyleGeneratedImage.cpp:
+        (WebCore::StyleGeneratedImage::imageSize):
+        (WebCore::StyleGeneratedImage::computeIntrinsicDimensions):
+        (WebCore::StyleGeneratedImage::image):
+        * rendering/style/StyleGeneratedImage.h:
+        * rendering/style/StyleImage.h:
+        * rendering/style/StylePendingImage.h:
+        * svg/graphics/SVGImageCache.cpp:
+        (WebCore::SVGImageCache::setContainerSizeForRenderer):
+        * svg/graphics/SVGImageCache.h:
+
 2014-04-02  Gergo Balogh  <gbalogh.u-szeged@partner.samsung.com>
 
         Warning fix for RenderLayer.
index 213dc0e..9314e58 100644 (file)
     <ClInclude Include="..\platform\graphics\FloatRect.h" />
     <ClInclude Include="..\platform\graphics\FloatRoundedRect.h" />
     <ClInclude Include="..\platform\graphics\FloatSize.h" />
+    <ClInclude Include="..\platform\graphics\FloatSizeHash.h" />
     <ClInclude Include="..\platform\graphics\Font.h" />
     <ClInclude Include="..\platform\graphics\FontCache.h" />
     <ClInclude Include="..\platform\graphics\FontData.h" />
index dde1603..4cc0659 100644 (file)
     <ClInclude Include="..\platform\graphics\FloatSize.h">
       <Filter>platform\graphics</Filter>
     </ClInclude>
+    <ClInclude Include="..\platform\graphics\FloatSizeHash.h">
+      <Filter>platform\graphics</Filter>
+    </ClInclude>
     <ClInclude Include="..\platform\graphics\Font.h">
       <Filter>platform\graphics</Filter>
     </ClInclude>
index da31c08..30bf395 100644 (file)
                57CF497514EE36D700ECFF14 /* InsertionPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 57CF497314EE36D700ECFF14 /* InsertionPoint.h */; };
                589556ED18D4A44000764B03 /* BorderEdge.h in Headers */ = {isa = PBXBuildFile; fileRef = 589556EC18D4A44000764B03 /* BorderEdge.h */; };
                58AEE2F418D4BCCF0022E7FE /* BorderEdge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 58AEE2F318D4BCCF0022E7FE /* BorderEdge.cpp */; };
+               58CD35CB18EB4C3900B9F3AC /* FloatSizeHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 58CD35CA18EB4C3900B9F3AC /* FloatSizeHash.h */; };
                5905ADBF1302F3CE00F116DF /* XMLTreeViewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5905ADBD1302F3CE00F116DF /* XMLTreeViewer.cpp */; };
                5905ADC01302F3CE00F116DF /* XMLTreeViewer.h in Headers */ = {isa = PBXBuildFile; fileRef = 5905ADBE1302F3CE00F116DF /* XMLTreeViewer.h */; };
                590E1B4911E4EF4B0069F784 /* DeviceOrientationData.h in Headers */ = {isa = PBXBuildFile; fileRef = 590E1B4811E4EF4B0069F784 /* DeviceOrientationData.h */; settings = {ATTRIBUTES = (Private, ); }; };
                57CF497314EE36D700ECFF14 /* InsertionPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InsertionPoint.h; sourceTree = "<group>"; };
                589556EC18D4A44000764B03 /* BorderEdge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BorderEdge.h; sourceTree = "<group>"; };
                58AEE2F318D4BCCF0022E7FE /* BorderEdge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BorderEdge.cpp; sourceTree = "<group>"; };
+               58CD35CA18EB4C3900B9F3AC /* FloatSizeHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatSizeHash.h; sourceTree = "<group>"; };
                5905ADBD1302F3CE00F116DF /* XMLTreeViewer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLTreeViewer.cpp; sourceTree = "<group>"; };
                5905ADBE1302F3CE00F116DF /* XMLTreeViewer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLTreeViewer.h; sourceTree = "<group>"; };
                590E1B4811E4EF4B0069F784 /* DeviceOrientationData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceOrientationData.h; sourceTree = "<group>"; };
                                6E0E569A183BFFE600E0E8D5 /* FloatRoundedRect.h */,
                                B275353E0B053814002CE64F /* FloatSize.cpp */,
                                B275353F0B053814002CE64F /* FloatSize.h */,
+                               58CD35CA18EB4C3900B9F3AC /* FloatSizeHash.h */,
                                B2C3DA4F0D006CD600EF6F26 /* Font.cpp */,
                                B2C3DA500D006CD600EF6F26 /* Font.h */,
                                BCB92D4E1293550B00C8387F /* FontBaseline.h */,
                                FD45A958175D414C00C21EC8 /* RectangleShape.h in Headers */,
                                A72EA3BB1585CF55004FAA26 /* RefCountedSupplement.h in Headers */,
                                9831AE4A154225C900FE2644 /* ReferrerPolicy.h in Headers */,
+                               58CD35CB18EB4C3900B9F3AC /* FloatSizeHash.h in Headers */,
                                BCAB418213E356E800D8AAF3 /* Region.h in Headers */,
                                6CDDE8D01770BB220016E072 /* RegionOversetState.h in Headers */,
                                26B9998F1803AE7200D01121 /* RegisterAllocator.h in Headers */,
index 5e41c88..4311071 100644 (file)
@@ -66,11 +66,11 @@ void CSSCanvasValue::canvasDestroyed(HTMLCanvasElement& element)
     m_element = nullptr;
 }
 
-IntSize CSSCanvasValue::fixedSize(const RenderElement* renderer)
+FloatSize CSSCanvasValue::fixedSize(const RenderElement* renderer)
 {
     if (HTMLCanvasElement* elt = element(renderer->document()))
-        return IntSize(elt->width(), elt->height());
-    return IntSize();
+        return FloatSize(elt->width(), elt->height());
+    return FloatSize();
 }
 
 HTMLCanvasElement* CSSCanvasValue::element(Document& document)
@@ -84,7 +84,7 @@ HTMLCanvasElement* CSSCanvasValue::element(Document& document)
     return m_element;
 }
 
-PassRefPtr<Image> CSSCanvasValue::image(RenderElement* renderer, const IntSize& /*size*/)
+PassRefPtr<Image> CSSCanvasValue::image(RenderElement* renderer, const FloatSize& /*size*/)
 {
     ASSERT(clients().contains(renderer));
     HTMLCanvasElement* element = this->element(renderer->document());
index f1b6cfb..b67d04f 100644 (file)
@@ -40,9 +40,9 @@ public:
 
     String customCSSText() const;
 
-    PassRefPtr<Image> image(RenderElement*, const IntSize&);
+    PassRefPtr<Image> image(RenderElement*, const FloatSize&);
     bool isFixedSize() const { return true; }
-    IntSize fixedSize(const RenderElement*);
+    FloatSize fixedSize(const RenderElement*);
 
     bool isPending() const { return false; }
     void loadSubimages(CachedResourceLoader*) { }
index 7418650..a730052 100644 (file)
@@ -78,7 +78,7 @@ String CSSCrossfadeValue::customCSSText() const
     return result.toString();
 }
 
-IntSize CSSCrossfadeValue::fixedSize(const RenderElement* renderer)
+FloatSize CSSCrossfadeValue::fixedSize(const RenderElement* renderer)
 {
     float percentage = m_percentageValue->getFloatValue();
     float inversePercentage = 1 - percentage;
@@ -88,7 +88,7 @@ IntSize CSSCrossfadeValue::fixedSize(const RenderElement* renderer)
     CachedImage* cachedToImage = cachedImageForCSSValue(m_toValue.get(), cachedResourceLoader);
 
     if (!cachedFromImage || !cachedToImage)
-        return IntSize();
+        return FloatSize();
 
     FloatSize fromImageSize = cachedFromImage->imageForRenderer(renderer)->size();
     FloatSize toImageSize = cachedToImage->imageForRenderer(renderer)->size();
@@ -96,9 +96,9 @@ IntSize CSSCrossfadeValue::fixedSize(const RenderElement* renderer)
     // Rounding issues can cause transitions between images of equal size to return
     // a different fixed size; avoid performing the interpolation if the images are the same size.
     if (fromImageSize == toImageSize)
-        return IntSize(fromImageSize);
+        return fromImageSize;
 
-    return IntSize(fromImageSize.width() * inversePercentage + toImageSize.width() * percentage,
+    return FloatSize(fromImageSize.width() * inversePercentage + toImageSize.width() * percentage,
         fromImageSize.height() * inversePercentage + toImageSize.height() * percentage);
 }
 
@@ -138,7 +138,7 @@ void CSSCrossfadeValue::loadSubimages(CachedResourceLoader* cachedResourceLoader
     m_crossfadeSubimageObserver.setReady(true);
 }
 
-PassRefPtr<Image> CSSCrossfadeValue::image(RenderElement* renderer, const IntSize& size)
+PassRefPtr<Image> CSSCrossfadeValue::image(RenderElement* renderer, const FloatSize& size)
 {
     if (size.isEmpty())
         return 0;
index 92beca1..14da59c 100644 (file)
@@ -52,9 +52,9 @@ public:
 
     String customCSSText() const;
 
-    PassRefPtr<Image> image(RenderElement*, const IntSize&);
+    PassRefPtr<Image> image(RenderElement*, const FloatSize&);
     bool isFixedSize() const { return true; }
-    IntSize fixedSize(const RenderElement*);
+    FloatSize fixedSize(const RenderElement*);
 
     bool isPending() const;
     bool knownToBeOpaque(const RenderElement*) const;
index 48eb5c1..1ac2fa4 100644 (file)
@@ -59,15 +59,15 @@ String CSSFilterImageValue::customCSSText() const
     return result.toString();
 }
 
-IntSize CSSFilterImageValue::fixedSize(const RenderElement* renderer)
+FloatSize CSSFilterImageValue::fixedSize(const RenderElement* renderer)
 {
     CachedResourceLoader* cachedResourceLoader = renderer->document().cachedResourceLoader();
     CachedImage* cachedImage = cachedImageForCSSValue(m_imageValue.get(), cachedResourceLoader);
 
     if (!cachedImage)
-        return IntSize();
+        return FloatSize();
 
-    return IntSize(cachedImage->imageForRenderer(renderer)->size());
+    return cachedImage->imageForRenderer(renderer)->size();
 }
 
 bool CSSFilterImageValue::isPending() const
@@ -96,7 +96,7 @@ void CSSFilterImageValue::loadSubimages(CachedResourceLoader* cachedResourceLoad
     m_filterSubimageObserver.setReady(true);
 }
 
-PassRefPtr<Image> CSSFilterImageValue::image(RenderElement* renderer, const IntSize& size)
+PassRefPtr<Image> CSSFilterImageValue::image(RenderElement* renderer, const FloatSize& size)
 {
     if (size.isEmpty())
         return 0;
index f212f51..42f22cd 100644 (file)
@@ -57,9 +57,9 @@ public:
 
     String customCSSText() const;
 
-    PassRefPtr<Image> image(RenderElement*, const IntSize&);
+    PassRefPtr<Image> image(RenderElement*, const FloatSize&);
     bool isFixedSize() const { return true; }
-    IntSize fixedSize(const RenderElement*);
+    FloatSize fixedSize(const RenderElement*);
 
     bool isPending() const;
     bool knownToBeOpaque(const RenderElement*) const;
index fb94b31..d179ded 100644 (file)
 
 #include "CSSCalculationValue.h"
 #include "CSSValueKeywords.h"
+#include "FloatSize.h"
+#include "FloatSizeHash.h"
 #include "Gradient.h"
 #include "GradientImage.h"
 #include "Image.h"
-#include "IntSize.h"
-#include "IntSizeHash.h"
 #include "NodeRenderStyle.h"
 #include "RenderElement.h"
 #include "StyleResolver.h"
@@ -41,7 +41,7 @@
 
 namespace WebCore {
 
-PassRefPtr<Image> CSSGradientValue::image(RenderElement* renderer, const IntSize& size)
+PassRefPtr<Image> CSSGradientValue::image(RenderElement* renderer, const FloatSize& size)
 {
     if (size.isEmpty())
         return 0;
@@ -390,7 +390,7 @@ void CSSGradientValue::addStops(Gradient* gradient, RenderElement* renderer, con
     gradient->setStopsSorted(true);
 }
 
-static float positionFromValue(CSSPrimitiveValue* value, const RenderStyle& style, const RenderStyle& rootStyle, const IntSize& size, bool isHorizontal)
+static float positionFromValue(CSSPrimitiveValue* value, const RenderStyle& style, const RenderStyle& rootStyle, const FloatSize& size, bool isHorizontal)
 {
     float zoomFactor = style.effectiveZoom();
 
@@ -424,7 +424,7 @@ static float positionFromValue(CSSPrimitiveValue* value, const RenderStyle& styl
     return value->computeLength<float>(&style, &rootStyle, zoomFactor);
 }
 
-FloatPoint CSSGradientValue::computeEndPoint(CSSPrimitiveValue* horizontal, CSSPrimitiveValue* vertical, const RenderStyle& style, const RenderStyle& rootStyle, const IntSize& size)
+FloatPoint CSSGradientValue::computeEndPoint(CSSPrimitiveValue* horizontal, CSSPrimitiveValue* vertical, const RenderStyle& style, const RenderStyle& rootStyle, const FloatSize& size)
 {
     FloatPoint result;
 
@@ -572,7 +572,7 @@ String CSSLinearGradientValue::customCSSText() const
 }
 
 // Compute the endpoints so that a gradient of the given angle covers a box of the given size.
-static void endPointsFromAngle(float angleDeg, const IntSize& size, FloatPoint& firstPoint, FloatPoint& secondPoint, CSSGradientType type)
+static void endPointsFromAngle(float angleDeg, const FloatSize& size, FloatPoint& firstPoint, FloatPoint& secondPoint, CSSGradientType type)
 {
     // Prefixed gradients use "polar coordinate" angles, rather than "bearing" angles.
     if (type == CSSPrefixedLinearGradient)
@@ -639,7 +639,7 @@ static void endPointsFromAngle(float angleDeg, const IntSize& size, FloatPoint&
     firstPoint.set(halfWidth - endX, halfHeight + endY);
 }
 
-PassRefPtr<Gradient> CSSLinearGradientValue::createGradient(RenderElement* renderer, const IntSize& size)
+PassRefPtr<Gradient> CSSLinearGradientValue::createGradient(RenderElement* renderer, const FloatSize& size)
 {
     ASSERT(!size.isEmpty());
 
@@ -979,7 +979,7 @@ static inline float horizontalEllipseRadius(const FloatSize& p, float aspectRati
 }
 
 // FIXME: share code with the linear version
-PassRefPtr<Gradient> CSSRadialGradientValue::createGradient(RenderElement* renderer, const IntSize& size)
+PassRefPtr<Gradient> CSSRadialGradientValue::createGradient(RenderElement* renderer, const FloatSize& size)
 {
     ASSERT(!size.isEmpty());
 
index 8fb432a..d080207 100644 (file)
@@ -61,7 +61,7 @@ struct CSSGradientColorStop {
 
 class CSSGradientValue : public CSSImageGeneratorValue {
 public:
-    PassRefPtr<Image> image(RenderElement*, const IntSize&);
+    PassRefPtr<Image> image(RenderElement*, const FloatSize&);
 
     void setFirstX(PassRefPtr<CSSPrimitiveValue> val) { m_firstX = val; }
     void setFirstY(PassRefPtr<CSSPrimitiveValue> val) { m_firstY = val; }
@@ -79,7 +79,7 @@ public:
     CSSGradientType gradientType() const { return m_gradientType; }
 
     bool isFixedSize() const { return false; }
-    IntSize fixedSize(const RenderElement*) const { return IntSize(); }
+    FloatSize fixedSize(const RenderElement*) const { return FloatSize(); }
 
     bool isPending() const { return false; }
     bool knownToBeOpaque(const RenderElement*) const;
@@ -112,7 +112,7 @@ protected:
     void addStops(Gradient*, RenderElement*, const RenderStyle& rootStyle, float maxLengthForRepeat = 0);
 
     // Resolve points/radii to front end values.
-    FloatPoint computeEndPoint(CSSPrimitiveValue*, CSSPrimitiveValue*, const RenderStyle&, const RenderStyle& rootStyle, const IntSize&);
+    FloatPoint computeEndPoint(CSSPrimitiveValue*, CSSPrimitiveValue*, const RenderStyle&, const RenderStyle& rootStyle, const FloatSize&);
 
     bool isCacheable() const;
 
@@ -145,7 +145,7 @@ public:
     String customCSSText() const;
 
     // Create the gradient for a given size.
-    PassRefPtr<Gradient> createGradient(RenderElement*, const IntSize&);
+    PassRefPtr<Gradient> createGradient(RenderElement*, const FloatSize&);
 
     PassRef<CSSLinearGradientValue> clone() const
     {
@@ -195,7 +195,7 @@ public:
     void setEndVerticalSize(PassRefPtr<CSSPrimitiveValue> val) { m_endVerticalSize = val; }
 
     // Create the gradient for a given size.
-    PassRefPtr<Gradient> createGradient(RenderElement*, const IntSize&);
+    PassRefPtr<Gradient> createGradient(RenderElement*, const FloatSize&);
 
     bool equals(const CSSRadialGradientValue&) const;
 
index 5511c2d..0d9cfca 100644 (file)
@@ -65,7 +65,7 @@ void CSSImageGeneratorValue::removeClient(RenderElement* renderer)
         deref();
 }
 
-GeneratedImage* CSSImageGeneratorValue::cachedImageForSize(IntSize size)
+GeneratedImage* CSSImageGeneratorValue::cachedImageForSize(FloatSize size)
 {
     if (size.isEmpty())
         return nullptr;
@@ -78,19 +78,19 @@ GeneratedImage* CSSImageGeneratorValue::cachedImageForSize(IntSize size)
     return cachedGeneratedImage->image();
 }
 
-void CSSImageGeneratorValue::saveCachedImageForSize(IntSize size, PassRefPtr<GeneratedImage> image)
+void CSSImageGeneratorValue::saveCachedImageForSize(FloatSize size, PassRefPtr<GeneratedImage> image)
 {
     ASSERT(!m_images.contains(size));
     m_images.add(size, std::make_unique<CachedGeneratedImage>(*this, size, image));
 }
 
-void CSSImageGeneratorValue::evictCachedGeneratedImage(IntSize size)
+void CSSImageGeneratorValue::evictCachedGeneratedImage(FloatSize size)
 {
     ASSERT(m_images.contains(size));
     m_images.remove(size);
 }
 
-CSSImageGeneratorValue::CachedGeneratedImage::CachedGeneratedImage(CSSImageGeneratorValue& owner, IntSize size, PassRefPtr<GeneratedImage> image)
+CSSImageGeneratorValue::CachedGeneratedImage::CachedGeneratedImage(CSSImageGeneratorValue& owner, FloatSize size, PassRefPtr<GeneratedImage> image)
     : m_owner(owner)
     , m_size(size)
     , m_image(image)
@@ -105,7 +105,7 @@ void CSSImageGeneratorValue::CachedGeneratedImage::evictionTimerFired(Deferrable
     m_owner.evictCachedGeneratedImage(m_size);
 }
 
-PassRefPtr<Image> CSSImageGeneratorValue::image(RenderElement* renderer, const IntSize& size)
+PassRefPtr<Image> CSSImageGeneratorValue::image(RenderElement* renderer, const FloatSize& size)
 {
     switch (classType()) {
     case CanvasClass:
@@ -147,7 +147,7 @@ bool CSSImageGeneratorValue::isFixedSize() const
     return false;
 }
 
-IntSize CSSImageGeneratorValue::fixedSize(const RenderElement* renderer)
+FloatSize CSSImageGeneratorValue::fixedSize(const RenderElement* renderer)
 {
     switch (classType()) {
     case CanvasClass:
@@ -165,7 +165,7 @@ IntSize CSSImageGeneratorValue::fixedSize(const RenderElement* renderer)
     default:
         ASSERT_NOT_REACHED();
     }
-    return IntSize();
+    return FloatSize();
 }
 
 bool CSSImageGeneratorValue::isPending() const
index 6c920fa..f4ab5d8 100644 (file)
@@ -27,7 +27,8 @@
 #define CSSImageGeneratorValue_h
 
 #include "CSSValue.h"
-#include "IntSizeHash.h"
+#include "FloatSize.h"
+#include "FloatSizeHash.h"
 #include "Timer.h"
 #include <wtf/HashCountedSet.h>
 
@@ -47,10 +48,10 @@ public:
     void addClient(RenderElement*);
     void removeClient(RenderElement*);
 
-    PassRefPtr<Image> image(RenderElement*, const IntSize&);
+    PassRefPtr<Image> image(RenderElement*, const FloatSize&);
 
     bool isFixedSize() const;
-    IntSize fixedSize(const RenderElement*);
+    FloatSize fixedSize(const RenderElement*);
 
     bool isPending() const;
     bool knownToBeOpaque(const RenderElement*) const;
@@ -60,8 +61,8 @@ public:
 protected:
     CSSImageGeneratorValue(ClassType);
 
-    GeneratedImage* cachedImageForSize(IntSize);
-    void saveCachedImageForSize(IntSize, PassRefPtr<GeneratedImage>);
+    GeneratedImage* cachedImageForSize(FloatSize);
+    void saveCachedImageForSize(FloatSize, PassRefPtr<GeneratedImage>);
     const HashCountedSet<RenderElement*>& clients() const { return m_clients; }
 
     // Helper functions for Crossfade and Filter.
@@ -71,7 +72,7 @@ protected:
 private:
     class CachedGeneratedImage {
     public:
-        CachedGeneratedImage(CSSImageGeneratorValue&, IntSize, PassRefPtr<GeneratedImage>);
+        CachedGeneratedImage(CSSImageGeneratorValue&, FloatSize, PassRefPtr<GeneratedImage>);
         GeneratedImage* image() { return m_image.get(); }
         void puntEvictionTimer() { m_evictionTimer.restart(); }
 
@@ -79,16 +80,16 @@ private:
         void evictionTimerFired(DeferrableOneShotTimer<CachedGeneratedImage>&);
 
         CSSImageGeneratorValue& m_owner;
-        IntSize m_size;
+        FloatSize m_size;
         RefPtr<GeneratedImage> m_image;
         DeferrableOneShotTimer<CachedGeneratedImage> m_evictionTimer;
     };
 
     friend class CachedGeneratedImage;
-    void evictCachedGeneratedImage(IntSize);
+    void evictCachedGeneratedImage(FloatSize);
 
     HashCountedSet<RenderElement*> m_clients;
-    HashMap<IntSize, std::unique_ptr<CachedGeneratedImage>> m_images;
+    HashMap<FloatSize, std::unique_ptr<CachedGeneratedImage>> m_images;
 };
 
 CSS_VALUE_TYPE_CASTS(CSSImageGeneratorValue, isImageGeneratorValue())
index 8ebc8f7..7726b52 100644 (file)
@@ -228,7 +228,7 @@ Image* CachedImage::imageForRenderer(const RenderObject* renderer)
     return m_image.get();
 }
 
-void CachedImage::setContainerSizeForRenderer(const CachedImageClient* renderer, const IntSize& containerSize, float containerZoom)
+void CachedImage::setContainerSizeForRenderer(const CachedImageClient* renderer, const LayoutSize& containerSize, float containerZoom)
 {
     if (containerSize.isEmpty())
         return;
index 86af03f..34629e0 100644 (file)
@@ -66,7 +66,7 @@ public:
 
     bool canRender(const RenderObject* renderer, float multiplier) { return !errorOccurred() && !imageSizeForRenderer(renderer, multiplier).isEmpty(); }
 
-    void setContainerSizeForRenderer(const CachedImageClient*, const IntSize&, float);
+    void setContainerSizeForRenderer(const CachedImageClient*, const LayoutSize&, float);
     bool usesImageContainerSize() const;
     bool imageHasRelativeWidth() const;
     bool imageHasRelativeHeight() const;
@@ -132,7 +132,7 @@ private:
 
     void addIncrementalDataBuffer(ResourceBuffer*);
 
-    typedef std::pair<IntSize, float> SizeAndZoom;
+    typedef std::pair<LayoutSize, float> SizeAndZoom;
     typedef HashMap<const CachedImageClient*, SizeAndZoom> ContainerSizeRequests;
     ContainerSizeRequests m_pendingContainerSizeRequests;
 
diff --git a/Source/WebCore/platform/graphics/FloatSizeHash.h b/Source/WebCore/platform/graphics/FloatSizeHash.h
new file mode 100644 (file)
index 0000000..c5a3966
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef FloatSizeHash_h
+#define FloatSizeHash_h
+
+#include "FloatSize.h"
+#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+
+namespace WTF {
+
+template<> struct FloatHash<WebCore::FloatSize> {
+    static unsigned hash(const WebCore::FloatSize& key) { return pairIntHash(DefaultHash<float>::Hash::hash(key.width()), DefaultHash<float>::Hash::hash(key.height())); }
+    static bool equal(const WebCore::FloatSize& a, const WebCore::FloatSize& b) { return a == b; }
+    static const bool safeToCompareToEmptyOrDeleted = true;
+};
+
+template<> struct DefaultHash<WebCore::FloatSize> {
+    typedef FloatHash<WebCore::FloatSize> Hash;
+};
+
+template<> struct HashTraits<WebCore::FloatSize> : GenericHashTraits<WebCore::FloatSize> {
+    static const bool emptyValueIsZero = true;
+    static const bool needsDestruction = false;
+    static void constructDeletedValue(WebCore::FloatSize& slot) { new (NotNull, &slot) WebCore::FloatSize(-1, -1); }
+    static bool isDeletedValue(const WebCore::FloatSize& value) { return value.width() == -1 && value.height() == -1; }
+};
+
+} // namespace WTF
+
+#endif
index f2d09ee..f77625a 100644 (file)
@@ -192,6 +192,16 @@ inline LayoutSize roundedLayoutSize(const FloatSize& s)
 #endif
 }
 
+inline FloatSize flooredForPainting(const LayoutSize& size, float pixelSnappingFactor)
+{
+#if ENABLE(SUBPIXEL_LAYOUT)
+    return FloatSize(floorToDevicePixel(size.width(), pixelSnappingFactor), floorToDevicePixel(size.height(), pixelSnappingFactor));
+#else
+    UNUSED_PARAM(pixelSnappingFactor);
+    return FloatSize(point);
+#endif
+}
+
 } // namespace WebCore
 
 #endif // LayoutSize_h
index e555093..df4a5af 100644 (file)
@@ -51,8 +51,8 @@ private:
     virtual bool imageHasRelativeWidth() const override { return m_styleImage->imageHasRelativeWidth(); }
     virtual bool imageHasRelativeHeight() const override { return m_styleImage->imageHasRelativeHeight(); }
 
-    virtual LayoutSize imageSize(float multiplier) const override { return m_styleImage->imageSize(m_renderer, multiplier); }
-    virtual LayoutSize intrinsicSize(float multiplier) const override { return m_styleImage->imageSize(m_renderer, multiplier); }
+    virtual LayoutSize imageSize(float multiplier) const override { return LayoutSize(m_styleImage->imageSize(m_renderer, multiplier)); }
+    virtual LayoutSize intrinsicSize(float multiplier) const override { return LayoutSize(m_styleImage->imageSize(m_renderer, multiplier)); }
 
     virtual WrappedImagePtr imagePtr() const override { return m_styleImage->data(); }
 
index 0c2ca04..b5b73c6 100644 (file)
@@ -1521,7 +1521,7 @@ void RenderListMarker::computePreferredLogicalWidths()
     updateContent();
 
     if (isImage()) {
-        LayoutSize imageSize = m_image->imageSize(this, style().effectiveZoom());
+        LayoutSize imageSize = LayoutSize(m_image->imageSize(this, style().effectiveZoom()));
         m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = style().isHorizontalWritingMode() ? imageSize.width() : imageSize.height();
         setPreferredLogicalWidthsDirty(false);
         updateMargins();
index 04d55e9..c2653a1 100644 (file)
@@ -61,7 +61,7 @@ bool StyleCachedImage::errorOccurred() const
     return m_image->errorOccurred();
 }
 
-LayoutSize StyleCachedImage::imageSize(const RenderElement* renderer, float multiplier) const
+FloatSize StyleCachedImage::imageSize(const RenderElement* renderer, float multiplier) const
 {
     return m_image->imageSizeForRenderer(renderer, multiplier);
 }
@@ -86,9 +86,9 @@ bool StyleCachedImage::usesImageContainerSize() const
     return m_image->usesImageContainerSize();
 }
 
-void StyleCachedImage::setContainerSizeForRenderer(const RenderElement* renderer, const IntSize& imageContainerSize, float imageContainerZoomFactor)
+void StyleCachedImage::setContainerSizeForRenderer(const RenderElement* renderer, const FloatSize& imageContainerSize, float imageContainerZoomFactor)
 {
-    m_image->setContainerSizeForRenderer(renderer, imageContainerSize, imageContainerZoomFactor);
+    m_image->setContainerSizeForRenderer(renderer, LayoutSize(imageContainerSize), imageContainerZoomFactor);
 }
 
 void StyleCachedImage::addClient(RenderElement* renderer)
@@ -101,7 +101,7 @@ void StyleCachedImage::removeClient(RenderElement* renderer)
     m_image->removeClient(renderer);
 }
 
-PassRefPtr<Image> StyleCachedImage::image(RenderElement* renderer, const IntSize&) const
+PassRefPtr<Image> StyleCachedImage::image(RenderElement* renderer, const FloatSize&) const
 {
     return m_image->imageForRenderer(renderer);
 }
index 95941fc..52c0c0f 100644 (file)
@@ -48,15 +48,15 @@ private:
     virtual bool canRender(const RenderObject*, float multiplier) const override;
     virtual bool isLoaded() const override;
     virtual bool errorOccurred() const override;
-    virtual LayoutSize imageSize(const RenderElement*, float multiplier) const override;
+    virtual FloatSize imageSize(const RenderElement*, float multiplier) const override;
     virtual bool imageHasRelativeWidth() const override;
     virtual bool imageHasRelativeHeight() const override;
     virtual void computeIntrinsicDimensions(const RenderElement*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) override;
     virtual bool usesImageContainerSize() const override;
-    virtual void setContainerSizeForRenderer(const RenderElement*, const IntSize&, float) override;
+    virtual void setContainerSizeForRenderer(const RenderElement*, const FloatSize&, float) override;
     virtual void addClient(RenderElement*) override;
     virtual void removeClient(RenderElement*) override;
-    virtual PassRefPtr<Image> image(RenderElement*, const IntSize&) const override;
+    virtual PassRefPtr<Image> image(RenderElement*, const FloatSize&) const override;
     virtual bool knownToBeOpaque(const RenderElement*) const override;
 
     explicit StyleCachedImage(CachedImage*);
index f95b2c9..6c1b017 100644 (file)
@@ -69,9 +69,9 @@ bool StyleCachedImageSet::errorOccurred() const
     return m_bestFitImage->errorOccurred();
 }
 
-LayoutSize StyleCachedImageSet::imageSize(const RenderElement* renderer, float multiplier) const
+FloatSize StyleCachedImageSet::imageSize(const RenderElement* renderer, float multiplier) const
 {
-    LayoutSize scaledImageSize = m_bestFitImage->imageSizeForRenderer(renderer, multiplier);
+    FloatSize scaledImageSize = m_bestFitImage->imageSizeForRenderer(renderer, multiplier);
     scaledImageSize.scale(1 / m_imageScaleFactor);
     return scaledImageSize;
 }
@@ -96,9 +96,9 @@ bool StyleCachedImageSet::usesImageContainerSize() const
     return m_bestFitImage->usesImageContainerSize();
 }
 
-void StyleCachedImageSet::setContainerSizeForRenderer(const RenderElement* renderer, const IntSize& imageContainerSize, float imageContainerZoomFactor)
+void StyleCachedImageSet::setContainerSizeForRenderer(const RenderElement* renderer, const FloatSize& imageContainerSize, float imageContainerZoomFactor)
 {
-    m_bestFitImage->setContainerSizeForRenderer(renderer, imageContainerSize, imageContainerZoomFactor);
+    m_bestFitImage->setContainerSizeForRenderer(renderer, LayoutSize(imageContainerSize), imageContainerZoomFactor);
 }
 
 void StyleCachedImageSet::addClient(RenderElement* renderer)
@@ -111,7 +111,7 @@ void StyleCachedImageSet::removeClient(RenderElement* renderer)
     m_bestFitImage->removeClient(renderer);
 }
 
-PassRefPtr<Image> StyleCachedImageSet::image(RenderElement* renderer, const IntSize&) const
+PassRefPtr<Image> StyleCachedImageSet::image(RenderElement* renderer, const FloatSize&) const
 {
     return m_bestFitImage->imageForRenderer(renderer);
 }
index cd9cf5e..44c9f30 100644 (file)
@@ -64,15 +64,15 @@ private:
     virtual bool canRender(const RenderObject*, float multiplier) const override;
     virtual bool isLoaded() const override;
     virtual bool errorOccurred() const override;
-    virtual LayoutSize imageSize(const RenderElement*, float multiplier) const override;
+    virtual FloatSize imageSize(const RenderElement*, float multiplier) const override;
     virtual bool imageHasRelativeWidth() const override;
     virtual bool imageHasRelativeHeight() const override;
     virtual void computeIntrinsicDimensions(const RenderElement*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) override;
     virtual bool usesImageContainerSize() const override;
-    virtual void setContainerSizeForRenderer(const RenderElement*, const IntSize&, float) override;
+    virtual void setContainerSizeForRenderer(const RenderElement*, const FloatSize&, float) override;
     virtual void addClient(RenderElement*) override;
     virtual void removeClient(RenderElement*) override;
-    virtual PassRefPtr<Image> image(RenderElement*, const IntSize&) const override;
+    virtual PassRefPtr<Image> image(RenderElement*, const FloatSize&) const override;
     virtual float imageScaleFactor() const override { return m_imageScaleFactor; }
     virtual bool knownToBeOpaque(const RenderElement*) const override;
 
index 6b59fe7..0f7f74f 100644 (file)
@@ -42,24 +42,25 @@ PassRefPtr<CSSValue> StyleGeneratedImage::cssValue() const
     return &const_cast<CSSImageGeneratorValue&>(m_imageGeneratorValue.get());
 }
 
-LayoutSize StyleGeneratedImage::imageSize(const RenderElement* renderer, float multiplier) const
+FloatSize StyleGeneratedImage::imageSize(const RenderElement* renderer, float multiplier) const
 {
     if (m_fixedSize) {
-        IntSize fixedSize = const_cast<CSSImageGeneratorValue&>(m_imageGeneratorValue.get()).fixedSize(renderer);
+        FloatSize fixedSize = const_cast<CSSImageGeneratorValue&>(m_imageGeneratorValue.get()).fixedSize(renderer);
         if (multiplier == 1.0f)
             return fixedSize;
 
-        LayoutUnit width = fixedSize.width() * multiplier;
-        LayoutUnit height = fixedSize.height() * multiplier;
+        float width = fixedSize.width() * multiplier;
+        float height = fixedSize.height() * multiplier;
 
-        // Don't let images that have a width/height >= 1 shrink below 1 when zoomed.
+        // Don't let images that have a width/height >= 1 shrink below 1 device pixel when zoomed.
+        float deviceScaleFactor = renderer ? renderer->document().deviceScaleFactor() : 1;
         if (fixedSize.width() > 0)
-            width = std::max<LayoutUnit>(1, width);
+            width = std::max<float>(1 / deviceScaleFactor, width);
 
         if (fixedSize.height() > 0)
-            height = std::max<LayoutUnit>(1, height);
+            height = std::max<float>(1 / deviceScaleFactor, height);
 
-        return LayoutSize(width, height);
+        return FloatSize(width, height);
     }
     
     return m_containerSize;
@@ -67,8 +68,8 @@ LayoutSize StyleGeneratedImage::imageSize(const RenderElement* renderer, float m
 
 void StyleGeneratedImage::computeIntrinsicDimensions(const RenderElement* renderer, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
 {
-    // At a zoom level of 1 the image is guaranteed to have an integer size.
-    IntSize size = flooredIntSize(imageSize(renderer, 1));
+    // At a zoom level of 1 the image is guaranteed to have a device pixel size.
+    FloatSize size = flooredForPainting(LayoutSize(imageSize(renderer, 1)), renderer ? renderer->document().deviceScaleFactor() : 1);
     intrinsicWidth = Length(size.width(), Fixed);
     intrinsicHeight = Length(size.height(), Fixed);
     intrinsicRatio = size;
@@ -84,7 +85,7 @@ void StyleGeneratedImage::removeClient(RenderElement* renderer)
     m_imageGeneratorValue->removeClient(renderer);
 }
 
-PassRefPtr<Image> StyleGeneratedImage::image(RenderElement* renderer, const IntSize& size) const
+PassRefPtr<Image> StyleGeneratedImage::image(RenderElement* renderer, const FloatSize& size) const
 {
     return const_cast<CSSImageGeneratorValue&>(m_imageGeneratorValue.get()).image(renderer, size);
 }
index 42a705c..4dbe1ee 100644 (file)
@@ -45,21 +45,21 @@ private:
 
     virtual PassRefPtr<CSSValue> cssValue() const override;
 
-    virtual LayoutSize imageSize(const RenderElement*, float multiplier) const override;
+    virtual FloatSize imageSize(const RenderElement*, float multiplier) const override;
     virtual bool imageHasRelativeWidth() const override { return !m_fixedSize; }
     virtual bool imageHasRelativeHeight() const override { return !m_fixedSize; }
     virtual void computeIntrinsicDimensions(const RenderElement*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) override;
     virtual bool usesImageContainerSize() const override { return !m_fixedSize; }
-    virtual void setContainerSizeForRenderer(const RenderElement*, const IntSize& containerSize, float) override { m_containerSize = containerSize; }
+    virtual void setContainerSizeForRenderer(const RenderElement*, const FloatSize& containerSize, float) override { m_containerSize = containerSize; }
     virtual void addClient(RenderElement*) override;
     virtual void removeClient(RenderElement*) override;
-    virtual PassRefPtr<Image> image(RenderElement*, const IntSize&) const override;
+    virtual PassRefPtr<Image> image(RenderElement*, const FloatSize&) const override;
     virtual bool knownToBeOpaque(const RenderElement*) const override;
 
     StyleGeneratedImage(PassRef<CSSImageGeneratorValue>);
     
     Ref<CSSImageGeneratorValue> m_imageGeneratorValue;
-    IntSize m_containerSize;
+    FloatSize m_containerSize;
     bool m_fixedSize;
 };
 
index 73cfdb9..c0cc7fc 100644 (file)
@@ -25,9 +25,8 @@
 #define StyleImage_h
 
 #include "CSSValue.h"
+#include "FloatSize.h"
 #include "Image.h"
-#include "IntSize.h"
-#include "LayoutSize.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
@@ -55,15 +54,15 @@ public:
     virtual bool canRender(const RenderObject*, float /*multiplier*/) const { return true; }
     virtual bool isLoaded() const { return true; }
     virtual bool errorOccurred() const { return false; }
-    virtual LayoutSize imageSize(const RenderElement*, float multiplier) const = 0;
+    virtual FloatSize imageSize(const RenderElement*, float multiplier) const = 0;
     virtual void computeIntrinsicDimensions(const RenderElement*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) = 0;
     virtual bool imageHasRelativeWidth() const = 0;
     virtual bool imageHasRelativeHeight() const = 0;
     virtual bool usesImageContainerSize() const = 0;
-    virtual void setContainerSizeForRenderer(const RenderElement*, const IntSize&, float) = 0;
+    virtual void setContainerSizeForRenderer(const RenderElement*, const FloatSize&, float) = 0;
     virtual void addClient(RenderElement*) = 0;
     virtual void removeClient(RenderElement*) = 0;
-    virtual PassRefPtr<Image> image(RenderElement*, const IntSize&) const = 0;
+    virtual PassRefPtr<Image> image(RenderElement*, const FloatSize&) const = 0;
     virtual WrappedImagePtr data() const = 0;
     virtual float imageScaleFactor() const { return 1; }
     virtual bool knownToBeOpaque(const RenderElement*) const = 0;
index 25f4317..b954868 100644 (file)
@@ -60,16 +60,16 @@ private:
 
     virtual PassRefPtr<CSSValue> cssValue() const override { return m_value; }
     
-    virtual LayoutSize imageSize(const RenderElement*, float /*multiplier*/) const override { return LayoutSize(); }
+    virtual FloatSize imageSize(const RenderElement*, float /*multiplier*/) const override { return FloatSize(); }
     virtual bool imageHasRelativeWidth() const override { return false; }
     virtual bool imageHasRelativeHeight() const override { return false; }
     virtual void computeIntrinsicDimensions(const RenderElement*, Length& /* intrinsicWidth */ , Length& /* intrinsicHeight */, FloatSize& /* intrinsicRatio */) { }
     virtual bool usesImageContainerSize() const override { return false; }
-    virtual void setContainerSizeForRenderer(const RenderElement*, const IntSize&, float) override { }
+    virtual void setContainerSizeForRenderer(const RenderElement*, const FloatSize&, float) override { }
     virtual void addClient(RenderElement*) override { }
     virtual void removeClient(RenderElement*) override { }
 
-    virtual PassRefPtr<Image> image(RenderElement*, const IntSize&) const override
+    virtual PassRefPtr<Image> image(RenderElement*, const FloatSize&) const override
     {
         ASSERT_NOT_REACHED();
         return nullptr;
index db5b06b..748660f 100644 (file)
@@ -25,6 +25,7 @@
 #include "GraphicsContext.h"
 #include "HTMLImageElement.h"
 #include "ImageBuffer.h"
+#include "LayoutSize.h"
 #include "Page.h"
 #include "RenderSVGRoot.h"
 #include "SVGImage.h"
@@ -50,7 +51,7 @@ void SVGImageCache::removeClientFromCache(const CachedImageClient* client)
     m_imageForContainerMap.remove(client);
 }
 
-void SVGImageCache::setContainerSizeForRenderer(const CachedImageClient* client, const IntSize& containerSize, float containerZoom)
+void SVGImageCache::setContainerSizeForRenderer(const CachedImageClient* client, const LayoutSize& containerSize, float containerZoom)
 {
     ASSERT(client);
     ASSERT(!containerSize.isEmpty());
index f860cbd..05f523e 100644 (file)
@@ -31,6 +31,7 @@ namespace WebCore {
 class CachedImage;
 class CachedImageClient;
 class ImageBuffer;
+class LayoutSize;
 class SVGImage;
 class SVGImageForContainer;
 class RenderObject;
@@ -43,7 +44,7 @@ public:
 
     void removeClientFromCache(const CachedImageClient*);
 
-    void setContainerSizeForRenderer(const CachedImageClient*, const IntSize&, float);
+    void setContainerSizeForRenderer(const CachedImageClient*, const LayoutSize&, float);
     FloatSize imageSizeForRenderer(const RenderObject*) const;
 
     Image* imageForRenderer(const RenderObject*);