Followup (r220289): RenderImageResourceStyleImage code clean up
[WebKit-https.git] / Source / WebCore / rendering / RenderImageResource.h
index a8874d6..a27327d 100644 (file)
@@ -38,9 +38,9 @@ class RenderImageResource {
     WTF_MAKE_NONCOPYABLE(RenderImageResource); WTF_MAKE_FAST_ALLOCATED;
 public:
     RenderImageResource();
-    virtual ~RenderImageResource();
+    virtual ~RenderImageResource() = default;
 
-    virtual void initialize(RenderElement*);
+    virtual void initialize(RenderElement& renderer) { initialize(renderer, nullptr); }
     virtual void shutdown();
 
     void setCachedImage(CachedImage*);
@@ -49,23 +49,28 @@ public:
     void resetAnimation();
 
     virtual RefPtr<Image> image(const IntSize& size = { }) const;
-    virtual bool errorOccurred() const;
+    virtual bool errorOccurred() const { return m_cachedImage && m_cachedImage->errorOccurred(); }
 
     virtual void setContainerSizeForRenderer(const IntSize&);
-    virtual bool imageHasRelativeWidth() const;
-    virtual bool imageHasRelativeHeight() const;
 
-    virtual LayoutSize imageSize(float multiplier) const;
-    virtual LayoutSize intrinsicSize(float multiplier) const;
+    virtual bool imageHasRelativeWidth() const { return m_cachedImage && m_cachedImage->imageHasRelativeWidth(); }
+    virtual bool imageHasRelativeHeight() const { return m_cachedImage && m_cachedImage->imageHasRelativeHeight(); }
+
+    inline LayoutSize imageSize(float multiplier) const { return imageSize(multiplier, CachedImage::UsedSize); }
+    inline LayoutSize intrinsicSize(float multiplier) const { return imageSize(multiplier, CachedImage::IntrinsicSize); }
 
     virtual WrappedImagePtr imagePtr() const { return m_cachedImage.get(); }
 
 protected:
+    RenderElement* renderer() const { return m_renderer; }
+    void initialize(RenderElement&, CachedImage*);
+    
+private:
+    virtual LayoutSize imageSize(float multiplier, CachedImage::SizeType) const;
+
     RenderElement* m_renderer { nullptr };
     CachedResourceHandle<CachedImage> m_cachedImage;
-
-private:
-    LayoutSize getImageSize(float multiplier, CachedImage::SizeType) const;
+    bool m_cachedImageRemoveClientIsNeeded { true };
 };
 
 } // namespace WebCore