2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
17 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
18 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
22 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
23 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 #ifndef CSSFilterImageValue_h
28 #define CSSFilterImageValue_h
30 #if ENABLE(CSS_FILTERS)
32 #include "CSSImageGeneratorValue.h"
33 #include "CSSPrimitiveValue.h"
34 #include "CachedImageClient.h"
35 #include "CachedResourceHandle.h"
36 #include "FilterOperations.h"
38 #include "ImageObserver.h"
43 class FilterSubimageObserverProxy;
48 class CSSFilterImageValue : public CSSImageGeneratorValue {
49 friend class FilterSubimageObserverProxy;
51 static PassRef<CSSFilterImageValue> create(PassRef<CSSValue> imageValue, PassRef<CSSValue> filterValue)
53 return adoptRef(*new CSSFilterImageValue(std::move(imageValue), std::move(filterValue)));
56 ~CSSFilterImageValue();
58 String customCSSText() const;
60 PassRefPtr<Image> image(RenderElement*, const IntSize&);
61 bool isFixedSize() const { return true; }
62 IntSize fixedSize(const RenderElement*);
64 bool isPending() const;
65 bool knownToBeOpaque(const RenderElement*) const;
67 void loadSubimages(CachedResourceLoader*);
69 bool hasFailedOrCanceledSubresources() const;
71 bool equals(const CSSFilterImageValue&) const;
73 bool equalInputImages(const CSSFilterImageValue&) const;
75 void createFilterOperations(StyleResolver*);
77 const FilterOperations& filterOperations() const { return m_filterOperations; }
78 void setFilterOperations(const FilterOperations& filterOperations)
80 m_filterOperations = filterOperations;
82 CachedImage* cachedImage() const { return m_cachedImage.get(); }
85 CSSFilterImageValue(PassRefPtr<CSSValue> imageValue, PassRefPtr<CSSValue> filterValue)
86 : CSSImageGeneratorValue(FilterImageClass)
87 , m_imageValue(imageValue)
88 , m_filterValue(filterValue)
89 , m_filterSubimageObserver(this)
93 class FilterSubimageObserverProxy : public CachedImageClient {
95 FilterSubimageObserverProxy(CSSFilterImageValue* ownerValue)
96 : m_ownerValue(ownerValue)
101 virtual ~FilterSubimageObserverProxy() { }
102 virtual void imageChanged(CachedImage*, const IntRect* = 0) OVERRIDE;
103 void setReady(bool ready) { m_ready = ready; }
105 CSSFilterImageValue* m_ownerValue;
109 void filterImageChanged(const IntRect&);
111 RefPtr<CSSValue> m_imageValue;
112 RefPtr<CSSValue> m_filterValue;
114 FilterOperations m_filterOperations;
116 CachedResourceHandle<CachedImage> m_cachedImage;
117 RefPtr<Image> m_generatedImage;
119 FilterSubimageObserverProxy m_filterSubimageObserver;
122 CSS_VALUE_TYPE_CASTS(CSSFilterImageValue, isFilterImageValue())
124 } // namespace WebCore
126 #endif // ENABLE(CSS_FILTERS)
128 #endif // CSSFilterImageValue_h