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

Side by Side Diff: Source/core/svg/SVGPathElement.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 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } 59 }
60 60
61 // Animated property definitions 61 // Animated property definitions
62 DEFINE_ANIMATED_NUMBER(SVGPathElement, SVGNames::pathLengthAttr, PathLength, pat hLength) 62 DEFINE_ANIMATED_NUMBER(SVGPathElement, SVGNames::pathLengthAttr, PathLength, pat hLength)
63 DEFINE_ANIMATED_BOOLEAN(SVGPathElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired) 63 DEFINE_ANIMATED_BOOLEAN(SVGPathElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired)
64 64
65 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGPathElement) 65 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGPathElement)
66 REGISTER_LOCAL_ANIMATED_PROPERTY(d) 66 REGISTER_LOCAL_ANIMATED_PROPERTY(d)
67 REGISTER_LOCAL_ANIMATED_PROPERTY(pathLength) 67 REGISTER_LOCAL_ANIMATED_PROPERTY(pathLength)
68 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) 68 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired)
69 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGStyledTransformableElement) 69 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement)
70 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTests)
71 END_REGISTER_ANIMATED_PROPERTIES 70 END_REGISTER_ANIMATED_PROPERTIES
72 71
73 inline SVGPathElement::SVGPathElement(const QualifiedName& tagName, Document* do cument) 72 inline SVGPathElement::SVGPathElement(const QualifiedName& tagName, Document* do cument)
74 : SVGStyledTransformableElement(tagName, document) 73 : SVGGraphicsElement(tagName, document)
75 , m_pathByteStream(SVGPathByteStream::create()) 74 , m_pathByteStream(SVGPathByteStream::create())
76 , m_pathSegList(PathSegUnalteredRole) 75 , m_pathSegList(PathSegUnalteredRole)
77 , m_isAnimValObserved(false) 76 , m_isAnimValObserved(false)
78 { 77 {
79 ASSERT(hasTagName(SVGNames::pathTag)); 78 ASSERT(hasTagName(SVGNames::pathTag));
80 ScriptWrappable::init(this); 79 ScriptWrappable::init(this);
81 registerAnimatedPropertiesForSVGPathElement(); 80 registerAnimatedPropertiesForSVGPathElement();
82 } 81 }
83 82
84 PassRefPtr<SVGPathElement> SVGPathElement::create(const QualifiedName& tagName, Document* document) 83 PassRefPtr<SVGPathElement> SVGPathElement::create(const QualifiedName& tagName, Document* document)
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes ); 210 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes );
212 supportedAttributes.add(SVGNames::dAttr); 211 supportedAttributes.add(SVGNames::dAttr);
213 supportedAttributes.add(SVGNames::pathLengthAttr); 212 supportedAttributes.add(SVGNames::pathLengthAttr);
214 } 213 }
215 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); 214 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
216 } 215 }
217 216
218 void SVGPathElement::parseAttribute(const QualifiedName& name, const AtomicStrin g& value) 217 void SVGPathElement::parseAttribute(const QualifiedName& name, const AtomicStrin g& value)
219 { 218 {
220 if (!isSupportedAttribute(name)) { 219 if (!isSupportedAttribute(name)) {
221 SVGStyledTransformableElement::parseAttribute(name, value); 220 SVGGraphicsElement::parseAttribute(name, value);
222 return; 221 return;
223 } 222 }
224 223
225 if (name == SVGNames::dAttr) { 224 if (name == SVGNames::dAttr) {
226 if (!buildSVGPathByteStreamFromString(value, m_pathByteStream.get(), Una lteredParsing)) 225 if (!buildSVGPathByteStreamFromString(value, m_pathByteStream.get(), Una lteredParsing))
227 document()->accessSVGExtensions()->reportError("Problem parsing d=\" " + value + "\""); 226 document()->accessSVGExtensions()->reportError("Problem parsing d=\" " + value + "\"");
228 return; 227 return;
229 } 228 }
230 229
231 if (name == SVGNames::pathLengthAttr) { 230 if (name == SVGNames::pathLengthAttr) {
232 setPathLengthBaseValue(value.toFloat()); 231 setPathLengthBaseValue(value.toFloat());
233 if (pathLengthBaseValue() < 0) 232 if (pathLengthBaseValue() < 0)
234 document()->accessSVGExtensions()->reportError("A negative value for path attribute <pathLength> is not allowed"); 233 document()->accessSVGExtensions()->reportError("A negative value for path attribute <pathLength> is not allowed");
235 return; 234 return;
236 } 235 }
237 236
238 if (SVGTests::parseAttribute(name, value)) 237 if (SVGTests::parseAttribute(name, value))
239 return; 238 return;
240 if (SVGLangSpace::parseAttribute(name, value)) 239 if (SVGLangSpace::parseAttribute(name, value))
241 return; 240 return;
242 if (SVGExternalResourcesRequired::parseAttribute(name, value)) 241 if (SVGExternalResourcesRequired::parseAttribute(name, value))
243 return; 242 return;
244 243
245 ASSERT_NOT_REACHED(); 244 ASSERT_NOT_REACHED();
246 } 245 }
247 246
248 void SVGPathElement::svgAttributeChanged(const QualifiedName& attrName) 247 void SVGPathElement::svgAttributeChanged(const QualifiedName& attrName)
249 { 248 {
250 if (!isSupportedAttribute(attrName)) { 249 if (!isSupportedAttribute(attrName)) {
251 SVGStyledTransformableElement::svgAttributeChanged(attrName); 250 SVGGraphicsElement::svgAttributeChanged(attrName);
252 return; 251 return;
253 } 252 }
254 253
255 SVGElementInstance::InvalidationGuard invalidationGuard(this); 254 SVGElementInstance::InvalidationGuard invalidationGuard(this);
256 255
257 if (SVGTests::handleAttributeChange(this, attrName)) 256 if (SVGTests::handleAttributeChange(this, attrName))
258 return; 257 return;
259 258
260 RenderSVGPath* renderer = toRenderSVGPath(this->renderer()); 259 RenderSVGPath* renderer = toRenderSVGPath(this->renderer());
261 260
(...skipping 23 matching lines...) Expand all
285 HashSet<SVGElement*>::iterator end = dependencies->end(); 284 HashSet<SVGElement*>::iterator end = dependencies->end();
286 for (HashSet<SVGElement*>::iterator it = dependencies->begin(); it != en d; ++it) { 285 for (HashSet<SVGElement*>::iterator it = dependencies->begin(); it != en d; ++it) {
287 if ((*it)->hasTagName(SVGNames::mpathTag)) 286 if ((*it)->hasTagName(SVGNames::mpathTag))
288 static_cast<SVGMPathElement*>(*it)->targetPathChanged(); 287 static_cast<SVGMPathElement*>(*it)->targetPathChanged();
289 } 288 }
290 } 289 }
291 } 290 }
292 291
293 Node::InsertionNotificationRequest SVGPathElement::insertedInto(ContainerNode* r ootParent) 292 Node::InsertionNotificationRequest SVGPathElement::insertedInto(ContainerNode* r ootParent)
294 { 293 {
295 SVGStyledTransformableElement::insertedInto(rootParent); 294 SVGGraphicsElement::insertedInto(rootParent);
296 invalidateMPathDependencies(); 295 invalidateMPathDependencies();
297 return InsertionDone; 296 return InsertionDone;
298 } 297 }
299 298
300 void SVGPathElement::removedFrom(ContainerNode* rootParent) 299 void SVGPathElement::removedFrom(ContainerNode* rootParent)
301 { 300 {
302 SVGStyledTransformableElement::removedFrom(rootParent); 301 SVGGraphicsElement::removedFrom(rootParent);
303 invalidateMPathDependencies(); 302 invalidateMPathDependencies();
304 } 303 }
305 304
306 SVGPathByteStream* SVGPathElement::pathByteStream() const 305 SVGPathByteStream* SVGPathElement::pathByteStream() const
307 { 306 {
308 SVGAnimatedProperty* property = SVGAnimatedProperty::lookupWrapper<SVGPathEl ement, SVGAnimatedPathSegListPropertyTearOff>(this, dPropertyInfo()); 307 SVGAnimatedProperty* property = SVGAnimatedProperty::lookupWrapper<SVGPathEl ement, SVGAnimatedPathSegListPropertyTearOff>(this, dPropertyInfo());
309 if (!property || !property->isAnimating()) 308 if (!property || !property->isAnimating())
310 return m_pathByteStream.get(); 309 return m_pathByteStream.get();
311 return static_cast<SVGAnimatedPathSegListPropertyTearOff*>(property)->animat edPathByteStream(); 310 return static_cast<SVGAnimatedPathSegListPropertyTearOff*>(property)->animat edPathByteStream();
312 } 311 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 return renderer->path().boundingRect(); 400 return renderer->path().boundingRect();
402 } 401 }
403 402
404 RenderObject* SVGPathElement::createRenderer(RenderStyle*) 403 RenderObject* SVGPathElement::createRenderer(RenderStyle*)
405 { 404 {
406 // By default, any subclass is expected to do path-based drawing 405 // By default, any subclass is expected to do path-based drawing
407 return new (document()->renderArena()) RenderSVGPath(this); 406 return new (document()->renderArena()) RenderSVGPath(this);
408 } 407 }
409 408
410 } 409 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698