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.
27 #include "core/CoreExport.h"
28 #include "core/css/CSSValue.h"
29 #include "platform/geometry/IntSize.h"
30 #include "platform/geometry/LayoutSize.h"
31 #include "platform/graphics/Image.h"
32 #include "wtf/PassRefPtr.h"
33 #include "wtf/RefCounted.h"
34 #include "wtf/RefPtr.h"
42 typedef void* WrappedImagePtr
;
44 class CORE_EXPORT StyleImage
: public RefCountedWillBeGarbageCollectedFinalized
<StyleImage
> {
46 virtual ~StyleImage() { }
48 bool operator==(const StyleImage
& other
) const
50 return data() == other
.data();
53 virtual PassRefPtrWillBeRawPtr
<CSSValue
> cssValue() const = 0;
54 virtual PassRefPtrWillBeRawPtr
<CSSValue
> computedCSSValue() const = 0;
56 virtual bool canRender(const LayoutObject
&, float /*multiplier*/) const { return true; }
57 virtual bool isLoaded() const { return true; }
58 virtual bool errorOccurred() const { return false; }
59 virtual LayoutSize
imageSize(const LayoutObject
*, float multiplier
) const = 0;
60 virtual void computeIntrinsicDimensions(const LayoutObject
*, Length
& intrinsicWidth
, Length
& intrinsicHeight
, FloatSize
& intrinsicRatio
) = 0;
61 virtual bool imageHasRelativeWidth() const = 0;
62 virtual bool imageHasRelativeHeight() const = 0;
63 virtual bool usesImageContainerSize() const = 0;
64 virtual void setContainerSizeForLayoutObject(const LayoutObject
*, const IntSize
&, float) = 0;
65 virtual void addClient(LayoutObject
*) = 0;
66 virtual void removeClient(LayoutObject
*) = 0;
67 virtual PassRefPtr
<Image
> image(LayoutObject
*, const IntSize
&) const = 0;
68 virtual WrappedImagePtr
data() const = 0;
69 virtual float imageScaleFactor() const { return 1; }
70 virtual bool knownToBeOpaque(const LayoutObject
*) const = 0;
71 virtual ImageResource
* cachedImage() const { return 0; }
73 ALWAYS_INLINE
bool isImageResource() const { return m_isImageResource
; }
74 ALWAYS_INLINE
bool isPendingImage() const { return m_isPendingImage
; }
75 ALWAYS_INLINE
bool isGeneratedImage() const { return m_isGeneratedImage
; }
76 ALWAYS_INLINE
bool isImageResourceSet() const { return m_isImageResourceSet
; }
78 DEFINE_INLINE_VIRTUAL_TRACE() { }
82 : m_isImageResource(false)
83 , m_isPendingImage(false)
84 , m_isGeneratedImage(false)
85 , m_isImageResourceSet(false)
88 bool m_isImageResource
:1;
89 bool m_isPendingImage
:1;
90 bool m_isGeneratedImage
:1;
91 bool m_isImageResourceSet
:1;
94 #define DEFINE_STYLE_IMAGE_TYPE_CASTS(thisType, function) \
95 DEFINE_TYPE_CASTS(thisType, StyleImage, styleImage, styleImage->function, styleImage.function); \
96 inline thisType* to##thisType(const RefPtrWillBeMember<StyleImage>& styleImage) { return to##thisType(styleImage.get()); } \
97 typedef int NeedsSemiColonAfterDefineStyleImageTypeCasts