• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef PatternAttributes_h
21 #define PatternAttributes_h
22 
23 #if ENABLE(SVG)
24 #include "SVGLength.h"
25 #include "SVGPreserveAspectRatio.h"
26 
27 namespace WebCore {
28 
29 class SVGPatternElement;
30 
31 struct PatternAttributes {
PatternAttributesPatternAttributes32     PatternAttributes()
33         : m_x()
34         , m_y()
35         , m_width()
36         , m_height()
37         , m_viewBox()
38         , m_preserveAspectRatio()
39         , m_boundingBoxMode(true)
40         , m_boundingBoxModeContent(false)
41         , m_patternContentElement(0)
42         , m_xSet(false)
43         , m_ySet(false)
44         , m_widthSet(false)
45         , m_heightSet(false)
46         , m_viewBoxSet(false)
47         , m_preserveAspectRatioSet(false)
48         , m_boundingBoxModeSet(false)
49         , m_boundingBoxModeContentSet(false)
50         , m_patternTransformSet(false)
51         , m_patternContentElementSet(false)
52     {
53     }
54 
xPatternAttributes55     SVGLength x() const { return m_x; }
yPatternAttributes56     SVGLength y() const { return m_y; }
widthPatternAttributes57     SVGLength width() const { return m_width; }
heightPatternAttributes58     SVGLength height() const { return m_height; }
viewBoxPatternAttributes59     FloatRect viewBox() const { return m_viewBox; }
preserveAspectRatioPatternAttributes60     SVGPreserveAspectRatio preserveAspectRatio() const { return m_preserveAspectRatio; }
boundingBoxModePatternAttributes61     bool boundingBoxMode() const { return m_boundingBoxMode; }
boundingBoxModeContentPatternAttributes62     bool boundingBoxModeContent() const { return m_boundingBoxModeContent; }
patternTransformPatternAttributes63     AffineTransform patternTransform() const { return m_patternTransform; }
patternContentElementPatternAttributes64     const SVGPatternElement* patternContentElement() const { return m_patternContentElement; }
65 
setXPatternAttributes66     void setX(const SVGLength& value)
67     {
68         m_x = value;
69         m_xSet = true;
70     }
71 
setYPatternAttributes72     void setY(const SVGLength& value)
73     {
74         m_y = value;
75         m_ySet = true;
76     }
77 
setWidthPatternAttributes78     void setWidth(const SVGLength& value)
79     {
80         m_width = value;
81         m_widthSet = true;
82     }
83 
setHeightPatternAttributes84     void setHeight(const SVGLength& value)
85     {
86         m_height = value;
87         m_heightSet = true;
88     }
89 
setViewBoxPatternAttributes90     void setViewBox(const FloatRect& value)
91     {
92         m_viewBox = value;
93         m_viewBoxSet = true;
94     }
95 
setPreserveAspectRatioPatternAttributes96     void setPreserveAspectRatio(const SVGPreserveAspectRatio& value)
97     {
98         m_preserveAspectRatio = value;
99         m_preserveAspectRatioSet = true;
100     }
101 
setBoundingBoxModePatternAttributes102     void setBoundingBoxMode(bool value)
103     {
104         m_boundingBoxMode = value;
105         m_boundingBoxModeSet = true;
106     }
107 
setBoundingBoxModeContentPatternAttributes108     void setBoundingBoxModeContent(bool value)
109     {
110         m_boundingBoxModeContent = value;
111         m_boundingBoxModeContentSet = true;
112     }
113 
setPatternTransformPatternAttributes114     void setPatternTransform(const AffineTransform& value)
115     {
116         m_patternTransform = value;
117         m_patternTransformSet = true;
118     }
119 
setPatternContentElementPatternAttributes120     void setPatternContentElement(const SVGPatternElement* value)
121     {
122         m_patternContentElement = value;
123         m_patternContentElementSet = true;
124     }
125 
hasXPatternAttributes126     bool hasX() const { return m_xSet; }
hasYPatternAttributes127     bool hasY() const { return m_ySet; }
hasWidthPatternAttributes128     bool hasWidth() const { return m_widthSet; }
hasHeightPatternAttributes129     bool hasHeight() const { return m_heightSet; }
hasViewBoxPatternAttributes130     bool hasViewBox() const { return m_viewBoxSet; }
hasPreserveAspectRatioPatternAttributes131     bool hasPreserveAspectRatio() const { return m_preserveAspectRatioSet; }
hasBoundingBoxModePatternAttributes132     bool hasBoundingBoxMode() const { return m_boundingBoxModeSet; }
hasBoundingBoxModeContentPatternAttributes133     bool hasBoundingBoxModeContent() const { return m_boundingBoxModeContentSet; }
hasPatternTransformPatternAttributes134     bool hasPatternTransform() const { return m_patternTransformSet; }
hasPatternContentElementPatternAttributes135     bool hasPatternContentElement() const { return m_patternContentElementSet; }
136 
137 private:
138     // Properties
139     SVGLength m_x;
140     SVGLength m_y;
141     SVGLength m_width;
142     SVGLength m_height;
143     FloatRect m_viewBox;
144     SVGPreserveAspectRatio m_preserveAspectRatio;
145     bool m_boundingBoxMode;
146     bool m_boundingBoxModeContent;
147     AffineTransform m_patternTransform;
148     const SVGPatternElement* m_patternContentElement;
149 
150     // Property states
151     bool m_xSet : 1;
152     bool m_ySet : 1;
153     bool m_widthSet : 1;
154     bool m_heightSet : 1;
155     bool m_viewBoxSet : 1;
156     bool m_preserveAspectRatioSet : 1;
157     bool m_boundingBoxModeSet : 1;
158     bool m_boundingBoxModeContentSet : 1;
159     bool m_patternTransformSet : 1;
160     bool m_patternContentElementSet : 1;
161 };
162 
163 } // namespace WebCore
164 
165 #endif // ENABLE(SVG)
166 #endif
167