Make some improvements in CSSImageGeneratorValue code
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Dec 2013 06:52:57 +0000 (06:52 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Dec 2013 06:52:57 +0000 (06:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=125676

Reviewed by Simon Fraser.

* css/CSSCrossfadeValue.cpp:
(WebCore::subimageKnownToBeOpaque): Take a reference to the CSSValue, since
it's known not to be null. Used checked cast.
(WebCore::CSSCrossfadeValue::knownToBeOpaque): Updated to pass a reference.

* css/CSSImageGeneratorValue.cpp:
(WebCore::CSSImageGeneratorValue::saveCachedImageForSize): Use
make_unique instead of adoptPtr.
(WebCore::CSSImageGeneratorValue::subimageIsPending): Use checked cast.
(WebCore::CSSImageGeneratorValue::cachedImageForCSSValue): Ditto, also
use nullptr.

* css/CSSImageGeneratorValue.h: Removed unneeded includes, added some forward
declarations, used unique_ptr instead of OwnPtr, and used CSS_VALUE_TYPE_CASTS
macro to create cast functions.

* css/CSSValue.cpp: Removed unneeded include of CSSImageGeneratorValue.h.

* css/StyleResolver.cpp:
(WebCore::StyleResolver::State::clear): Use nullptr instead of 0.
(WebCore::StyleResolver::applyProperty): Use checked cast and pass references
instead of pointers to StyleGeneratedImage::create.
(WebCore::StyleResolver::styleImage): Use checked cast and pass references
instead of pointers to generatedOrPendingFromValue.
(WebCore::StyleResolver::generatedOrPendingFromValue): Take the value as a
reference instead of a pointer.
(WebCore::StyleResolver::loadPendingImage): Pass a refernece instead of a
pointer to StyleGeneratedImage::create.
(WebCore::StyleResolver::loadPendingImages): Use auto for iteration instead of
a lot type name.

* css/StyleResolver.h: Changed generatedOrPendingFromValue to take the value
as a reference instead of a pointer.

* page/animation/CSSPropertyAnimation.cpp:
(WebCore::blendFilter): Pass a reference insted of a pointer to
StyleGeneratedImage::create.
(WebCore::crossfadeBlend): Ditto.
(WebCore::blendFunc): Ditto. Also use references for local variables.

* rendering/style/StyleGeneratedImage.cpp:
(WebCore::StyleGeneratedImage::StyleGeneratedImage): Use PassRef instead of
PassRefPtr for the argument type.
(WebCore::StyleGeneratedImage::cssValue): Updated since m_imageGeneratorValue
is now a Ref instead of a RefPtr. Sadly this requires a const_cast that we can
come back and get rid of later.
(WebCore::StyleGeneratedImage::imageSize): Ditto.
(WebCore::StyleGeneratedImage::image): Ditto.

* rendering/style/StyleGeneratedImage.h: Changed create function and constructor
to take a PassRef. Made imageValue non-const since it returns a non-const value,
to be consistent with "conceptual const". Changed m_imageGeneratorValue to be a
Ref instead of a RefPtr.

* rendering/style/StyleImage.h: Made WrappedImagePtr be const void*, since it's
a pointer used only for equality checks. Not a great idiom, but fine to use a
const pointer instead of non-const, and avoids the const_cast we'd otherwise
need in StyleGeneratedImage::data.

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

Source/WebCore/ChangeLog
Source/WebCore/css/CSSCrossfadeValue.cpp
Source/WebCore/css/CSSImageGeneratorValue.cpp
Source/WebCore/css/CSSImageGeneratorValue.h
Source/WebCore/css/CSSValue.cpp
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleResolver.h
Source/WebCore/page/animation/CSSPropertyAnimation.cpp
Source/WebCore/rendering/style/StyleGeneratedImage.cpp
Source/WebCore/rendering/style/StyleGeneratedImage.h
Source/WebCore/rendering/style/StyleImage.h

index 96d680d..4213672 100644 (file)
@@ -1,3 +1,69 @@
+2013-12-12  Darin Adler  <darin@apple.com>
+
+        Make some improvements in CSSImageGeneratorValue code
+        https://bugs.webkit.org/show_bug.cgi?id=125676
+
+        Reviewed by Simon Fraser.
+
+        * css/CSSCrossfadeValue.cpp:
+        (WebCore::subimageKnownToBeOpaque): Take a reference to the CSSValue, since
+        it's known not to be null. Used checked cast.
+        (WebCore::CSSCrossfadeValue::knownToBeOpaque): Updated to pass a reference.
+
+        * css/CSSImageGeneratorValue.cpp:
+        (WebCore::CSSImageGeneratorValue::saveCachedImageForSize): Use
+        make_unique instead of adoptPtr.
+        (WebCore::CSSImageGeneratorValue::subimageIsPending): Use checked cast.
+        (WebCore::CSSImageGeneratorValue::cachedImageForCSSValue): Ditto, also
+        use nullptr.
+
+        * css/CSSImageGeneratorValue.h: Removed unneeded includes, added some forward
+        declarations, used unique_ptr instead of OwnPtr, and used CSS_VALUE_TYPE_CASTS
+        macro to create cast functions.
+
+        * css/CSSValue.cpp: Removed unneeded include of CSSImageGeneratorValue.h.
+
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::State::clear): Use nullptr instead of 0.
+        (WebCore::StyleResolver::applyProperty): Use checked cast and pass references
+        instead of pointers to StyleGeneratedImage::create.
+        (WebCore::StyleResolver::styleImage): Use checked cast and pass references
+        instead of pointers to generatedOrPendingFromValue.
+        (WebCore::StyleResolver::generatedOrPendingFromValue): Take the value as a
+        reference instead of a pointer.
+        (WebCore::StyleResolver::loadPendingImage): Pass a refernece instead of a
+        pointer to StyleGeneratedImage::create.
+        (WebCore::StyleResolver::loadPendingImages): Use auto for iteration instead of
+        a lot type name.
+
+        * css/StyleResolver.h: Changed generatedOrPendingFromValue to take the value
+        as a reference instead of a pointer.
+
+        * page/animation/CSSPropertyAnimation.cpp:
+        (WebCore::blendFilter): Pass a reference insted of a pointer to
+        StyleGeneratedImage::create.
+        (WebCore::crossfadeBlend): Ditto.
+        (WebCore::blendFunc): Ditto. Also use references for local variables.
+
+        * rendering/style/StyleGeneratedImage.cpp:
+        (WebCore::StyleGeneratedImage::StyleGeneratedImage): Use PassRef instead of
+        PassRefPtr for the argument type.
+        (WebCore::StyleGeneratedImage::cssValue): Updated since m_imageGeneratorValue
+        is now a Ref instead of a RefPtr. Sadly this requires a const_cast that we can
+        come back and get rid of later.
+        (WebCore::StyleGeneratedImage::imageSize): Ditto.
+        (WebCore::StyleGeneratedImage::image): Ditto.
+
+        * rendering/style/StyleGeneratedImage.h: Changed create function and constructor
+        to take a PassRef. Made imageValue non-const since it returns a non-const value,
+        to be consistent with "conceptual const". Changed m_imageGeneratorValue to be a
+        Ref instead of a RefPtr.
+
+        * rendering/style/StyleImage.h: Made WrappedImagePtr be const void*, since it's
+        a pointer used only for equality checks. Not a great idiom, but fine to use a
+        const pointer instead of non-const, and avoids the const_cast we'd otherwise
+        need in StyleGeneratedImage::data.
+
 2013-12-12  KyungTae Kim  <ktf.kim@samsung.com>
 
         Improve the find word boundary performance
index 00a4bdc..2647226 100644 (file)
@@ -44,13 +44,13 @@ static inline double blendFunc(double from, double to, double progress)
     return blend(from, to, progress);
 }
 
-static bool subimageKnownToBeOpaque(CSSValue* value, const RenderElement* renderer)
+static bool subimageKnownToBeOpaque(CSSValue& value, const RenderElement* renderer)
 {
-    if (value->isImageValue())
-        return toCSSImageValue(value)->knownToBeOpaque(renderer);
+    if (value.isImageValue())
+        return toCSSImageValue(value).knownToBeOpaque(renderer);
 
-    if (value->isImageGeneratorValue())
-        return static_cast<CSSImageGeneratorValue*>(value)->knownToBeOpaque(renderer);
+    if (value.isImageGeneratorValue())
+        return toCSSImageGeneratorValue(value).knownToBeOpaque(renderer);
 
     ASSERT_NOT_REACHED();
 
@@ -110,7 +110,7 @@ bool CSSCrossfadeValue::isPending() const
 
 bool CSSCrossfadeValue::knownToBeOpaque(const RenderElement* renderer) const
 {
-    return subimageKnownToBeOpaque(m_fromValue.get(), renderer) && subimageKnownToBeOpaque(m_toValue.get(), renderer);
+    return subimageKnownToBeOpaque(*m_fromValue, renderer) && subimageKnownToBeOpaque(*m_toValue, renderer);
 }
 
 void CSSCrossfadeValue::loadSubimages(CachedResourceLoader* cachedResourceLoader)
index e73c034..8e6ee1a 100644 (file)
@@ -32,6 +32,7 @@
 #include "CSSFilterImageValue.h"
 #include "CSSGradientValue.h"
 #include "CSSImageValue.h"
+#include "GeneratedImage.h"
 #include "Image.h"
 #include "RenderElement.h"
 #include "StyleCachedImage.h"
@@ -80,7 +81,7 @@ GeneratedImage* CSSImageGeneratorValue::cachedImageForSize(IntSize size)
 void CSSImageGeneratorValue::saveCachedImageForSize(IntSize size, PassRefPtr<GeneratedImage> image)
 {
     ASSERT(!m_images.contains(size));
-    m_images.add(size, adoptPtr(new CachedGeneratedImage(*this, size, image)));
+    m_images.add(size, std::make_unique<CachedGeneratedImage>(*this, size, image));
 }
 
 void CSSImageGeneratorValue::evictCachedGeneratedImage(IntSize size)
@@ -240,7 +241,7 @@ bool CSSImageGeneratorValue::subimageIsPending(CSSValue* value)
         return toCSSImageValue(value)->cachedOrPendingImage()->isPendingImage();
     
     if (value->isImageGeneratorValue())
-        return static_cast<CSSImageGeneratorValue*>(value)->isPending();
+        return toCSSImageGeneratorValue(value)->isPending();
 
     if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == CSSValueNone)
         return false;
@@ -253,27 +254,27 @@ bool CSSImageGeneratorValue::subimageIsPending(CSSValue* value)
 CachedImage* CSSImageGeneratorValue::cachedImageForCSSValue(CSSValue* value, CachedResourceLoader* cachedResourceLoader)
 {
     if (!value)
-        return 0;
+        return nullptr;
 
     if (value->isImageValue()) {
         StyleCachedImage* styleCachedImage = toCSSImageValue(value)->cachedImage(cachedResourceLoader);
         if (!styleCachedImage)
-            return 0;
+            return nullptr;
 
         return styleCachedImage->cachedImage();
     }
     
     if (value->isImageGeneratorValue()) {
-        static_cast<CSSImageGeneratorValue*>(value)->loadSubimages(cachedResourceLoader);
+        toCSSImageGeneratorValue(value)->loadSubimages(cachedResourceLoader);
         // FIXME: Handle CSSImageGeneratorValue (and thus cross-fades with gradients and canvas).
-        return 0;
+        return nullptr;
     }
 
     if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == CSSValueNone)
-        return 0;
+        return nullptr;
 
     ASSERT_NOT_REACHED();
     
-    return 0;
+    return nullptr;
 }
 } // namespace WebCore
index a832f8b..461f3f4 100644 (file)
 #define CSSImageGeneratorValue_h
 
 #include "CSSValue.h"
-#include "CachedImage.h"
-#include "GeneratedImage.h"
 #include "IntSizeHash.h"
 #include "Timer.h"
 #include <wtf/HashCountedSet.h>
-#include <wtf/RefPtr.h>
 
 namespace WebCore {
 
+class CachedImage;
 class CachedResourceLoader;
 class GeneratedImage;
+class Image;
 class RenderElement;
 class StyleResolver;
 
@@ -89,9 +88,11 @@ private:
     void evictCachedGeneratedImage(IntSize);
 
     HashCountedSet<RenderElement*> m_clients;
-    HashMap<IntSize, OwnPtr<CachedGeneratedImage>> m_images;
+    HashMap<IntSize, std::unique_ptr<CachedGeneratedImage>> m_images;
 };
 
+CSS_VALUE_TYPE_CASTS(CSSImageGeneratorValue, isImageGeneratorValue())
+
 } // namespace WebCore
 
 #endif // CSSImageGeneratorValue_h
index 176a2be..22b684e 100644 (file)
@@ -41,7 +41,6 @@
 #include "CSSFunctionValue.h"
 #include "CSSGradientValue.h"
 #include "CSSGridTemplateValue.h"
-#include "CSSImageGeneratorValue.h"
 #include "CSSImageSetValue.h"
 #include "CSSImageValue.h"
 #include "CSSInheritedValue.h"
index 8b25e23..362395a 100644 (file)
@@ -218,11 +218,11 @@ inline void StyleResolver::State::cacheBorderAndBackground()
 
 inline void StyleResolver::State::clear()
 {
-    m_element = 0;
-    m_styledElement = 0;
-    m_parentStyle = 0;
-    m_parentNode = 0;
-    m_regionForStyling = 0;
+    m_element = nullptr;
+    m_styledElement = nullptr;
+    m_parentStyle = nullptr;
+    m_parentNode = nullptr;
+    m_regionForStyling = nullptr;
     m_pendingImageProperties.clear();
 #if ENABLE(CSS_SHADERS)
     m_hasPendingShaders = false;
@@ -2090,9 +2090,9 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value)
                 CSSValue* item = i.value();
                 if (item->isImageGeneratorValue()) {
                     if (item->isGradientValue())
-                        state.style()->setContent(StyleGeneratedImage::create(toCSSGradientValue(item)->gradientWithStylesResolved(this).get()), didSet);
+                        state.style()->setContent(StyleGeneratedImage::create(*toCSSGradientValue(item)->gradientWithStylesResolved(this)), didSet);
                     else
-                        state.style()->setContent(StyleGeneratedImage::create(static_cast<CSSImageGeneratorValue*>(item)), didSet);
+                        state.style()->setContent(StyleGeneratedImage::create(*toCSSImageGeneratorValue(item)), didSet);
                     didSet = true;
 #if ENABLE(CSS_IMAGE_SET)
                 } else if (item->isImageSetValue()) {
@@ -3067,8 +3067,8 @@ PassRefPtr<StyleImage> StyleResolver::styleImage(CSSPropertyID property, CSSValu
 
     if (value->isImageGeneratorValue()) {
         if (value->isGradientValue())
-            return generatedOrPendingFromValue(property, toCSSGradientValue(value)->gradientWithStylesResolved(this).get());
-        return generatedOrPendingFromValue(property, static_cast<CSSImageGeneratorValue*>(value));
+            return generatedOrPendingFromValue(property, *toCSSGradientValue(value)->gradientWithStylesResolved(this));
+        return generatedOrPendingFromValue(property, toCSSImageGeneratorValue(*value));
     }
 
 #if ENABLE(CSS_IMAGE_SET)
@@ -3090,17 +3090,17 @@ PassRefPtr<StyleImage> StyleResolver::cachedOrPendingFromValue(CSSPropertyID pro
     return image.release();
 }
 
-PassRefPtr<StyleImage> StyleResolver::generatedOrPendingFromValue(CSSPropertyID property, CSSImageGeneratorValue* value)
+PassRefPtr<StyleImage> StyleResolver::generatedOrPendingFromValue(CSSPropertyID property, CSSImageGeneratorValue& value)
 {
 #if ENABLE(CSS_FILTERS)
-    if (value->isFilterImageValue()) {
+    if (value.isFilterImageValue()) {
         // FilterImage needs to calculate FilterOperations.
-        toCSSFilterImageValue(value)->createFilterOperations(this);
+        toCSSFilterImageValue(value).createFilterOperations(this);
     }
 #endif
-    if (value->isPending()) {
-        m_state.pendingImageProperties().set(property, value);
-        return StylePendingImage::create(value);
+    if (value.isPending()) {
+        m_state.pendingImageProperties().set(property, &value);
+        return StylePendingImage::create(&value);
     }
     return StyleGeneratedImage::create(value);
 }
@@ -3881,7 +3881,7 @@ PassRefPtr<StyleImage> StyleResolver::loadPendingImage(StylePendingImage* pendin
 
     if (auto imageGeneratorValue = pendingImage->cssImageGeneratorValue()) {
         imageGeneratorValue->loadSubimages(m_state.document().cachedResourceLoader());
-        return StyleGeneratedImage::create(imageGeneratorValue);
+        return StyleGeneratedImage::create(*imageGeneratorValue);
     }
 
     if (auto cursorImageValue = pendingImage->cssCursorImageValue())
@@ -3923,8 +3923,8 @@ void StyleResolver::loadPendingImages()
     if (m_state.pendingImageProperties().isEmpty())
         return;
 
-    PendingImagePropertyMap::const_iterator::Keys end = m_state.pendingImageProperties().end().keys();
-    for (PendingImagePropertyMap::const_iterator::Keys it = m_state.pendingImageProperties().begin().keys(); it != end; ++it) {
+    auto end = m_state.pendingImageProperties().end().keys();
+    for (auto it = m_state.pendingImageProperties().begin().keys(); it != end; ++it) {
         CSSPropertyID currentProperty = *it;
 
         switch (currentProperty) {
index 74fe0d8..29c5191 100644 (file)
@@ -503,7 +503,7 @@ public:
 
     PassRefPtr<StyleImage> styleImage(CSSPropertyID, CSSValue*);
     PassRefPtr<StyleImage> cachedOrPendingFromValue(CSSPropertyID, CSSImageValue*);
-    PassRefPtr<StyleImage> generatedOrPendingFromValue(CSSPropertyID, CSSImageGeneratorValue*);
+    PassRefPtr<StyleImage> generatedOrPendingFromValue(CSSPropertyID, CSSImageGeneratorValue&);
 #if ENABLE(CSS_IMAGE_SET)
     PassRefPtr<StyleImage> setOrPendingFromValue(CSSPropertyID, CSSImageSetValue*);
 #endif
index 2f773f7..54458bd 100644 (file)
@@ -221,7 +221,7 @@ static inline PassRefPtr<StyleImage> blendFilter(const AnimationBase* anim, Cach
     RefPtr<CSSFilterImageValue> result = CSSFilterImageValue::create(std::move(imageValue), filterValue);
     result->setFilterOperations(filterResult);
 
-    return StyleGeneratedImage::create(result.get());
+    return StyleGeneratedImage::create(*result);
 }
 #endif // ENABLE(CSS_FILTERS)
 
@@ -288,7 +288,7 @@ static inline PassRefPtr<StyleImage> crossfadeBlend(const AnimationBase*, StyleC
 
     crossfadeValue->setPercentage(CSSPrimitiveValue::create(progress, CSSPrimitiveValue::CSS_NUMBER));
 
-    return StyleGeneratedImage::create(crossfadeValue.get());
+    return StyleGeneratedImage::create(*crossfadeValue);
 }
 
 static inline PassRefPtr<StyleImage> blendFunc(const AnimationBase* anim, StyleImage* from, StyleImage* to, double progress)
@@ -298,42 +298,42 @@ static inline PassRefPtr<StyleImage> blendFunc(const AnimationBase* anim, StyleI
 
     // Animation between two generated images. Cross fade for all other cases.
     if (from->isGeneratedImage() && to->isGeneratedImage()) {
-        CSSImageGeneratorValue* fromGenerated = toStyleGeneratedImage(from)->imageValue();
-        CSSImageGeneratorValue* toGenerated = toStyleGeneratedImage(to)->imageValue();
+        CSSImageGeneratorValue& fromGenerated = toStyleGeneratedImage(from)->imageValue();
+        CSSImageGeneratorValue& toGenerated = toStyleGeneratedImage(to)->imageValue();
 
 #if ENABLE(CSS_FILTERS)
-        if (fromGenerated->isFilterImageValue() && toGenerated->isFilterImageValue()) {
+        if (fromGenerated.isFilterImageValue() && toGenerated.isFilterImageValue()) {
             // Animation of generated images just possible if input images are equal.
             // Otherwise fall back to cross fade animation.
-            CSSFilterImageValue& fromFilter = *toCSSFilterImageValue(fromGenerated);
-            CSSFilterImageValue& toFilter = *toCSSFilterImageValue(toGenerated);
+            CSSFilterImageValue& fromFilter = toCSSFilterImageValue(fromGenerated);
+            CSSFilterImageValue& toFilter = toCSSFilterImageValue(toGenerated);
             if (fromFilter.equalInputImages(toFilter) && fromFilter.cachedImage())
                 return blendFilter(anim, fromFilter.cachedImage(), fromFilter.filterOperations(), toFilter.filterOperations(), progress);
         }
 #endif
 
-        if (fromGenerated->isCrossfadeValue() && toGenerated->isCrossfadeValue()) {
-            CSSCrossfadeValue& fromCrossfade = *toCSSCrossfadeValue(fromGenerated);
-            CSSCrossfadeValue& toCrossfade = *toCSSCrossfadeValue(toGenerated);
+        if (fromGenerated.isCrossfadeValue() && toGenerated.isCrossfadeValue()) {
+            CSSCrossfadeValue& fromCrossfade = toCSSCrossfadeValue(fromGenerated);
+            CSSCrossfadeValue& toCrossfade = toCSSCrossfadeValue(toGenerated);
             if (fromCrossfade.equalInputImages(toCrossfade))
-                return StyleGeneratedImage::create(toCrossfade.blend(fromCrossfade, progress).get());
+                return StyleGeneratedImage::create(*toCrossfade.blend(fromCrossfade, progress));
         }
 
         // FIXME: Add support for animation between two *gradient() functions.
         // https://bugs.webkit.org/show_bug.cgi?id=119956
 #if ENABLE(CSS_FILTERS)
     } else if (from->isGeneratedImage() && to->isCachedImage()) {
-        CSSImageGeneratorValue* fromGenerated = toStyleGeneratedImage(from)->imageValue();
-        if (fromGenerated->isFilterImageValue()) {
-            CSSFilterImageValue& fromFilter = *toCSSFilterImageValue(fromGenerated);
+        CSSImageGeneratorValue& fromGenerated = toStyleGeneratedImage(from)->imageValue();
+        if (fromGenerated.isFilterImageValue()) {
+            CSSFilterImageValue& fromFilter = toCSSFilterImageValue(fromGenerated);
             if (fromFilter.cachedImage() && static_cast<StyleCachedImage*>(to)->cachedImage() == fromFilter.cachedImage())
                 return blendFilter(anim, fromFilter.cachedImage(), fromFilter.filterOperations(), FilterOperations(), progress);
         }
         // FIXME: Add interpolation between cross-fade and image source.
     } else if (from->isCachedImage() && to->isGeneratedImage()) {
-        CSSImageGeneratorValue* toGenerated = toStyleGeneratedImage(to)->imageValue();
-        if (toGenerated->isFilterImageValue()) {
-            CSSFilterImageValue& toFilter = *toCSSFilterImageValue(toGenerated);
+        CSSImageGeneratorValue& toGenerated = toStyleGeneratedImage(to)->imageValue();
+        if (toGenerated.isFilterImageValue()) {
+            CSSFilterImageValue& toFilter = toCSSFilterImageValue(toGenerated);
             if (toFilter.cachedImage() && static_cast<StyleCachedImage*>(from)->cachedImage() == toFilter.cachedImage())     
                 return blendFilter(anim, toFilter.cachedImage(), FilterOperations(), toFilter.filterOperations(), progress);
         }
index e4fc712..6b59fe7 100644 (file)
@@ -30,8 +30,8 @@
 
 namespace WebCore {
     
-StyleGeneratedImage::StyleGeneratedImage(PassRefPtr<CSSImageGeneratorValue> value)
-    : m_imageGeneratorValue(value)  
+StyleGeneratedImage::StyleGeneratedImage(PassRef<CSSImageGeneratorValue> value)
+    : m_imageGeneratorValue(std::move(value))
     , m_fixedSize(m_imageGeneratorValue->isFixedSize())
 {
     m_isGeneratedImage = true;
@@ -39,13 +39,13 @@ StyleGeneratedImage::StyleGeneratedImage(PassRefPtr<CSSImageGeneratorValue> valu
 
 PassRefPtr<CSSValue> StyleGeneratedImage::cssValue() const
 {
-    return m_imageGeneratorValue;
+    return &const_cast<CSSImageGeneratorValue&>(m_imageGeneratorValue.get());
 }
 
 LayoutSize StyleGeneratedImage::imageSize(const RenderElement* renderer, float multiplier) const
 {
     if (m_fixedSize) {
-        IntSize fixedSize = m_imageGeneratorValue->fixedSize(renderer);
+        IntSize fixedSize = const_cast<CSSImageGeneratorValue&>(m_imageGeneratorValue.get()).fixedSize(renderer);
         if (multiplier == 1.0f)
             return fixedSize;
 
@@ -86,7 +86,7 @@ void StyleGeneratedImage::removeClient(RenderElement* renderer)
 
 PassRefPtr<Image> StyleGeneratedImage::image(RenderElement* renderer, const IntSize& size) const
 {
-    return m_imageGeneratorValue->image(renderer, size);
+    return const_cast<CSSImageGeneratorValue&>(m_imageGeneratorValue.get()).image(renderer, size);
 }
 
 bool StyleGeneratedImage::knownToBeOpaque(const RenderElement* renderer) const
index 043100c..ae357ed 100644 (file)
@@ -33,15 +33,15 @@ class CSSImageGeneratorValue;
 
 class StyleGeneratedImage FINAL : public StyleImage {
 public:
-    static PassRefPtr<StyleGeneratedImage> create(CSSImageGeneratorValue* value)
+    static PassRefPtr<StyleGeneratedImage> create(PassRef<CSSImageGeneratorValue> value)
     {
-        return adoptRef(new StyleGeneratedImage(value));
+        return adoptRef(new StyleGeneratedImage(std::move(value)));
     }
 
-    CSSImageGeneratorValue* imageValue() const { return m_imageGeneratorValue.get(); }
+    CSSImageGeneratorValue& imageValue() { return m_imageGeneratorValue.get(); }
 
 private:
-    virtual WrappedImagePtr data() const OVERRIDE { return m_imageGeneratorValue.get(); }
+    virtual WrappedImagePtr data() const OVERRIDE { return &m_imageGeneratorValue.get(); }
 
     virtual PassRefPtr<CSSValue> cssValue() const OVERRIDE;
 
@@ -56,9 +56,9 @@ private:
     virtual PassRefPtr<Image> image(RenderElement*, const IntSize&) const OVERRIDE;
     virtual bool knownToBeOpaque(const RenderElement*) const OVERRIDE;
 
-    StyleGeneratedImage(PassRefPtr<CSSImageGeneratorValue>);
+    StyleGeneratedImage(PassRef<CSSImageGeneratorValue>);
     
-    RefPtr<CSSImageGeneratorValue> m_imageGeneratorValue;
+    Ref<CSSImageGeneratorValue> m_imageGeneratorValue;
     IntSize m_containerSize;
     bool m_fixedSize;
 };
index c3cd13a..a0bd45a 100644 (file)
@@ -39,7 +39,7 @@ class CSSValue;
 class RenderElement;
 class RenderObject;
 
-typedef void* WrappedImagePtr;
+typedef const void* WrappedImagePtr;
 
 class StyleImage : public RefCounted<StyleImage> {
 public: