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 | #pragma once |
21 | |
22 | #include "SVGLengthValue.h" |
23 | #include "SVGPreserveAspectRatioValue.h" |
24 | |
25 | namespace WebCore { |
26 | |
27 | class SVGPatternElement; |
28 | |
29 | struct PatternAttributes { |
30 | PatternAttributes() |
31 | : m_x() |
32 | , m_y() |
33 | , m_width() |
34 | , m_height() |
35 | , m_viewBox() |
36 | , m_preserveAspectRatio() |
37 | , m_patternUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) |
38 | , m_patternContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) |
39 | , m_patternContentElement(nullptr) |
40 | , m_xSet(false) |
41 | , m_ySet(false) |
42 | , m_widthSet(false) |
43 | , m_heightSet(false) |
44 | , m_viewBoxSet(false) |
45 | , m_preserveAspectRatioSet(false) |
46 | , m_patternUnitsSet(false) |
47 | , m_patternContentUnitsSet(false) |
48 | , m_patternTransformSet(false) |
49 | , m_patternContentElementSet(false) |
50 | { |
51 | } |
52 | |
53 | SVGLengthValue x() const { return m_x; } |
54 | SVGLengthValue y() const { return m_y; } |
55 | SVGLengthValue width() const { return m_width; } |
56 | SVGLengthValue height() const { return m_height; } |
57 | FloatRect viewBox() const { return m_viewBox; } |
58 | SVGPreserveAspectRatioValue preserveAspectRatio() const { return m_preserveAspectRatio; } |
59 | SVGUnitTypes::SVGUnitType patternUnits() const { return m_patternUnits; } |
60 | SVGUnitTypes::SVGUnitType patternContentUnits() const { return m_patternContentUnits; } |
61 | AffineTransform patternTransform() const { return m_patternTransform; } |
62 | const SVGPatternElement* patternContentElement() const { return m_patternContentElement; } |
63 | |
64 | void setX(SVGLengthValue value) |
65 | { |
66 | m_x = value; |
67 | m_xSet = true; |
68 | } |
69 | |
70 | void setY(SVGLengthValue value) |
71 | { |
72 | m_y = value; |
73 | m_ySet = true; |
74 | } |
75 | |
76 | void setWidth(SVGLengthValue value) |
77 | { |
78 | m_width = value; |
79 | m_widthSet = true; |
80 | } |
81 | |
82 | void setHeight(SVGLengthValue value) |
83 | { |
84 | m_height = value; |
85 | m_heightSet = true; |
86 | } |
87 | |
88 | void setViewBox(const FloatRect& value) |
89 | { |
90 | m_viewBox = value; |
91 | m_viewBoxSet = true; |
92 | } |
93 | |
94 | void setPreserveAspectRatio(SVGPreserveAspectRatioValue value) |
95 | { |
96 | m_preserveAspectRatio = value; |
97 | m_preserveAspectRatioSet = true; |
98 | } |
99 | |
100 | void setPatternUnits(SVGUnitTypes::SVGUnitType value) |
101 | { |
102 | m_patternUnits = value; |
103 | m_patternUnitsSet = true; |
104 | } |
105 | |
106 | void setPatternContentUnits(SVGUnitTypes::SVGUnitType value) |
107 | { |
108 | m_patternContentUnits = value; |
109 | m_patternContentUnitsSet = true; |
110 | } |
111 | |
112 | void setPatternTransform(const AffineTransform& value) |
113 | { |
114 | m_patternTransform = value; |
115 | m_patternTransformSet = true; |
116 | } |
117 | |
118 | void setPatternContentElement(const SVGPatternElement* value) |
119 | { |
120 | m_patternContentElement = value; |
121 | m_patternContentElementSet = true; |
122 | } |
123 | |
124 | bool hasX() const { return m_xSet; } |
125 | bool hasY() const { return m_ySet; } |
126 | bool hasWidth() const { return m_widthSet; } |
127 | bool hasHeight() const { return m_heightSet; } |
128 | bool hasViewBox() const { return m_viewBoxSet; } |
129 | bool hasPreserveAspectRatio() const { return m_preserveAspectRatioSet; } |
130 | bool hasPatternUnits() const { return m_patternUnitsSet; } |
131 | bool hasPatternContentUnits() const { return m_patternContentUnitsSet; } |
132 | bool hasPatternTransform() const { return m_patternTransformSet; } |
133 | bool hasPatternContentElement() const { return m_patternContentElementSet; } |
134 | |
135 | private: |
136 | // Properties |
137 | SVGLengthValue m_x; |
138 | SVGLengthValue m_y; |
139 | SVGLengthValue m_width; |
140 | SVGLengthValue m_height; |
141 | FloatRect m_viewBox; |
142 | SVGPreserveAspectRatioValue m_preserveAspectRatio; |
143 | SVGUnitTypes::SVGUnitType m_patternUnits; |
144 | SVGUnitTypes::SVGUnitType m_patternContentUnits; |
145 | AffineTransform m_patternTransform; |
146 | const SVGPatternElement* m_patternContentElement; |
147 | |
148 | // Property states |
149 | bool m_xSet : 1; |
150 | bool m_ySet : 1; |
151 | bool m_widthSet : 1; |
152 | bool m_heightSet : 1; |
153 | bool m_viewBoxSet : 1; |
154 | bool m_preserveAspectRatioSet : 1; |
155 | bool m_patternUnitsSet : 1; |
156 | bool m_patternContentUnitsSet : 1; |
157 | bool m_patternTransformSet : 1; |
158 | bool m_patternContentElementSet : 1; |
159 | }; |
160 | |
161 | } // namespace WebCore |
162 | |