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

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

Issue 18053005: Introduce SVGGraphicsElement IDL interface (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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, 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 DEFINE_ANIMATED_BOOLEAN(SVGImageElement, SVGNames::externalResourcesRequiredAttr , ExternalResourcesRequired, externalResourcesRequired) 43 DEFINE_ANIMATED_BOOLEAN(SVGImageElement, SVGNames::externalResourcesRequiredAttr , ExternalResourcesRequired, externalResourcesRequired)
44 44
45 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGImageElement) 45 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGImageElement)
46 REGISTER_LOCAL_ANIMATED_PROPERTY(x) 46 REGISTER_LOCAL_ANIMATED_PROPERTY(x)
47 REGISTER_LOCAL_ANIMATED_PROPERTY(y) 47 REGISTER_LOCAL_ANIMATED_PROPERTY(y)
48 REGISTER_LOCAL_ANIMATED_PROPERTY(width) 48 REGISTER_LOCAL_ANIMATED_PROPERTY(width)
49 REGISTER_LOCAL_ANIMATED_PROPERTY(height) 49 REGISTER_LOCAL_ANIMATED_PROPERTY(height)
50 REGISTER_LOCAL_ANIMATED_PROPERTY(preserveAspectRatio) 50 REGISTER_LOCAL_ANIMATED_PROPERTY(preserveAspectRatio)
51 REGISTER_LOCAL_ANIMATED_PROPERTY(href) 51 REGISTER_LOCAL_ANIMATED_PROPERTY(href)
52 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) 52 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired)
53 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGStyledTransformableElement) 53 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement)
54 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTests)
55 END_REGISTER_ANIMATED_PROPERTIES 54 END_REGISTER_ANIMATED_PROPERTIES
56 55
57 inline SVGImageElement::SVGImageElement(const QualifiedName& tagName, Document* document) 56 inline SVGImageElement::SVGImageElement(const QualifiedName& tagName, Document* document)
58 : SVGStyledTransformableElement(tagName, document) 57 : SVGGraphicsElement(tagName, document)
59 , m_x(LengthModeWidth) 58 , m_x(LengthModeWidth)
60 , m_y(LengthModeHeight) 59 , m_y(LengthModeHeight)
61 , m_width(LengthModeWidth) 60 , m_width(LengthModeWidth)
62 , m_height(LengthModeHeight) 61 , m_height(LengthModeHeight)
63 , m_imageLoader(this) 62 , m_imageLoader(this)
64 { 63 {
65 ASSERT(hasTagName(SVGNames::imageTag)); 64 ASSERT(hasTagName(SVGNames::imageTag));
66 ScriptWrappable::init(this); 65 ScriptWrappable::init(this);
67 registerAnimatedPropertiesForSVGImageElement(); 66 registerAnimatedPropertiesForSVGImageElement();
68 } 67 }
(...skipping 17 matching lines...) Expand all
86 supportedAttributes.add(SVGNames::heightAttr); 85 supportedAttributes.add(SVGNames::heightAttr);
87 supportedAttributes.add(SVGNames::preserveAspectRatioAttr); 86 supportedAttributes.add(SVGNames::preserveAspectRatioAttr);
88 } 87 }
89 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); 88 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
90 } 89 }
91 90
92 bool SVGImageElement::isPresentationAttribute(const QualifiedName& name) const 91 bool SVGImageElement::isPresentationAttribute(const QualifiedName& name) const
93 { 92 {
94 if (name == SVGNames::widthAttr || name == SVGNames::heightAttr) 93 if (name == SVGNames::widthAttr || name == SVGNames::heightAttr)
95 return true; 94 return true;
96 return SVGStyledTransformableElement::isPresentationAttribute(name); 95 return SVGGraphicsElement::isPresentationAttribute(name);
97 } 96 }
98 97
99 void SVGImageElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style) 98 void SVGImageElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style)
100 { 99 {
101 if (!isSupportedAttribute(name)) 100 if (!isSupportedAttribute(name))
102 SVGStyledTransformableElement::collectStyleForPresentationAttribute(name , value, style); 101 SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, st yle);
103 else if (name == SVGNames::widthAttr) 102 else if (name == SVGNames::widthAttr)
104 addPropertyToPresentationAttributeStyle(style, CSSPropertyWidth, value); 103 addPropertyToPresentationAttributeStyle(style, CSSPropertyWidth, value);
105 else if (name == SVGNames::heightAttr) 104 else if (name == SVGNames::heightAttr)
106 addPropertyToPresentationAttributeStyle(style, CSSPropertyHeight, value) ; 105 addPropertyToPresentationAttributeStyle(style, CSSPropertyHeight, value) ;
107 } 106 }
108 107
109 void SVGImageElement::parseAttribute(const QualifiedName& name, const AtomicStri ng& value) 108 void SVGImageElement::parseAttribute(const QualifiedName& name, const AtomicStri ng& value)
110 { 109 {
111 SVGParsingError parseError = NoError; 110 SVGParsingError parseError = NoError;
112 111
113 if (!isSupportedAttribute(name)) 112 if (!isSupportedAttribute(name))
114 SVGStyledTransformableElement::parseAttribute(name, value); 113 SVGGraphicsElement::parseAttribute(name, value);
115 else if (name == SVGNames::xAttr) 114 else if (name == SVGNames::xAttr)
116 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); 115 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError));
117 else if (name == SVGNames::yAttr) 116 else if (name == SVGNames::yAttr)
118 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError)) ; 117 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError)) ;
119 else if (name == SVGNames::preserveAspectRatioAttr) { 118 else if (name == SVGNames::preserveAspectRatioAttr) {
120 SVGPreserveAspectRatio preserveAspectRatio; 119 SVGPreserveAspectRatio preserveAspectRatio;
121 preserveAspectRatio.parse(value); 120 preserveAspectRatio.parse(value);
122 setPreserveAspectRatioBaseValue(preserveAspectRatio); 121 setPreserveAspectRatioBaseValue(preserveAspectRatio);
123 } else if (name == SVGNames::widthAttr) 122 } else if (name == SVGNames::widthAttr)
124 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro r, ForbidNegativeLengths)); 123 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro r, ForbidNegativeLengths));
125 else if (name == SVGNames::heightAttr) 124 else if (name == SVGNames::heightAttr)
126 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr ror, ForbidNegativeLengths)); 125 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr ror, ForbidNegativeLengths));
127 else if (SVGTests::parseAttribute(name, value) 126 else if (SVGTests::parseAttribute(name, value)
128 || SVGLangSpace::parseAttribute(name, value) 127 || SVGLangSpace::parseAttribute(name, value)
129 || SVGExternalResourcesRequired::parseAttribute(name, value) 128 || SVGExternalResourcesRequired::parseAttribute(name, value)
130 || SVGURIReference::parseAttribute(name, value)) { 129 || SVGURIReference::parseAttribute(name, value)) {
131 } else 130 } else
132 ASSERT_NOT_REACHED(); 131 ASSERT_NOT_REACHED();
133 132
134 reportAttributeParsingError(parseError, name, value); 133 reportAttributeParsingError(parseError, name, value);
135 } 134 }
136 135
137 void SVGImageElement::svgAttributeChanged(const QualifiedName& attrName) 136 void SVGImageElement::svgAttributeChanged(const QualifiedName& attrName)
138 { 137 {
139 if (!isSupportedAttribute(attrName)) { 138 if (!isSupportedAttribute(attrName)) {
140 SVGStyledTransformableElement::svgAttributeChanged(attrName); 139 SVGGraphicsElement::svgAttributeChanged(attrName);
141 return; 140 return;
142 } 141 }
143 142
144 SVGElementInstance::InvalidationGuard invalidationGuard(this); 143 SVGElementInstance::InvalidationGuard invalidationGuard(this);
145 144
146 bool isLengthAttribute = attrName == SVGNames::xAttr 145 bool isLengthAttribute = attrName == SVGNames::xAttr
147 || attrName == SVGNames::yAttr 146 || attrName == SVGNames::yAttr
148 || attrName == SVGNames::widthAttr 147 || attrName == SVGNames::widthAttr
149 || attrName == SVGNames::heightAttr; 148 || attrName == SVGNames::heightAttr;
150 149
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 return new (document()->renderArena()) RenderSVGImage(this); 191 return new (document()->renderArena()) RenderSVGImage(this);
193 } 192 }
194 193
195 bool SVGImageElement::haveLoadedRequiredResources() 194 bool SVGImageElement::haveLoadedRequiredResources()
196 { 195 {
197 return !externalResourcesRequiredBaseValue() || !m_imageLoader.hasPendingAct ivity(); 196 return !externalResourcesRequiredBaseValue() || !m_imageLoader.hasPendingAct ivity();
198 } 197 }
199 198
200 void SVGImageElement::attach(const AttachContext& context) 199 void SVGImageElement::attach(const AttachContext& context)
201 { 200 {
202 SVGStyledTransformableElement::attach(context); 201 SVGGraphicsElement::attach(context);
203 202
204 if (RenderSVGImage* imageObj = toRenderSVGImage(renderer())) { 203 if (RenderSVGImage* imageObj = toRenderSVGImage(renderer())) {
205 if (imageObj->imageResource()->hasImage()) 204 if (imageObj->imageResource()->hasImage())
206 return; 205 return;
207 206
208 imageObj->imageResource()->setCachedImage(m_imageLoader.image()); 207 imageObj->imageResource()->setCachedImage(m_imageLoader.image());
209 } 208 }
210 } 209 }
211 210
212 Node::InsertionNotificationRequest SVGImageElement::insertedInto(ContainerNode* rootParent) 211 Node::InsertionNotificationRequest SVGImageElement::insertedInto(ContainerNode* rootParent)
213 { 212 {
214 SVGStyledTransformableElement::insertedInto(rootParent); 213 SVGGraphicsElement::insertedInto(rootParent);
215 if (!rootParent->inDocument()) 214 if (!rootParent->inDocument())
216 return InsertionDone; 215 return InsertionDone;
217 // Update image loader, as soon as we're living in the tree. 216 // Update image loader, as soon as we're living in the tree.
218 // We can only resolve base URIs properly, after that! 217 // We can only resolve base URIs properly, after that!
219 m_imageLoader.updateFromElement(); 218 m_imageLoader.updateFromElement();
220 return InsertionDone; 219 return InsertionDone;
221 } 220 }
222 221
223 const AtomicString& SVGImageElement::imageSourceURL() const 222 const AtomicString& SVGImageElement::imageSourceURL() const
224 { 223 {
225 return getAttribute(XLinkNames::hrefAttr); 224 return getAttribute(XLinkNames::hrefAttr);
226 } 225 }
227 226
228 void SVGImageElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const 227 void SVGImageElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
229 { 228 {
230 SVGStyledTransformableElement::addSubresourceAttributeURLs(urls); 229 SVGGraphicsElement::addSubresourceAttributeURLs(urls);
231 230
232 addSubresourceURL(urls, document()->completeURL(href())); 231 addSubresourceURL(urls, document()->completeURL(href()));
233 } 232 }
234 233
235 void SVGImageElement::didMoveToNewDocument(Document* oldDocument) 234 void SVGImageElement::didMoveToNewDocument(Document* oldDocument)
236 { 235 {
237 m_imageLoader.elementDidMoveToNewDocument(); 236 m_imageLoader.elementDidMoveToNewDocument();
238 SVGStyledTransformableElement::didMoveToNewDocument(oldDocument); 237 SVGGraphicsElement::didMoveToNewDocument(oldDocument);
239 } 238 }
240 239
241 } 240 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698