• 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 #include "core/svg/SVGLength.h"
24 #include "core/svg/SVGPreserveAspectRatio.h"
25 #include "platform/transforms/AffineTransform.h"
26 
27 namespace WebCore {
28 
29 class SVGPatternElement;
30 
31 struct PatternAttributes {
PatternAttributesPatternAttributes32     PatternAttributes()
33         : m_x(SVGLength::create(LengthModeWidth))
34         , m_y(SVGLength::create(LengthModeHeight))
35         , m_width(SVGLength::create(LengthModeWidth))
36         , m_height(SVGLength::create(LengthModeHeight))
37         , m_viewBox()
38         , m_preserveAspectRatio(SVGPreserveAspectRatio::create())
39         , m_patternUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
40         , m_patternContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE)
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_patternUnitsSet(false)
49         , m_patternContentUnitsSet(false)
50         , m_patternTransformSet(false)
51         , m_patternContentElementSet(false)
52     {
53     }
54 
xPatternAttributes55     SVGLength* x() const { return m_x.get(); }
yPatternAttributes56     SVGLength* y() const { return m_y.get(); }
widthPatternAttributes57     SVGLength* width() const { return m_width.get(); }
heightPatternAttributes58     SVGLength* height() const { return m_height.get(); }
viewBoxPatternAttributes59     FloatRect viewBox() const { return m_viewBox; }
preserveAspectRatioPatternAttributes60     SVGPreserveAspectRatio* preserveAspectRatio() const { return m_preserveAspectRatio.get(); }
patternUnitsPatternAttributes61     SVGUnitTypes::SVGUnitType patternUnits() const { return m_patternUnits; }
patternContentUnitsPatternAttributes62     SVGUnitTypes::SVGUnitType patternContentUnits() const { return m_patternContentUnits; }
patternTransformPatternAttributes63     AffineTransform patternTransform() const { return m_patternTransform; }
patternContentElementPatternAttributes64     const SVGPatternElement* patternContentElement() const { return m_patternContentElement; }
65 
setXPatternAttributes66     void setX(PassRefPtr<SVGLength> value)
67     {
68         m_x = value;
69         m_xSet = true;
70     }
71 
setYPatternAttributes72     void setY(PassRefPtr<SVGLength> value)
73     {
74         m_y = value;
75         m_ySet = true;
76     }
77 
setWidthPatternAttributes78     void setWidth(PassRefPtr<SVGLength> value)
79     {
80         m_width = value;
81         m_widthSet = true;
82     }
83 
setHeightPatternAttributes84     void setHeight(PassRefPtr<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(PassRefPtr<SVGPreserveAspectRatio> value)
97     {
98         m_preserveAspectRatio = value;
99         m_preserveAspectRatioSet = true;
100     }
101 
setPatternUnitsPatternAttributes102     void setPatternUnits(SVGUnitTypes::SVGUnitType value)
103     {
104         m_patternUnits = value;
105         m_patternUnitsSet = true;
106     }
107 
setPatternContentUnitsPatternAttributes108     void setPatternContentUnits(SVGUnitTypes::SVGUnitType value)
109     {
110         m_patternContentUnits = value;
111         m_patternContentUnitsSet = 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; }
hasPatternUnitsPatternAttributes132     bool hasPatternUnits() const { return m_patternUnitsSet; }
hasPatternContentUnitsPatternAttributes133     bool hasPatternContentUnits() const { return m_patternContentUnitsSet; }
hasPatternTransformPatternAttributes134     bool hasPatternTransform() const { return m_patternTransformSet; }
hasPatternContentElementPatternAttributes135     bool hasPatternContentElement() const { return m_patternContentElementSet; }
136 
137 private:
138     // Properties
139     RefPtr<SVGLength> m_x;
140     RefPtr<SVGLength> m_y;
141     RefPtr<SVGLength> m_width;
142     RefPtr<SVGLength> m_height;
143     FloatRect m_viewBox;
144     RefPtr<SVGPreserveAspectRatio> m_preserveAspectRatio;
145     SVGUnitTypes::SVGUnitType m_patternUnits;
146     SVGUnitTypes::SVGUnitType m_patternContentUnits;
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_patternUnitsSet : 1;
158     bool m_patternContentUnitsSet : 1;
159     bool m_patternTransformSet : 1;
160     bool m_patternContentElementSet : 1;
161 };
162 
163 } // namespace WebCore
164 
165 #endif
166