2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
24 #ifndef StyleCachedImage_h
25 #define StyleCachedImage_h
27 #include "CachedImageClient.h"
28 #include "CachedResourceHandle.h"
29 #include "StyleImage.h"
37 class StyleCachedImage final : public StyleImage {
38 WTF_MAKE_FAST_ALLOCATED;
40 static Ref<StyleCachedImage> create(CSSValue& cssValue) { return adoptRef(*new StyleCachedImage(cssValue)); }
41 virtual ~StyleCachedImage();
43 bool operator==(const StyleImage& other) const override;
45 CachedImage* cachedImage() const override;
47 WrappedImagePtr data() const override { return m_cachedImage.get(); }
49 PassRefPtr<CSSValue> cssValue() const override;
51 bool canRender(const RenderObject*, float multiplier) const override;
52 bool isPending() const override;
53 void load(CachedResourceLoader&, const ResourceLoaderOptions&) override;
54 bool isLoaded() const override;
55 bool errorOccurred() const override;
56 FloatSize imageSize(const RenderElement*, float multiplier) const override;
57 bool imageHasRelativeWidth() const override;
58 bool imageHasRelativeHeight() const override;
59 void computeIntrinsicDimensions(const RenderElement*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) override;
60 bool usesImageContainerSize() const override;
61 void setContainerSizeForRenderer(const RenderElement*, const FloatSize&, float) override;
62 void addClient(RenderElement*) override;
63 void removeClient(RenderElement*) override;
64 RefPtr<Image> image(RenderElement*, const FloatSize&) const override;
65 float imageScaleFactor() const override;
66 bool knownToBeOpaque(const RenderElement*) const override;
69 StyleCachedImage(CSSValue&);
71 Ref<CSSValue> m_cssValue;
72 bool m_isPending { true };
73 mutable float m_scaleFactor { 1 };
74 mutable CachedResourceHandle<CachedImage> m_cachedImage;
77 } // namespace WebCore
79 SPECIALIZE_TYPE_TRAITS_STYLE_IMAGE(StyleCachedImage, isCachedImage)
81 #endif // StyleCachedImage_h