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

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: fix tests 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
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 DEFINE_ANIMATED_BOOLEAN(SVGLineElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired) 32 DEFINE_ANIMATED_BOOLEAN(SVGLineElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired)
37 33
38 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGLineElement) 34 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGLineElement)
39 REGISTER_LOCAL_ANIMATED_PROPERTY(x1)
40 REGISTER_LOCAL_ANIMATED_PROPERTY(y1)
41 REGISTER_LOCAL_ANIMATED_PROPERTY(x2)
42 REGISTER_LOCAL_ANIMATED_PROPERTY(y2)
43 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) 35 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired)
44 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) 36 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement)
45 END_REGISTER_ANIMATED_PROPERTIES 37 END_REGISTER_ANIMATED_PROPERTIES
46 38
47 inline SVGLineElement::SVGLineElement(Document& document) 39 inline SVGLineElement::SVGLineElement(Document& document)
48 : SVGGeometryElement(SVGNames::lineTag, document) 40 : SVGGeometryElement(SVGNames::lineTag, document)
49 , m_x1(LengthModeWidth) 41 , m_x1(SVGAnimatedLength::create(this, SVGNames::x1Attr, SVGLength::create(L engthModeWidth)))
50 , m_y1(LengthModeHeight) 42 , m_y1(SVGAnimatedLength::create(this, SVGNames::y1Attr, SVGLength::create(L engthModeHeight)))
51 , m_x2(LengthModeWidth) 43 , m_x2(SVGAnimatedLength::create(this, SVGNames::x2Attr, SVGLength::create(L engthModeWidth)))
52 , m_y2(LengthModeHeight) 44 , m_y2(SVGAnimatedLength::create(this, SVGNames::y2Attr, SVGLength::create(L engthModeHeight)))
53 { 45 {
54 ScriptWrappable::init(this); 46 ScriptWrappable::init(this);
47
48 addToPropertyMap(m_x1);
49 addToPropertyMap(m_y1);
50 addToPropertyMap(m_x2);
51 addToPropertyMap(m_y2);
55 registerAnimatedPropertiesForSVGLineElement(); 52 registerAnimatedPropertiesForSVGLineElement();
56 } 53 }
57 54
58 PassRefPtr<SVGLineElement> SVGLineElement::create(Document& document) 55 PassRefPtr<SVGLineElement> SVGLineElement::create(Document& document)
59 { 56 {
60 return adoptRef(new SVGLineElement(document)); 57 return adoptRef(new SVGLineElement(document));
61 } 58 }
62 59
63 bool SVGLineElement::isSupportedAttribute(const QualifiedName& attrName) 60 bool SVGLineElement::isSupportedAttribute(const QualifiedName& attrName)
64 { 61 {
65 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); 62 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
66 if (supportedAttributes.isEmpty()) { 63 if (supportedAttributes.isEmpty()) {
67 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes ); 64 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes );
68 supportedAttributes.add(SVGNames::x1Attr); 65 supportedAttributes.add(SVGNames::x1Attr);
69 supportedAttributes.add(SVGNames::x2Attr); 66 supportedAttributes.add(SVGNames::x2Attr);
70 supportedAttributes.add(SVGNames::y1Attr); 67 supportedAttributes.add(SVGNames::y1Attr);
71 supportedAttributes.add(SVGNames::y2Attr); 68 supportedAttributes.add(SVGNames::y2Attr);
72 } 69 }
73 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); 70 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
74 } 71 }
75 72
76 void SVGLineElement::parseAttribute(const QualifiedName& name, const AtomicStrin g& value) 73 void SVGLineElement::parseAttribute(const QualifiedName& name, const AtomicStrin g& value)
77 { 74 {
78 SVGParsingError parseError = NoError; 75 SVGParsingError parseError = NoError;
79 76
80 if (!isSupportedAttribute(name)) 77 if (!isSupportedAttribute(name))
81 SVGGeometryElement::parseAttribute(name, value); 78 SVGGeometryElement::parseAttribute(name, value);
82 else if (name == SVGNames::x1Attr) 79 else if (name == SVGNames::x1Attr)
83 setX1BaseValue(SVGLength::construct(LengthModeWidth, value, parseError)) ; 80 m_x1->setBaseValueAsString(value, AllowNegativeLengths, parseError);
84 else if (name == SVGNames::y1Attr) 81 else if (name == SVGNames::y1Attr)
85 setY1BaseValue(SVGLength::construct(LengthModeHeight, value, parseError) ); 82 m_y1->setBaseValueAsString(value, AllowNegativeLengths, parseError);
86 else if (name == SVGNames::x2Attr) 83 else if (name == SVGNames::x2Attr)
87 setX2BaseValue(SVGLength::construct(LengthModeWidth, value, parseError)) ; 84 m_x2->setBaseValueAsString(value, AllowNegativeLengths, parseError);
88 else if (name == SVGNames::y2Attr) 85 else if (name == SVGNames::y2Attr)
89 setY2BaseValue(SVGLength::construct(LengthModeHeight, value, parseError) ); 86 m_y2->setBaseValueAsString(value, AllowNegativeLengths, parseError);
90 else if (SVGExternalResourcesRequired::parseAttribute(name, value)) { 87 else if (SVGExternalResourcesRequired::parseAttribute(name, value)) {
91 } else 88 } else
92 ASSERT_NOT_REACHED(); 89 ASSERT_NOT_REACHED();
93 90
94 reportAttributeParsingError(parseError, name, value); 91 reportAttributeParsingError(parseError, name, value);
95 } 92 }
96 93
97 void SVGLineElement::svgAttributeChanged(const QualifiedName& attrName) 94 void SVGLineElement::svgAttributeChanged(const QualifiedName& attrName)
98 { 95 {
99 if (!isSupportedAttribute(attrName)) { 96 if (!isSupportedAttribute(attrName)) {
(...skipping 24 matching lines...) Expand all
124 if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) { 121 if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) {
125 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); 122 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
126 return; 123 return;
127 } 124 }
128 125
129 ASSERT_NOT_REACHED(); 126 ASSERT_NOT_REACHED();
130 } 127 }
131 128
132 bool SVGLineElement::selfHasRelativeLengths() const 129 bool SVGLineElement::selfHasRelativeLengths() const
133 { 130 {
134 return x1CurrentValue().isRelative() 131 return m_x1->currentValue()->isRelative()
135 || y1CurrentValue().isRelative() 132 || m_y1->currentValue()->isRelative()
136 || x2CurrentValue().isRelative() 133 || m_x2->currentValue()->isRelative()
137 || y2CurrentValue().isRelative(); 134 || m_y2->currentValue()->isRelative();
138 } 135 }
139 136
140 } 137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698