1 /* 2 * Copyright (C) 2000 Lars Knoll (knoll (at) kde.org) 3 * (C) 2000 Antti Koivisto (koivisto (at) kde.org) 4 * (C) 2000 Dirk Mueller (mueller (at) kde.org) 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * 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. 11 * 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. 16 * 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. 21 * 22 */ 23 24 #ifndef StyleImage_h 25 #define StyleImage_h 26 27 #include "CSSValue.h" 28 #include "Image.h" 29 #include "IntSize.h" 30 #include <wtf/PassRefPtr.h> 31 #include <wtf/RefCounted.h> 32 #include <wtf/RefPtr.h> 33 34 namespace WebCore { 35 36 class CSSValue; 37 class RenderObject; 38 39 typedef void* WrappedImagePtr; 40 41 class StyleImage : public RefCounted<StyleImage> { 42 public: 43 virtual ~StyleImage() { } 44 45 bool operator==(const StyleImage& other) const 46 { 47 return data() == other.data(); 48 } 49 50 virtual PassRefPtr<CSSValue> cssValue() const = 0; 51 52 virtual bool canRender(float /*multiplier*/) const { return true; } 53 virtual bool isLoaded() const { return true; } 54 virtual bool errorOccurred() const { return false; } 55 virtual IntSize imageSize(const RenderObject*, float multiplier) const = 0; 56 virtual bool imageHasRelativeWidth() const = 0; 57 virtual bool imageHasRelativeHeight() const = 0; 58 virtual bool usesImageContainerSize() const = 0; 59 virtual void setImageContainerSize(const IntSize&) = 0; 60 virtual void addClient(RenderObject*) = 0; 61 virtual void removeClient(RenderObject*) = 0; 62 virtual PassRefPtr<Image> image(RenderObject*, const IntSize&) const = 0; 63 virtual WrappedImagePtr data() const = 0; 64 65 virtual bool isCachedImage() const { return false; } 66 virtual bool isPendingImage() const { return false; } 67 virtual bool isGeneratedImage() const { return false; } 68 69 static bool imagesEquivalent(StyleImage* image1, StyleImage* image2) 70 { 71 if (image1 != image2) { 72 if (!image1 || !image2) 73 return false; 74 return *image1 == *image2; 75 } 76 return true; 77 } 78 79 protected: 80 StyleImage() { } 81 }; 82 83 } 84 #endif 85