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

Side by Side Diff: Source/core/svg/SVGForeignObjectElement.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) 2006 Apple Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@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 13 matching lines...) Expand all
24 #include "XLinkNames.h" 24 #include "XLinkNames.h"
25 #include "core/rendering/svg/RenderSVGForeignObject.h" 25 #include "core/rendering/svg/RenderSVGForeignObject.h"
26 #include "core/rendering/svg/RenderSVGResource.h" 26 #include "core/rendering/svg/RenderSVGResource.h"
27 #include "core/svg/SVGElementInstance.h" 27 #include "core/svg/SVGElementInstance.h"
28 #include "core/svg/SVGLength.h" 28 #include "core/svg/SVGLength.h"
29 #include "wtf/Assertions.h" 29 #include "wtf/Assertions.h"
30 30
31 namespace WebCore { 31 namespace WebCore {
32 32
33 // Animated property definitions 33 // Animated property definitions
34 DEFINE_ANIMATED_LENGTH(SVGForeignObjectElement, SVGNames::xAttr, X, x)
35 DEFINE_ANIMATED_LENGTH(SVGForeignObjectElement, SVGNames::yAttr, Y, y)
36 DEFINE_ANIMATED_LENGTH(SVGForeignObjectElement, SVGNames::widthAttr, Width, widt h)
37 DEFINE_ANIMATED_LENGTH(SVGForeignObjectElement, SVGNames::heightAttr, Height, he ight)
38 DEFINE_ANIMATED_STRING(SVGForeignObjectElement, XLinkNames::hrefAttr, Href, href ) 34 DEFINE_ANIMATED_STRING(SVGForeignObjectElement, XLinkNames::hrefAttr, Href, href )
39 DEFINE_ANIMATED_BOOLEAN(SVGForeignObjectElement, SVGNames::externalResourcesRequ iredAttr, ExternalResourcesRequired, externalResourcesRequired) 35 DEFINE_ANIMATED_BOOLEAN(SVGForeignObjectElement, SVGNames::externalResourcesRequ iredAttr, ExternalResourcesRequired, externalResourcesRequired)
40 36
41 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGForeignObjectElement) 37 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGForeignObjectElement)
42 REGISTER_LOCAL_ANIMATED_PROPERTY(x)
43 REGISTER_LOCAL_ANIMATED_PROPERTY(y)
44 REGISTER_LOCAL_ANIMATED_PROPERTY(width)
45 REGISTER_LOCAL_ANIMATED_PROPERTY(height)
46 REGISTER_LOCAL_ANIMATED_PROPERTY(href) 38 REGISTER_LOCAL_ANIMATED_PROPERTY(href)
47 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) 39 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired)
48 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) 40 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement)
49 END_REGISTER_ANIMATED_PROPERTIES 41 END_REGISTER_ANIMATED_PROPERTIES
50 42
51 inline SVGForeignObjectElement::SVGForeignObjectElement(Document& document) 43 inline SVGForeignObjectElement::SVGForeignObjectElement(Document& document)
52 : SVGGraphicsElement(SVGNames::foreignObjectTag, document) 44 : SVGGraphicsElement(SVGNames::foreignObjectTag, document)
53 , m_x(LengthModeWidth) 45 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len gthModeWidth)))
54 , m_y(LengthModeHeight) 46 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len gthModeHeight)))
55 , m_width(LengthModeWidth) 47 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr eate(LengthModeWidth)))
56 , m_height(LengthModeHeight) 48 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength:: create(LengthModeHeight)))
57 { 49 {
58 ScriptWrappable::init(this); 50 ScriptWrappable::init(this);
51
52 addToPropertyMap(m_x);
53 addToPropertyMap(m_y);
54 addToPropertyMap(m_width);
55 addToPropertyMap(m_height);
56
59 registerAnimatedPropertiesForSVGForeignObjectElement(); 57 registerAnimatedPropertiesForSVGForeignObjectElement();
60 } 58 }
61 59
62 PassRefPtr<SVGForeignObjectElement> SVGForeignObjectElement::create(Document& do cument) 60 PassRefPtr<SVGForeignObjectElement> SVGForeignObjectElement::create(Document& do cument)
63 { 61 {
64 return adoptRef(new SVGForeignObjectElement(document)); 62 return adoptRef(new SVGForeignObjectElement(document));
65 } 63 }
66 64
67 bool SVGForeignObjectElement::isSupportedAttribute(const QualifiedName& attrName ) 65 bool SVGForeignObjectElement::isSupportedAttribute(const QualifiedName& attrName )
68 { 66 {
69 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); 67 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
70 if (supportedAttributes.isEmpty()) { 68 if (supportedAttributes.isEmpty()) {
71 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes ); 69 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes );
72 supportedAttributes.add(SVGNames::xAttr); 70 supportedAttributes.add(SVGNames::xAttr);
73 supportedAttributes.add(SVGNames::yAttr); 71 supportedAttributes.add(SVGNames::yAttr);
74 supportedAttributes.add(SVGNames::widthAttr); 72 supportedAttributes.add(SVGNames::widthAttr);
75 supportedAttributes.add(SVGNames::heightAttr); 73 supportedAttributes.add(SVGNames::heightAttr);
76 } 74 }
77 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); 75 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
78 } 76 }
79 77
80 void SVGForeignObjectElement::parseAttribute(const QualifiedName& name, const At omicString& value) 78 void SVGForeignObjectElement::parseAttribute(const QualifiedName& name, const At omicString& value)
81 { 79 {
82 SVGParsingError parseError = NoError; 80 SVGParsingError parseError = NoError;
83 81
84 if (!isSupportedAttribute(name)) 82 if (!isSupportedAttribute(name))
85 SVGGraphicsElement::parseAttribute(name, value); 83 SVGGraphicsElement::parseAttribute(name, value);
86 else if (name == SVGNames::xAttr) 84 else if (name == SVGNames::xAttr)
87 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); 85 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError);
88 else if (name == SVGNames::yAttr) 86 else if (name == SVGNames::yAttr)
89 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError)) ; 87 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError);
90 else if (name == SVGNames::widthAttr) 88 else if (name == SVGNames::widthAttr)
91 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro r)); 89 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError);
92 else if (name == SVGNames::heightAttr) 90 else if (name == SVGNames::heightAttr)
93 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr ror)); 91 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError) ;
94 else if (SVGExternalResourcesRequired::parseAttribute(name, value)) { 92 else if (SVGExternalResourcesRequired::parseAttribute(name, value)) {
95 } else 93 } else
96 ASSERT_NOT_REACHED(); 94 ASSERT_NOT_REACHED();
97 95
98 reportAttributeParsingError(parseError, name, value); 96 reportAttributeParsingError(parseError, name, value);
99 } 97 }
100 98
101 void SVGForeignObjectElement::svgAttributeChanged(const QualifiedName& attrName) 99 void SVGForeignObjectElement::svgAttributeChanged(const QualifiedName& attrName)
102 { 100 {
103 if (!isSupportedAttribute(attrName)) { 101 if (!isSupportedAttribute(attrName)) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 return false; 145 return false;
148 146
149 ancestor = ancestor->parentElement(); 147 ancestor = ancestor->parentElement();
150 } 148 }
151 149
152 return SVGGraphicsElement::rendererIsNeeded(style); 150 return SVGGraphicsElement::rendererIsNeeded(style);
153 } 151 }
154 152
155 bool SVGForeignObjectElement::selfHasRelativeLengths() const 153 bool SVGForeignObjectElement::selfHasRelativeLengths() const
156 { 154 {
157 return xCurrentValue().isRelative() 155 return m_x->currentValue()->isRelative()
158 || yCurrentValue().isRelative() 156 || m_y->currentValue()->isRelative()
159 || widthCurrentValue().isRelative() 157 || m_width->currentValue()->isRelative()
160 || heightCurrentValue().isRelative(); 158 || m_height->currentValue()->isRelative();
161 } 159 }
162 160
163 } 161 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698