OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006, 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) 2005 Alexander Kellett <lypanov@kde.org> | 4 * Copyright (C) 2005 Alexander Kellett <lypanov@kde.org> |
5 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 5 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
6 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "core/svg/SVGMaskElement.h" | 26 #include "core/svg/SVGMaskElement.h" |
27 | 27 |
28 #include "core/rendering/svg/RenderSVGResourceMasker.h" | 28 #include "core/rendering/svg/RenderSVGResourceMasker.h" |
29 #include "core/svg/SVGElementInstance.h" | 29 #include "core/svg/SVGElementInstance.h" |
30 | 30 |
31 namespace WebCore { | 31 namespace WebCore { |
32 | 32 |
33 // Animated property definitions | 33 // Animated property definitions |
34 DEFINE_ANIMATED_ENUMERATION(SVGMaskElement, SVGNames::maskUnitsAttr, MaskUnits,
maskUnits, SVGUnitTypes::SVGUnitType) | 34 DEFINE_ANIMATED_ENUMERATION(SVGMaskElement, SVGNames::maskUnitsAttr, MaskUnits,
maskUnits, SVGUnitTypes::SVGUnitType) |
35 DEFINE_ANIMATED_ENUMERATION(SVGMaskElement, SVGNames::maskContentUnitsAttr, Mask
ContentUnits, maskContentUnits, SVGUnitTypes::SVGUnitType) | 35 DEFINE_ANIMATED_ENUMERATION(SVGMaskElement, SVGNames::maskContentUnitsAttr, Mask
ContentUnits, maskContentUnits, SVGUnitTypes::SVGUnitType) |
36 DEFINE_ANIMATED_LENGTH(SVGMaskElement, SVGNames::xAttr, X, x) | |
37 DEFINE_ANIMATED_LENGTH(SVGMaskElement, SVGNames::yAttr, Y, y) | |
38 DEFINE_ANIMATED_LENGTH(SVGMaskElement, SVGNames::widthAttr, Width, width) | |
39 DEFINE_ANIMATED_LENGTH(SVGMaskElement, SVGNames::heightAttr, Height, height) | |
40 DEFINE_ANIMATED_BOOLEAN(SVGMaskElement, SVGNames::externalResourcesRequiredAttr,
ExternalResourcesRequired, externalResourcesRequired) | 36 DEFINE_ANIMATED_BOOLEAN(SVGMaskElement, SVGNames::externalResourcesRequiredAttr,
ExternalResourcesRequired, externalResourcesRequired) |
41 | 37 |
42 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGMaskElement) | 38 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGMaskElement) |
43 REGISTER_LOCAL_ANIMATED_PROPERTY(maskUnits) | 39 REGISTER_LOCAL_ANIMATED_PROPERTY(maskUnits) |
44 REGISTER_LOCAL_ANIMATED_PROPERTY(maskContentUnits) | 40 REGISTER_LOCAL_ANIMATED_PROPERTY(maskContentUnits) |
45 REGISTER_LOCAL_ANIMATED_PROPERTY(x) | |
46 REGISTER_LOCAL_ANIMATED_PROPERTY(y) | |
47 REGISTER_LOCAL_ANIMATED_PROPERTY(width) | |
48 REGISTER_LOCAL_ANIMATED_PROPERTY(height) | |
49 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) | 41 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) |
50 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) | 42 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) |
51 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTests) | 43 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTests) |
52 END_REGISTER_ANIMATED_PROPERTIES | 44 END_REGISTER_ANIMATED_PROPERTIES |
53 | 45 |
54 inline SVGMaskElement::SVGMaskElement(Document& document) | 46 inline SVGMaskElement::SVGMaskElement(Document& document) |
55 : SVGElement(SVGNames::maskTag, document) | 47 : SVGElement(SVGNames::maskTag, document) |
| 48 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth))) |
| 49 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight))) |
| 50 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth))) |
| 51 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight))) |
56 , m_maskUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) | 52 , m_maskUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) |
57 , m_maskContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) | 53 , m_maskContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) |
58 , m_x(LengthModeWidth, "-10%") | |
59 , m_y(LengthModeHeight, "-10%") | |
60 , m_width(LengthModeWidth, "120%") | |
61 , m_height(LengthModeHeight, "120%") | |
62 { | 54 { |
| 55 ScriptWrappable::init(this); |
| 56 |
63 // Spec: If the x/y attribute is not specified, the effect is as if a value
of "-10%" were specified. | 57 // Spec: If the x/y attribute is not specified, the effect is as if a value
of "-10%" were specified. |
| 58 m_x->setDefaultValueAsString("-10%"); |
| 59 m_y->setDefaultValueAsString("-10%"); |
| 60 |
64 // Spec: If the width/height attribute is not specified, the effect is as if
a value of "120%" were specified. | 61 // Spec: If the width/height attribute is not specified, the effect is as if
a value of "120%" were specified. |
65 ScriptWrappable::init(this); | 62 m_width->setDefaultValueAsString("120%"); |
| 63 m_height->setDefaultValueAsString("120%"); |
| 64 |
| 65 addToPropertyMap(m_x); |
| 66 addToPropertyMap(m_y); |
| 67 addToPropertyMap(m_width); |
| 68 addToPropertyMap(m_height); |
66 registerAnimatedPropertiesForSVGMaskElement(); | 69 registerAnimatedPropertiesForSVGMaskElement(); |
67 } | 70 } |
68 | 71 |
69 PassRefPtr<SVGMaskElement> SVGMaskElement::create(Document& document) | 72 PassRefPtr<SVGMaskElement> SVGMaskElement::create(Document& document) |
70 { | 73 { |
71 return adoptRef(new SVGMaskElement(document)); | 74 return adoptRef(new SVGMaskElement(document)); |
72 } | 75 } |
73 | 76 |
74 bool SVGMaskElement::isSupportedAttribute(const QualifiedName& attrName) | 77 bool SVGMaskElement::isSupportedAttribute(const QualifiedName& attrName) |
75 { | 78 { |
(...skipping 21 matching lines...) Expand all Loading... |
97 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes
::SVGUnitType>::fromString(value); | 100 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes
::SVGUnitType>::fromString(value); |
98 if (propertyValue > 0) | 101 if (propertyValue > 0) |
99 setMaskUnitsBaseValue(propertyValue); | 102 setMaskUnitsBaseValue(propertyValue); |
100 return; | 103 return; |
101 } else if (name == SVGNames::maskContentUnitsAttr) { | 104 } else if (name == SVGNames::maskContentUnitsAttr) { |
102 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes
::SVGUnitType>::fromString(value); | 105 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes
::SVGUnitType>::fromString(value); |
103 if (propertyValue > 0) | 106 if (propertyValue > 0) |
104 setMaskContentUnitsBaseValue(propertyValue); | 107 setMaskContentUnitsBaseValue(propertyValue); |
105 return; | 108 return; |
106 } else if (name == SVGNames::xAttr) | 109 } else if (name == SVGNames::xAttr) |
107 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); | 110 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
108 else if (name == SVGNames::yAttr) | 111 else if (name == SVGNames::yAttr) |
109 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError))
; | 112 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
110 else if (name == SVGNames::widthAttr) | 113 else if (name == SVGNames::widthAttr) |
111 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro
r)); | 114 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError); |
112 else if (name == SVGNames::heightAttr) | 115 else if (name == SVGNames::heightAttr) |
113 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr
ror)); | 116 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError)
; |
114 else if (SVGTests::parseAttribute(name, value) | 117 else if (SVGTests::parseAttribute(name, value) |
115 || SVGExternalResourcesRequired::parseAttribute(name, value)) { | 118 || SVGExternalResourcesRequired::parseAttribute(name, value)) { |
116 } else | 119 } else |
117 ASSERT_NOT_REACHED(); | 120 ASSERT_NOT_REACHED(); |
118 | 121 |
119 reportAttributeParsingError(parseError, name, value); | 122 reportAttributeParsingError(parseError, name, value); |
120 } | 123 } |
121 | 124 |
122 void SVGMaskElement::svgAttributeChanged(const QualifiedName& attrName) | 125 void SVGMaskElement::svgAttributeChanged(const QualifiedName& attrName) |
123 { | 126 { |
(...skipping 26 matching lines...) Expand all Loading... |
150 object->setNeedsLayout(); | 153 object->setNeedsLayout(); |
151 } | 154 } |
152 | 155 |
153 RenderObject* SVGMaskElement::createRenderer(RenderStyle*) | 156 RenderObject* SVGMaskElement::createRenderer(RenderStyle*) |
154 { | 157 { |
155 return new RenderSVGResourceMasker(this); | 158 return new RenderSVGResourceMasker(this); |
156 } | 159 } |
157 | 160 |
158 bool SVGMaskElement::selfHasRelativeLengths() const | 161 bool SVGMaskElement::selfHasRelativeLengths() const |
159 { | 162 { |
160 return xCurrentValue().isRelative() | 163 return m_x->currentValue()->isRelative() |
161 || yCurrentValue().isRelative() | 164 || m_y->currentValue()->isRelative() |
162 || widthCurrentValue().isRelative() | 165 || m_width->currentValue()->isRelative() |
163 || heightCurrentValue().isRelative(); | 166 || m_height->currentValue()->isRelative(); |
164 } | 167 } |
165 | 168 |
166 } | 169 } |
OLD | NEW |