Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(642)

Side by Side Diff: Source/core/svg/SVGMaskElement.cpp

Issue 112003003: [SVG] SVGLength{,List} migration to new SVG property impl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: revert aggressive svgAttributeChanged, add NeedsRebaseline Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/svg/SVGMaskElement.h ('k') | Source/core/svg/SVGPatternElement.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 36
41 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGMaskElement) 37 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGMaskElement)
42 REGISTER_LOCAL_ANIMATED_PROPERTY(maskUnits) 38 REGISTER_LOCAL_ANIMATED_PROPERTY(maskUnits)
43 REGISTER_LOCAL_ANIMATED_PROPERTY(maskContentUnits) 39 REGISTER_LOCAL_ANIMATED_PROPERTY(maskContentUnits)
44 REGISTER_LOCAL_ANIMATED_PROPERTY(x)
45 REGISTER_LOCAL_ANIMATED_PROPERTY(y)
46 REGISTER_LOCAL_ANIMATED_PROPERTY(width)
47 REGISTER_LOCAL_ANIMATED_PROPERTY(height)
48 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) 40 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement)
49 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTests) 41 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTests)
50 END_REGISTER_ANIMATED_PROPERTIES 42 END_REGISTER_ANIMATED_PROPERTIES
51 43
52 inline SVGMaskElement::SVGMaskElement(Document& document) 44 inline SVGMaskElement::SVGMaskElement(Document& document)
53 : SVGElement(SVGNames::maskTag, document) 45 : SVGElement(SVGNames::maskTag, document)
46 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len gthModeWidth)))
47 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len gthModeHeight)))
48 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr eate(LengthModeWidth)))
49 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength:: create(LengthModeHeight)))
54 , m_maskUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) 50 , m_maskUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
55 , m_maskContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) 51 , m_maskContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE)
56 , m_x(LengthModeWidth, "-10%")
57 , m_y(LengthModeHeight, "-10%")
58 , m_width(LengthModeWidth, "120%")
59 , m_height(LengthModeHeight, "120%")
60 { 52 {
53 ScriptWrappable::init(this);
54
61 // Spec: If the x/y attribute is not specified, the effect is as if a value of "-10%" were specified. 55 // Spec: If the x/y attribute is not specified, the effect is as if a value of "-10%" were specified.
56 m_x->setDefaultValueAsString("-10%");
57 m_y->setDefaultValueAsString("-10%");
58
62 // Spec: If the width/height attribute is not specified, the effect is as if a value of "120%" were specified. 59 // Spec: If the width/height attribute is not specified, the effect is as if a value of "120%" were specified.
63 ScriptWrappable::init(this); 60 m_width->setDefaultValueAsString("120%");
61 m_height->setDefaultValueAsString("120%");
62
63 addToPropertyMap(m_x);
64 addToPropertyMap(m_y);
65 addToPropertyMap(m_width);
66 addToPropertyMap(m_height);
64 registerAnimatedPropertiesForSVGMaskElement(); 67 registerAnimatedPropertiesForSVGMaskElement();
65 } 68 }
66 69
67 PassRefPtr<SVGMaskElement> SVGMaskElement::create(Document& document) 70 PassRefPtr<SVGMaskElement> SVGMaskElement::create(Document& document)
68 { 71 {
69 return adoptRef(new SVGMaskElement(document)); 72 return adoptRef(new SVGMaskElement(document));
70 } 73 }
71 74
72 bool SVGMaskElement::isSupportedAttribute(const QualifiedName& attrName) 75 bool SVGMaskElement::isSupportedAttribute(const QualifiedName& attrName)
73 { 76 {
(...skipping 20 matching lines...) Expand all
94 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes ::SVGUnitType>::fromString(value); 97 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes ::SVGUnitType>::fromString(value);
95 if (propertyValue > 0) 98 if (propertyValue > 0)
96 setMaskUnitsBaseValue(propertyValue); 99 setMaskUnitsBaseValue(propertyValue);
97 return; 100 return;
98 } else if (name == SVGNames::maskContentUnitsAttr) { 101 } else if (name == SVGNames::maskContentUnitsAttr) {
99 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes ::SVGUnitType>::fromString(value); 102 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes ::SVGUnitType>::fromString(value);
100 if (propertyValue > 0) 103 if (propertyValue > 0)
101 setMaskContentUnitsBaseValue(propertyValue); 104 setMaskContentUnitsBaseValue(propertyValue);
102 return; 105 return;
103 } else if (name == SVGNames::xAttr) 106 } else if (name == SVGNames::xAttr)
104 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); 107 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError);
105 else if (name == SVGNames::yAttr) 108 else if (name == SVGNames::yAttr)
106 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError)) ; 109 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError);
107 else if (name == SVGNames::widthAttr) 110 else if (name == SVGNames::widthAttr)
108 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro r)); 111 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError);
109 else if (name == SVGNames::heightAttr) 112 else if (name == SVGNames::heightAttr)
110 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr ror)); 113 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError) ;
111 else if (SVGTests::parseAttribute(name, value)) { 114 else if (SVGTests::parseAttribute(name, value)) {
112 } else 115 } else
113 ASSERT_NOT_REACHED(); 116 ASSERT_NOT_REACHED();
114 117
115 reportAttributeParsingError(parseError, name, value); 118 reportAttributeParsingError(parseError, name, value);
116 } 119 }
117 120
118 void SVGMaskElement::svgAttributeChanged(const QualifiedName& attrName) 121 void SVGMaskElement::svgAttributeChanged(const QualifiedName& attrName)
119 { 122 {
120 if (!isSupportedAttribute(attrName)) { 123 if (!isSupportedAttribute(attrName)) {
(...skipping 25 matching lines...) Expand all
146 object->setNeedsLayout(); 149 object->setNeedsLayout();
147 } 150 }
148 151
149 RenderObject* SVGMaskElement::createRenderer(RenderStyle*) 152 RenderObject* SVGMaskElement::createRenderer(RenderStyle*)
150 { 153 {
151 return new RenderSVGResourceMasker(this); 154 return new RenderSVGResourceMasker(this);
152 } 155 }
153 156
154 bool SVGMaskElement::selfHasRelativeLengths() const 157 bool SVGMaskElement::selfHasRelativeLengths() const
155 { 158 {
156 return xCurrentValue().isRelative() 159 return m_x->currentValue()->isRelative()
157 || yCurrentValue().isRelative() 160 || m_y->currentValue()->isRelative()
158 || widthCurrentValue().isRelative() 161 || m_width->currentValue()->isRelative()
159 || heightCurrentValue().isRelative(); 162 || m_height->currentValue()->isRelative();
160 } 163 }
161 164
162 } 165 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGMaskElement.h ('k') | Source/core/svg/SVGPatternElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698