| 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 16 matching lines...) Expand all Loading... |
| 27 #include "core/rendering/svg/RenderSVGResourcePattern.h" | 27 #include "core/rendering/svg/RenderSVGResourcePattern.h" |
| 28 #include "core/svg/PatternAttributes.h" | 28 #include "core/svg/PatternAttributes.h" |
| 29 #include "core/svg/SVGElementInstance.h" | 29 #include "core/svg/SVGElementInstance.h" |
| 30 #include "platform/transforms/AffineTransform.h" | 30 #include "platform/transforms/AffineTransform.h" |
| 31 | 31 |
| 32 namespace WebCore { | 32 namespace WebCore { |
| 33 | 33 |
| 34 // Animated property definitions | 34 // Animated property definitions |
| 35 DEFINE_ANIMATED_ENUMERATION(SVGPatternElement, SVGNames::patternUnitsAttr, Patte
rnUnits, patternUnits, SVGUnitTypes::SVGUnitType) | 35 DEFINE_ANIMATED_ENUMERATION(SVGPatternElement, SVGNames::patternUnitsAttr, Patte
rnUnits, patternUnits, SVGUnitTypes::SVGUnitType) |
| 36 DEFINE_ANIMATED_ENUMERATION(SVGPatternElement, SVGNames::patternContentUnitsAttr
, PatternContentUnits, patternContentUnits, SVGUnitTypes::SVGUnitType) | 36 DEFINE_ANIMATED_ENUMERATION(SVGPatternElement, SVGNames::patternContentUnitsAttr
, PatternContentUnits, patternContentUnits, SVGUnitTypes::SVGUnitType) |
| 37 DEFINE_ANIMATED_TRANSFORM_LIST(SVGPatternElement, SVGNames::patternTransformAttr
, PatternTransform, patternTransform) | |
| 38 | 37 |
| 39 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGPatternElement) | 38 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGPatternElement) |
| 40 REGISTER_LOCAL_ANIMATED_PROPERTY(patternUnits) | 39 REGISTER_LOCAL_ANIMATED_PROPERTY(patternUnits) |
| 41 REGISTER_LOCAL_ANIMATED_PROPERTY(patternContentUnits) | 40 REGISTER_LOCAL_ANIMATED_PROPERTY(patternContentUnits) |
| 42 REGISTER_LOCAL_ANIMATED_PROPERTY(patternTransform) | |
| 43 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) | 41 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) |
| 44 END_REGISTER_ANIMATED_PROPERTIES | 42 END_REGISTER_ANIMATED_PROPERTIES |
| 45 | 43 |
| 46 inline SVGPatternElement::SVGPatternElement(Document& document) | 44 inline SVGPatternElement::SVGPatternElement(Document& document) |
| 47 : SVGElement(SVGNames::patternTag, document) | 45 : SVGElement(SVGNames::patternTag, document) |
| 48 , SVGTests(this) | 46 , SVGTests(this) |
| 49 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth))) | 47 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth))) |
| 50 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight))) | 48 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight))) |
| 51 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth))) | 49 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth))) |
| 52 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight))) | 50 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight))) |
| 53 , m_viewBox(SVGAnimatedRect::create(this, SVGNames::viewBoxAttr)) | 51 , m_viewBox(SVGAnimatedRect::create(this, SVGNames::viewBoxAttr)) |
| 54 , m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(this, SVGName
s::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())) | 52 , m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(this, SVGName
s::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())) |
| 55 , m_href(SVGAnimatedString::create(this, XLinkNames::hrefAttr, SVGString::cr
eate())) | 53 , m_href(SVGAnimatedString::create(this, XLinkNames::hrefAttr, SVGString::cr
eate())) |
| 54 , m_patternTransform(SVGAnimatedTransformList::create(this, SVGNames::patter
nTransformAttr, SVGTransformList::create())) |
| 56 , m_patternUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) | 55 , m_patternUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) |
| 57 , m_patternContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) | 56 , m_patternContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) |
| 58 { | 57 { |
| 59 ScriptWrappable::init(this); | 58 ScriptWrappable::init(this); |
| 60 | 59 |
| 61 addToPropertyMap(m_x); | 60 addToPropertyMap(m_x); |
| 62 addToPropertyMap(m_y); | 61 addToPropertyMap(m_y); |
| 63 addToPropertyMap(m_width); | 62 addToPropertyMap(m_width); |
| 64 addToPropertyMap(m_height); | 63 addToPropertyMap(m_height); |
| 65 addToPropertyMap(m_viewBox); | 64 addToPropertyMap(m_viewBox); |
| 66 addToPropertyMap(m_preserveAspectRatio); | 65 addToPropertyMap(m_preserveAspectRatio); |
| 67 addToPropertyMap(m_href); | 66 addToPropertyMap(m_href); |
| 67 addToPropertyMap(m_patternTransform); |
| 68 registerAnimatedPropertiesForSVGPatternElement(); | 68 registerAnimatedPropertiesForSVGPatternElement(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 PassRefPtr<SVGPatternElement> SVGPatternElement::create(Document& document) | 71 PassRefPtr<SVGPatternElement> SVGPatternElement::create(Document& document) |
| 72 { | 72 { |
| 73 return adoptRef(new SVGPatternElement(document)); | 73 return adoptRef(new SVGPatternElement(document)); |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool SVGPatternElement::isSupportedAttribute(const QualifiedName& attrName) | 76 bool SVGPatternElement::isSupportedAttribute(const QualifiedName& attrName) |
| 77 { | 77 { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 101 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes
::SVGUnitType>::fromString(value); | 101 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes
::SVGUnitType>::fromString(value); |
| 102 if (propertyValue > 0) | 102 if (propertyValue > 0) |
| 103 setPatternUnitsBaseValue(propertyValue); | 103 setPatternUnitsBaseValue(propertyValue); |
| 104 return; | 104 return; |
| 105 } else if (name == SVGNames::patternContentUnitsAttr) { | 105 } else if (name == SVGNames::patternContentUnitsAttr) { |
| 106 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes
::SVGUnitType>::fromString(value); | 106 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes
::SVGUnitType>::fromString(value); |
| 107 if (propertyValue > 0) | 107 if (propertyValue > 0) |
| 108 setPatternContentUnitsBaseValue(propertyValue); | 108 setPatternContentUnitsBaseValue(propertyValue); |
| 109 return; | 109 return; |
| 110 } else if (name == SVGNames::patternTransformAttr) { | 110 } else if (name == SVGNames::patternTransformAttr) { |
| 111 SVGTransformList newList; | 111 m_patternTransform->setBaseValueAsString(value, parseError); |
| 112 newList.parse(value); | |
| 113 detachAnimatedPatternTransformListWrappers(newList.size()); | |
| 114 setPatternTransformBaseValue(newList); | |
| 115 return; | |
| 116 } else if (name == SVGNames::xAttr) | 112 } else if (name == SVGNames::xAttr) |
| 117 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError); | 113 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
| 118 else if (name == SVGNames::yAttr) | 114 else if (name == SVGNames::yAttr) |
| 119 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError); | 115 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
| 120 else if (name == SVGNames::widthAttr) | 116 else if (name == SVGNames::widthAttr) |
| 121 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError); | 117 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError); |
| 122 else if (name == SVGNames::heightAttr) | 118 else if (name == SVGNames::heightAttr) |
| 123 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError)
; | 119 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError)
; |
| 124 else if (name.matches(XLinkNames::hrefAttr)) | 120 else if (name.matches(XLinkNames::hrefAttr)) |
| 125 m_href->setBaseValueAsString(value, parseError); | 121 m_href->setBaseValueAsString(value, parseError); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 182 |
| 187 if (!attributes.hasPreserveAspectRatio() && element->preserveAspectRatio()->
isSpecified()) | 183 if (!attributes.hasPreserveAspectRatio() && element->preserveAspectRatio()->
isSpecified()) |
| 188 attributes.setPreserveAspectRatio(element->preserveAspectRatio()->curren
tValue()); | 184 attributes.setPreserveAspectRatio(element->preserveAspectRatio()->curren
tValue()); |
| 189 | 185 |
| 190 if (!attributes.hasPatternUnits() && element->patternUnitsSpecified()) | 186 if (!attributes.hasPatternUnits() && element->patternUnitsSpecified()) |
| 191 attributes.setPatternUnits(element->patternUnitsCurrentValue()); | 187 attributes.setPatternUnits(element->patternUnitsCurrentValue()); |
| 192 | 188 |
| 193 if (!attributes.hasPatternContentUnits() && element->patternContentUnitsSpec
ified()) | 189 if (!attributes.hasPatternContentUnits() && element->patternContentUnitsSpec
ified()) |
| 194 attributes.setPatternContentUnits(element->patternContentUnitsCurrentVal
ue()); | 190 attributes.setPatternContentUnits(element->patternContentUnitsCurrentVal
ue()); |
| 195 | 191 |
| 196 if (!attributes.hasPatternTransform() && element->patternTransformSpecified(
)) { | 192 if (!attributes.hasPatternTransform() && element->patternTransform()->isSpec
ified()) { |
| 197 AffineTransform transform; | 193 AffineTransform transform; |
| 198 element->patternTransformCurrentValue().concatenate(transform); | 194 element->patternTransform()->currentValue()->concatenate(transform); |
| 199 attributes.setPatternTransform(transform); | 195 attributes.setPatternTransform(transform); |
| 200 } | 196 } |
| 201 | 197 |
| 202 if (!attributes.hasPatternContentElement() && element->childElementCount()) | 198 if (!attributes.hasPatternContentElement() && element->childElementCount()) |
| 203 attributes.setPatternContentElement(element); | 199 attributes.setPatternContentElement(element); |
| 204 } | 200 } |
| 205 | 201 |
| 206 void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes)
const | 202 void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes)
const |
| 207 { | 203 { |
| 208 HashSet<const SVGPatternElement*> processedPatterns; | 204 HashSet<const SVGPatternElement*> processedPatterns; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 224 return; | 220 return; |
| 225 } | 221 } |
| 226 } | 222 } |
| 227 | 223 |
| 228 ASSERT_NOT_REACHED(); | 224 ASSERT_NOT_REACHED(); |
| 229 } | 225 } |
| 230 | 226 |
| 231 AffineTransform SVGPatternElement::localCoordinateSpaceTransform(SVGElement::CTM
Scope) const | 227 AffineTransform SVGPatternElement::localCoordinateSpaceTransform(SVGElement::CTM
Scope) const |
| 232 { | 228 { |
| 233 AffineTransform matrix; | 229 AffineTransform matrix; |
| 234 patternTransformCurrentValue().concatenate(matrix); | 230 m_patternTransform->currentValue()->concatenate(matrix); |
| 235 return matrix; | 231 return matrix; |
| 236 } | 232 } |
| 237 | 233 |
| 238 bool SVGPatternElement::selfHasRelativeLengths() const | 234 bool SVGPatternElement::selfHasRelativeLengths() const |
| 239 { | 235 { |
| 240 return m_x->currentValue()->isRelative() | 236 return m_x->currentValue()->isRelative() |
| 241 || m_y->currentValue()->isRelative() | 237 || m_y->currentValue()->isRelative() |
| 242 || m_width->currentValue()->isRelative() | 238 || m_width->currentValue()->isRelative() |
| 243 || m_height->currentValue()->isRelative(); | 239 || m_height->currentValue()->isRelative(); |
| 244 } | 240 } |
| 245 | 241 |
| 246 } | 242 } |
| OLD | NEW |