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

Side by Side Diff: Source/core/svg/SVGLineElement.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/SVGLineElement.h ('k') | Source/core/svg/SVGLinearGradientElement.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 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 11 matching lines...) Expand all
22 22
23 #include "core/svg/SVGLineElement.h" 23 #include "core/svg/SVGLineElement.h"
24 24
25 #include "core/rendering/svg/RenderSVGResource.h" 25 #include "core/rendering/svg/RenderSVGResource.h"
26 #include "core/svg/SVGElementInstance.h" 26 #include "core/svg/SVGElementInstance.h"
27 #include "core/svg/SVGLength.h" 27 #include "core/svg/SVGLength.h"
28 28
29 namespace WebCore { 29 namespace WebCore {
30 30
31 // Animated property definitions 31 // Animated property definitions
32 DEFINE_ANIMATED_LENGTH(SVGLineElement, SVGNames::x1Attr, X1, x1)
33 DEFINE_ANIMATED_LENGTH(SVGLineElement, SVGNames::y1Attr, Y1, y1)
34 DEFINE_ANIMATED_LENGTH(SVGLineElement, SVGNames::x2Attr, X2, x2)
35 DEFINE_ANIMATED_LENGTH(SVGLineElement, SVGNames::y2Attr, Y2, y2)
36
37 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGLineElement) 32 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGLineElement)
38 REGISTER_LOCAL_ANIMATED_PROPERTY(x1)
39 REGISTER_LOCAL_ANIMATED_PROPERTY(y1)
40 REGISTER_LOCAL_ANIMATED_PROPERTY(x2)
41 REGISTER_LOCAL_ANIMATED_PROPERTY(y2)
42 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) 33 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement)
43 END_REGISTER_ANIMATED_PROPERTIES 34 END_REGISTER_ANIMATED_PROPERTIES
44 35
45 inline SVGLineElement::SVGLineElement(Document& document) 36 inline SVGLineElement::SVGLineElement(Document& document)
46 : SVGGeometryElement(SVGNames::lineTag, document) 37 : SVGGeometryElement(SVGNames::lineTag, document)
47 , m_x1(LengthModeWidth) 38 , m_x1(SVGAnimatedLength::create(this, SVGNames::x1Attr, SVGLength::create(L engthModeWidth)))
48 , m_y1(LengthModeHeight) 39 , m_y1(SVGAnimatedLength::create(this, SVGNames::y1Attr, SVGLength::create(L engthModeHeight)))
49 , m_x2(LengthModeWidth) 40 , m_x2(SVGAnimatedLength::create(this, SVGNames::x2Attr, SVGLength::create(L engthModeWidth)))
50 , m_y2(LengthModeHeight) 41 , m_y2(SVGAnimatedLength::create(this, SVGNames::y2Attr, SVGLength::create(L engthModeHeight)))
51 { 42 {
52 ScriptWrappable::init(this); 43 ScriptWrappable::init(this);
44
45 addToPropertyMap(m_x1);
46 addToPropertyMap(m_y1);
47 addToPropertyMap(m_x2);
48 addToPropertyMap(m_y2);
53 registerAnimatedPropertiesForSVGLineElement(); 49 registerAnimatedPropertiesForSVGLineElement();
54 } 50 }
55 51
56 PassRefPtr<SVGLineElement> SVGLineElement::create(Document& document) 52 PassRefPtr<SVGLineElement> SVGLineElement::create(Document& document)
57 { 53 {
58 return adoptRef(new SVGLineElement(document)); 54 return adoptRef(new SVGLineElement(document));
59 } 55 }
60 56
61 bool SVGLineElement::isSupportedAttribute(const QualifiedName& attrName) 57 bool SVGLineElement::isSupportedAttribute(const QualifiedName& attrName)
62 { 58 {
63 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); 59 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
64 if (supportedAttributes.isEmpty()) { 60 if (supportedAttributes.isEmpty()) {
65 supportedAttributes.add(SVGNames::x1Attr); 61 supportedAttributes.add(SVGNames::x1Attr);
66 supportedAttributes.add(SVGNames::x2Attr); 62 supportedAttributes.add(SVGNames::x2Attr);
67 supportedAttributes.add(SVGNames::y1Attr); 63 supportedAttributes.add(SVGNames::y1Attr);
68 supportedAttributes.add(SVGNames::y2Attr); 64 supportedAttributes.add(SVGNames::y2Attr);
69 } 65 }
70 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); 66 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
71 } 67 }
72 68
73 void SVGLineElement::parseAttribute(const QualifiedName& name, const AtomicStrin g& value) 69 void SVGLineElement::parseAttribute(const QualifiedName& name, const AtomicStrin g& value)
74 { 70 {
75 SVGParsingError parseError = NoError; 71 SVGParsingError parseError = NoError;
76 72
77 if (!isSupportedAttribute(name)) 73 if (!isSupportedAttribute(name))
78 SVGGeometryElement::parseAttribute(name, value); 74 SVGGeometryElement::parseAttribute(name, value);
79 else if (name == SVGNames::x1Attr) 75 else if (name == SVGNames::x1Attr)
80 setX1BaseValue(SVGLength::construct(LengthModeWidth, value, parseError)) ; 76 m_x1->setBaseValueAsString(value, AllowNegativeLengths, parseError);
81 else if (name == SVGNames::y1Attr) 77 else if (name == SVGNames::y1Attr)
82 setY1BaseValue(SVGLength::construct(LengthModeHeight, value, parseError) ); 78 m_y1->setBaseValueAsString(value, AllowNegativeLengths, parseError);
83 else if (name == SVGNames::x2Attr) 79 else if (name == SVGNames::x2Attr)
84 setX2BaseValue(SVGLength::construct(LengthModeWidth, value, parseError)) ; 80 m_x2->setBaseValueAsString(value, AllowNegativeLengths, parseError);
85 else if (name == SVGNames::y2Attr) 81 else if (name == SVGNames::y2Attr)
86 setY2BaseValue(SVGLength::construct(LengthModeHeight, value, parseError) ); 82 m_y2->setBaseValueAsString(value, AllowNegativeLengths, parseError);
87 else 83 else
88 ASSERT_NOT_REACHED(); 84 ASSERT_NOT_REACHED();
89 85
90 reportAttributeParsingError(parseError, name, value); 86 reportAttributeParsingError(parseError, name, value);
91 } 87 }
92 88
93 void SVGLineElement::svgAttributeChanged(const QualifiedName& attrName) 89 void SVGLineElement::svgAttributeChanged(const QualifiedName& attrName)
94 { 90 {
95 if (!isSupportedAttribute(attrName)) { 91 if (!isSupportedAttribute(attrName)) {
96 SVGGeometryElement::svgAttributeChanged(attrName); 92 SVGGeometryElement::svgAttributeChanged(attrName);
(...skipping 18 matching lines...) Expand all
115 renderer->setNeedsShapeUpdate(); 111 renderer->setNeedsShapeUpdate();
116 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); 112 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
117 return; 113 return;
118 } 114 }
119 115
120 ASSERT_NOT_REACHED(); 116 ASSERT_NOT_REACHED();
121 } 117 }
122 118
123 bool SVGLineElement::selfHasRelativeLengths() const 119 bool SVGLineElement::selfHasRelativeLengths() const
124 { 120 {
125 return x1CurrentValue().isRelative() 121 return m_x1->currentValue()->isRelative()
126 || y1CurrentValue().isRelative() 122 || m_y1->currentValue()->isRelative()
127 || x2CurrentValue().isRelative() 123 || m_x2->currentValue()->isRelative()
128 || y2CurrentValue().isRelative(); 124 || m_y2->currentValue()->isRelative();
129 } 125 }
130 126
131 } 127 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGLineElement.h ('k') | Source/core/svg/SVGLinearGradientElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698