diff options
Diffstat (limited to 'Source/WebCore/css/CSSImageSetValue.h')
-rw-r--r-- | Source/WebCore/css/CSSImageSetValue.h | 45 |
1 files changed, 14 insertions, 31 deletions
diff --git a/Source/WebCore/css/CSSImageSetValue.h b/Source/WebCore/css/CSSImageSetValue.h index c1899f3ab..d6f09b171 100644 --- a/Source/WebCore/css/CSSImageSetValue.h +++ b/Source/WebCore/css/CSSImageSetValue.h @@ -23,74 +23,57 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef CSSImageSetValue_h -#define CSSImageSetValue_h - -#if ENABLE(CSS_IMAGE_SET) +#pragma once #include "CSSValueList.h" +#include "CachedImageClient.h" +#include "CachedResourceHandle.h" namespace WebCore { class CachedResourceLoader; class Document; -class StyleCachedImageSet; -class StyleImage; struct ResourceLoaderOptions; -class CSSImageSetValue : public CSSValueList { +class CSSImageSetValue final : public CSSValueList { public: - - static PassRef<CSSImageSetValue> create() + static Ref<CSSImageSetValue> create() { return adoptRef(*new CSSImageSetValue()); } ~CSSImageSetValue(); - StyleCachedImageSet* cachedImageSet(CachedResourceLoader*, const ResourceLoaderOptions&); - StyleCachedImageSet* cachedImageSet(CachedResourceLoader*); - - // Returns a StyleCachedImageSet if the best fit image has been cached already, otherwise a StylePendingImage. - StyleImage* cachedOrPendingImageSet(Document&); + std::pair<CachedImage*, float> loadBestFitImage(CachedResourceLoader&, const ResourceLoaderOptions&); + CachedImage* cachedImage() const { return m_cachedImage.get(); } String customCSSText() const; - bool isPending() const { return !m_accessedBestFitImage; } - struct ImageWithScale { String imageURL; float scaleFactor; }; - bool hasFailedOrCanceledSubresources() const; + bool traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const; - PassRefPtr<CSSImageSetValue> cloneForCSSOM() const; + void updateDeviceScaleFactor(const Document&); protected: ImageWithScale bestImageForScaleFactor(); private: CSSImageSetValue(); - CSSImageSetValue(const CSSImageSetValue& cloneFrom); - void detachPendingImage(); void fillImageSet(); static inline bool compareByScaleFactor(ImageWithScale first, ImageWithScale second) { return first.scaleFactor < second.scaleFactor; } - RefPtr<StyleImage> m_imageSet; - bool m_accessedBestFitImage; - - // This represents the scale factor that we used to find the best fit image. It does not necessarily - // correspond to the scale factor of the best fit image. - float m_scaleFactor; + CachedResourceHandle<CachedImage> m_cachedImage; + bool m_accessedBestFitImage { false }; + float m_bestFitImageScaleFactor { 1 }; + float m_deviceScaleFactor { 1 }; Vector<ImageWithScale> m_imagesInSet; }; -CSS_VALUE_TYPE_CASTS(CSSImageSetValue, isImageSetValue()) - } // namespace WebCore -#endif // ENABLE(CSS_IMAGE_SET) - -#endif // CSSImageSetValue_h +SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSImageSetValue, isImageSetValue()) |