| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 ASSERT(node); | 42 ASSERT(node); |
| 43 while ((node = node->previousSibling())) { | 43 while ((node = node->previousSibling())) { |
| 44 if (node->isSVGElement() && toSVGElement(node)->isValid()) | 44 if (node->isSVGElement() && toSVGElement(node)->isValid()) |
| 45 return true; | 45 return true; |
| 46 } | 46 } |
| 47 return false; | 47 return false; |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool RenderSVGTransformableContainer::isChildAllowed(RenderObject* child, Render
Style* style) const | 50 bool RenderSVGTransformableContainer::isChildAllowed(RenderObject* child, Render
Style* style) const |
| 51 { | 51 { |
| 52 if (element()->hasTagName(SVGNames::switchTag)) { | 52 ASSERT(element()); |
| 53 if (isSVGSwitchElement(*element())) { |
| 53 Node* node = child->node(); | 54 Node* node = child->node(); |
| 54 // Reject non-SVG/non-valid elements. | 55 // Reject non-SVG/non-valid elements. |
| 55 if (!node->isSVGElement() || !toSVGElement(node)->isValid()) | 56 if (!node->isSVGElement() || !toSVGElement(node)->isValid()) |
| 56 return false; | 57 return false; |
| 57 // Reject this child if it isn't the first valid node. | 58 // Reject this child if it isn't the first valid node. |
| 58 if (hasValidPredecessor(node)) | 59 if (hasValidPredecessor(node)) |
| 59 return false; | 60 return false; |
| 60 } else if (element()->hasTagName(SVGNames::aTag)) { | 61 } else if (isSVGAElement(*element())) { |
| 61 // http://www.w3.org/2003/01/REC-SVG11-20030114-errata#linking-text-envi
ronment | 62 // 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 // The 'a' element may contain any element that its parent may contain,
except itself. |
| 63 if (child->node()->hasTagName(SVGNames::aTag)) | 64 if (isSVGAElement(*child->node())) |
| 64 return false; | 65 return false; |
| 65 if (parent() && parent()->isSVG()) | 66 if (parent() && parent()->isSVG()) |
| 66 return parent()->isChildAllowed(child, style); | 67 return parent()->isChildAllowed(child, style); |
| 67 } | 68 } |
| 68 return RenderSVGContainer::isChildAllowed(child, style); | 69 return RenderSVGContainer::isChildAllowed(child, style); |
| 69 } | 70 } |
| 70 | 71 |
| 71 bool RenderSVGTransformableContainer::calculateLocalTransform() | 72 bool RenderSVGTransformableContainer::calculateLocalTransform() |
| 72 { | 73 { |
| 73 SVGGraphicsElement* element = toSVGGraphicsElement(this->element()); | 74 SVGGraphicsElement* element = toSVGGraphicsElement(this->element()); |
| 75 ASSERT(element); |
| 74 | 76 |
| 75 // If we're either the renderer for a <use> element, or for any <g> element
inside the shadow | 77 // If we're either the renderer for a <use> element, or for any <g> element
inside the shadow |
| 76 // tree, that was created during the use/symbol/svg expansion in SVGUseEleme
nt. These containers | 78 // tree, that was created during the use/symbol/svg expansion in SVGUseEleme
nt. These containers |
| 77 // need to respect the translations induced by their corresponding use eleme
nts x/y attributes. | 79 // need to respect the translations induced by their corresponding use eleme
nts x/y attributes. |
| 78 SVGUseElement* useElement = 0; | 80 SVGUseElement* useElement = 0; |
| 79 if (element->hasTagName(SVGNames::useTag)) | 81 if (isSVGUseElement(*element)) { |
| 80 useElement = toSVGUseElement(element); | 82 useElement = toSVGUseElement(element); |
| 81 else if (element->isInShadowTree() && element->hasTagName(SVGNames::gTag)) { | 83 } else if (element->isInShadowTree() && isSVGGElement(*element)) { |
| 82 SVGElement* correspondingElement = element->correspondingElement(); | 84 SVGElement* correspondingElement = element->correspondingElement(); |
| 83 if (correspondingElement && correspondingElement->hasTagName(SVGNames::u
seTag)) | 85 if (isSVGUseElement(correspondingElement)) |
| 84 useElement = toSVGUseElement(correspondingElement); | 86 useElement = toSVGUseElement(correspondingElement); |
| 85 } | 87 } |
| 86 | 88 |
| 87 if (useElement) { | 89 if (useElement) { |
| 88 SVGLengthContext lengthContext(useElement); | 90 SVGLengthContext lengthContext(useElement); |
| 89 FloatSize translation( | 91 FloatSize translation( |
| 90 useElement->x()->currentValue()->value(lengthContext), | 92 useElement->x()->currentValue()->value(lengthContext), |
| 91 useElement->y()->currentValue()->value(lengthContext)); | 93 useElement->y()->currentValue()->value(lengthContext)); |
| 92 if (translation != m_lastTranslation) | 94 if (translation != m_lastTranslation) |
| 93 m_needsTransformUpdate = true; | 95 m_needsTransformUpdate = true; |
| 94 m_lastTranslation = translation; | 96 m_lastTranslation = translation; |
| 95 } | 97 } |
| 96 | 98 |
| 97 m_didTransformToRootUpdate = m_needsTransformUpdate || SVGRenderSupport::tra
nsformToRootChanged(parent()); | 99 m_didTransformToRootUpdate = m_needsTransformUpdate || SVGRenderSupport::tra
nsformToRootChanged(parent()); |
| 98 if (!m_needsTransformUpdate) | 100 if (!m_needsTransformUpdate) |
| 99 return false; | 101 return false; |
| 100 | 102 |
| 101 m_localTransform = element->animatedLocalTransform(); | 103 m_localTransform = element->animatedLocalTransform(); |
| 102 m_localTransform.translate(m_lastTranslation.width(), m_lastTranslation.heig
ht()); | 104 m_localTransform.translate(m_lastTranslation.width(), m_lastTranslation.heig
ht()); |
| 103 m_needsTransformUpdate = false; | 105 m_needsTransformUpdate = false; |
| 104 return true; | 106 return true; |
| 105 } | 107 } |
| 106 | 108 |
| 107 } | 109 } |
| OLD | NEW |