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

Side by Side Diff: Source/core/svg/SVGTextPositioningElement.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/SVGTextPositioningElement.h ('k') | Source/core/svg/SVGUseElement.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, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 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 14 matching lines...) Expand all
25 #include "SVGNames.h" 25 #include "SVGNames.h"
26 #include "core/rendering/svg/RenderSVGResource.h" 26 #include "core/rendering/svg/RenderSVGResource.h"
27 #include "core/rendering/svg/RenderSVGText.h" 27 #include "core/rendering/svg/RenderSVGText.h"
28 #include "core/svg/SVGElementInstance.h" 28 #include "core/svg/SVGElementInstance.h"
29 #include "core/svg/SVGLengthList.h" 29 #include "core/svg/SVGLengthList.h"
30 #include "core/svg/SVGNumberList.h" 30 #include "core/svg/SVGNumberList.h"
31 31
32 namespace WebCore { 32 namespace WebCore {
33 33
34 // Animated property definitions 34 // Animated property definitions
35 DEFINE_ANIMATED_LENGTH_LIST(SVGTextPositioningElement, SVGNames::xAttr, X, x)
36 DEFINE_ANIMATED_LENGTH_LIST(SVGTextPositioningElement, SVGNames::yAttr, Y, y)
37 DEFINE_ANIMATED_LENGTH_LIST(SVGTextPositioningElement, SVGNames::dxAttr, Dx, dx)
38 DEFINE_ANIMATED_LENGTH_LIST(SVGTextPositioningElement, SVGNames::dyAttr, Dy, dy)
39 DEFINE_ANIMATED_NUMBER_LIST(SVGTextPositioningElement, SVGNames::rotateAttr, Rot ate, rotate) 35 DEFINE_ANIMATED_NUMBER_LIST(SVGTextPositioningElement, SVGNames::rotateAttr, Rot ate, rotate)
40 36
41 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGTextPositioningElement) 37 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGTextPositioningElement)
42 REGISTER_LOCAL_ANIMATED_PROPERTY(x)
43 REGISTER_LOCAL_ANIMATED_PROPERTY(y)
44 REGISTER_LOCAL_ANIMATED_PROPERTY(dx)
45 REGISTER_LOCAL_ANIMATED_PROPERTY(dy)
46 REGISTER_LOCAL_ANIMATED_PROPERTY(rotate) 38 REGISTER_LOCAL_ANIMATED_PROPERTY(rotate)
47 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTextContentElement) 39 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTextContentElement)
48 END_REGISTER_ANIMATED_PROPERTIES 40 END_REGISTER_ANIMATED_PROPERTIES
49 41
50 SVGTextPositioningElement::SVGTextPositioningElement(const QualifiedName& tagNam e, Document& document) 42 SVGTextPositioningElement::SVGTextPositioningElement(const QualifiedName& tagNam e, Document& document)
51 : SVGTextContentElement(tagName, document) 43 : SVGTextContentElement(tagName, document)
44 , m_x(SVGAnimatedLengthList::create(this, SVGNames::xAttr, SVGLengthList::cr eate(LengthModeWidth)))
45 , m_y(SVGAnimatedLengthList::create(this, SVGNames::yAttr, SVGLengthList::cr eate(LengthModeHeight)))
46 , m_dx(SVGAnimatedLengthList::create(this, SVGNames::dxAttr, SVGLengthList:: create(LengthModeWidth)))
47 , m_dy(SVGAnimatedLengthList::create(this, SVGNames::dyAttr, SVGLengthList:: create(LengthModeHeight)))
52 { 48 {
53 ScriptWrappable::init(this); 49 ScriptWrappable::init(this);
50
51 addToPropertyMap(m_x);
52 addToPropertyMap(m_y);
53 addToPropertyMap(m_dx);
54 addToPropertyMap(m_dy);
54 registerAnimatedPropertiesForSVGTextPositioningElement(); 55 registerAnimatedPropertiesForSVGTextPositioningElement();
55 } 56 }
56 57
57 bool SVGTextPositioningElement::isSupportedAttribute(const QualifiedName& attrNa me) 58 bool SVGTextPositioningElement::isSupportedAttribute(const QualifiedName& attrNa me)
58 { 59 {
59 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); 60 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
60 if (supportedAttributes.isEmpty()) { 61 if (supportedAttributes.isEmpty()) {
61 supportedAttributes.add(SVGNames::xAttr); 62 supportedAttributes.add(SVGNames::xAttr);
62 supportedAttributes.add(SVGNames::yAttr); 63 supportedAttributes.add(SVGNames::yAttr);
63 supportedAttributes.add(SVGNames::dxAttr); 64 supportedAttributes.add(SVGNames::dxAttr);
64 supportedAttributes.add(SVGNames::dyAttr); 65 supportedAttributes.add(SVGNames::dyAttr);
65 supportedAttributes.add(SVGNames::rotateAttr); 66 supportedAttributes.add(SVGNames::rotateAttr);
66 } 67 }
67 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); 68 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
68 } 69 }
69 70
70 void SVGTextPositioningElement::parseAttribute(const QualifiedName& name, const AtomicString& value) 71 void SVGTextPositioningElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
71 { 72 {
72 if (!isSupportedAttribute(name)) { 73 if (!isSupportedAttribute(name)) {
73 SVGTextContentElement::parseAttribute(name, value); 74 SVGTextContentElement::parseAttribute(name, value);
74 return; 75 return;
75 } 76 }
76 77
78 SVGParsingError parseError = NoError;
79
77 if (name == SVGNames::xAttr) { 80 if (name == SVGNames::xAttr) {
78 SVGLengthList newList; 81 m_x->setBaseValueAsString(value, parseError);
79 newList.parse(value, LengthModeWidth); 82 } else if (name == SVGNames::yAttr) {
80 detachAnimatedXListWrappers(newList.size()); 83 m_y->setBaseValueAsString(value, parseError);
81 setXBaseValue(newList); 84 } else if (name == SVGNames::dxAttr) {
82 return; 85 m_dx->setBaseValueAsString(value, parseError);
83 } 86 } else if (name == SVGNames::dyAttr) {
84 87 m_dy->setBaseValueAsString(value, parseError);
85 if (name == SVGNames::yAttr) { 88 } else if (name == SVGNames::rotateAttr) {
86 SVGLengthList newList;
87 newList.parse(value, LengthModeHeight);
88 detachAnimatedYListWrappers(newList.size());
89 setYBaseValue(newList);
90 return;
91 }
92
93 if (name == SVGNames::dxAttr) {
94 SVGLengthList newList;
95 newList.parse(value, LengthModeWidth);
96 detachAnimatedDxListWrappers(newList.size());
97 setDxBaseValue(newList);
98 return;
99 }
100
101 if (name == SVGNames::dyAttr) {
102 SVGLengthList newList;
103 newList.parse(value, LengthModeHeight);
104 detachAnimatedDyListWrappers(newList.size());
105 setDyBaseValue(newList);
106 return;
107 }
108
109 if (name == SVGNames::rotateAttr) {
110 SVGNumberList newList; 89 SVGNumberList newList;
111 newList.parse(value); 90 newList.parse(value);
112 detachAnimatedRotateListWrappers(newList.size()); 91 detachAnimatedRotateListWrappers(newList.size());
113 setRotateBaseValue(newList); 92 setRotateBaseValue(newList);
114 return; 93 return;
94 } else {
95 ASSERT_NOT_REACHED();
115 } 96 }
116 97
117 ASSERT_NOT_REACHED(); 98 reportAttributeParsingError(parseError, name, value);
118 } 99 }
119 100
120 void SVGTextPositioningElement::svgAttributeChanged(const QualifiedName& attrNam e) 101 void SVGTextPositioningElement::svgAttributeChanged(const QualifiedName& attrNam e)
121 { 102 {
122 if (!isSupportedAttribute(attrName)) { 103 if (!isSupportedAttribute(attrName)) {
123 SVGTextContentElement::svgAttributeChanged(attrName); 104 SVGTextContentElement::svgAttributeChanged(attrName);
124 return; 105 return;
125 } 106 }
126 107
127 SVGElementInstance::InvalidationGuard invalidationGuard(this); 108 SVGElementInstance::InvalidationGuard invalidationGuard(this);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 #if ENABLE(SVG_FONTS) 145 #if ENABLE(SVG_FONTS)
165 && !node->hasTagName(SVGNames::altGlyphTag) 146 && !node->hasTagName(SVGNames::altGlyphTag)
166 #endif 147 #endif
167 && !node->hasTagName(SVGNames::tspanTag)) 148 && !node->hasTagName(SVGNames::tspanTag))
168 return 0; 149 return 0;
169 150
170 return static_cast<SVGTextPositioningElement*>(node); 151 return static_cast<SVGTextPositioningElement*>(node);
171 } 152 }
172 153
173 } 154 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGTextPositioningElement.h ('k') | Source/core/svg/SVGUseElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698