blob: 8a75347a81ee97f8117cdafbb80d0ed6e20edfee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 200 800">
<!-- Bug 544809 - nsSVGPatternFrame::GetPatternWithAttr and callers should
take account of SMIL animation.
Test animating pattern attributes doesn't rely on the presence of
attributes in the DOM, but also correctly detects attributes set by
animation.
The format of each test is that we have a base pattern named (attName)Ref
which does NOT specify the attribute under test, but instead sets the
attribute to a non-default value using animation.
Then we have a referencing pattern named (attName) that refers to the
base pattern and also does NOT specify the attribute under test.
When we go to look up the attribute under test we begin at (attName),
notice the attribute isn't specified (either in the DOM or by animation),
then go to (attName)Ref and detect that the attribute is specified there
by animation and use that value.
To the right of each test we also include a rect that directly references
(attName)Ref. The two rectangles should be identical but prior to fixing
this bug they were not.
-->
<!-- 1. patternUnits: defaults to objectBoundingBox -->
<defs>
<pattern xlink:href="#patternUnitsRef" id="patternUnits"/>
<pattern id="patternUnitsRef" width="80" height="80">
<set attributeName="patternUnits" to="userSpaceOnUse"/>
<rect width="50" height="50" fill="blue"/>
<rect x="50" width="50" height="50" fill="red"/>
<rect y="50" width="50" height="50" fill="red"/>
<rect x="50" y="50" width="50" height="50" fill="blue"/>
</pattern>
</defs>
<rect width="100" height="100" stroke="black" fill="url(#patternUnits)"/>
<g transform="translate(100)">
<rect width="100" height="100" stroke="black" fill="url(#patternUnitsRef)"/>
</g>
<!-- 2. patternContentUnits: defaults to userSpaceOnUse -->
<defs>
<pattern xlink:href="#patternContentUnitsRef" id="patternContentUnits"/>
<pattern id="patternContentUnitsRef" width="1" height="1">
<set attributeName="patternContentUnits" to="objectBoundingBox"/>
<rect width="0.5" height="0.5" fill="blue"/>
<rect x="0.5" width="0.5" height="0.5" fill="red"/>
<rect y="0.5" width="0.5" height="0.5" fill="red"/>
<rect x="0.5" y="0.5" width="0.5" height="0.5" fill="blue"/>
</pattern>
</defs>
<g transform="translate(0 100)">
<rect width="100" height="100" stroke="black"
fill="url(#patternContentUnits)"/>
<g transform="translate(100)">
<rect width="100" height="100" stroke="black"
fill="url(#patternContentUnitsRef)"/>
</g>
</g>
<!-- 3. patternTransform: defaults to identity -->
<defs>
<pattern xlink:href="#patternTransformRef" id="patternTransform"/>
<pattern id="patternTransformRef" width="1" height="1">
<animateTransform attributeName="patternTransform" type="rotate"
values="45 50 50" fill="freeze"/>
<rect width="50" height="50" fill="blue"/>
<rect x="50" width="50" height="50" fill="red"/>
<rect y="50" width="50" height="50" fill="red"/>
<rect x="50" y="50" width="50" height="50" fill="blue"/>
</pattern>
</defs>
<g transform="translate(0 200)">
<rect width="100" height="100" stroke="black"
fill="url(#patternTransform)"/>
<g transform="translate(100)">
<rect width="100" height="100" stroke="black"
fill="url(#patternTransformRef)"/>
</g>
</g>
<!-- 4. preserveAspectRatio: defaults to xMidYMid meet -->
<defs>
<pattern xlink:href="#parRef" id="par"/>
<pattern id="parRef" width="1" height="1" viewBox="0.1 0.1 0.6 0.85">
<set attributeName="preserveAspectRatio" to="none"/>
<rect width="50" height="50" fill="blue"/>
<rect x="50" width="50" height="50" fill="red"/>
<rect y="50" width="50" height="50" fill="red"/>
<rect x="50" y="50" width="50" height="50" fill="blue"/>
</pattern>
</defs>
<g transform="translate(0 300)">
<rect width="100" height="100" stroke="black" fill="url(#par)"/>
<g transform="translate(100)">
<rect width="100" height="100" stroke="black" fill="url(#parRef)"/>
</g>
</g>
<!-- 5. viewBox -->
<defs>
<pattern xlink:href="#viewBoxRef" id="viewBox"/>
<pattern id="viewBoxRef" width="1" height="1"
preserveAspectRatio="none">
<set attributeName="viewBox" to="0.1 0.1 0.6 0.85"/>
<rect width="50" height="50" fill="blue"/>
<rect x="50" width="50" height="50" fill="red"/>
<rect y="50" width="50" height="50" fill="red"/>
<rect x="50" y="50" width="50" height="50" fill="blue"/>
</pattern>
</defs>
<g transform="translate(0 400)">
<rect width="100" height="100" stroke="black" fill="url(#viewBox)"/>
<g transform="translate(100)">
<rect width="100" height="100" stroke="black" fill="url(#viewBoxRef)"/>
</g>
</g>
<!-- 6. xlink:href
This attribute is not affected by bug 544809, i.e. it doesn't use
nsSVGPatternFrame::GetPatternWithAttr, but we test it here for completeness
-->
<defs>
<pattern id="xlink">
<set attributeName="xlink:href" to="#xlinkRef"/>
</pattern>
<pattern id="xlinkRef" width="1" height="1">
<rect width="50" height="50" fill="blue"/>
<rect x="50" width="50" height="50" fill="red"/>
<rect y="50" width="50" height="50" fill="red"/>
<rect x="50" y="50" width="50" height="50" fill="blue"/>
</pattern>
</defs>
<g transform="translate(0 500)">
<rect width="100" height="100" stroke="black" fill="url(#xlink)"/>
<g transform="translate(100)">
<rect width="100" height="100" stroke="black" fill="url(#xlinkRef)"/>
</g>
</g>
<!-- 6. x, y: defaults to 0 -->
<defs>
<pattern xlink:href="#xyRef" id="xy"/>
<pattern id="xyRef" width="1" height="1">
<set attributeName="x" to="0.1"/>
<set attributeName="y" to="-0.1"/>
<rect width="50" height="50" fill="blue"/>
<rect x="50" width="50" height="50" fill="red"/>
<rect y="50" width="50" height="50" fill="red"/>
<rect x="50" y="50" width="50" height="50" fill="blue"/>
</pattern>
</defs>
<g transform="translate(0 600)">
<rect width="100" height="100" stroke="black" fill="url(#xy)"/>
<g transform="translate(100)">
<rect width="100" height="100" stroke="black" fill="url(#xyRef)"/>
</g>
</g>
<!-- 7. width, height: defaults to 0 (disables rendering) -->
<defs>
<pattern xlink:href="#widthHeightRef" id="widthHeight"/>
<pattern id="widthHeightRef">
<set attributeName="width" to="1"/>
<set attributeName="height" to="1"/>
<rect width="50" height="50" fill="blue"/>
<rect x="50" width="50" height="50" fill="red"/>
<rect y="50" width="50" height="50" fill="red"/>
<rect x="50" y="50" width="50" height="50" fill="blue"/>
</pattern>
</defs>
<g transform="translate(0 700)">
<rect width="100" height="100" stroke="black" fill="url(#widthHeight)"/>
<g transform="translate(100)">
<rect width="100" height="100" stroke="black"
fill="url(#widthHeightRef)"/>
</g>
</g>
<!-- If adding more tests here, be sure to update the viewBox on the root svg
element -->
</svg>
|