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

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: 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/SVGForeignObjectElement.h ('k') | Source/core/svg/SVGImageElement.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) 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 35
40 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGForeignObjectElement) 36 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGForeignObjectElement)
41 REGISTER_LOCAL_ANIMATED_PROPERTY(x)
42 REGISTER_LOCAL_ANIMATED_PROPERTY(y)
43 REGISTER_LOCAL_ANIMATED_PROPERTY(width)
44 REGISTER_LOCAL_ANIMATED_PROPERTY(height)
45 REGISTER_LOCAL_ANIMATED_PROPERTY(href) 37 REGISTER_LOCAL_ANIMATED_PROPERTY(href)
46 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) 38 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement)
47 END_REGISTER_ANIMATED_PROPERTIES 39 END_REGISTER_ANIMATED_PROPERTIES
48 40
49 inline SVGForeignObjectElement::SVGForeignObjectElement(Document& document) 41 inline SVGForeignObjectElement::SVGForeignObjectElement(Document& document)
50 : SVGGraphicsElement(SVGNames::foreignObjectTag, document) 42 : SVGGraphicsElement(SVGNames::foreignObjectTag, document)
51 , m_x(LengthModeWidth) 43 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len gthModeWidth)))
52 , m_y(LengthModeHeight) 44 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len gthModeHeight)))
53 , m_width(LengthModeWidth) 45 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr eate(LengthModeWidth)))
54 , m_height(LengthModeHeight) 46 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength:: create(LengthModeHeight)))
55 { 47 {
56 ScriptWrappable::init(this); 48 ScriptWrappable::init(this);
49
50 addToPropertyMap(m_x);
51 addToPropertyMap(m_y);
52 addToPropertyMap(m_width);
53 addToPropertyMap(m_height);
54
57 registerAnimatedPropertiesForSVGForeignObjectElement(); 55 registerAnimatedPropertiesForSVGForeignObjectElement();
58 } 56 }
59 57
60 PassRefPtr<SVGForeignObjectElement> SVGForeignObjectElement::create(Document& do cument) 58 PassRefPtr<SVGForeignObjectElement> SVGForeignObjectElement::create(Document& do cument)
61 { 59 {
62 return adoptRef(new SVGForeignObjectElement(document)); 60 return adoptRef(new SVGForeignObjectElement(document));
63 } 61 }
64 62
65 bool SVGForeignObjectElement::isSupportedAttribute(const QualifiedName& attrName ) 63 bool SVGForeignObjectElement::isSupportedAttribute(const QualifiedName& attrName )
66 { 64 {
67 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); 65 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
68 if (supportedAttributes.isEmpty()) { 66 if (supportedAttributes.isEmpty()) {
69 supportedAttributes.add(SVGNames::xAttr); 67 supportedAttributes.add(SVGNames::xAttr);
70 supportedAttributes.add(SVGNames::yAttr); 68 supportedAttributes.add(SVGNames::yAttr);
71 supportedAttributes.add(SVGNames::widthAttr); 69 supportedAttributes.add(SVGNames::widthAttr);
72 supportedAttributes.add(SVGNames::heightAttr); 70 supportedAttributes.add(SVGNames::heightAttr);
73 } 71 }
74 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); 72 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
75 } 73 }
76 74
77 void SVGForeignObjectElement::parseAttribute(const QualifiedName& name, const At omicString& value) 75 void SVGForeignObjectElement::parseAttribute(const QualifiedName& name, const At omicString& value)
78 { 76 {
79 SVGParsingError parseError = NoError; 77 SVGParsingError parseError = NoError;
80 78
81 if (!isSupportedAttribute(name)) 79 if (!isSupportedAttribute(name))
82 SVGGraphicsElement::parseAttribute(name, value); 80 SVGGraphicsElement::parseAttribute(name, value);
83 else if (name == SVGNames::xAttr) 81 else if (name == SVGNames::xAttr)
84 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); 82 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError);
85 else if (name == SVGNames::yAttr) 83 else if (name == SVGNames::yAttr)
86 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError)) ; 84 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError);
87 else if (name == SVGNames::widthAttr) 85 else if (name == SVGNames::widthAttr)
88 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro r)); 86 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError);
89 else if (name == SVGNames::heightAttr) 87 else if (name == SVGNames::heightAttr)
90 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr ror)); 88 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError) ;
91 else 89 else
92 ASSERT_NOT_REACHED(); 90 ASSERT_NOT_REACHED();
93 91
94 reportAttributeParsingError(parseError, name, value); 92 reportAttributeParsingError(parseError, name, value);
95 } 93 }
96 94
97 void SVGForeignObjectElement::svgAttributeChanged(const QualifiedName& attrName) 95 void SVGForeignObjectElement::svgAttributeChanged(const QualifiedName& attrName)
98 { 96 {
99 if (!isSupportedAttribute(attrName)) { 97 if (!isSupportedAttribute(attrName)) {
100 SVGGraphicsElement::svgAttributeChanged(attrName); 98 SVGGraphicsElement::svgAttributeChanged(attrName);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 return false; 141 return false;
144 142
145 ancestor = ancestor->parentElement(); 143 ancestor = ancestor->parentElement();
146 } 144 }
147 145
148 return SVGGraphicsElement::rendererIsNeeded(style); 146 return SVGGraphicsElement::rendererIsNeeded(style);
149 } 147 }
150 148
151 bool SVGForeignObjectElement::selfHasRelativeLengths() const 149 bool SVGForeignObjectElement::selfHasRelativeLengths() const
152 { 150 {
153 return xCurrentValue().isRelative() 151 return m_x->currentValue()->isRelative()
154 || yCurrentValue().isRelative() 152 || m_y->currentValue()->isRelative()
155 || widthCurrentValue().isRelative() 153 || m_width->currentValue()->isRelative()
156 || heightCurrentValue().isRelative(); 154 || m_height->currentValue()->isRelative();
157 } 155 }
158 156
159 } 157 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGForeignObjectElement.h ('k') | Source/core/svg/SVGImageElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698