OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006 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, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
19 */ | 19 */ |
20 | 20 |
21 #include "config.h" | 21 #include "config.h" |
22 | 22 |
23 #include "core/svg/SVGSwitchElement.h" | 23 #include "core/svg/SVGSwitchElement.h" |
24 | 24 |
25 #include "SVGNames.h" | 25 #include "SVGNames.h" |
26 #include "core/dom/NodeRenderingContext.h" | |
27 #include "core/page/UseCounter.h" | 26 #include "core/page/UseCounter.h" |
28 #include "core/rendering/svg/RenderSVGTransformableContainer.h" | 27 #include "core/rendering/svg/RenderSVGTransformableContainer.h" |
29 | 28 |
30 namespace WebCore { | 29 namespace WebCore { |
31 | 30 |
32 // Animated property definitions | 31 // Animated property definitions |
33 DEFINE_ANIMATED_BOOLEAN(SVGSwitchElement, SVGNames::externalResourcesRequiredAtt
r, ExternalResourcesRequired, externalResourcesRequired) | 32 DEFINE_ANIMATED_BOOLEAN(SVGSwitchElement, SVGNames::externalResourcesRequiredAtt
r, ExternalResourcesRequired, externalResourcesRequired) |
34 | 33 |
35 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGSwitchElement) | 34 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGSwitchElement) |
36 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) | 35 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) |
37 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) | 36 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) |
38 END_REGISTER_ANIMATED_PROPERTIES | 37 END_REGISTER_ANIMATED_PROPERTIES |
39 | 38 |
40 inline SVGSwitchElement::SVGSwitchElement(const QualifiedName& tagName, Document
& document) | 39 inline SVGSwitchElement::SVGSwitchElement(const QualifiedName& tagName, Document
& document) |
41 : SVGGraphicsElement(tagName, document) | 40 : SVGGraphicsElement(tagName, document) |
42 { | 41 { |
43 ASSERT(hasTagName(SVGNames::switchTag)); | 42 ASSERT(hasTagName(SVGNames::switchTag)); |
44 ScriptWrappable::init(this); | 43 ScriptWrappable::init(this); |
45 registerAnimatedPropertiesForSVGSwitchElement(); | 44 registerAnimatedPropertiesForSVGSwitchElement(); |
46 | 45 |
47 UseCounter::count(&document, UseCounter::SVGSwitchElement); | 46 UseCounter::count(&document, UseCounter::SVGSwitchElement); |
48 } | 47 } |
49 | 48 |
50 PassRefPtr<SVGSwitchElement> SVGSwitchElement::create(const QualifiedName& tagNa
me, Document& document) | 49 PassRefPtr<SVGSwitchElement> SVGSwitchElement::create(const QualifiedName& tagNa
me, Document& document) |
51 { | 50 { |
52 return adoptRef(new SVGSwitchElement(tagName, document)); | 51 return adoptRef(new SVGSwitchElement(tagName, document)); |
53 } | 52 } |
54 | 53 |
55 bool SVGSwitchElement::childShouldCreateRenderer(const NodeRenderingContext& chi
ldContext) const | 54 bool SVGSwitchElement::childShouldCreateRenderer(const Node& child) const |
56 { | 55 { |
57 // FIXME: This function does not do what the comment below implies it does. | 56 // FIXME: This function does not do what the comment below implies it does. |
58 // It will create a renderer for any valid SVG element children, not just th
e first one. | 57 // It will create a renderer for any valid SVG element children, not just th
e first one. |
59 for (Node* node = firstChild(); node; node = node->nextSibling()) { | 58 for (Node* node = firstChild(); node; node = node->nextSibling()) { |
60 if (!node->isSVGElement()) | 59 if (!node->isSVGElement()) |
61 continue; | 60 continue; |
62 | 61 |
63 SVGElement* element = toSVGElement(node); | 62 SVGElement* element = toSVGElement(node); |
64 if (!element || !element->isValid()) | 63 if (!element || !element->isValid()) |
65 continue; | 64 continue; |
66 | 65 |
67 return node == childContext.node(); // Only allow this child if it's the
first valid child | 66 return node == &child; // Only allow this child if it's the first valid
child |
68 } | 67 } |
69 | 68 |
70 return false; | 69 return false; |
71 } | 70 } |
72 | 71 |
73 RenderObject* SVGSwitchElement::createRenderer(RenderStyle*) | 72 RenderObject* SVGSwitchElement::createRenderer(RenderStyle*) |
74 { | 73 { |
75 return new RenderSVGTransformableContainer(this); | 74 return new RenderSVGTransformableContainer(this); |
76 } | 75 } |
77 | 76 |
78 } | 77 } |
OLD | NEW |