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

Side by Side Diff: Source/core/svg/SVGImageElement.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/SVGImageElement.h ('k') | Source/core/svg/SVGLength.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, 2008, 2009 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Rob Buis <buis@kde.org>
4 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> 4 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org>
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 15 matching lines...) Expand all
26 #include "CSSPropertyNames.h" 26 #include "CSSPropertyNames.h"
27 #include "XLinkNames.h" 27 #include "XLinkNames.h"
28 #include "core/rendering/RenderImageResource.h" 28 #include "core/rendering/RenderImageResource.h"
29 #include "core/rendering/svg/RenderSVGImage.h" 29 #include "core/rendering/svg/RenderSVGImage.h"
30 #include "core/rendering/svg/RenderSVGResource.h" 30 #include "core/rendering/svg/RenderSVGResource.h"
31 #include "core/svg/SVGElementInstance.h" 31 #include "core/svg/SVGElementInstance.h"
32 32
33 namespace WebCore { 33 namespace WebCore {
34 34
35 // Animated property definitions 35 // Animated property definitions
36 DEFINE_ANIMATED_LENGTH(SVGImageElement, SVGNames::xAttr, X, x)
37 DEFINE_ANIMATED_LENGTH(SVGImageElement, SVGNames::yAttr, Y, y)
38 DEFINE_ANIMATED_LENGTH(SVGImageElement, SVGNames::widthAttr, Width, width)
39 DEFINE_ANIMATED_LENGTH(SVGImageElement, SVGNames::heightAttr, Height, height)
40 DEFINE_ANIMATED_PRESERVEASPECTRATIO(SVGImageElement, SVGNames::preserveAspectRat ioAttr, PreserveAspectRatio, preserveAspectRatio) 36 DEFINE_ANIMATED_PRESERVEASPECTRATIO(SVGImageElement, SVGNames::preserveAspectRat ioAttr, PreserveAspectRatio, preserveAspectRatio)
41 DEFINE_ANIMATED_STRING(SVGImageElement, XLinkNames::hrefAttr, Href, href) 37 DEFINE_ANIMATED_STRING(SVGImageElement, XLinkNames::hrefAttr, Href, href)
42 38
43 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGImageElement) 39 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGImageElement)
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_LOCAL_ANIMATED_PROPERTY(preserveAspectRatio) 40 REGISTER_LOCAL_ANIMATED_PROPERTY(preserveAspectRatio)
49 REGISTER_LOCAL_ANIMATED_PROPERTY(href) 41 REGISTER_LOCAL_ANIMATED_PROPERTY(href)
50 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) 42 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement)
51 END_REGISTER_ANIMATED_PROPERTIES 43 END_REGISTER_ANIMATED_PROPERTIES
52 44
53 inline SVGImageElement::SVGImageElement(Document& document) 45 inline SVGImageElement::SVGImageElement(Document& document)
54 : SVGGraphicsElement(SVGNames::imageTag, document) 46 : SVGGraphicsElement(SVGNames::imageTag, document)
55 , m_x(LengthModeWidth) 47 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len gthModeWidth)))
56 , m_y(LengthModeHeight) 48 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len gthModeHeight)))
57 , m_width(LengthModeWidth) 49 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr eate(LengthModeWidth)))
58 , m_height(LengthModeHeight) 50 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength:: create(LengthModeHeight)))
59 , m_imageLoader(this) 51 , m_imageLoader(this)
60 { 52 {
61 ScriptWrappable::init(this); 53 ScriptWrappable::init(this);
54
55 addToPropertyMap(m_x);
56 addToPropertyMap(m_y);
57 addToPropertyMap(m_width);
58 addToPropertyMap(m_height);
59
62 registerAnimatedPropertiesForSVGImageElement(); 60 registerAnimatedPropertiesForSVGImageElement();
63 } 61 }
64 62
65 PassRefPtr<SVGImageElement> SVGImageElement::create(Document& document) 63 PassRefPtr<SVGImageElement> SVGImageElement::create(Document& document)
66 { 64 {
67 return adoptRef(new SVGImageElement(document)); 65 return adoptRef(new SVGImageElement(document));
68 } 66 }
69 67
70 bool SVGImageElement::currentFrameHasSingleSecurityOrigin() const 68 bool SVGImageElement::currentFrameHasSingleSecurityOrigin() const
71 { 69 {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 addPropertyToPresentationAttributeStyle(style, CSSPropertyHeight, value) ; 108 addPropertyToPresentationAttributeStyle(style, CSSPropertyHeight, value) ;
111 } 109 }
112 110
113 void SVGImageElement::parseAttribute(const QualifiedName& name, const AtomicStri ng& value) 111 void SVGImageElement::parseAttribute(const QualifiedName& name, const AtomicStri ng& value)
114 { 112 {
115 SVGParsingError parseError = NoError; 113 SVGParsingError parseError = NoError;
116 114
117 if (!isSupportedAttribute(name)) 115 if (!isSupportedAttribute(name))
118 SVGGraphicsElement::parseAttribute(name, value); 116 SVGGraphicsElement::parseAttribute(name, value);
119 else if (name == SVGNames::xAttr) 117 else if (name == SVGNames::xAttr)
120 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); 118 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError);
121 else if (name == SVGNames::yAttr) 119 else if (name == SVGNames::yAttr)
122 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError)) ; 120 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError);
121 else if (name == SVGNames::widthAttr)
122 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError);
123 else if (name == SVGNames::heightAttr)
124 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError) ;
123 else if (name == SVGNames::preserveAspectRatioAttr) { 125 else if (name == SVGNames::preserveAspectRatioAttr) {
124 SVGPreserveAspectRatio preserveAspectRatio; 126 SVGPreserveAspectRatio preserveAspectRatio;
125 preserveAspectRatio.parse(value); 127 preserveAspectRatio.parse(value);
126 setPreserveAspectRatioBaseValue(preserveAspectRatio); 128 setPreserveAspectRatioBaseValue(preserveAspectRatio);
127 } else if (name == SVGNames::widthAttr) 129 } else if (SVGURIReference::parseAttribute(name, value)) {
128 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro r, ForbidNegativeLengths));
129 else if (name == SVGNames::heightAttr)
130 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr ror, ForbidNegativeLengths));
131 else if (SVGURIReference::parseAttribute(name, value)) {
132 } else 130 } else
133 ASSERT_NOT_REACHED(); 131 ASSERT_NOT_REACHED();
134 132
135 reportAttributeParsingError(parseError, name, value); 133 reportAttributeParsingError(parseError, name, value);
136 } 134 }
137 135
138 void SVGImageElement::svgAttributeChanged(const QualifiedName& attrName) 136 void SVGImageElement::svgAttributeChanged(const QualifiedName& attrName)
139 { 137 {
140 if (!isSupportedAttribute(attrName)) { 138 if (!isSupportedAttribute(attrName)) {
141 SVGGraphicsElement::svgAttributeChanged(attrName); 139 SVGGraphicsElement::svgAttributeChanged(attrName);
(...skipping 28 matching lines...) Expand all
170 if (attrName == SVGNames::preserveAspectRatioAttr) { 168 if (attrName == SVGNames::preserveAspectRatioAttr) {
171 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); 169 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
172 return; 170 return;
173 } 171 }
174 172
175 ASSERT_NOT_REACHED(); 173 ASSERT_NOT_REACHED();
176 } 174 }
177 175
178 bool SVGImageElement::selfHasRelativeLengths() const 176 bool SVGImageElement::selfHasRelativeLengths() const
179 { 177 {
180 return xCurrentValue().isRelative() 178 return m_x->currentValue()->isRelative()
181 || yCurrentValue().isRelative() 179 || m_y->currentValue()->isRelative()
182 || widthCurrentValue().isRelative() 180 || m_width->currentValue()->isRelative()
183 || heightCurrentValue().isRelative(); 181 || m_height->currentValue()->isRelative();
184 } 182 }
185 183
186 RenderObject* SVGImageElement::createRenderer(RenderStyle*) 184 RenderObject* SVGImageElement::createRenderer(RenderStyle*)
187 { 185 {
188 return new RenderSVGImage(this); 186 return new RenderSVGImage(this);
189 } 187 }
190 188
191 bool SVGImageElement::haveLoadedRequiredResources() 189 bool SVGImageElement::haveLoadedRequiredResources()
192 { 190 {
193 return !m_imageLoader.hasPendingActivity(); 191 return !m_imageLoader.hasPendingActivity();
(...skipping 27 matching lines...) Expand all
221 return AtomicString(hrefCurrentValue()); 219 return AtomicString(hrefCurrentValue());
222 } 220 }
223 221
224 void SVGImageElement::didMoveToNewDocument(Document& oldDocument) 222 void SVGImageElement::didMoveToNewDocument(Document& oldDocument)
225 { 223 {
226 m_imageLoader.elementDidMoveToNewDocument(); 224 m_imageLoader.elementDidMoveToNewDocument();
227 SVGGraphicsElement::didMoveToNewDocument(oldDocument); 225 SVGGraphicsElement::didMoveToNewDocument(oldDocument);
228 } 226 }
229 227
230 } 228 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGImageElement.h ('k') | Source/core/svg/SVGLength.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698