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 * Copyright (C) 2009 Google, Inc. | 4 * Copyright (C) 2009 Google, Inc. |
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 19 matching lines...) Expand all Loading... |
30 | 30 |
31 namespace WebCore { | 31 namespace WebCore { |
32 | 32 |
33 RenderSVGTransformableContainer::RenderSVGTransformableContainer(SVGGraphicsElem
ent* node) | 33 RenderSVGTransformableContainer::RenderSVGTransformableContainer(SVGGraphicsElem
ent* node) |
34 : RenderSVGContainer(node) | 34 : RenderSVGContainer(node) |
35 , m_needsTransformUpdate(true) | 35 , m_needsTransformUpdate(true) |
36 , m_didTransformToRootUpdate(false) | 36 , m_didTransformToRootUpdate(false) |
37 { | 37 { |
38 } | 38 } |
39 | 39 |
| 40 static bool hasValidPredecessor(const Node* node) |
| 41 { |
| 42 ASSERT(node); |
| 43 while ((node = node->previousSibling())) { |
| 44 if (node->isSVGElement() && toSVGElement(node)->isValid()) |
| 45 return true; |
| 46 } |
| 47 return false; |
| 48 } |
| 49 |
| 50 bool RenderSVGTransformableContainer::isChildAllowed(RenderObject* child, Render
Style* style) const |
| 51 { |
| 52 if (element()->hasTagName(SVGNames::switchTag)) { |
| 53 Node* node = child->node(); |
| 54 // Reject non-SVG/non-valid elements. |
| 55 if (!node->isSVGElement() || !toSVGElement(node)->isValid()) |
| 56 return false; |
| 57 // Reject this child if it isn't the first valid node. |
| 58 if (hasValidPredecessor(node)) |
| 59 return false; |
| 60 } else if (element()->hasTagName(SVGNames::aTag)) { |
| 61 // http://www.w3.org/2003/01/REC-SVG11-20030114-errata#linking-text-envi
ronment |
| 62 // The 'a' element may contain any element that its parent may contain,
except itself. |
| 63 if (child->node()->hasTagName(SVGNames::aTag)) |
| 64 return false; |
| 65 if (parent() && parent()->isSVG()) |
| 66 return parent()->isChildAllowed(child, style); |
| 67 } |
| 68 return RenderSVGContainer::isChildAllowed(child, style); |
| 69 } |
| 70 |
40 bool RenderSVGTransformableContainer::calculateLocalTransform() | 71 bool RenderSVGTransformableContainer::calculateLocalTransform() |
41 { | 72 { |
42 SVGGraphicsElement* element = toSVGGraphicsElement(this->element()); | 73 SVGGraphicsElement* element = toSVGGraphicsElement(this->element()); |
43 | 74 |
44 // If we're either the renderer for a <use> element, or for any <g> element
inside the shadow | 75 // If we're either the renderer for a <use> element, or for any <g> element
inside the shadow |
45 // tree, that was created during the use/symbol/svg expansion in SVGUseEleme
nt. These containers | 76 // tree, that was created during the use/symbol/svg expansion in SVGUseEleme
nt. These containers |
46 // need to respect the translations induced by their corresponding use eleme
nts x/y attributes. | 77 // need to respect the translations induced by their corresponding use eleme
nts x/y attributes. |
47 SVGUseElement* useElement = 0; | 78 SVGUseElement* useElement = 0; |
48 if (element->hasTagName(SVGNames::useTag)) | 79 if (element->hasTagName(SVGNames::useTag)) |
49 useElement = toSVGUseElement(element); | 80 useElement = toSVGUseElement(element); |
(...skipping 17 matching lines...) Expand all Loading... |
67 if (!m_needsTransformUpdate) | 98 if (!m_needsTransformUpdate) |
68 return false; | 99 return false; |
69 | 100 |
70 m_localTransform = element->animatedLocalTransform(); | 101 m_localTransform = element->animatedLocalTransform(); |
71 m_localTransform.translate(m_lastTranslation.width(), m_lastTranslation.heig
ht()); | 102 m_localTransform.translate(m_lastTranslation.width(), m_lastTranslation.heig
ht()); |
72 m_needsTransformUpdate = false; | 103 m_needsTransformUpdate = false; |
73 return true; | 104 return true; |
74 } | 105 } |
75 | 106 |
76 } | 107 } |
OLD | NEW |