Implement object-fit CSS property
[WebKit-https.git] / Source / WebCore / rendering / RenderImageResource.cpp
index 0c3a79e..934225e 100644 (file)
@@ -28,6 +28,7 @@
 #include "config.h"
 #include "RenderImageResource.h"
 
+#include "CachedImage.h"
 #include "Image.h"
 #include "RenderImageResourceStyleImage.h"
 #include "RenderObject.h"
@@ -36,7 +37,6 @@ namespace WebCore {
 
 RenderImageResource::RenderImageResource()
     : m_renderer(0)
-    , m_cachedImage(0)
 {
 }
 
@@ -89,6 +89,16 @@ void RenderImageResource::resetAnimation()
         m_renderer->repaint();
 }
 
+PassRefPtr<Image> RenderImageResource::image(int, int) const
+{
+    return m_cachedImage ? m_cachedImage->imageForRenderer(m_renderer) : nullImage();
+}
+
+bool RenderImageResource::errorOccurred() const
+{
+    return m_cachedImage && m_cachedImage->errorOccurred();
+}
+
 void RenderImageResource::setContainerSizeForRenderer(const IntSize& imageContainerSize)
 {
     ASSERT(m_renderer);
@@ -101,4 +111,29 @@ Image* RenderImageResource::nullImage()
     return Image::nullImage();
 }
 
+bool RenderImageResource::usesImageContainerSize() const
+{
+    return m_cachedImage ? m_cachedImage->usesImageContainerSize() : false;
+}
+
+bool RenderImageResource::imageHasRelativeWidth() const
+{
+    return m_cachedImage ? m_cachedImage->imageHasRelativeWidth() : false;
+}
+
+bool RenderImageResource::imageHasRelativeHeight() const
+{
+    return m_cachedImage ? m_cachedImage->imageHasRelativeHeight() : false;
+}
+
+LayoutSize RenderImageResource::imageSize(float multiplier) const
+{
+    return m_cachedImage ? m_cachedImage->imageSizeForRenderer(m_renderer, multiplier) : LayoutSize();
+}
+
+LayoutSize RenderImageResource::intrinsicSize(float multiplier) const
+{
+    return m_cachedImage ? m_cachedImage->imageSizeForRenderer(m_renderer, multiplier, CachedImage::IntrinsicSize) : LayoutSize();
+}
+
 } // namespace WebCore