| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 DEFINE_ANIMATED_BOOLEAN(SVGMaskElement, SVGNames::externalResourcesRequiredAttr,
ExternalResourcesRequired, externalResourcesRequired) | 42 DEFINE_ANIMATED_BOOLEAN(SVGMaskElement, SVGNames::externalResourcesRequiredAttr,
ExternalResourcesRequired, externalResourcesRequired) |
| 43 | 43 |
| 44 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGMaskElement) | 44 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGMaskElement) |
| 45 REGISTER_LOCAL_ANIMATED_PROPERTY(maskUnits) | 45 REGISTER_LOCAL_ANIMATED_PROPERTY(maskUnits) |
| 46 REGISTER_LOCAL_ANIMATED_PROPERTY(maskContentUnits) | 46 REGISTER_LOCAL_ANIMATED_PROPERTY(maskContentUnits) |
| 47 REGISTER_LOCAL_ANIMATED_PROPERTY(x) | 47 REGISTER_LOCAL_ANIMATED_PROPERTY(x) |
| 48 REGISTER_LOCAL_ANIMATED_PROPERTY(y) | 48 REGISTER_LOCAL_ANIMATED_PROPERTY(y) |
| 49 REGISTER_LOCAL_ANIMATED_PROPERTY(width) | 49 REGISTER_LOCAL_ANIMATED_PROPERTY(width) |
| 50 REGISTER_LOCAL_ANIMATED_PROPERTY(height) | 50 REGISTER_LOCAL_ANIMATED_PROPERTY(height) |
| 51 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) | 51 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) |
| 52 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGStyledElement) | 52 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) |
| 53 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTests) | 53 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTests) |
| 54 END_REGISTER_ANIMATED_PROPERTIES | 54 END_REGISTER_ANIMATED_PROPERTIES |
| 55 | 55 |
| 56 inline SVGMaskElement::SVGMaskElement(const QualifiedName& tagName, Document* do
cument) | 56 inline SVGMaskElement::SVGMaskElement(const QualifiedName& tagName, Document* do
cument) |
| 57 : SVGStyledElement(tagName, document) | 57 : SVGElement(tagName, document) |
| 58 , m_maskUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) | 58 , m_maskUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) |
| 59 , m_maskContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) | 59 , m_maskContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) |
| 60 , m_x(LengthModeWidth, "-10%") | 60 , m_x(LengthModeWidth, "-10%") |
| 61 , m_y(LengthModeHeight, "-10%") | 61 , m_y(LengthModeHeight, "-10%") |
| 62 , m_width(LengthModeWidth, "120%") | 62 , m_width(LengthModeWidth, "120%") |
| 63 , m_height(LengthModeHeight, "120%") | 63 , m_height(LengthModeHeight, "120%") |
| 64 { | 64 { |
| 65 // Spec: If the x/y attribute is not specified, the effect is as if a value
of "-10%" were specified. | 65 // Spec: If the x/y attribute is not specified, the effect is as if a value
of "-10%" were specified. |
| 66 // Spec: If the width/height attribute is not specified, the effect is as if
a value of "120%" were specified. | 66 // Spec: If the width/height attribute is not specified, the effect is as if
a value of "120%" were specified. |
| 67 ASSERT(hasTagName(SVGNames::maskTag)); | 67 ASSERT(hasTagName(SVGNames::maskTag)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 88 supportedAttributes.add(SVGNames::heightAttr); | 88 supportedAttributes.add(SVGNames::heightAttr); |
| 89 } | 89 } |
| 90 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 90 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void SVGMaskElement::parseAttribute(const QualifiedName& name, const AtomicStrin
g& value) | 93 void SVGMaskElement::parseAttribute(const QualifiedName& name, const AtomicStrin
g& value) |
| 94 { | 94 { |
| 95 SVGParsingError parseError = NoError; | 95 SVGParsingError parseError = NoError; |
| 96 | 96 |
| 97 if (!isSupportedAttribute(name)) | 97 if (!isSupportedAttribute(name)) |
| 98 SVGStyledElement::parseAttribute(name, value); | 98 SVGElement::parseAttribute(name, value); |
| 99 else if (name == SVGNames::maskUnitsAttr) { | 99 else if (name == SVGNames::maskUnitsAttr) { |
| 100 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes
::SVGUnitType>::fromString(value); | 100 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes
::SVGUnitType>::fromString(value); |
| 101 if (propertyValue > 0) | 101 if (propertyValue > 0) |
| 102 setMaskUnitsBaseValue(propertyValue); | 102 setMaskUnitsBaseValue(propertyValue); |
| 103 return; | 103 return; |
| 104 } else if (name == SVGNames::maskContentUnitsAttr) { | 104 } else if (name == SVGNames::maskContentUnitsAttr) { |
| 105 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes
::SVGUnitType>::fromString(value); | 105 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes
::SVGUnitType>::fromString(value); |
| 106 if (propertyValue > 0) | 106 if (propertyValue > 0) |
| 107 setMaskContentUnitsBaseValue(propertyValue); | 107 setMaskContentUnitsBaseValue(propertyValue); |
| 108 return; | 108 return; |
| 109 } else if (name == SVGNames::xAttr) | 109 } else if (name == SVGNames::xAttr) |
| 110 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); | 110 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); |
| 111 else if (name == SVGNames::yAttr) | 111 else if (name == SVGNames::yAttr) |
| 112 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError))
; | 112 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError))
; |
| 113 else if (name == SVGNames::widthAttr) | 113 else if (name == SVGNames::widthAttr) |
| 114 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro
r)); | 114 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro
r)); |
| 115 else if (name == SVGNames::heightAttr) | 115 else if (name == SVGNames::heightAttr) |
| 116 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr
ror)); | 116 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr
ror)); |
| 117 else if (SVGTests::parseAttribute(name, value) | 117 else if (SVGTests::parseAttribute(name, value) |
| 118 || SVGExternalResourcesRequired::parseAttribute(name, value)) { | 118 || SVGExternalResourcesRequired::parseAttribute(name, value)) { |
| 119 } else | 119 } else |
| 120 ASSERT_NOT_REACHED(); | 120 ASSERT_NOT_REACHED(); |
| 121 | 121 |
| 122 reportAttributeParsingError(parseError, name, value); | 122 reportAttributeParsingError(parseError, name, value); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void SVGMaskElement::svgAttributeChanged(const QualifiedName& attrName) | 125 void SVGMaskElement::svgAttributeChanged(const QualifiedName& attrName) |
| 126 { | 126 { |
| 127 if (!isSupportedAttribute(attrName)) { | 127 if (!isSupportedAttribute(attrName)) { |
| 128 SVGStyledElement::svgAttributeChanged(attrName); | 128 SVGElement::svgAttributeChanged(attrName); |
| 129 return; | 129 return; |
| 130 } | 130 } |
| 131 | 131 |
| 132 SVGElementInstance::InvalidationGuard invalidationGuard(this); | 132 SVGElementInstance::InvalidationGuard invalidationGuard(this); |
| 133 | 133 |
| 134 if (attrName == SVGNames::xAttr | 134 if (attrName == SVGNames::xAttr |
| 135 || attrName == SVGNames::yAttr | 135 || attrName == SVGNames::yAttr |
| 136 || attrName == SVGNames::widthAttr | 136 || attrName == SVGNames::widthAttr |
| 137 || attrName == SVGNames::heightAttr) | 137 || attrName == SVGNames::heightAttr) |
| 138 updateRelativeLengthsInformation(); | 138 updateRelativeLengthsInformation(); |
| 139 | 139 |
| 140 if (RenderObject* object = renderer()) | 140 if (RenderObject* object = renderer()) |
| 141 object->setNeedsLayout(true); | 141 object->setNeedsLayout(true); |
| 142 } | 142 } |
| 143 | 143 |
| 144 void SVGMaskElement::childrenChanged(bool changedByParser, Node* beforeChange, N
ode* afterChange, int childCountDelta) | 144 void SVGMaskElement::childrenChanged(bool changedByParser, Node* beforeChange, N
ode* afterChange, int childCountDelta) |
| 145 { | 145 { |
| 146 SVGStyledElement::childrenChanged(changedByParser, beforeChange, afterChange
, childCountDelta); | 146 SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, chil
dCountDelta); |
| 147 | 147 |
| 148 if (changedByParser) | 148 if (changedByParser) |
| 149 return; | 149 return; |
| 150 | 150 |
| 151 if (RenderObject* object = renderer()) | 151 if (RenderObject* object = renderer()) |
| 152 object->setNeedsLayout(true); | 152 object->setNeedsLayout(true); |
| 153 } | 153 } |
| 154 | 154 |
| 155 RenderObject* SVGMaskElement::createRenderer(RenderStyle*) | 155 RenderObject* SVGMaskElement::createRenderer(RenderStyle*) |
| 156 { | 156 { |
| 157 return new RenderSVGResourceMasker(this); | 157 return new RenderSVGResourceMasker(this); |
| 158 } | 158 } |
| 159 | 159 |
| 160 bool SVGMaskElement::selfHasRelativeLengths() const | 160 bool SVGMaskElement::selfHasRelativeLengths() const |
| 161 { | 161 { |
| 162 return xCurrentValue().isRelative() | 162 return xCurrentValue().isRelative() |
| 163 || yCurrentValue().isRelative() | 163 || yCurrentValue().isRelative() |
| 164 || widthCurrentValue().isRelative() | 164 || widthCurrentValue().isRelative() |
| 165 || heightCurrentValue().isRelative(); | 165 || heightCurrentValue().isRelative(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 } | 168 } |
| OLD | NEW |