KHtml

SVGResource.h
1 /*
2  * Copyright (C) 2006, 2008 Nikolas Zimmermann <[email protected]>
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef SVGResource_h
27 #define SVGResource_h
28 
29 #if ENABLE(SVG)
30 #include "PlatformString.h"
31 //#include "StringHash.h"
32 
33 #include <wtf/HashMap.h>
34 #include <wtf/HashSet.h>
35 #include <wtf/RefCounted.h>
36 
37 #include "Document.h"
38 
39 namespace WebCore
40 {
41 
42 //class AtomicString;
43 //class Document;
44 class SVGStyledElement;
45 //class TextStream;
46 
47 enum SVGResourceType {
48  // Painting mode
49  ClipperResourceType = 0,
50  MarkerResourceType,
51  ImageResourceType,
52  FilterResourceType,
53  MaskerResourceType,
54  PaintServerResourceType,
55 
56  // For resource tracking we need to know how many types of resource there are
57  _ResourceTypeCount
58 };
59 
60 // The SVGResource file represent various graphics resources:
61 // - Filter resource
62 // - Clipper resource
63 // - Masker resource
64 // - Marker resource
65 // - Pattern resource
66 // - Linear/Radial gradient resource
67 //
68 // SVG creates/uses these resources.
69 
70 class SVGResource : public RefCounted<SVGResource>
71 {
72 public:
73  virtual ~SVGResource();
74 
75  virtual void invalidate();
76 
77  void addClient(SVGStyledElement *);
78  virtual SVGResourceType resourceType() const = 0;
79 
80  bool isPaintServer() const
81  {
82  return resourceType() == PaintServerResourceType;
83  }
84  bool isFilter() const
85  {
86  return resourceType() == FilterResourceType;
87  }
88  bool isClipper() const
89  {
90  return resourceType() == ClipperResourceType;
91  }
92  bool isMarker() const
93  {
94  return resourceType() == MarkerResourceType;
95  }
96  bool isMasker() const
97  {
98  return resourceType() == MaskerResourceType;
99  }
100 
101  /*virtual TextStream& externalRepresentation(TextStream&) const;*/
102 
103  static void invalidateClients(HashSet<SVGStyledElement *>);
104  static void removeClient(SVGStyledElement *);
105 
106 protected:
107  SVGResource();
108 
109 private:
110  HashSet<SVGStyledElement *> m_clients;
111 };
112 
113 SVGResource *getResourceById(Document *, const AtomicString &);
114 
115 /*TextStream& operator<<(TextStream&, const SVGResource&);*/
116 
117 } // namespace WebCore
118 
119 #endif
120 #endif // SVGResource_h
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:10 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.