| 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 #include "XLinkNames.h" | 26 #include "XLinkNames.h" |
| 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_LENGTH(SVGPatternElement, SVGNames::xAttr, X, x) | |
| 36 DEFINE_ANIMATED_LENGTH(SVGPatternElement, SVGNames::yAttr, Y, y) | |
| 37 DEFINE_ANIMATED_LENGTH(SVGPatternElement, SVGNames::widthAttr, Width, width) | |
| 38 DEFINE_ANIMATED_LENGTH(SVGPatternElement, SVGNames::heightAttr, Height, height) | |
| 39 DEFINE_ANIMATED_ENUMERATION(SVGPatternElement, SVGNames::patternUnitsAttr, Patte
rnUnits, patternUnits, SVGUnitTypes::SVGUnitType) | 35 DEFINE_ANIMATED_ENUMERATION(SVGPatternElement, SVGNames::patternUnitsAttr, Patte
rnUnits, patternUnits, SVGUnitTypes::SVGUnitType) |
| 40 DEFINE_ANIMATED_ENUMERATION(SVGPatternElement, SVGNames::patternContentUnitsAttr
, PatternContentUnits, patternContentUnits, SVGUnitTypes::SVGUnitType) | 36 DEFINE_ANIMATED_ENUMERATION(SVGPatternElement, SVGNames::patternContentUnitsAttr
, PatternContentUnits, patternContentUnits, SVGUnitTypes::SVGUnitType) |
| 41 DEFINE_ANIMATED_TRANSFORM_LIST(SVGPatternElement, SVGNames::patternTransformAttr
, PatternTransform, patternTransform) | 37 DEFINE_ANIMATED_TRANSFORM_LIST(SVGPatternElement, SVGNames::patternTransformAttr
, PatternTransform, patternTransform) |
| 42 DEFINE_ANIMATED_STRING(SVGPatternElement, XLinkNames::hrefAttr, Href, href) | 38 DEFINE_ANIMATED_STRING(SVGPatternElement, XLinkNames::hrefAttr, Href, href) |
| 43 DEFINE_ANIMATED_BOOLEAN(SVGPatternElement, SVGNames::externalResourcesRequiredAt
tr, ExternalResourcesRequired, externalResourcesRequired) | 39 DEFINE_ANIMATED_BOOLEAN(SVGPatternElement, SVGNames::externalResourcesRequiredAt
tr, ExternalResourcesRequired, externalResourcesRequired) |
| 44 DEFINE_ANIMATED_RECT(SVGPatternElement, SVGNames::viewBoxAttr, ViewBox, viewBox) | 40 DEFINE_ANIMATED_RECT(SVGPatternElement, SVGNames::viewBoxAttr, ViewBox, viewBox) |
| 45 DEFINE_ANIMATED_PRESERVEASPECTRATIO(SVGPatternElement, SVGNames::preserveAspectR
atioAttr, PreserveAspectRatio, preserveAspectRatio) | 41 DEFINE_ANIMATED_PRESERVEASPECTRATIO(SVGPatternElement, SVGNames::preserveAspectR
atioAttr, PreserveAspectRatio, preserveAspectRatio) |
| 46 | 42 |
| 47 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGPatternElement) | 43 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGPatternElement) |
| 48 REGISTER_LOCAL_ANIMATED_PROPERTY(x) | |
| 49 REGISTER_LOCAL_ANIMATED_PROPERTY(y) | |
| 50 REGISTER_LOCAL_ANIMATED_PROPERTY(width) | |
| 51 REGISTER_LOCAL_ANIMATED_PROPERTY(height) | |
| 52 REGISTER_LOCAL_ANIMATED_PROPERTY(patternUnits) | 44 REGISTER_LOCAL_ANIMATED_PROPERTY(patternUnits) |
| 53 REGISTER_LOCAL_ANIMATED_PROPERTY(patternContentUnits) | 45 REGISTER_LOCAL_ANIMATED_PROPERTY(patternContentUnits) |
| 54 REGISTER_LOCAL_ANIMATED_PROPERTY(patternTransform) | 46 REGISTER_LOCAL_ANIMATED_PROPERTY(patternTransform) |
| 55 REGISTER_LOCAL_ANIMATED_PROPERTY(href) | 47 REGISTER_LOCAL_ANIMATED_PROPERTY(href) |
| 56 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) | 48 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) |
| 57 REGISTER_LOCAL_ANIMATED_PROPERTY(viewBox) | 49 REGISTER_LOCAL_ANIMATED_PROPERTY(viewBox) |
| 58 REGISTER_LOCAL_ANIMATED_PROPERTY(preserveAspectRatio) | 50 REGISTER_LOCAL_ANIMATED_PROPERTY(preserveAspectRatio) |
| 59 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) | 51 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) |
| 60 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTests) | 52 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTests) |
| 61 END_REGISTER_ANIMATED_PROPERTIES | 53 END_REGISTER_ANIMATED_PROPERTIES |
| 62 | 54 |
| 63 inline SVGPatternElement::SVGPatternElement(Document& document) | 55 inline SVGPatternElement::SVGPatternElement(Document& document) |
| 64 : SVGElement(SVGNames::patternTag, document) | 56 : SVGElement(SVGNames::patternTag, document) |
| 65 , m_x(LengthModeWidth) | 57 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth))) |
| 66 , m_y(LengthModeHeight) | 58 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight))) |
| 67 , m_width(LengthModeWidth) | 59 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth))) |
| 68 , m_height(LengthModeHeight) | 60 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight))) |
| 69 , m_patternUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) | 61 , m_patternUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) |
| 70 , m_patternContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) | 62 , m_patternContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) |
| 71 { | 63 { |
| 72 ScriptWrappable::init(this); | 64 ScriptWrappable::init(this); |
| 65 |
| 66 addToPropertyMap(m_x); |
| 67 addToPropertyMap(m_y); |
| 68 addToPropertyMap(m_width); |
| 69 addToPropertyMap(m_height); |
| 73 registerAnimatedPropertiesForSVGPatternElement(); | 70 registerAnimatedPropertiesForSVGPatternElement(); |
| 74 } | 71 } |
| 75 | 72 |
| 76 PassRefPtr<SVGPatternElement> SVGPatternElement::create(Document& document) | 73 PassRefPtr<SVGPatternElement> SVGPatternElement::create(Document& document) |
| 77 { | 74 { |
| 78 return adoptRef(new SVGPatternElement(document)); | 75 return adoptRef(new SVGPatternElement(document)); |
| 79 } | 76 } |
| 80 | 77 |
| 81 bool SVGPatternElement::isSupportedAttribute(const QualifiedName& attrName) | 78 bool SVGPatternElement::isSupportedAttribute(const QualifiedName& attrName) |
| 82 { | 79 { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 113 if (propertyValue > 0) | 110 if (propertyValue > 0) |
| 114 setPatternContentUnitsBaseValue(propertyValue); | 111 setPatternContentUnitsBaseValue(propertyValue); |
| 115 return; | 112 return; |
| 116 } else if (name == SVGNames::patternTransformAttr) { | 113 } else if (name == SVGNames::patternTransformAttr) { |
| 117 SVGTransformList newList; | 114 SVGTransformList newList; |
| 118 newList.parse(value); | 115 newList.parse(value); |
| 119 detachAnimatedPatternTransformListWrappers(newList.size()); | 116 detachAnimatedPatternTransformListWrappers(newList.size()); |
| 120 setPatternTransformBaseValue(newList); | 117 setPatternTransformBaseValue(newList); |
| 121 return; | 118 return; |
| 122 } else if (name == SVGNames::xAttr) | 119 } else if (name == SVGNames::xAttr) |
| 123 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); | 120 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
| 124 else if (name == SVGNames::yAttr) | 121 else if (name == SVGNames::yAttr) |
| 125 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError))
; | 122 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
| 126 else if (name == SVGNames::widthAttr) | 123 else if (name == SVGNames::widthAttr) |
| 127 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro
r, ForbidNegativeLengths)); | 124 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError); |
| 128 else if (name == SVGNames::heightAttr) | 125 else if (name == SVGNames::heightAttr) |
| 129 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr
ror, ForbidNegativeLengths)); | 126 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError)
; |
| 130 else if (SVGURIReference::parseAttribute(name, value) | 127 else if (SVGURIReference::parseAttribute(name, value) |
| 131 || SVGTests::parseAttribute(name, value) | 128 || SVGTests::parseAttribute(name, value) |
| 132 || SVGExternalResourcesRequired::parseAttribute(name, value) | 129 || SVGExternalResourcesRequired::parseAttribute(name, value) |
| 133 || SVGFitToViewBox::parseAttribute(this, name, value)) { | 130 || SVGFitToViewBox::parseAttribute(this, name, value)) { |
| 134 } else | 131 } else |
| 135 ASSERT_NOT_REACHED(); | 132 ASSERT_NOT_REACHED(); |
| 136 | 133 |
| 137 reportAttributeParsingError(parseError, name, value); | 134 reportAttributeParsingError(parseError, name, value); |
| 138 } | 135 } |
| 139 | 136 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 return new RenderSVGResourcePattern(this); | 170 return new RenderSVGResourcePattern(this); |
| 174 } | 171 } |
| 175 | 172 |
| 176 void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes)
const | 173 void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes)
const |
| 177 { | 174 { |
| 178 HashSet<const SVGPatternElement*> processedPatterns; | 175 HashSet<const SVGPatternElement*> processedPatterns; |
| 179 | 176 |
| 180 const SVGPatternElement* current = this; | 177 const SVGPatternElement* current = this; |
| 181 while (current) { | 178 while (current) { |
| 182 if (!attributes.hasX() && current->hasAttribute(SVGNames::xAttr)) | 179 if (!attributes.hasX() && current->hasAttribute(SVGNames::xAttr)) |
| 183 attributes.setX(current->xCurrentValue()); | 180 attributes.setX(current->x()->currentValue()); |
| 184 | 181 |
| 185 if (!attributes.hasY() && current->hasAttribute(SVGNames::yAttr)) | 182 if (!attributes.hasY() && current->hasAttribute(SVGNames::yAttr)) |
| 186 attributes.setY(current->yCurrentValue()); | 183 attributes.setY(current->y()->currentValue()); |
| 187 | 184 |
| 188 if (!attributes.hasWidth() && current->hasAttribute(SVGNames::widthAttr)
) | 185 if (!attributes.hasWidth() && current->hasAttribute(SVGNames::widthAttr)
) |
| 189 attributes.setWidth(current->widthCurrentValue()); | 186 attributes.setWidth(current->width()->currentValue()); |
| 190 | 187 |
| 191 if (!attributes.hasHeight() && current->hasAttribute(SVGNames::heightAtt
r)) | 188 if (!attributes.hasHeight() && current->hasAttribute(SVGNames::heightAtt
r)) |
| 192 attributes.setHeight(current->heightCurrentValue()); | 189 attributes.setHeight(current->height()->currentValue()); |
| 193 | 190 |
| 194 if (!attributes.hasViewBox() && current->hasAttribute(SVGNames::viewBoxA
ttr) && current->viewBoxCurrentValue().isValid()) | 191 if (!attributes.hasViewBox() && current->hasAttribute(SVGNames::viewBoxA
ttr) && current->viewBoxCurrentValue().isValid()) |
| 195 attributes.setViewBox(current->viewBoxCurrentValue()); | 192 attributes.setViewBox(current->viewBoxCurrentValue()); |
| 196 | 193 |
| 197 if (!attributes.hasPreserveAspectRatio() && current->hasAttribute(SVGNam
es::preserveAspectRatioAttr)) | 194 if (!attributes.hasPreserveAspectRatio() && current->hasAttribute(SVGNam
es::preserveAspectRatioAttr)) |
| 198 attributes.setPreserveAspectRatio(current->preserveAspectRatioCurren
tValue()); | 195 attributes.setPreserveAspectRatio(current->preserveAspectRatioCurren
tValue()); |
| 199 | 196 |
| 200 if (!attributes.hasPatternUnits() && current->hasAttribute(SVGNames::pat
ternUnitsAttr)) | 197 if (!attributes.hasPatternUnits() && current->hasAttribute(SVGNames::pat
ternUnitsAttr)) |
| 201 attributes.setPatternUnits(current->patternUnitsCurrentValue()); | 198 attributes.setPatternUnits(current->patternUnitsCurrentValue()); |
| 202 | 199 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 231 | 228 |
| 232 AffineTransform SVGPatternElement::localCoordinateSpaceTransform(SVGElement::CTM
Scope) const | 229 AffineTransform SVGPatternElement::localCoordinateSpaceTransform(SVGElement::CTM
Scope) const |
| 233 { | 230 { |
| 234 AffineTransform matrix; | 231 AffineTransform matrix; |
| 235 patternTransformCurrentValue().concatenate(matrix); | 232 patternTransformCurrentValue().concatenate(matrix); |
| 236 return matrix; | 233 return matrix; |
| 237 } | 234 } |
| 238 | 235 |
| 239 bool SVGPatternElement::selfHasRelativeLengths() const | 236 bool SVGPatternElement::selfHasRelativeLengths() const |
| 240 { | 237 { |
| 241 return xCurrentValue().isRelative() | 238 return m_x->currentValue()->isRelative() |
| 242 || yCurrentValue().isRelative() | 239 || m_y->currentValue()->isRelative() |
| 243 || widthCurrentValue().isRelative() | 240 || m_width->currentValue()->isRelative() |
| 244 || heightCurrentValue().isRelative(); | 241 || m_height->currentValue()->isRelative(); |
| 245 } | 242 } |
| 246 | 243 |
| 247 } | 244 } |
| OLD | NEW |