CSSFilterImageValue constructor should require both image and filter.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Dec 2013 10:32:05 +0000 (10:32 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Dec 2013 10:32:05 +0000 (10:32 +0000)
<https://webkit.org/b/125056>

Make the CSSFilterImageValue::create() helper take both the image and
filter CSSValues by PassRef since they should never be null.

Tweaked ComputedStyleExtractor::valueForFilter() to return a PassRef
for this to work.

Reviewed by Anders Carlsson.

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

Source/WebCore/ChangeLog
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSComputedStyleDeclaration.h
Source/WebCore/css/CSSFilterImageValue.h
Source/WebCore/css/CSSParser.cpp
Source/WebCore/page/animation/CSSPropertyAnimation.cpp

index 1565babdf85bbf11a26321f9873dc48ba1efad74..d12cd6f4d60286cc51a005eb307c2ca8364bef80 100644 (file)
@@ -1,3 +1,16 @@
+2013-12-13  Andreas Kling  <akling@apple.com>
+
+        CSSFilterImageValue constructor should require both image and filter.
+        <https://webkit.org/b/125056>
+
+        Make the CSSFilterImageValue::create() helper take both the image and
+        filter CSSValues by PassRef since they should never be null.
+
+        Tweaked ComputedStyleExtractor::valueForFilter() to return a PassRef
+        for this to work.
+
+        Reviewed by Anders Carlsson.
+
 2013-12-12  Andreas Kling  <akling@apple.com>
 
         StyleResolver::adjustRenderStyle() should take RenderStyle references.
index 00a32e22e94648b5ef489c6d1e5920ffc96add9c..21308e822a3e27fdc3961789d45ee117bd067880 100644 (file)
@@ -940,7 +940,7 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::valueForShadow(const ShadowData* sh
 }
 
 #if ENABLE(CSS_FILTERS)
-PassRefPtr<CSSValue> ComputedStyleExtractor::valueForFilter(const RenderObject* renderer, const RenderStyle* style, const FilterOperations& filterOperations, AdjustPixelValuesForComputedStyle adjust)
+PassRef<CSSValue> ComputedStyleExtractor::valueForFilter(const RenderObject* renderer, const RenderStyle* style, const FilterOperations& filterOperations, AdjustPixelValuesForComputedStyle adjust)
 {
 #if !ENABLE(CSS_SHADERS)
     UNUSED_PARAM(renderer);
@@ -948,7 +948,7 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::valueForFilter(const RenderObject*
     if (filterOperations.operations().isEmpty())
         return cssValuePool().createIdentifierValue(CSSValueNone);
 
-    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
+    auto list = CSSValueList::createSpaceSeparated();
 
     RefPtr<WebKitCSSFilterValue> filterValue;
 
@@ -1092,10 +1092,10 @@ PassRefPtr<CSSValue> ComputedStyleExtractor::valueForFilter(const RenderObject*
             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::UnknownFilterOperation);
             break;
         }
-        list->append(filterValue.release());
+        list.get().append(filterValue.release());
     }
 
-    return list.release();
+    return std::move(list);
 }
 #endif
 
index bd92e79e638d655da80b22b82649cdab3431bec6..1676aa7020faed8455a74b82998d7d6f99d2188f 100644 (file)
@@ -64,7 +64,7 @@ public:
     bool propertyMatches(CSSPropertyID, const CSSValue*) const;
 
 #if ENABLE(CSS_FILTERS)
-    static PassRefPtr<CSSValue> valueForFilter(const RenderObject*, const RenderStyle*, const FilterOperations&, AdjustPixelValuesForComputedStyle = AdjustPixelValues);
+    static PassRef<CSSValue> valueForFilter(const RenderObject*, const RenderStyle*, const FilterOperations&, AdjustPixelValuesForComputedStyle = AdjustPixelValues);
 #endif
 
 private:
index 75b4797db85e978f0499cc57675d264fd2efad02..99afacfcc5ecacf7cf7c776094914f09bbd08752 100644 (file)
@@ -48,9 +48,9 @@ class StyleResolver;
 class CSSFilterImageValue : public CSSImageGeneratorValue {
     friend class FilterSubimageObserverProxy;
 public:
-    static PassRef<CSSFilterImageValue> create(PassRefPtr<CSSValue> imageValue, PassRefPtr<CSSValue> filterValue)
+    static PassRef<CSSFilterImageValue> create(PassRef<CSSValue> imageValue, PassRef<CSSValue> filterValue)
     {
-        return adoptRef(*new CSSFilterImageValue(imageValue, filterValue));
+        return adoptRef(*new CSSFilterImageValue(std::move(imageValue), std::move(filterValue)));
     }
 
     ~CSSFilterImageValue();
index 3b6ec8bec5b96ed4399edc6fa83e8afe4115e889..ae59fd190062ad7a2bfebae154ed45d22f0ad3d2 100644 (file)
@@ -8529,7 +8529,7 @@ bool CSSParser::parseFilterImage(CSSParserValueList* valueList, RefPtr<CSSValue>
         return false;
     value = args->next();
 
-    result = CSSFilterImageValue::create(imageValue, filterValue);
+    result = CSSFilterImageValue::create(imageValue.releaseNonNull(), filterValue.releaseNonNull());
 
     filter = result;
 
index 54458bd52d3f3b1b6f961deb94abae38fca43a72..8f806bee2d1ed6e2858c81d1e43442e2fbfb22c6 100644 (file)
@@ -217,11 +217,11 @@ static inline PassRefPtr<StyleImage> blendFilter(const AnimationBase* anim, Cach
 
     RefPtr<StyleCachedImage> styledImage = StyleCachedImage::create(image);
     auto imageValue = CSSImageValue::create(image->url(), styledImage.get());
-    RefPtr<CSSValue> filterValue = ComputedStyleExtractor::valueForFilter(anim->renderer(), &anim->renderer()->style(), filterResult, DoNotAdjustPixelValues);
-    RefPtr<CSSFilterImageValue> result = CSSFilterImageValue::create(std::move(imageValue), filterValue);
-    result->setFilterOperations(filterResult);
+    auto filterValue = ComputedStyleExtractor::valueForFilter(anim->renderer(), &anim->renderer()->style(), filterResult, DoNotAdjustPixelValues);
 
-    return StyleGeneratedImage::create(*result);
+    auto result = CSSFilterImageValue::create(std::move(imageValue), std::move(filterValue));
+    result.get().setFilterOperations(filterResult);
+    return StyleGeneratedImage::create(std::move(result));
 }
 #endif // ENABLE(CSS_FILTERS)
 
@@ -284,11 +284,10 @@ static inline PassRefPtr<StyleImage> crossfadeBlend(const AnimationBase*, StyleC
 
     auto fromImageValue = CSSImageValue::create(fromStyleImage->cachedImage()->url(), fromStyleImage);
     auto toImageValue = CSSImageValue::create(toStyleImage->cachedImage()->url(), toStyleImage);
-    RefPtr<CSSCrossfadeValue> crossfadeValue = CSSCrossfadeValue::create(std::move(fromImageValue), std::move(toImageValue));
 
-    crossfadeValue->setPercentage(CSSPrimitiveValue::create(progress, CSSPrimitiveValue::CSS_NUMBER));
-
-    return StyleGeneratedImage::create(*crossfadeValue);
+    auto crossfadeValue = CSSCrossfadeValue::create(std::move(fromImageValue), std::move(toImageValue));
+    crossfadeValue.get().setPercentage(CSSPrimitiveValue::create(progress, CSSPrimitiveValue::CSS_NUMBER));
+    return StyleGeneratedImage::create(std::move(crossfadeValue));
 }
 
 static inline PassRefPtr<StyleImage> blendFunc(const AnimationBase* anim, StyleImage* from, StyleImage* to, double progress)