File indexing completed on 2024-05-12 15:39:16
0001 /* 0002 * Copyright (C) 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 0003 * 0004 * Redistribution and use in source and binary forms, with or without 0005 * modification, are permitted provided that the following conditions 0006 * are met: 0007 * 1. Redistributions of source code must retain the above copyright 0008 * notice, this list of conditions and the following disclaimer. 0009 * 2. Redistributions in binary form must reproduce the above copyright 0010 * notice, this list of conditions and the following disclaimer in the 0011 * documentation and/or other materials provided with the distribution. 0012 * 0013 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 0014 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0015 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 0016 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 0017 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 0018 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 0019 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 0020 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 0021 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0022 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0023 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0024 */ 0025 0026 #ifndef SVGResource_h 0027 #define SVGResource_h 0028 0029 #if ENABLE(SVG) 0030 #include "PlatformString.h" 0031 //#include "StringHash.h" 0032 0033 #include <wtf/HashMap.h> 0034 #include <wtf/HashSet.h> 0035 #include <wtf/RefCounted.h> 0036 0037 #include "Document.h" 0038 0039 namespace WebCore 0040 { 0041 0042 //class AtomicString; 0043 //class Document; 0044 class SVGStyledElement; 0045 //class TextStream; 0046 0047 enum SVGResourceType { 0048 // Painting mode 0049 ClipperResourceType = 0, 0050 MarkerResourceType, 0051 ImageResourceType, 0052 FilterResourceType, 0053 MaskerResourceType, 0054 PaintServerResourceType, 0055 0056 // For resource tracking we need to know how many types of resource there are 0057 _ResourceTypeCount 0058 }; 0059 0060 // The SVGResource file represent various graphics resources: 0061 // - Filter resource 0062 // - Clipper resource 0063 // - Masker resource 0064 // - Marker resource 0065 // - Pattern resource 0066 // - Linear/Radial gradient resource 0067 // 0068 // SVG creates/uses these resources. 0069 0070 class SVGResource : public RefCounted<SVGResource> 0071 { 0072 public: 0073 virtual ~SVGResource(); 0074 0075 virtual void invalidate(); 0076 0077 void addClient(SVGStyledElement *); 0078 virtual SVGResourceType resourceType() const = 0; 0079 0080 bool isPaintServer() const 0081 { 0082 return resourceType() == PaintServerResourceType; 0083 } 0084 bool isFilter() const 0085 { 0086 return resourceType() == FilterResourceType; 0087 } 0088 bool isClipper() const 0089 { 0090 return resourceType() == ClipperResourceType; 0091 } 0092 bool isMarker() const 0093 { 0094 return resourceType() == MarkerResourceType; 0095 } 0096 bool isMasker() const 0097 { 0098 return resourceType() == MaskerResourceType; 0099 } 0100 0101 /*virtual TextStream& externalRepresentation(TextStream&) const;*/ 0102 0103 static void invalidateClients(HashSet<SVGStyledElement *>); 0104 static void removeClient(SVGStyledElement *); 0105 0106 protected: 0107 SVGResource(); 0108 0109 private: 0110 HashSet<SVGStyledElement *> m_clients; 0111 }; 0112 0113 SVGResource *getResourceById(Document *, const AtomicString &); 0114 0115 /*TextStream& operator<<(TextStream&, const SVGResource&);*/ 0116 0117 } // namespace WebCore 0118 0119 #endif 0120 #endif // SVGResource_h