2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
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.
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.
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.
20 #ifndef PatternAttributes_h
21 #define PatternAttributes_h
23 #include "core/svg/SVGLength.h"
24 #include "core/svg/SVGPreserveAspectRatio.h"
25 #include "platform/heap/Handle.h"
26 #include "platform/transforms/AffineTransform.h"
30 class SVGPatternElement
;
32 class PatternAttributes final
{
33 DISALLOW_ALLOCATION();
36 : m_x(SVGLength::create(SVGLengthMode::Width
))
37 , m_y(SVGLength::create(SVGLengthMode::Height
))
38 , m_width(SVGLength::create(SVGLengthMode::Width
))
39 , m_height(SVGLength::create(SVGLengthMode::Height
))
41 , m_preserveAspectRatio(SVGPreserveAspectRatio::create())
42 , m_patternUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
)
43 , m_patternContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE
)
44 , m_patternContentElement(nullptr)
50 , m_preserveAspectRatioSet(false)
51 , m_patternUnitsSet(false)
52 , m_patternContentUnitsSet(false)
53 , m_patternTransformSet(false)
54 , m_patternContentElementSet(false)
58 SVGLength
* x() const { return m_x
.get(); }
59 SVGLength
* y() const { return m_y
.get(); }
60 SVGLength
* width() const { return m_width
.get(); }
61 SVGLength
* height() const { return m_height
.get(); }
62 FloatRect
viewBox() const { return m_viewBox
; }
63 SVGPreserveAspectRatio
* preserveAspectRatio() const { return m_preserveAspectRatio
.get(); }
64 SVGUnitTypes::SVGUnitType
patternUnits() const { return m_patternUnits
; }
65 SVGUnitTypes::SVGUnitType
patternContentUnits() const { return m_patternContentUnits
; }
66 AffineTransform
patternTransform() const { return m_patternTransform
; }
67 const SVGPatternElement
* patternContentElement() const { return m_patternContentElement
; }
69 void setX(PassRefPtrWillBeRawPtr
<SVGLength
> value
)
75 void setY(PassRefPtrWillBeRawPtr
<SVGLength
> value
)
81 void setWidth(PassRefPtrWillBeRawPtr
<SVGLength
> value
)
87 void setHeight(PassRefPtrWillBeRawPtr
<SVGLength
> value
)
93 void setViewBox(const FloatRect
& value
)
99 void setPreserveAspectRatio(PassRefPtrWillBeRawPtr
<SVGPreserveAspectRatio
> value
)
101 m_preserveAspectRatio
= value
;
102 m_preserveAspectRatioSet
= true;
105 void setPatternUnits(SVGUnitTypes::SVGUnitType value
)
107 m_patternUnits
= value
;
108 m_patternUnitsSet
= true;
111 void setPatternContentUnits(SVGUnitTypes::SVGUnitType value
)
113 m_patternContentUnits
= value
;
114 m_patternContentUnitsSet
= true;
117 void setPatternTransform(const AffineTransform
& value
)
119 m_patternTransform
= value
;
120 m_patternTransformSet
= true;
123 void setPatternContentElement(const SVGPatternElement
* value
)
125 m_patternContentElement
= value
;
126 m_patternContentElementSet
= true;
129 bool hasX() const { return m_xSet
; }
130 bool hasY() const { return m_ySet
; }
131 bool hasWidth() const { return m_widthSet
; }
132 bool hasHeight() const { return m_heightSet
; }
133 bool hasViewBox() const { return m_viewBoxSet
; }
134 bool hasPreserveAspectRatio() const { return m_preserveAspectRatioSet
; }
135 bool hasPatternUnits() const { return m_patternUnitsSet
; }
136 bool hasPatternContentUnits() const { return m_patternContentUnitsSet
; }
137 bool hasPatternTransform() const { return m_patternTransformSet
; }
138 bool hasPatternContentElement() const { return m_patternContentElementSet
; }
140 DEFINE_INLINE_TRACE()
144 visitor
->trace(m_width
);
145 visitor
->trace(m_height
);
146 visitor
->trace(m_preserveAspectRatio
);
147 visitor
->trace(m_patternContentElement
);
152 RefPtrWillBeMember
<SVGLength
> m_x
;
153 RefPtrWillBeMember
<SVGLength
> m_y
;
154 RefPtrWillBeMember
<SVGLength
> m_width
;
155 RefPtrWillBeMember
<SVGLength
> m_height
;
157 RefPtrWillBeMember
<SVGPreserveAspectRatio
> m_preserveAspectRatio
;
158 SVGUnitTypes::SVGUnitType m_patternUnits
;
159 SVGUnitTypes::SVGUnitType m_patternContentUnits
;
160 AffineTransform m_patternTransform
;
161 RawPtrWillBeMember
<const SVGPatternElement
> m_patternContentElement
;
167 bool m_heightSet
: 1;
168 bool m_viewBoxSet
: 1;
169 bool m_preserveAspectRatioSet
: 1;
170 bool m_patternUnitsSet
: 1;
171 bool m_patternContentUnitsSet
: 1;
172 bool m_patternTransformSet
: 1;
173 bool m_patternContentElementSet
: 1;
177 // Wrapper object for the PatternAttributes part object.
178 class PatternAttributesWrapper
: public GarbageCollectedFinalized
<PatternAttributesWrapper
> {
180 static PatternAttributesWrapper
* create()
182 return new PatternAttributesWrapper
;
185 PatternAttributes
& attributes() { return m_attributes
; }
186 void set(const PatternAttributes
& attributes
) { m_attributes
= attributes
; }
187 DEFINE_INLINE_TRACE() { visitor
->trace(m_attributes
); }
190 PatternAttributesWrapper()
194 PatternAttributes m_attributes
;
200 #endif // PatternAttributes_h