OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org> | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org> |
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 addToPropertyMap(m_y); | 50 addToPropertyMap(m_y); |
51 addToPropertyMap(m_width); | 51 addToPropertyMap(m_width); |
52 addToPropertyMap(m_height); | 52 addToPropertyMap(m_height); |
53 addToPropertyMap(m_patternTransform); | 53 addToPropertyMap(m_patternTransform); |
54 addToPropertyMap(m_patternUnits); | 54 addToPropertyMap(m_patternUnits); |
55 addToPropertyMap(m_patternContentUnits); | 55 addToPropertyMap(m_patternContentUnits); |
56 } | 56 } |
57 | 57 |
58 DEFINE_NODE_FACTORY(SVGPatternElement) | 58 DEFINE_NODE_FACTORY(SVGPatternElement) |
59 | 59 |
60 bool SVGPatternElement::isPresentationAttribute(const QualifiedName& name) const | |
61 { | |
62 if (name == SVGNames::patternTransformAttr) | |
63 return true; | |
64 return SVGElement::isPresentationAttribute(name); | |
65 } | |
66 | |
67 void SVGPatternElement::collectStyleForPresentationAttribute(const QualifiedName & name, const AtomicString& value, MutableStylePropertySet* style) | |
68 { | |
69 // Don't add invalid (empty) values to the style | |
pdr.
2014/08/01 22:43:10
I don't understand this comment.
Erik Dahlström (inactive)
2014/08/04 13:57:57
It was a misunderstanding of the spec (this avoide
| |
70 if (name == SVGNames::patternTransformAttr) | |
71 addPropertyToPresentationAttributeStyle(style, CSSPropertyTransform, val ue); | |
72 else | |
73 SVGElement::collectStyleForPresentationAttribute(name, value, style); | |
74 } | |
75 | |
60 bool SVGPatternElement::isSupportedAttribute(const QualifiedName& attrName) | 76 bool SVGPatternElement::isSupportedAttribute(const QualifiedName& attrName) |
61 { | 77 { |
62 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | 78 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); |
63 if (supportedAttributes.isEmpty()) { | 79 if (supportedAttributes.isEmpty()) { |
64 SVGURIReference::addSupportedAttributes(supportedAttributes); | 80 SVGURIReference::addSupportedAttributes(supportedAttributes); |
65 SVGTests::addSupportedAttributes(supportedAttributes); | 81 SVGTests::addSupportedAttributes(supportedAttributes); |
66 SVGFitToViewBox::addSupportedAttributes(supportedAttributes); | 82 SVGFitToViewBox::addSupportedAttributes(supportedAttributes); |
67 supportedAttributes.add(SVGNames::patternUnitsAttr); | 83 supportedAttributes.add(SVGNames::patternUnitsAttr); |
68 supportedAttributes.add(SVGNames::patternContentUnitsAttr); | 84 supportedAttributes.add(SVGNames::patternContentUnitsAttr); |
69 supportedAttributes.add(SVGNames::patternTransformAttr); | 85 supportedAttributes.add(SVGNames::patternTransformAttr); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 | 176 |
161 if (!attributes.hasPreserveAspectRatio() && element->preserveAspectRatio()-> isSpecified()) | 177 if (!attributes.hasPreserveAspectRatio() && element->preserveAspectRatio()-> isSpecified()) |
162 attributes.setPreserveAspectRatio(element->preserveAspectRatio()->curren tValue()); | 178 attributes.setPreserveAspectRatio(element->preserveAspectRatio()->curren tValue()); |
163 | 179 |
164 if (!attributes.hasPatternUnits() && element->patternUnits()->isSpecified()) | 180 if (!attributes.hasPatternUnits() && element->patternUnits()->isSpecified()) |
165 attributes.setPatternUnits(element->patternUnits()->currentValue()->enum Value()); | 181 attributes.setPatternUnits(element->patternUnits()->currentValue()->enum Value()); |
166 | 182 |
167 if (!attributes.hasPatternContentUnits() && element->patternContentUnits()-> isSpecified()) | 183 if (!attributes.hasPatternContentUnits() && element->patternContentUnits()-> isSpecified()) |
168 attributes.setPatternContentUnits(element->patternContentUnits()->curren tValue()->enumValue()); | 184 attributes.setPatternContentUnits(element->patternContentUnits()->curren tValue()->enumValue()); |
169 | 185 |
170 if (!attributes.hasPatternTransform() && element->patternTransform()->isSpec ified()) { | 186 if (!attributes.hasPatternTransform()) { |
171 AffineTransform transform; | 187 AffineTransform transform; |
172 element->patternTransform()->currentValue()->concatenate(transform); | 188 RenderStyle* style = element->renderer() ? element->renderer()->style() : 0; |
173 attributes.setPatternTransform(transform); | 189 |
190 // If CSS property was set, use that, otherwise fallback to attribute (i f set). | |
191 if (style && style->hasTransform()) { | |
192 TransformationMatrix matrix; | |
193 float zoom = style->effectiveZoom(); | |
194 | |
195 // CSS transforms operate with pre-scaled lengths. To make this work with SVG | |
196 // (which applies the zoom factor globally, at the root level) we | |
197 // | |
198 // * pre-scale the bounding box (to bring it into the same space a s the other CSS values) | |
199 // * invert the zoom factor (to effectively compute the CSS transf orm under a 1.0 zoom) | |
200 // | |
201 // Note: objectBoundingBox is an emptyRect for elements like pattern or clipPath. | |
202 // See the "Object bounding box units" section of http://dev.w3.org/ csswg/css3-transforms/ | |
203 if (zoom != 1) { | |
204 FloatRect scaledBBox = element->renderer()->objectBoundingBox(); | |
205 scaledBBox.scale(zoom); | |
206 transform.scale(1 / zoom); | |
207 style->applyTransform(matrix, scaledBBox); | |
208 matrix.scale(zoom); | |
209 } else { | |
210 style->applyTransform(matrix, element->renderer()->objectBoundin gBox()); | |
211 } | |
212 | |
213 // Flatten any 3D transform. | |
214 transform = matrix.toAffineTransform(); | |
215 } else if (element->patternTransform()->isSpecified()) { | |
216 element->patternTransform()->currentValue()->concatenate(transform); | |
217 } | |
218 | |
219 if (!transform.isIdentity()) | |
220 attributes.setPatternTransform(transform); | |
174 } | 221 } |
175 | 222 |
176 if (!attributes.hasPatternContentElement() && ElementTraversal::firstWithin( *element)) | 223 if (!attributes.hasPatternContentElement() && ElementTraversal::firstWithin( *element)) |
177 attributes.setPatternContentElement(element); | 224 attributes.setPatternContentElement(element); |
178 } | 225 } |
179 | 226 |
180 void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes) const | 227 void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes) const |
181 { | 228 { |
182 WillBeHeapHashSet<RawPtrWillBeMember<const SVGPatternElement> > processedPat terns; | 229 WillBeHeapHashSet<RawPtrWillBeMember<const SVGPatternElement> > processedPat terns; |
183 const SVGPatternElement* current = this; | 230 const SVGPatternElement* current = this; |
(...skipping 27 matching lines...) Expand all Loading... | |
211 | 258 |
212 bool SVGPatternElement::selfHasRelativeLengths() const | 259 bool SVGPatternElement::selfHasRelativeLengths() const |
213 { | 260 { |
214 return m_x->currentValue()->isRelative() | 261 return m_x->currentValue()->isRelative() |
215 || m_y->currentValue()->isRelative() | 262 || m_y->currentValue()->isRelative() |
216 || m_width->currentValue()->isRelative() | 263 || m_width->currentValue()->isRelative() |
217 || m_height->currentValue()->isRelative(); | 264 || m_height->currentValue()->isRelative(); |
218 } | 265 } |
219 | 266 |
220 } | 267 } |
OLD | NEW |